    /* Mini Leaderboard Modal */
    #mini-leaderboard {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) scale(0.9);
        background: var(--bg-primary);
        padding: 1.5rem;
        border-radius: 16px;
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
        z-index: 2000;
        width: 90%;
        max-width: 350px;
        display: none;
        flex-direction: column;
        gap: 1rem;
        transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        opacity: 0;
        perspective: 1000px;
    }

    #mini-leaderboard.active {
        display: flex;
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    .mini-lb-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 0.5rem;
    }

    .mini-lb-title {
        display: flex;
        align-items: center;
        gap: 0.8rem;
        font-weight: 700;
        font-size: 1.1rem;
        color: var(--text-primary);
    }

    /* Toggle Switch */
    .lb-switch {
        display: flex;
        background: var(--bg-secondary);
        padding: 3px;
        border-radius: 8px;
        gap: 2px;
    }

    .lb-switch-btn {
        padding: 4px 8px;
        border-radius: 6px;
        font-size: 10px;
        font-weight: 700;
        cursor: pointer;
        border: none;
        background: transparent;
        color: var(--text-tertiary);
        transition: all 0.2s;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .lb-switch-btn.active {
        background: var(--bg-primary);
        color: var(--accent-color);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .mini-lb-list {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        transition: opacity 0.2s ease, transform 0.2s ease;
        opacity: 1;
        transform: translateY(0);
    }

    .mini-lb-list.flipping {
        opacity: 0;
        transform: translateY(5px);
    }

    .lb-switch-btn {
        padding: 4px 12px;
        border-radius: 6px;
        font-size: 11px;
        font-weight: 700;
        cursor: pointer;
        border: none;
        background: transparent;
        color: var(--text-tertiary);
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        position: relative;
        overflow: hidden;
    }

    .lb-switch-btn.active {
        background: var(--bg-primary);
        color: var(--accent-color);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        transform: translateY(-1px);
    }

    .mini-lb-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.6rem 0.8rem;
        background: rgba(0, 0, 0, 0.03);
        border-radius: 8px;
    }

    [data-theme="dark"] .mini-lb-item {
        background: rgba(255, 255, 255, 0.03);
    }

    .mini-lb-name {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        font-weight: 500;
        font-size: 0.9rem;
    }

    .mini-lb-wpm {
        font-weight: 700;
        color: var(--accent-color);
    }

    .mini-lb-cta {
        margin-top: 0.5rem;
        padding: 1rem;
        background: linear-gradient(135deg, var(--main-color), #764ba2);
        color: white;
        text-decoration: none;
        border-radius: 10px;
        text-align: center;
        font-size: 0.85rem;
        font-weight: 600;
        transition: transform 0.2s;
    }

    .mini-lb-cta:hover {
        transform: translateY(-2px);
    }

    #sidebar {
        position: fixed;
        top: 0;
        right: -100%;
        width: 300px;
        height: 100%;
        background-color: var(--bg-secondary, var(--sidebar-bg));
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
        z-index: 1000;
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding: 1.25rem 1.5rem;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
    }

    #sidebar.open {
        right: 0;
    }

    .sidebar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 1.2rem;
        font-weight: bold;
        color: var(--text-primary);
        margin: 0 0 0.5rem 0;
    }

    .sidebar-section {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .section-title {
        font-size: 0.9rem;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 1px;
        margin-bottom: 0.4rem;
    }

    .setting-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .setting-label {
        color: var(--text-primary);
    }

    select,
    button.setting-btn {
        background: rgba(0, 0, 0, 0.05);
        border: 1px solid transparent;
        padding: 0.5rem 1rem;
        color: var(--text-primary);
        border-radius: 4px;
        font-family: inherit;
        cursor: pointer;
        transition: all 0.2s;
    }

    [data-theme="dark"] select,
    [data-theme="dark"] button.setting-btn {
        background: #2d3748 !important;
        border: 1px solid var(--border-color);
        color: #ffffff !important;
    }

    [data-theme="dark"] select option {
        background-color: #1a1f2e !important;
        color: #ffffff !important;
    }

    select:hover,
    button.setting-btn:hover {
        background: rgba(0, 0, 0, 0.1);
    }

    [data-theme="dark"] select:hover,
    [data-theme="dark"] button.setting-btn:hover {
        background: rgba(255, 255, 255, 0.15) !important;
    }

    /* Segmented Control */
    .segmented-control {
        display: flex;
        gap: 0.3rem;
        width: 100%;
    }

    .segment-btn {
        flex: 1;
        padding: 0.5rem 0.2rem;
        background: rgba(0, 0, 0, 0.05);
        border: 1px solid transparent;
        color: var(--text-secondary);
        border-radius: 4px;
        cursor: pointer;
        font-size: 0.9rem;
        transition: all 0.2s;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .segment-btn:hover {
        background: rgba(0, 0, 0, 0.1);
        color: var(--text-primary);
    }

    .segment-btn.active {
        background: var(--accent-color) !important;
        color: #ffffff !important;
    }

    [data-theme="dark"] .segment-btn {
        background: #2d3748;
        color: #94a3b8;
    }

    [data-theme="dark"] .segment-btn:hover {
        background: #3a475a;
        color: #f8fafc;
    }

    .custom-time-wrapper {
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        display: flex;
        /* Always flex but hidden by height/opacity */
        flex-direction: column;
        width: 100%;
        gap: 0.8rem;
        margin-top: 0;
        padding: 0 1rem;
        background: rgba(0, 0, 0, 0.04);
        border-radius: 10px;
        border: 1px solid rgba(0, 0, 0, 0.05);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        pointer-events: none;
    }

    .custom-time-wrapper.active {
        max-height: 200px;
        opacity: 1;
        margin-top: 0.5rem;
        padding: 0.75rem;
        pointer-events: auto;
    }

    .unit-toggle {
        display: flex;
        gap: 0.2rem;
        background: rgba(0, 0, 0, 0.05);
        padding: 0.2rem;
        border-radius: 6px;
        width: 100%;
    }

    [data-theme="dark"] .unit-toggle {
        background: #1a1f2e;
    }

    .unit-btn {
        flex: 1;
        padding: 0.4rem;
        border: none;
        background: none;
        color: var(--text-secondary);
        font-size: 0.8rem;
        cursor: pointer;
        border-radius: 4px;
        transition: all 0.2s;
    }

    .unit-btn.active {
        background: var(--accent-color);
        color: #ffffff;
    }

    .custom-time-controls {
        display: flex;
        gap: 0.4rem;
        width: 100%;
        align-items: stretch;
    }

    .custom-time-input {
        flex: 1;
        height: 40px;
        line-height: 40px;
        background: rgba(0, 0, 0, 0.05);
        border: 1px solid transparent;
        padding: 0 0.8rem;
        border-radius: 6px;
        color: var(--text-primary);
        outline: none;
        font-family: inherit;
        text-align: center;
        font-size: 1rem;
        min-width: 0;
        box-sizing: border-box;
        vertical-align: middle;
    }

    [data-theme="dark"] .custom-time-input {
        background: #1a1f2e;
        border-color: rgba(255, 255, 255, 0.1);
    }

    #apply-custom-time {
        height: 40px;
        padding: 0;
        border: none;
        border-radius: 6px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        vertical-align: middle;
        cursor: pointer;
    }

    #custom-time-btn svg {
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    #custom-time-btn .plus-v {
        transition: opacity 0.2s, transform 0.3s;
        transform-origin: center;
    }

    #custom-time-btn.expanded svg {
        transform: rotate(180deg);
    }

    #custom-time-btn.expanded .plus-v {
        opacity: 0;
        transform: scaleY(0);
    }

    .toggle-switch {
        width: 40px;
        height: 20px;
        background: var(--text-secondary);
        border-radius: 10px;
        position: relative;
        cursor: pointer;
        transition: 0.3s;
    }

    /* Attribution Styles */
    .attribution-container {
        margin-top: 0.5rem;
        font-size: 0.8rem;
        color: var(--text-secondary);
        display: flex;
        justify-content: flex-end;
        align-items: center;
        opacity: 0;
        transition: opacity 0.3s;
        min-height: 1.2rem;
    }

    .source-citation {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        background: rgba(0, 0, 0, 0.03);
        padding: 0.2rem 0.6rem;
        border-radius: 4px;
    }

    [data-theme="dark"] .source-citation {
        background: rgba(255, 255, 255, 0.05);
    }

    .source-citation a {
        color: var(--accent-color);
        text-decoration: none;
        font-weight: 500;
    }

    .source-citation a:hover {
        text-decoration: underline;
    }

    .license-badge {
        font-size: 0.7rem;
        opacity: 0.7;
        border: 1px solid var(--text-secondary);
        padding: 0 0.2rem;
        border-radius: 3px;
    }

    .original-badge {
        background-color: var(--accent-color);
        color: white;
        padding: 0 0.4rem;
        border-radius: 3px;
        font-size: 0.7rem;
        font-weight: bold;
    }

    .toggle-switch::after {
        content: '';
        position: absolute;
        top: 2px;
        left: 2px;
        width: 16px;
        height: 16px;
        background: var(--bg-primary);
        border-radius: 50%;
        transition: 0.3s;
    }

    .toggle-switch.active {
        background: var(--accent-color);
    }

    .toggle-switch.active::after {
        left: 22px;
    }

    .overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
    }

    .overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    /* Unlock CTA Button */
    .unlock-cta {
        display: block;
        padding: 1rem 1.25rem;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border-radius: 12px;
        text-decoration: none;
        color: white;
        text-align: center;
        transition: transform 0.2s, box-shadow 0.2s;
        border: 1px solid rgba(255, 255, 255, 0.15);
    }

    .unlock-cta:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    }

    .unlock-cta-title {
        display: block;
        font-weight: 600;
        font-size: 0.95rem;
        letter-spacing: 0.02em;
    }

    .unlock-cta-features {
        display: block;
        font-size: 0.7rem;
        opacity: 0.85;
        margin-top: 0.35rem;
        font-weight: 400;
    }

    /* Guest Conversion Hook */
    .guest-conversion-hook {
        display: none;
        background: rgba(25, 118, 210, 0.1);
        border: 1px solid rgba(25, 118, 210, 0.2);
        padding: 1.25rem;
        border-radius: 12px;
        margin-bottom: 0.5rem;
        position: relative;
        overflow: hidden;
    }

    [data-theme="dark"] .guest-conversion-hook {
        background: rgba(96, 165, 250, 0.1);
        border-color: rgba(96, 165, 250, 0.2);
    }

    .guest-hook-content {
        display: flex;
        flex-direction: column;
        gap: 0.4rem;
        position: relative;
        z-index: 1;
    }

    .guest-hook-title {
        font-weight: 700;
        font-size: 1.1rem;
        color: var(--accent-color);
        margin: 0;
    }

    .guest-hook-text {
        font-size: 0.85rem;
        line-height: 1.4;
        color: var(--text-secondary);
    }

    .guest-hook-cta {
        margin-top: 0.75rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: var(--accent-color);
        color: white !important;
        padding: 0.6rem 1.25rem;
        border-radius: 8px;
        font-weight: 700;
        text-decoration: none;
        font-size: 0.9rem;
        transition: all 0.2s;
        box-shadow: 0 4px 12px rgba(25, 118, 210, 0.2);
        width: fit-content;
    }

    .guest-hook-cta:hover {
        transform: translateY(-1px);
        box-shadow: 0 6px 16px rgba(25, 118, 210, 0.3);
        text-decoration: none;
        opacity: 0.9;
    }

    .guest-hook-badge {
        position: absolute;
        right: -10px;
        top: -10px;
        opacity: 0.05;
        transform: rotate(15deg);
    }

    #result-modal {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.85);
        z-index: 2000;
        justify-content: center;
        align-items: flex-start;
        /* Allow content to start from top for scrolling */
        backdrop-filter: blur(12px);
        padding: 2rem 1rem;
        overflow-y: auto;
        /* Enable scroll for future ads/content */
    }

    .result-content {
        background: var(--bg-primary);
        padding: 1.5rem 2rem;
        border-radius: 1rem;
        width: 100%;
        max-width: 800px;
        margin-top: auto;
        margin-bottom: auto;
        text-align: left;
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
        border: 1px solid rgba(255, 255, 255, 0.1);
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .result-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
    }

    .wpm-main {
        display: flex;
        flex-direction: column;
    }

    .wpm-big {
        font-size: 3.5rem;
        font-weight: 700;
        color: var(--accent-color);
        line-height: 1;
    }

    .wpm-label {
        font-size: 1rem;
        color: var(--text-secondary);
        margin-top: 0.25rem;
    }

    .chart-container {
        width: 100%;
        height: 180px;
        position: relative;
    }

    .stats-grid-new {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 1rem;
        padding-top: 0.75rem;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
    }

    .stat-box {
        display: flex;
        flex-direction: column;
        gap: 0.15rem;
    }

    .stat-box .stat-label {
        font-size: 0.75rem;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .stat-box .stat-value {
        font-size: 1.3rem;
        font-weight: 600;
        color: var(--text-primary);
    }

    .result-footer {
        display: flex;
        gap: 0.75rem;
        justify-content: flex-end;
        margin-top: 0.5rem;
    }

    #app.focus-mode header,
    #app.focus-mode footer,
    #app.focus-mode .stats-container {
        opacity: 0 !important;
        pointer-events: none;
    }

    footer {
        display: flex;
        justify-content: center;
        color: var(--text-secondary);
        font-size: 0.8rem;
        gap: 1.5rem;
        padding-top: 1rem;
        user-select: none;
        flex-wrap: wrap;
    }

    .footer-links {
        display: flex;
        gap: 1.2rem;
        align-items: center;
        flex-wrap: wrap;
        justify-content: center;
    }

    @media (max-width: 600px) {
        #sidebar {
            width: 85%;
        }

        /* Mobile Results Polish */
        .result-content {
            padding: 1.5rem;
            gap: 1.5rem;
        }

        .wpm-big {
            font-size: 3.5rem;
        }

        .wpm-label {
            font-size: 1rem;
        }

        .chart-container {
            height: 200px;
        }

        .stats-grid-new {
            gap: 1.2rem;
            grid-template-columns: 1fr 1fr;
            /* 2 columns on mobile */
        }

        .stat-box .stat-value {
            font-size: 1.4rem;
        }

        .result-footer {
            flex-direction: column;
        }

        .result-footer .setting-btn {
            width: 100%;
            justify-content: center;
        }
    }