:root {
    --brand-blue: #2563eb;
    --brand-blue-strong: #1d4ed8;
    --brand-blue-deep: #1e3a8a;
    --brand-cyan: #0891b2;
    --brand-orange: #c2410c;
    --brand-orange-deep: #9a3412;
    --ink-900: #0f172a;
    --ink-700: #334155;
    --surface: #ffffff;
    --line: #e2e8f0;
}

body {
    margin: 0;
    font-family: 'Segoe UI', 'Trebuchet MS', 'Verdana', sans-serif;
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    background:
        radial-gradient(1200px 700px at -10% -20%, rgba(14, 165, 233, 0.18), transparent 50%),
        radial-gradient(1000px 600px at 110% -10%, rgba(37, 99, 235, 0.15), transparent 50%),
        linear-gradient(180deg, #f8fbff 0%, #ffffff 45%, #f8fafc 100%);
    color: #111827;
    overflow-x: hidden;
    overflow-y: auto;
}

#main-container {
    display: none;
}

/* Login Screen */
#login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f0f9ff 0%, #eef2ff 45%, #ffffff 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.welcome-shell {
    width: min(1120px, 95vw);
    display: grid;
    grid-template-columns: 1.3fr 0.9fr;
    gap: 24px;
    align-items: stretch;
}

.welcome-panel {
    background:
        linear-gradient(165deg, rgba(255, 255, 255, 0.94), rgba(245, 251, 255, 0.95)),
        radial-gradient(circle at 12% 12%, #dbeafe 0%, #eff6ff 28%, #ffffff 100%);
    border: 1px solid #bfdbfe;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 18px 46px rgba(37, 99, 235, 0.14);
    backdrop-filter: blur(6px);
}

.welcome-kicker {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #1e40af;
    background: #dbeafe;
    border: 1px solid #93c5fd;
    padding: 6px 10px;
    border-radius: 999px;
    margin-bottom: 10px;
}

.welcome-panel h1 {
    margin: 0 0 10px;
    color: var(--ink-900);
    font-size: clamp(1.5rem, 2.2vw, 2.2rem);
    letter-spacing: -0.02em;
}

.welcome-subtitle {
    margin: 0 0 22px;
    color: var(--ink-700);
    line-height: 1.55;
}

.welcome-test-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.welcome-test-card {
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    background: #ffffff;
    text-align: left;
    padding: 14px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    box-shadow: 0 5px 14px rgba(15, 23, 42, 0.06);
}

.welcome-test-card:hover {
    transform: translateY(-2px);
    border-color: #60a5fa;
    box-shadow: 0 14px 24px rgba(30, 64, 175, 0.16);
}

.welcome-test-icon {
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.welcome-test-icon-img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    display: block;
}

.welcome-test-title {
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
}

.welcome-test-desc {
    font-size: 0.9rem;
    color: #475569;
}

.welcome-plan-promo {
    border: 1px solid #fed7aa;
    border-radius: 12px;
    background: linear-gradient(135deg, #fff7ed, #fffbeb);
    padding: 14px;
    margin-bottom: 16px;
}

.welcome-plan-promo h3 {
    margin: 0 0 6px;
    color: #92400e;
}

.welcome-plan-promo p {
    margin: 0 0 10px;
    color: #78350f;
}

.promo-btn {
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--brand-orange), #ea580c);
    color: #ffffff;
    padding: 10px 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(234, 88, 12, 0.25);
}

.promo-btn:hover {
    background: linear-gradient(135deg, var(--brand-orange-deep), var(--brand-orange));
}

#lang-switcher button {
    color: var(--ink-900);
    font-weight: 700;
    background: rgba(255, 255, 255, 0.92) !important;
}

#lang-switcher button:hover {
    border-color: #93c5fd !important;
    background: #eff6ff !important;
}

.welcome-tools-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    align-items: center;
}

.login-box {
    background: #ffffff;
    padding: 32px 28px;
    border-radius: 16px;
    border: 1px solid #e5e7eb;
    text-align: center;
    width: 300px;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.11);
}

.login-box h2 {
    color: #1e293b;
    margin-top: 0;
    margin-bottom: 6px;
    font-size: 1.3rem;
}

.login-box > p:first-of-type {
    margin: 0 0 16px;
    color: #64748b;
    font-size: 0.95rem;
}

.login-box input {
    width: 100%;
    padding: 11px;
    margin: 8px 0;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    color: #111827;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 16px;
    transition: border-color 0.2s;
}

.login-box input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.login-box button {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-blue-strong));
    color: white;
    transition: all 0.2s;
    margin-top: 8px;
}

.login-box button:first-of-type {
    margin-top: 14px;
}

.login-box button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.2);
}

.paid-access-box {
    width: auto;
    min-width: 330px;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.paid-access-box h2 {
    color: #1e293b;
    margin-top: 0;
    margin-bottom: 8px;
}

.login-box .btn-secondary {
    background: linear-gradient(90deg, #2563eb 0%, #0891b2 100%);
    color: #fff;
    box-shadow: 0 4px 16px rgba(37,99,235,0.10);
    margin-top: 12px;
    margin-bottom: 8px;
    transition: all 0.2s;
}

.login-box .btn-secondary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(37,99,235,0.16);
    background: linear-gradient(90deg, #0891b2 0%, #2563eb 100%);
}

.login-box .btn-secondary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.btn-pwa-install {
    width: 100%;
    padding: 13px 0;
    border: none;
    border-radius: 8px;
    font-size: 1.08rem;
    font-weight: 700;
    background: linear-gradient(90deg, #2563eb 0%, #0891b2 100%);
    color: #fff;
    box-shadow: 0 4px 16px rgba(37,99,235,0.10);
    margin-top: 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    cursor: pointer;
}
.btn-pwa-install:hover {
    background: linear-gradient(90deg, #0891b2 0%, #2563eb 100%);
    transform: translateY(-1px) scale(1.03);
}
.btn-pwa-install:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.terms-consent-row {
    margin: 8px 0 6px;
    text-align: left;
    font-size: 0.84rem;
    color: #334155;
}

.terms-consent-row label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.4;
}

.terms-consent-row input[type="checkbox"] {
    margin-top: 2px;
}

.terms-consent-row a {
    color: #1d4ed8;
    font-weight: 600;
    text-decoration: underline;
}

.terms-error {
    margin: 0 0 8px;
    color: #b91c1c;
    font-size: 0.82rem;
    text-align: left;
}

.legal-footer {
    position: fixed;
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%);
    z-index: 9997;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid #dbe2ea;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.78rem;
    color: #334155;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.1);
    backdrop-filter: blur(4px);
}

.legal-footer a {
    color: #1d4ed8;
    font-weight: 700;
    text-decoration: none;
}

.legal-footer a:hover {
    text-decoration: underline;
}

.install-status {
    margin: 0 0 6px;
    min-height: 18px;
    font-size: 12px;
    color: #6b7280;
}

@media (max-width: 980px) {
    .welcome-shell {
        grid-template-columns: 1fr;
    }

    .welcome-test-grid {
        grid-template-columns: 1fr;
    }

    .paid-access-box {
        min-width: 0;
    }
}

.login-box button:hover {
    background: linear-gradient(135deg, var(--brand-blue-strong), var(--brand-blue-deep));
    transform: translateY(-1px);
}

/* Sidebar Styles */
aside {
    width: 280px;
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: margin-left 0.3s ease;
}

aside.collapsed {
    margin-left: -280px;
}

.sidebar-toggle {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 50;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    color: #374151;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    background: #f3f4f6;
    color: #111827;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #ffffff;
}

.sidebar-header h1 {
    margin: 0;
    font-size: 1.2rem;
    color: #1d4ed8;
}

.back-link {
    display: inline-block;
    margin-top: 8px;
    font-size: 0.85rem;
    color: #6b7280;
    text-decoration: none;
    cursor: pointer;
}

.back-link:hover {
    color: #111827;
}

.nav-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

/* Navigation Items (Shared) */
.nav-group {
    border-bottom: 1px solid #e5e7eb;
}

.nav-item-title {
    padding: 8px 15px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #374151;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
}

.nav-item-title:hover {
    background: #f9fafb;
    color: #111827;
}

.nav-sublist {
    display: none;
    background: #ffffff;
}

.nav-sublist.open {
    display: block;
}

.sub-item-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 6px 15px 6px 25px;
    background: transparent;
    border: none;
    color: #374151;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
    font-weight: 600;
    border-bottom: 1px solid #f3f4f6;
    white-space: normal;
    line-height: 1.3;
}

.sub-item-btn:hover {
    background: #f9fafb;
    color: #111827;
}

.sub-item-btn.active {
    background: #eef2ff;
    color: #1d4ed8;
    border-left: 3px solid #ef4444;
    padding-left: 22px;
}

/* Main Content Area */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #ffffff;
    position: relative;
}

/* Dashboard */
.dashboard {
    padding: 40px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    width: 100%;
    max-width: 1200px; /* Limit width to keep centered */
    margin: 0 auto; /* Center the container */
    box-sizing: border-box;
    overflow-y: auto;
    align-content: start; /* Align content to top */
}

/* Test Grid (Replaces inline styles in app.js) */
.test-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
    justify-content: center;
}

/* View Selection Screen */
#view-selection-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f8fafc;
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 1000;
    flex-direction: column;
}

.view-selection-container {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.view-option {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    padding: 40px;
    width: 200px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.view-option:hover {
    transform: translateY(-5px);
    border-color: #2563eb;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.view-option-icon {
    font-size: 4rem;
}

.view-option-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
}

.view-option-desc {
    font-size: 0.9rem;
    color: #64748b;
}

.dashboard-card {
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    border: 1px solid #dbe2ea;
    border-radius: 14px;
    padding: 24px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.dashboard-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 28px rgba(15, 23, 42, 0.13);
    border-color: var(--brand-blue);
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.card-icon-img {
    width: 54px;
    height: 54px;
    object-fit: contain;
    display: block;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 8px;
}

.card-desc {
    font-size: 0.9rem;
    color: #6b7280;
    line-height: 1.5;
}

.card-lock {
    margin-top: 12px;
    padding: 8px 12px;
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.delf-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.delf-toolbar-title {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
}

.delf-toolbar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.delf-action-btn {
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #0f172a;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.delf-action-btn:hover {
    background: #f8fafc;
}

.delf-exercise-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.delf-exercise-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.delf-exercise-title {
    margin: 0 0 10px;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

.delf-meta {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 10px;
}

.delf-transcript {
    margin: 10px 0 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px;
    font-size: 14px;
    color: #0f172a;
    max-height: 240px;
    overflow: auto;
}

.delf-reading {
    margin: 10px 0 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    max-height: 340px;
    overflow: auto;
}

.delf-source {
    margin-top: 8px;
    font-size: 12px;
    word-break: break-word;
}

.delf-source a {
    color: #2563eb;
    text-decoration: underline;
}

.delf-questions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.delf-question {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-left: 4px solid #fb923c;
    border-radius: 10px;
    padding: 12px;
}

.delf-question-title {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
}

.delf-answer {
    margin-top: 10px;
    padding: 10px 12px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    color: #334155;
}

/* Content Header */
.content-header {
    padding: 16px 28px;
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 12px;
    backdrop-filter: blur(6px);
}

.content-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #111827;
}

.header-back-btn {
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #0f172a;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
}

.header-back-btn:hover {
    background: #f8fafc;
}

/* Content Viewers */
.content-viewer {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    position: relative;
}

.content-viewer.grammar-viewer {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.text-content {
    max-width: 800px;
    margin: 0 auto;
    font-size: 1.1rem;
    line-height: 1.8;
    color: #111827;
}

/* Question Viewer specific */
#question-viewer {
    display: flex;
    flex-direction: column;
    align-items: center; /* Centers content horizontally */
    /* justify-content: center; Removed to prevent vertical centering issues on mobile */
    min-height: 0; /* Important for nested flex scrolling */
}

.question-container {
    max-width: 900px;
    margin: auto; /* Centers in the flex container (horizontal + vertical) */
    width: 100%;
    padding-bottom: 20px;
}

@media (max-width: 768px) {
    #question-viewer {
        padding-bottom: 120px !important; /* Ensure space for fixed bottom elements */
        justify-content: flex-start !important;
    }
}

.question-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 16px; /* Increased radius */
    padding: 32px; /* Increased padding */
    margin-bottom: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03); /* Added soft shadow */
}

.btn {
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 700;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* Question Controls */
.controls-container {
    margin-top: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Added for safety on smaller desktop screens */
}

.controls-left, .controls-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

@media (max-width: 768px) {
    .controls-container {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .controls-left, .controls-right {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }
    
    .controls-left button, .controls-right button {
        width: 100% !important;
        margin-right: 0 !important;
        margin-bottom: 0 !important;
    }
}

.btn-primary {
    background: #1d4ed8;
    color: #ffffff;
}

.btn-primary:hover {
    background: #1e40af;
}

.btn-secondary {
    background: #ffffff;
    color: #1d4ed8;
    border-color: #1d4ed8;
}

.btn-secondary:hover {
    background: #eef2ff;
}

.btn-next {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}

.btn-next:hover {
    background: #1e40af;
    border-color: #1e40af;
}

.btn-transcription {
    background: #ffffff;
    color: #ef4444;
    border-color: #ef4444;
}

.btn-transcription:hover {
    background: #fee2e2;
}

.question-media {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
}

.question-media img {
    display: block;
    max-width: clamp(280px, 70vw, 800px);
    height: auto;
    margin: 0 auto;
}

.question-media audio {
    width: 85%;
    max-width: 900px;
    margin: 0 auto;
    display: block;
}

/* When sidebar is collapsed, allow a wider content area */
aside.collapsed + main .question-container {
    max-width: 1100px;
}

.question-text {
    font-size: 1.25rem; /* Increased font size */
    margin-bottom: 24px;
    font-weight: 500;
    color: #111827;
    white-space: pre-wrap;
    line-height: 1.6; /* Improved line height */
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 16px; /* Increased gap */
}

.option-btn {
    text-align: left;
    padding: 20px; /* Increased padding */
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px; /* Rounded corners */
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.05rem; /* Slightly larger text */
    position: relative;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.option-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    transform: translateY(-1px);
}

/* Control Buttons */
.btn-control {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-control:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.btn-control:active {
    transform: translateY(0);
}

.btn-primary {
    background: #2563eb;
    color: white;
}
.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #64748b;
    color: white;
}
.btn-secondary:hover {
    background: #475569;
}

.btn-success {
    background: #10b981;
    color: white;
}
.btn-success:hover {
    background: #059669;
}

.btn-warning {
    background: #f59e0b;
    color: white;
}
.btn-warning:hover {
    background: #d97706;
}

.btn-danger {
    background: #ef4444;
    color: white;
}
.btn-danger:hover {
    background: #dc2626;
}

/* Controls Container Refinement */
.controls-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #f1f5f9;
    gap: 20px;
    flex-wrap: wrap;
}

.controls-left, .controls-right {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .question-container {
        padding-bottom: 20px;
    }
    
    .question-card {
        padding: 20px;
        margin-bottom: 16px;
    }

    .controls-container {
        flex-direction: column;
        gap: 16px;
        margin-top: 24px;
        border-top: none;
    }

    .controls-left, .controls-right {
        flex-direction: column;
        width: 100%;
        gap: 12px;
    }

    .btn-control {
        width: 100%;
        padding: 16px; /* Larger touch target */
        font-size: 1.1rem;
    }
}

.option-btn.selected {
    border-color: #1d4ed8;
    background: #eef2ff;
}

.option-btn.correct {
    background: #065f46;
    border-color: #059669;
    color: #fff;
}

.option-btn.incorrect {
    background: #7f1d1d;
    border-color: #dc2626;
    color: #fff;
}

/* Question Controls */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
    flex-wrap: wrap;
    gap: 10px;
}

.transcription-box {
    margin-top: 20px;
    padding: 15px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-left: 4px solid #ef4444;
    border-radius: 8px;
    color: #111827;
    font-size: 0.95rem;
    line-height: 1.6;
    display: none;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Formatted Body (EE/EO) */
.formatted-body {
    margin-top: 20px;
}

/* Empty State */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 1.1rem;
}

/* Expression specific */
.task-section {
    background: #ffffff;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid #e5e7eb;
}

.task-section h3 {
    margin-top: 0;
    color: #1d4ed8;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.task-text {
    white-space: pre-wrap;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #ffffff;
}

::-webkit-scrollbar-thumb {
    background: #e5e7eb;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #d1d5db;
}

/* Results Report */
.results-report {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.summary-card {
    display: flex;
    justify-content: space-around;
    background: #f8fafc;
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 24px;
    border: 1px solid #e2e8f0;
}

.summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.summary-label {
    font-size: 0.9rem;
    color: #64748b;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.summary-value {
    font-size: 2rem;
    font-weight: 700;
    color: #0f172a;
}

.level-badge {
    color: #2563eb;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.stat-item {
    padding: 16px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid transparent;
}

.stat-item.correct {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.stat-item.incorrect {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.stat-item.skipped {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #475569;
}

.stat-count {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.85rem;
    opacity: 0.9;
}

.table-container {
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.results-table th,
.results-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.results-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
}

.results-table tr:last-child td {
    border-bottom: none;
}

.status-correct td {
    background: #f0fdf4;
    color: #166534;
}

.status-incorrect td {
    background: #fef2f2;
    color: #991b1b;
}

.status-skipped td {
    background: #f8fafc;
    color: #64748b;
    font-style: italic;
}
/* --- Grammar Section Styles --- */
.grammar-container {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.grammar-sidebar {
    width: 250px;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    overflow-y: auto;
    padding: 10px;
    flex-shrink: 0;
}

.grammar-sidebar h3 {
    font-size: 1rem;
    color: #1e293b;
    margin-top: 15px;
    margin-bottom: 10px;
    padding-left: 10px;
    border-bottom: 2px solid #cbd5e1;
    padding-bottom: 5px;
}

.grammar-sidebar ul {
    list-style: none;
    padding: 0;
}

.grammar-sidebar li {
    margin-bottom: 5px;
}

.grammar-sidebar button {
    width: 100%;
    text-align: left;
    padding: 10px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    color: #475569;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.grammar-sidebar button:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.grammar-sidebar button.active {
    background: #bfdbfe;
    color: #1e40af;
    font-weight: 600;
}

.grammar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.exercise-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.exercise-question {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: #334155;
}

.exercise-interaction {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.exercise-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    min-width: 200px;
}

.check-btn {
    padding: 10px 20px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.check-btn:hover {
    background: #1d4ed8;
}

.toggle-answer-btn {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.9rem;
}

.answer {
    margin-top: 10px;
    padding: 10px;
    background: #dcfce7;
    border: 1px solid #86efac;
    border-radius: 6px;
    color: #166534;
}

.answer.hidden {
    display: none;
}

.feedback-msg {
    margin-left: 10px;
    font-weight: 500;
}

.feedback-msg.success {
    color: #16a34a;
}

.feedback-msg.error-msg {
    color: #dc2626;
}

.feedback-msg.warning {
    color: #d97706;
}

/* Mobile adjustments for Grammar */
@media (max-width: 768px) {
    .grammar-container {
        flex-direction: column;
        height: auto;
    }
    
    .grammar-sidebar {
        width: 100%;
        max-height: none;
        border-right: none;
        border-bottom: none;
    }
    
    .grammar-content {
        padding-bottom: 100px; /* Space for fixed buttons */
    }
}
