/* === CSCA Trilingual Platform - Style === */
:root {
    /* Linear Pro / Apple Studio design tokens */
    color-scheme: dark;
    --primary: #4f46e5;
    --primary-strong: #6366f1;
    --secondary: #3b82f6;
    --accent: #6366f1;
    --cyan: #38bdf8;
    --bg-dark: #08090d;
    --bg-elevated: #12151d;
    --card-bg: rgba(18, 21, 29, 0.72);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --text-tertiary: #64748b;
    --glass-border: rgba(255, 255, 255, 0.07);
    --glass-highlight: rgba(255, 255, 255, 0.04);
    --shadow-glass: 0 12px 36px rgba(0, 0, 0, 0.5);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #f43f5e;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --motion-fast: 140ms ease;
    --motion-standard: 220ms ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(ellipse 90% 60% at 50% -10%, rgba(79, 70, 229, 0.08), transparent 70%),
        radial-gradient(ellipse 70% 50% at 90% 100%, rgba(59, 130, 246, 0.05), transparent 60%),
        linear-gradient(180deg, #0b0d13 0%, var(--bg-dark) 100%);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.5;
    letter-spacing: -0.011em;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Language-specific fonts */
body[lang="en"] { font-family: 'Inter', 'Cairo', sans-serif; direction: ltr; }
body[lang="zh"] { font-family: 'Noto Sans SC', 'Inter', sans-serif; direction: ltr; }
body[lang="ar"] { direction: rtl; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== Language Switcher ===== */
.lang-switcher {
    display: flex;
    gap: 8px;
    align-items: center;
}
.lang-bar { background:rgba(8,13,28,.72); border-bottom:1px solid var(--glass-border); padding:8px 0; }
.lang-bar-inner { display:flex; align-items:center; gap:14px; }

.lang-btn {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    transition: all 0.3s;
}

.lang-btn.active {
    background: linear-gradient(135deg, var(--primary-strong), var(--secondary));
    color: #fff;
    border-color: rgba(190, 207, 255, 0.42);
    font-weight: 600;
}

.lang-btn:hover:not(.active) {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

/* ===== Hero ===== */
.hero {
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: radial-gradient(ellipse at 18% 20%, rgba(88, 127, 242, 0.2), transparent 42%),
                radial-gradient(ellipse at 82% 80%, rgba(148, 110, 235, 0.16), transparent 40%);
    position: relative;
    border-bottom: 1px solid var(--glass-border);
    padding: 40px 20px;
}

.hero::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px;
    background: linear-gradient(to top, var(--bg-dark), transparent);
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 800px;
}

.hero-content h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(115deg, #fff 5%, #b6ccff 58%, #beaaff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
    animation: fadeInUp 1s ease;
}

.hero-content p {
    font-size: 1.1rem;
    color: var(--text-dim);
    margin-bottom: 2rem;
    animation: fadeInUp 1.2s ease;
}

.search-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    animation: fadeInUp 1.4s ease;
}

.search-container input {
    width: 100%;
    padding: 15px 50px 15px 20px;
    border-radius: 30px;
    border: 1px solid var(--glass-border);
    background: rgba(14, 23, 44, 0.76);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    font-family: inherit;
    transition: all 0.3s ease;
}

.search-container input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 3px rgba(118, 169, 255, 0.14), 0 12px 30px rgba(25, 51, 116, 0.2);
}
.search-results { position:absolute; z-index:30; top:calc(100% + 10px); inset-inline:0; max-height:min(68vh,540px); overflow-y:auto; padding:7px; border:1px solid rgba(186,203,255,.2); border-radius:16px; background:rgba(12,19,37,.97); box-shadow:0 22px 48px rgba(0,0,0,.46); text-align:start; }
.search-result { display:grid; grid-template-columns:auto 1fr; gap:3px 11px; padding:11px 12px; border-radius:10px; color:var(--text-main); text-decoration:none; }
.search-result:hover, .search-result.active { background:rgba(118,169,255,.11); }
.search-result-type { grid-row:span 2; align-self:center; min-width:62px; padding:4px 7px; border:1px solid rgba(167,139,250,.2); border-radius:8px; color:#cbbfff; font-size:.75rem; text-align:center; }
.search-result strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:.92rem; }
.search-result-detail { overflow:hidden; color:var(--text-dim); text-overflow:ellipsis; white-space:nowrap; font-size:.79rem; }
.search-empty { padding:18px; color:var(--text-dim); }

.search-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
}
body[lang="ar"] .search-icon { right: 20px; }
body[lang="en"] .search-icon, body[lang="zh"] .search-icon { left: 20px; }

/* ===== Nav ===== */
.main-nav {
    background: rgba(8, 9, 13, 0.82);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--glass-border);
    padding: 10px 0;
}

.main-nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.brand {
    flex: 0 0 auto;
    color: var(--text-main);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-decoration: none;
    white-space: nowrap;
}
.brand span { color: var(--text-tertiary); font-weight: 500; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; margin-inline-start: 4px; }
.nav-toggle {
    display: none;
    width: 36px;
    height: 36px;
    padding: 8px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    cursor: pointer;
}
.nav-toggle span { display: block; height: 2px; margin: 3px 0; border-radius: 1px; background: var(--text-main); }

.nav-links {
    display: flex;
    gap: 8px;
}

.nav-links a {
    color: var(--text-dim);
    text-decoration: none;
    font-weight: 500;
    transition: all var(--motion-fast);
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.nav-links a:hover {
    color: var(--text-main);
    background: var(--bg-elevated);
}

.nav-links a.active {
    color: var(--text-main);
    background: var(--bg-elevated);
    border: 1px solid var(--glass-border);
    font-weight: 600;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin: 24px 0;
}

.stat-card {
    background: var(--bg-elevated);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 25px;
    text-align: center;
    box-shadow: var(--shadow-glass), inset 0 1px 0 var(--glass-highlight);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: #a9c6ff;
}

.stat-label {
    color: var(--text-dim);
    margin-top: 8px;
    font-size: 0.9rem;
}

/* Dashboard overview and activity snapshots */
.dashboard-panel { margin: 0 0 46px; padding: 30px; }
.dashboard-heading-row { display:flex; justify-content:space-between; align-items:flex-start; gap:22px; }
.dashboard-kicker { margin-bottom:8px; color:#aabaff; font-size:.76rem; font-weight:700; letter-spacing:.14em; }
.dashboard-heading-row h2 { color:#fff; font-size:clamp(1.35rem, 3vw, 1.9rem); margin-bottom:7px; }
.dashboard-intro { color:var(--text-dim); }
.dashboard-action { flex:0 0 auto; margin-top:8px; padding:11px 17px; border:1px solid rgba(178,197,255,.25); border-radius:12px; color:#fff; text-decoration:none; background:linear-gradient(130deg,rgba(73,109,198,.42),rgba(124,91,188,.35)); }
.dashboard-snapshot { display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:14px; margin-top:24px; }
.snapshot-item { padding:15px 17px; border:1px solid rgba(186,203,255,.1); border-radius:13px; background:rgba(8,14,29,.38); }
.snapshot-label { color:var(--text-dim); font-size:.83rem; }
.snapshot-value { display:block; margin-top:4px; color:#e8edff; font-size:1.08rem; font-weight:700; }

/* ===== Subject Sections ===== */
.subject-section { padding: 50px 0; }

.section-title {
    font-size: 1.8rem;
    margin-bottom: 25px;
    position: relative;
    padding-bottom: 10px;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    width: 60px;
    height: 4px;
    background: var(--primary);
    border-radius: 2px;
}
body[lang="ar"] .section-title::after { right: 0; }
body[lang="en"] .section-title::after, body[lang="zh"] .section-title::after { left: 0; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

.card {
    padding: 25px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: var(--shadow-glass), inset 0 1px 0 var(--glass-highlight);
    transition: transform var(--motion-standard), border-color var(--motion-standard), background var(--motion-standard), box-shadow var(--motion-standard);
    text-decoration: none;
    color: inherit;
    display: block;
}

.card:hover {
    transform: translateY(-3px);
    background: rgba(28, 40, 69, 0.82);
    border-color: rgba(145, 177, 255, 0.38);
    box-shadow: 0 24px 55px rgba(1, 5, 18, 0.42), inset 0 1px 0 rgba(255,255,255,.1);
}

.card h3, .card h4 {
    font-size: 1.3rem;
    margin-bottom: 12px;
    color: #fff;
}

.card p {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.card-difficulty {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    margin-top: 8px;
}

.diff-easy { background: rgba(46, 213, 115, 0.2); color: #2ed573; }
.diff-medium { background: rgba(255, 165, 2, 0.2); color: #ffa502; }
.diff-hard { background: rgba(255, 71, 87, 0.2); color: #ff4757; }

/* ===== Exam Info ===== */
.exam-info {
    background: linear-gradient(135deg, rgba(77, 111, 205, 0.18), rgba(123, 89, 199, 0.14));
    border: 1px solid rgba(164, 177, 255, 0.28);
    border-radius: 24px;
    padding: 40px;
    margin: 50px 0;
}

.info-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.info-item {
    text-align: center;
    padding: 15px;
    background: rgba(7, 12, 26, 0.4);
    border: 1px solid rgba(255,255,255,.055);
    border-radius: 12px;
}

.info-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
}

.info-label {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 5px;
}

/* ===== Questions Page ===== */
.filter-container {
    margin: 25px 0;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    background: var(--bg-elevated);
    color: var(--text-dim);
    cursor: pointer;
    transition: all var(--motion-fast);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
}

.filter-btn.active {
    background: var(--primary);
    border-color: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.filter-btn:hover:not(.active) {
    background: #171b26;
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.12);
}

.question-card {
    margin-bottom: 16px;
    padding: 22px 24px;
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-sm);
}
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.question-tools { display:grid; grid-template-columns:minmax(220px,1.5fr) minmax(180px,1fr) auto; gap:12px; align-items:center; margin:20px 0; padding:16px; background:var(--bg-elevated); border:1px solid var(--glass-border); border-radius:var(--radius-lg); }
.question-tools input, .question-tools select { min-height:40px; padding:8px 12px; background:var(--bg-dark); border:1px solid var(--glass-border); border-radius:var(--radius-sm); color:var(--text-main); }
.question-tools input::placeholder { color:var(--text-tertiary); }
.question-modes { display:flex; flex-wrap:wrap; gap:6px; grid-column:1 / -1; }
.question-modes .filter-btn { padding:6px 12px; }
.question-topic { padding:3px 8px; color:var(--text-tertiary); border:1px solid var(--glass-border); border-radius:var(--radius-xs); font-size:.72rem; font-family:'JetBrains Mono',monospace; }
.bookmark-button { margin-inline-start:auto; padding:4px 10px; border:1px solid var(--glass-border); border-radius:var(--radius-xs); background:transparent; color:var(--text-tertiary); cursor:pointer; font-size:.72rem; transition:all var(--motion-fast); }
.bookmark-button[aria-pressed="true"] { color:var(--amber); border-color:rgba(245,158,11,.3); background:rgba(245,158,11,.1); }
.bookmark-button:hover { color:var(--text-main); border-color:rgba(255,255,255,0.18); }
.bookmark-button:disabled { opacity:.65; cursor:not-allowed; }
.question-option { display:flex; align-items:center; gap:12px; margin:8px 0; padding:10px 14px; border:1px solid var(--glass-border); border-radius:var(--radius-md); background:var(--bg-dark); cursor:pointer; transition:all var(--motion-fast); }
.question-option:hover { background:#141824; border-color:rgba(255,255,255,0.14); }
.question-option input[type="radio"] { accent-color:var(--primary); width:15px; height:15px; margin:0; }
.question-option:has(input:checked) { border-color:rgba(118,169,255,.36); background:rgba(118,169,255,.09); }
.question-option input { flex:0 0 auto; margin-block-start:.35em; accent-color:var(--primary-strong); }
.answer-feedback { min-height:1.5em; margin:8px 0; color:#c8d5f1; font-weight:700; }

.question-text {
    font-size: 1.1rem;
    margin-bottom: 15px;
    font-weight: 600;
}

.question-en {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-bottom: 12px;
    font-style: italic;
}

body[lang="en"] .question-en, body[lang="zh"] .question-en { display: none; }

.option-label {
    display: block;
    margin: 8px 0;
    cursor: pointer;
    padding: 8px 15px;
    border-radius: 10px;
    transition: background 0.2s;
}

.option-label:hover {
    background: rgba(255,255,255,0.05);
}

.option-input {
    margin-left: 10px;
    margin-right: 10px;
}

.tag {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 5px;
    font-size: 0.8rem;
    margin-bottom: 10px;
    color: #fff;
}

.tag-math { background: var(--secondary); }
.tag-phys { background: var(--accent); }
.tag-chem { background: #4ade80; }
.tag-eng  { background: #a78bfa; }

/* ===== Formulas stay LTR and isolated even in the Arabic (RTL) view ===== */
mjx-container { direction: ltr; unicode-bidi: isolate; }
body[lang="ar"] .lesson-section table { direction: rtl; }
body[lang="ar"] .lesson-section td, body[lang="ar"] .lesson-section th { direction: rtl; }

/* ===== Lesson Viewer ===== */
.lesson-section {
    margin: 30px 0;
    padding: 25px;
    border-radius: var(--radius-md);
    background: rgba(17, 25, 45, 0.58);
    border: 1px solid var(--glass-border);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.035);
}
.lesson-actions { margin:36px 0 50px; padding:22px; border:1px solid var(--glass-border); border-radius:var(--radius-md); background:rgba(17,25,45,.55); }
.lesson-navigation { display:grid; grid-template-columns:1fr auto 1fr; align-items:center; gap:12px; }
.lesson-nav-link { color:#b7c8ff; text-decoration:none; padding:11px 14px; border:1px solid rgba(186,203,255,.12); border-radius:11px; }
.lesson-nav-link:hover { background:rgba(118,169,255,.08); }
.lesson-nav-link:last-child { text-align:end; }
.lesson-complete { color:var(--text-main); padding:11px 15px; border:1px solid rgba(186,203,255,.2); border-radius:11px; background:rgba(72,93,153,.24); cursor:pointer; }
.lesson-complete[aria-pressed="true"] { border-color:rgba(84,214,160,.4); background:rgba(43,139,101,.2); }
.lesson-complete:disabled { opacity:.65; cursor:not-allowed; }
.lesson-practice { display:flex; justify-content:center; margin-top:22px; }
.lesson-practice .start-btn { display:inline-block; padding:13px 25px; border-radius:13px; text-decoration:none; font-weight:700; }
.tutor-box { margin:18px 0; padding:17px; border:1px solid rgba(167,139,250,.2); border-radius:var(--radius-md); background:rgba(70,57,120,.12); }
.tutor-box h2 { margin-bottom:8px; color:#d7cbff; font-size:1.08rem; }
.tutor-note { margin:0 0 10px; color:var(--text-dim); font-size:.82rem; }
.tutor-prompt { display:block; width:100%; min-height:74px; margin:8px 0; padding:11px 13px; resize:vertical; }
.tutor-button { padding:9px 14px; border:1px solid rgba(183,166,255,.28); border-radius:10px; color:#f1edff; background:rgba(120,96,191,.26); cursor:pointer; }
.tutor-button:disabled { opacity:.7; cursor:wait; }
.tutor-response { margin-top:14px; padding:14px; border-radius:11px; background:rgba(6,11,24,.45); white-space:pre-wrap; }
.tutor-response > strong { color:#c7b8ff; }
.tutor-response > p { margin-top:8px; color:#e4e9f7; }

/* Results and analytics */
.analytics-page { padding-bottom:30px; }
.analytics-header { padding:38px 0 20px; }
.analytics-header .section-title { margin:0 0 8px; }
.analytics-header > p:last-child, .analytics-note { color:var(--text-dim); }
.analytics-stats { display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:15px; margin:18px 0 24px; }
.analytics-stat { display:flex; flex-direction:column; gap:5px; padding:19px; }
.analytics-stat-value { color:#c1d2ff; font-size:1.7rem; }
.analytics-stat-label { color:var(--text-dim); font-size:.86rem; }
.analytics-section { margin:22px 0; padding:24px; }
.analytics-section h2 { margin-bottom:10px; color:#f4f6ff; font-size:1.2rem; }
.chart-wrap { width:100%; min-height:210px; overflow:hidden; }
.chart-wrap svg { display:block; width:100%; min-width:420px; height:260px; overflow:visible; }
.chart-axis { stroke:rgba(201,213,245,.36); stroke-width:1; }
.chart-gridline { stroke:rgba(201,213,245,.12); stroke-width:1; stroke-dasharray:4 5; }
.chart-tick { fill:#a4b0c8; font-size:12px; }
.score-line { fill:none; stroke:#a994ff; stroke-width:3; stroke-linecap:round; stroke-linejoin:round; }
.score-point { fill:#c4b5fd; stroke:#17162e; stroke-width:3; }
.analytics-columns { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:20px; }
.performance-row { margin:15px 0; }
.performance-row-head { display:flex; justify-content:space-between; gap:12px; margin-bottom:7px; color:#dce4f8; font-size:.9rem; }
.performance-row-head strong { color:#bacbff; white-space:nowrap; }
.performance-track { height:8px; overflow:hidden; border-radius:10px; background:rgba(255,255,255,.08); }
.performance-track span { display:block; height:100%; border-radius:inherit; background:linear-gradient(90deg,#668fe8,#a58bf1); }
.recommendation { margin:12px 0 18px; padding:13px 15px; border:1px solid rgba(118,169,255,.2); border-radius:12px; color:#dce5ff; background:rgba(64,91,164,.14); }
.empty-state { padding:18px 4px; color:var(--text-dim); }
.table-scroll { overflow-x:auto; }
.analytics-table { width:100%; min-width:560px; border-collapse:collapse; text-align:start; }
.analytics-table th, .analytics-table td { padding:12px 10px; border-bottom:1px solid rgba(186,203,255,.1); text-align:start; }
.analytics-table th { color:#b8c9f6; font-size:.82rem; }
.analytics-table td { color:#e1e8f8; }
.profile-page { padding-bottom:32px; }
.profile-settings { margin:10px 0 22px; padding:22px; }
.profile-settings h2, .profile-section h2 { margin-bottom:10px; color:#f4f6ff; font-size:1.15rem; }
.profile-form-fields { display:grid; grid-template-columns:minmax(160px, .7fr) minmax(180px, 1.3fr); align-items:center; gap:12px 18px; max-width:680px; margin:18px 0; }
.profile-form-fields label { color:#cbd5ec; }
.profile-form-fields input { min-height:42px; padding:9px 12px; }
.profile-save-message { min-height:1.5em; margin-top:10px; color:#bdc9e2; }
.profile-stats { display:grid; grid-template-columns:repeat(auto-fit,minmax(175px,1fr)); gap:14px; margin:22px 0; }
.profile-stat { display:flex; flex-direction:column; gap:4px; padding:18px; }
.profile-stat-value { color:#c1d2ff; font-size:1.5rem; }
.profile-stat-label { color:var(--text-dim); font-size:.85rem; }
.profile-columns { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:20px; }
.profile-section { margin:20px 0; padding:22px; }
.profile-subheading { margin-top:25px; }
.profile-recommendation { display:block; text-decoration:none; }
.achievement-list { display:grid; gap:10px; }
.achievement { padding:11px 13px; color:#8995ad; border:1px solid rgba(186,203,255,.09); border-radius:10px; background:rgba(8,14,29,.25); }
.achievement.earned { color:#d4ddf2; border-color:rgba(165,139,241,.27); background:rgba(111,89,180,.12); }
.activity-row { display:flex; justify-content:space-between; gap:16px; padding:12px 2px; border-bottom:1px solid rgba(186,203,255,.08); color:#dce4f6; }
.activity-row time { flex:0 0 auto; color:var(--text-dim); font-size:.85rem; }

.lesson-section h2 {
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.lesson-section h3 {
    color: #fff;
    margin: 20px 0 10px;
    font-size: 1.2rem;
}

.lesson-section p, .lesson-section li {
    color: var(--text-dim);
    line-height: 1.8;
    margin: 8px 0;
}

body[lang="zh"] .lesson-section p,
body[lang="zh"] .lesson-section li {
    font-size: 0.95rem;
}

.definition-box {
    background: rgba(76, 201, 240, 0.08);
    border-right: 4px solid var(--primary);
    padding: 20px;
    margin: 20px 0;
    border-radius: 12px;
}
body[lang="en"] .definition-box, body[lang="zh"] .definition-box {
    border-right: none;
    border-left: 4px solid var(--primary);
}

body[lang="zh"] .definition-box {
    border-left-color: var(--accent);
}

.law-box {
    background: rgba(67, 97, 238, 0.08);
    border: 1px dashed var(--secondary);
    padding: 20px;
    margin: 20px 0;
    border-radius: 12px;
}

.example-box {
    background: rgba(46, 213, 115, 0.05);
    border: 1px dashed var(--success);
    padding: 25px;
    margin: 25px 0;
    border-radius: 15px;
}

.example-box h4 {
    color: var(--success);
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.tip-box {
    background: rgba(255, 165, 2, 0.08);
    border-right: 5px solid var(--warning);
    padding: 20px;
    margin: 20px 0;
    border-radius: 12px;
}
body[lang="en"] .tip-box, body[lang="zh"] .tip-box {
    border-right: none;
    border-left: 5px solid var(--warning);
}

.tip-box h4 { color: var(--warning); }

.pitfall-box {
    background: rgba(255, 71, 87, 0.08);
    border-right: 5px solid var(--danger);
    padding: 20px;
    margin: 20px 0;
    border-radius: 12px;
}
body[lang="en"] .pitfall-box, body[lang="zh"] .pitfall-box {
    border-right: none;
    border-left: 5px solid var(--danger);
}

.pitfall-box h4 { color: var(--danger); }

/* ===== Back Button ===== */
.back-btn {
    display: inline-block;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    margin: 20px 0;
    transition: transform 0.3s;
}

.back-btn:hover { transform: translateX(-5px); }
body[lang="en"] .back-btn:hover, body[lang="zh"] .back-btn:hover { transform: translateX(5px); }

/* ===== Animations ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Footer ===== */
footer {
    padding: 40px 0;
    text-align: center;
    border-top: 1px solid var(--glass-border);
    color: var(--text-dim);
    margin-top: 60px;
}

/* ===== Developer Signature ===== */
.developer-sig {
    text-align: center;
    padding: 50px 20px;
    border-top: 1px solid var(--glass-border);
    margin-top: 60px;
    background: linear-gradient(to bottom, transparent, rgba(89, 113, 203, 0.08));
}

.developer-sig h3 {
    color: var(--primary);
    font-size: 1.6rem;
    margin-bottom: 10px;
}

.motivational {
    font-style: italic;
    color: var(--text-dim);
    font-size: 1.05rem;
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
    .hero-content h1 { font-size: 2rem; }
    .grid { grid-template-columns: 1fr; }
    .main-nav .container { flex-direction: row; flex-wrap: wrap; }
    .main-nav .container > .brand { margin-inline-end: auto; }
    .nav-toggle { display:block; order:2; }
    .nav-links { display:none; order:3; width:100%; flex-direction:column; align-items:stretch; gap:2px; padding:8px 0 4px; }
    .nav-links.is-open { display:flex; }
    .nav-links a { padding:12px 14px; border-radius:10px; }
    .nav-links a:hover, .nav-links a.active { background:rgba(118,169,255,.09); }
    .lang-switcher { margin-top: 5px; }
    .exam-info { padding: 20px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .card { border-radius: var(--radius-md); }
    .main-nav { position: sticky; }
    .nav-links { gap: 12px 18px; }
}

/* Shared interaction, form, and accessibility primitives */
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 3px;
}
input:not([type="radio"]):not([type="checkbox"]), select, textarea {
    color: var(--text-main);
    background: rgba(11, 18, 35, 0.82);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
}
select option { background: #111a30; color: var(--text-main); }
.exam-btn, .start-btn {
    color: #fff;
    background: linear-gradient(135deg, var(--primary-strong), #6e63cf);
    border: 1px solid rgba(203, 215, 255, .2);
    box-shadow: 0 8px 20px rgba(48, 70, 150, .22), inset 0 1px 0 rgba(255,255,255,.12);
    transition: transform var(--motion-fast), filter var(--motion-fast), box-shadow var(--motion-fast);
}
.exam-btn:hover:not(:disabled), .start-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
    box-shadow: 0 11px 25px rgba(48, 70, 150, .32), inset 0 1px 0 rgba(255,255,255,.16);
}
.exam-btn.submit { background: linear-gradient(135deg, #7766df, #9b68d5); }
.timer { background: rgba(119, 102, 223, .15) !important; border-color: rgba(167, 139, 250, .56) !important; color: #c2b5ff !important; }
.timer.warn { color: var(--danger) !important; border-color: var(--danger) !important; }
.storage-warning { margin:16px 0; padding:12px 15px; border:1px solid rgba(244,189,104,.34); border-radius:12px; color:#f5d7a2; background:rgba(115,78,25,.18); }
.option-label:hover, .opt-row:hover { background: rgba(118, 169, 255, .09); }

.exam-question-navigation { margin: 1rem 0 1.25rem; }
.exam-question-navigation-header { display:flex; align-items:center; justify-content:space-between; gap:1rem; margin-bottom:.7rem; }
.exam-question-navigation-header h2 { margin:0; font-size:1rem; }
.exam-question-palette { display:flex; flex-wrap:wrap; gap:.45rem; }
.exam-question-number { min-width:2.5rem; min-height:2.5rem; border:1px solid var(--glass-border); border-radius:.75rem; color:var(--text-main); background:rgba(255,255,255,.04); cursor:pointer; transition:background .16s ease, border-color .16s ease, transform .16s ease; }
.exam-question-number:hover { transform:translateY(-1px); background:rgba(118,169,255,.12); }
.exam-question-number.answered { background:rgba(51,211,163,.12); border-color:rgba(51,211,163,.45); }
.exam-question-number.marked-review { box-shadow:inset 0 -3px 0 var(--secondary); }
.exam-question-number.current { outline:2px solid var(--primary); outline-offset:2px; }
.exam-question-number:focus-visible { outline:2px solid var(--cyan); outline-offset:3px; }
@media (max-width:600px) { .exam-question-navigation-header { align-items:flex-start; flex-direction:column; } .exam-question-number { min-width:2.75rem; min-height:2.75rem; } }
::selection { background: rgba(118, 169, 255, .32); color: #fff; }

@media (max-width: 480px) {
    .container { padding-inline: 16px; }
    .hero { min-height: 42vh; padding: 34px 16px; }
    .hero-content h1 { font-size: clamp(1.7rem, 8vw, 2.2rem); }
    .hero-content p { font-size: 1rem; }
    .stats-grid { gap: 12px; }
    .stat-card { padding: 17px 12px; }
    .stat-number { font-size: 2rem; }
    .exam-desc { padding: 22px 16px; border-radius: var(--radius-md); }
    .question-card { padding: 18px; }
    .dashboard-panel { padding:20px 17px; }
    .dashboard-heading-row { flex-direction:column; }
    .dashboard-action { margin-top:0; }
    .lesson-actions { padding:15px; }
    .lesson-navigation { grid-template-columns:1fr 1fr; }
    .lesson-complete { grid-column:1 / -1; grid-row:1; }
    .question-tools { grid-template-columns:1fr; padding:14px; }
    .question-modes { grid-column:1; }
    .analytics-section { padding:18px; }
    .analytics-columns { grid-template-columns:1fr; gap:0; }
    .analytics-stats { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .profile-columns { grid-template-columns:1fr; gap:0; }
    .profile-form-fields { grid-template-columns:1fr; gap:8px; }
    .profile-form-fields label:not(:first-child) { margin-top:8px; }
    .activity-row { flex-direction:column; gap:4px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .card, .main-nav, .search-container input { background-color: rgba(16, 24, 44, .96); }
}

/* ===== Linear Pro / Apple Studio Dashboard ===== */
.dashboard-page {
    background: var(--bg-dark);
    background-image:
        radial-gradient(ellipse 90% 60% at 50% -10%, rgba(79, 70, 229, 0.08), transparent 70%),
        radial-gradient(ellipse 70% 50% at 90% 100%, rgba(59, 130, 246, 0.05), transparent 60%),
        linear-gradient(180deg, #0b0d13 0%, var(--bg-dark) 100%);
}
.dashboard-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.dashboard-sidebar {
    position: sticky; top: 0; z-index: 120;
    display: flex; flex-direction: column; height: 100vh;
    padding: 16px 12px;
    border-inline-end: 1px solid var(--glass-border);
    background: var(--bg-dark);
}
.dashboard-sidebar-head { margin-bottom: 20px; }
.dashboard-brand {
    display: flex; align-items: center; gap: 10px;
    color: var(--text-main); text-decoration: none;
    font-size: 1.05rem; font-weight: 700; letter-spacing: -0.02em;
}
.dashboard-brand b { color: var(--text-main); font-weight: 600; }
.dashboard-brand small { display: block; margin-top: 2px; color: var(--text-tertiary); font-size: .68rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.dashboard-brand-mark {
    display: grid; width: 34px; height: 34px; place-items: center;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #4f46e5, #3b82f6);
    box-shadow: 0 0 12px rgba(79, 70, 229, 0.35), inset 0 1px 0 rgba(255,255,255,0.2);
    font-size: 1.1rem;
}
.dashboard-nav { display: grid; gap: 2px; }
.dashboard-shell .dashboard-nav a {
    display: flex; align-items: center; gap: 10px; min-height: 38px;
    padding: 0 10px; border-radius: var(--radius-sm);
    color: var(--text-dim); text-decoration: none;
    font-size: .84rem; font-weight: 500;
    transition: background var(--motion-fast), color var(--motion-fast);
}
.dashboard-shell .dashboard-nav a:hover { color: var(--text-main); background: var(--bg-elevated); }
.dashboard-shell .dashboard-nav a.active {
    color: var(--text-main); background: var(--bg-elevated);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 1px 3px rgba(0,0,0,0.4);
    font-weight: 600;
}
.dashboard-icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.dashboard-shell svg:not(.dashboard-icon-library) { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side-icon {
    display: grid; flex: 0 0 22px; width: 22px; height: 22px; place-items: center;
    border-radius: var(--radius-xs); color: var(--text-tertiary);
}
.dashboard-shell .dashboard-nav a.active .side-icon { color: var(--accent); }
.side-icon svg { width: 15px; height: 15px; }
.dashboard-sidebar-bottom {
    margin-top: auto; padding: 12px 2px 0;
    border-top: 1px solid var(--glass-border);
}
.sidebar-language-label { display: block; margin: 0 0 6px 4px; color: var(--text-tertiary); font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.dashboard-sidebar .lang-switcher {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px;
    padding: 2px; border-radius: var(--radius-sm);
    background: var(--bg-elevated); border: 1px solid var(--glass-border);
}
.dashboard-sidebar .lang-btn {
    padding: 4px 0; text-align: center; border-radius: var(--radius-xs);
    border: none; background: transparent; color: var(--text-tertiary);
    font-size: .72rem; font-weight: 600; cursor: pointer; transition: all .15s ease;
}
.dashboard-sidebar .lang-btn:hover { color: var(--text-dim); }
.dashboard-sidebar .lang-btn.active {
    background: var(--bg-dark); color: var(--text-main);
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.sidebar-version { margin: 12px 4px 0; color: var(--text-tertiary); font-size: .66rem; font-family: 'JetBrains Mono', monospace; }
.dashboard-main { min-width: 0; background: var(--bg-dark); }
.dashboard-topbar {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; gap: 16px;
    min-height: 62px; padding: 10px clamp(18px, 3vw, 36px);
    border-bottom: 1px solid var(--glass-border);
    background: rgba(8, 9, 13, 0.75);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.dashboard-search { width: auto; max-width: 440px; flex: 1; margin: 0; animation: none; position: relative; }
.dashboard-search input {
    min-height: 38px; padding-block: 8px; padding-inline: 36px 54px;
    border: 1px solid var(--glass-border); border-radius: var(--radius-md);
    background: var(--bg-elevated); color: var(--text-main); font-size: .84rem;
    transition: all .15s ease;
}
.dashboard-search input:focus {
    border-color: rgba(99, 102, 241, 0.45);
    background: #171b26;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
.dashboard-search .search-icon {
    position: absolute; top: 50%; transform: translateY(-50%);
    left: 12px; right: auto; display: grid; width: 15px; height: 15px;
    place-items: center; color: var(--text-tertiary); pointer-events: none;
}
.dashboard-search .search-icon svg { width: 14px; height: 14px; }
body[lang="ar"] .dashboard-search .search-icon { right: 12px; left: auto; }
.dashboard-search kbd {
    position: absolute; top: 50%; right: 10px; transform: translateY(-50%);
    padding: 2px 5px; border: 1px solid var(--glass-border);
    border-radius: var(--radius-xs); color: var(--text-tertiary);
    background: var(--bg-dark); font-family: 'JetBrains Mono', monospace; font-size: .65rem; font-weight: 500;
}
body[lang="ar"] .dashboard-search kbd { left: 10px; right: auto; }
.dashboard-user {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 12px; border-radius: var(--radius-sm);
    background: var(--bg-elevated); border: 1px solid var(--glass-border);
    color: var(--text-main); text-decoration: none;
    font-size: .8rem; font-weight: 500; white-space: nowrap;
    transition: all .12s ease;
}
.dashboard-user:hover { background: #171b26; border-color: rgba(255,255,255,0.12); }
.dashboard-avatar {
    display: grid; width: 22px; height: 22px; place-items: center;
    border-radius: 50%; color: #fff;
    background: linear-gradient(135deg, #4f46e5, #3b82f6);
}
.dashboard-avatar svg { width: 12px; height: 12px; }
.dashboard-content.container { width: 100%; max-width: none; margin: 0; padding: 24px clamp(18px, 3vw, 36px) 48px; }

/* Linear Pro Hero */
.dashboard-hero {
    position: relative; display: flex; align-items: center;
    min-height: 180px; overflow: hidden;
    padding: 24px 28px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    background:
        radial-gradient(ellipse 60% 80% at 85% 50%, rgba(79, 70, 229, 0.16), transparent 60%),
        radial-gradient(ellipse 50% 60% at 40% 100%, rgba(59, 130, 246, 0.1), transparent 50%),
        linear-gradient(135deg, #10141f 0%, #0d1017 100%);
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.06);
}
.dashboard-hero::after { display: none; }
.dashboard-hero-copy { position: relative; z-index: 3; max-width: 65%; }
.dashboard-kicker {
    margin-bottom: 6px; color: var(--accent);
    font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
    font-family: 'JetBrains Mono', monospace;
}
.dashboard-hero h1 {
    max-width: 640px; margin: 0 0 6px;
    color: var(--text-main); font-size: clamp(1.4rem, 2.5vw, 1.9rem);
    font-weight: 600; line-height: 1.25; letter-spacing: -0.025em;
}
.dashboard-hero #hero-subtitle {
    max-width: 560px; margin: 0;
    color: var(--text-dim); font-size: .88rem; line-height: 1.5;
}
.dashboard-hero-action {
    display: inline-flex; align-items: center; gap: 8px; margin-top: 16px;
    padding: 8px 16px; border: 1px solid rgba(255,255,255,0.12); border-radius: var(--radius-sm);
    color: #fff; background: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.18);
    text-decoration: none; font-weight: 500; font-size: .82rem;
    transition: all var(--motion-fast);
}
.dashboard-hero-action:hover {
    background: var(--primary-strong);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
    transform: translateY(-1px);
}
.dashboard-hero-action::after { content: "→"; font-size: 1.1em; }
body[lang="ar"] .dashboard-hero-action::after { content: "←"; }
.dashboard-hero-art { display: none; }
.dashboard-streak {
    position: absolute; z-index: 3; top: 16px; right: 18px;
    display: flex; align-items: center; gap: 6px;
    padding: 5px 10px; border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm); color: var(--text-dim);
    background: var(--bg-elevated); font-size: .72rem;
    font-family: 'JetBrains Mono', monospace;
}
body[lang="ar"] .dashboard-streak { right: auto; left: 18px; }
.dashboard-streak span { color: var(--emerald); font-weight: 600; }

/* Metrics Grid (Linear Pro) */
.dashboard-content .stats-grid {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px; margin: 18px 0;
}
.dashboard-content .dashboard-stat {
    display: flex; align-items: center; gap: 12px; min-width: 0;
    padding: 14px 16px;
    border: 1px solid var(--glass-border); border-radius: var(--radius-md);
    background: var(--bg-elevated);
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.04);
    text-align: start; transition: border-color var(--motion-fast);
}
.dashboard-content .dashboard-stat:hover { border-color: rgba(255,255,255,0.12); }
.dashboard-stat-icon {
    display: grid; flex: 0 0 32px; width: 32px; height: 32px; place-items: center;
    border: 1px solid var(--glass-border); border-radius: var(--radius-xs);
    color: var(--secondary); background: rgba(59, 130, 246, 0.1);
}
.dashboard-stat-icon svg { width: 16px; height: 16px; }
.dashboard-stat:nth-child(2) .dashboard-stat-icon,
.dashboard-stat:nth-child(5) .dashboard-stat-icon { color: var(--accent); background: rgba(99, 102, 241, 0.1); }
.dashboard-stat:nth-child(3) .dashboard-stat-icon { color: var(--amber); background: rgba(245, 158, 11, 0.1); }
.dashboard-stat:nth-child(4) .dashboard-stat-icon { color: var(--emerald); background: rgba(16, 185, 129, 0.1); }
.dashboard-stat-copy { min-width: 0; }
.dashboard-stat .stat-number {
    color: var(--text-main); font-family: 'JetBrains Mono', monospace;
    font-size: 1.35rem; line-height: 1.15; font-weight: 600; letter-spacing: -0.02em;
}
.dashboard-stat .stat-label { margin: 2px 0 0; color: var(--text-tertiary); font-size: .7rem; line-height: 1.3; font-weight: 500; }

.dashboard-overview-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 14px; margin-top: 14px; }
.dashboard-block {
    min-width: 0; padding: 18px 20px;
    border: 1px solid var(--glass-border); border-radius: var(--radius-lg);
    background: var(--bg-elevated);
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.04);
}
.dashboard-continue {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    margin-top: 14px; padding: 16px 20px;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.08), rgba(59, 130, 246, 0.06)), var(--bg-elevated);
    border: 1px solid var(--glass-border);
}
.dashboard-continue .dashboard-section-head { margin: 0; }
.dashboard-continue-content { display: flex; flex: 1; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; }
.continue-copy { display: grid; gap: 3px; min-width: 0; }
.continue-title { overflow: hidden; color: var(--text-main); font-size: .92rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-continue-action {
    flex: 0 0 auto; padding: 7px 14px;
    border: 1px solid rgba(255,255,255,0.12); border-radius: var(--radius-sm);
    color: #fff; background: var(--primary);
    text-decoration: none; font-size: .78rem; font-weight: 500;
    transition: all var(--motion-fast);
}
.dashboard-continue-action:hover { background: var(--primary-strong); }
.dashboard-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.dashboard-section-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text-main); font-size: .92rem; font-weight: 600; letter-spacing: -0.01em; }
.section-title-icon { display: grid; width: 20px; height: 20px; place-items: center; color: var(--accent); }
.section-title-icon svg { width: 16px; height: 16px; }
.dashboard-section-head a { color: var(--accent); text-decoration: none; white-space: nowrap; font-size: .74rem; font-weight: 500; }
.dashboard-section-head a:hover { text-decoration: underline; }

/* Quick Access Linear Tiles */
.quick-access-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.quick-access-card {
    position: relative; display: flex; min-height: 115px; flex-direction: column; align-items: flex-start;
    padding: 14px; overflow: hidden;
    border: 1px solid var(--glass-border); border-radius: var(--radius-md);
    color: var(--text-main); background: var(--bg-dark);
    text-decoration: none; transition: all var(--motion-fast);
}
.quick-access-card:hover {
    background: #141824; border-color: rgba(255,255,255,0.14);
    transform: translateY(-1px);
}
.quick-violet, .quick-cyan, .quick-purple { background: var(--bg-dark); }
.quick-icon {
    display: grid; width: 30px; height: 30px; place-items: center;
    border: 1px solid var(--glass-border); border-radius: var(--radius-xs);
    color: var(--secondary); background: rgba(59, 130, 246, 0.1);
}
.quick-icon svg { width: 16px; height: 16px; }
.quick-violet .quick-icon, .quick-purple .quick-icon { color: var(--accent); background: rgba(99, 102, 241, 0.1); }
.quick-cyan .quick-icon { color: var(--emerald); background: rgba(16, 185, 129, 0.1); }
.quick-access-card strong { margin-top: 10px; font-size: .8rem; font-weight: 600; line-height: 1.25; color: var(--text-main); }
.quick-access-card small { margin-top: 2px; color: var(--text-tertiary); font-size: .68rem; line-height: 1.3; }
.review-due-count {
    position: absolute; top: 10px; inset-inline-end: 10px;
    padding: 2px 6px; border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-xs); color: var(--accent);
    background: rgba(99, 102, 241, 0.12); font-size: .62rem;
    font-family: 'JetBrains Mono', monospace; font-weight: 600;
}
.quick-arrow {
    position: absolute; right: 10px; bottom: 10px;
    color: var(--text-tertiary); font-size: 13px;
    transition: transform var(--motion-fast);
}
body[lang="ar"] .quick-arrow { right: auto; left: 10px; }
.quick-access-card:hover .quick-arrow { transform: translateX(2px); color: var(--text-main); }

.dashboard-snapshot { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 4px; }
.snapshot-item {
    min-height: 70px; padding: 12px 14px;
    border: 1px solid var(--glass-border); border-radius: var(--radius-md);
    background: var(--bg-dark);
}
.snapshot-label { color: var(--text-tertiary); font-size: .72rem; }
.snapshot-value { display: block; margin: 4px 0 2px; color: var(--text-main); font-size: 1rem; font-weight: 600; }
.dashboard-progress .snapshot-item::before { content: "◷"; float: inline-end; color: var(--text-tertiary); font-size: 1rem; }

/* Course Cards */
.dashboard-courses { margin-top: 14px; }
.dashboard-course-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.dashboard-course-card {
    display: flex; min-height: 105px; flex-direction: column; align-items: flex-start;
    padding: 12px 14px;
    border: 1px solid var(--glass-border); border-radius: var(--radius-md);
    color: var(--text-main); background: var(--bg-elevated);
    text-decoration: none; transition: all var(--motion-fast);
}
.dashboard-course-card:hover {
    transform: translateY(-1px); border-color: rgba(255,255,255,0.14);
    background: #151926;
}
.dashboard-course-card > span:first-child {
    display: grid; width: 28px; height: 28px; place-items: center;
    border-radius: var(--radius-xs); color: var(--secondary);
    background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.2);
    font-size: .95rem; font-weight: 700; font-family: 'JetBrains Mono', monospace;
}
.dashboard-course-card > span:first-child svg { width: 16px; height: 16px; }
.course-physics > span:first-child { color: var(--accent); background: rgba(99, 102, 241, 0.1); border-color: rgba(99, 102, 241, 0.2); }
.course-chemistry > span:first-child { color: var(--emerald); background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.2); }
.course-english > span:first-child { color: var(--amber); background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.2); }
.course-chinese > span:first-child { color: var(--rose); background: rgba(244, 63, 94, 0.1); border-color: rgba(244, 63, 94, 0.2); }
.dashboard-course-card strong { margin-top: 8px; font-size: .78rem; font-weight: 600; color: var(--text-main); }
.dashboard-course-card small { margin-top: 2px; color: var(--text-tertiary); font-size: .66rem; }
.course-progress-track {
    display: block!important; width: 100%!important; height: 3px!important;
    margin-top: 8px; overflow: hidden; border: 0!important;
    border-radius: 2px!important; background: rgba(255,255,255,0.06)!important;
}
.course-progress-track[hidden] { display: none!important; }
.course-progress-track i {
    display: block; width: var(--progress, 0%); height: 100%;
    border-radius: inherit; background: var(--secondary); transition: width .3s ease;
}
.course-physics .course-progress-track i { background: var(--accent); }
.course-chemistry .course-progress-track i { background: var(--emerald); }
.course-english .course-progress-track i { background: var(--amber); }

.past-paper-transcript {
    margin: 20px 0; padding: 18px;
    border: 1px solid var(--glass-border); border-radius: var(--radius-lg);
    background: var(--bg-elevated);
}
.past-paper-transcript h2 { margin: 0 0 8px; color: var(--text-main); font-size: 1.1rem; font-weight: 600; }
.past-paper-notice { margin: 0 0 14px; color: var(--text-tertiary); font-size: .84rem; line-height: 1.5; }
.past-paper-page { margin: 8px 0; border: 1px solid var(--glass-border); border-radius: var(--radius-sm); background: var(--bg-dark); }
.past-paper-page summary { padding: 10px 14px; color: var(--text-main); cursor: pointer; font-weight: 600; font-size: .84rem; }
.past-paper-page pre {
    max-height: 70vh; margin: 0; padding: 14px; overflow: auto;
    border-top: 1px solid var(--glass-border); color: var(--text-dim);
    background: #050608; font: .82rem/1.6 'JetBrains Mono', monospace;
    white-space: pre-wrap; overflow-wrap: anywhere; unicode-bidi: plaintext;
}
.dashboard-content > .exam-desc, .dashboard-content > .exam-section { max-width: 1320px; margin-inline: auto; }
.dashboard-content > .exam-section:first-of-type { margin-top: 10px; }
.dashboard-content .card.glass {
    background: var(--bg-elevated);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
}
.dashboard-page footer { margin-inline-start: 0; border-top: 1px solid var(--glass-border); color: var(--text-tertiary); background: var(--bg-dark); font-size: .78rem; }
.dashboard-page .nav-toggle { border-color: var(--glass-border); background: var(--bg-elevated); }
.dashboard-page .nav-toggle span { background: var(--text-main); }
@media (max-width:1180px) {
 .dashboard-shell { grid-template-columns:220px minmax(0,1fr); }
 .dashboard-content .stats-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
 .quick-access-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
 .quick-access-card { min-height:105px; }
 .dashboard-overview-grid { grid-template-columns:minmax(0,1.2fr) minmax(240px,.8fr); }
 .dashboard-page footer { margin-inline-start:220px; }
}
@media (max-width:820px) {
 .dashboard-shell { display:block; }
 .dashboard-sidebar { position:sticky; height:auto; min-height:0; padding:11px 16px; border-inline-end:0; border-bottom:1px solid rgba(142,173,244,.18); }
 .dashboard-sidebar-head { display:flex; align-items:center; justify-content:space-between; margin:0; }
 .dashboard-brand-mark { width:39px; height:39px; border-radius:12px; font-size:1.3rem; }
 .dashboard-brand { font-size:1rem; }
 .dashboard-brand small { display:none; }
 .dashboard-page .nav-toggle { display:block; }
 .dashboard-sidebar .dashboard-nav { display:none; position:static; width:100%; margin-top:10px; padding:7px; border:1px solid rgba(142,173,244,.18); border-radius:13px; background:rgba(8,19,48,.98); }
 .dashboard-sidebar .dashboard-nav.is-open { display:grid; }
 .dashboard-shell .dashboard-nav a { min-height:42px; }
 .dashboard-sidebar-bottom { display:flex; align-items:center; gap:9px; margin-top:10px; padding:7px 0 0; border-top:1px solid rgba(142,173,244,.1); }
 .sidebar-language-label { margin:0; }
 .dashboard-sidebar .lang-switcher { gap:4px; }
 .dashboard-sidebar .lang-btn { padding:4px 6px; font-size:.67rem; }
 .sidebar-version { display:none; }
 .dashboard-topbar { min-height:65px; padding:10px 18px; }
 .dashboard-page footer { margin-inline-start:0; }
}
@media (max-width:680px) {
 .dashboard-content.container { padding:16px 15px 38px; }
 .dashboard-topbar { gap:10px; }
 .dashboard-user { gap:6px; font-size:.72rem; }
 .dashboard-avatar { width:31px; height:31px; }
 .dashboard-hero { min-height:215px; padding:22px 19px; }
 .dashboard-hero-copy { max-width:74%; }
 .dashboard-hero h1 { max-width:430px; font-size:1.65rem; }
 .dashboard-hero #hero-subtitle { font-size:.84rem; }
 .dashboard-hero-art { right:-3%; width:34%; opacity:.82; }
 body[lang="ar"] .dashboard-hero-art { right:auto; left:-3%; }
 .hero-book-stack { transform:scale(.75); transform-origin:bottom center; }
 .dashboard-hero::after { right:3%; }
 body[lang="ar"] .dashboard-hero::after { right:auto; left:3%; }
 .dashboard-streak { top:auto; right:12px; bottom:11px; max-width:52%; padding:6px 8px; font-size:.67rem; }
 body[lang="ar"] .dashboard-streak { right:auto; left:12px; }
 .dashboard-content .stats-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:9px; }
 .dashboard-stat .stat-number { font-size:1.28rem; }
 .dashboard-stat .stat-label { font-size:.65rem; }
 .dashboard-overview-grid { grid-template-columns:1fr; }
 .dashboard-continue { align-items:flex-start; flex-direction:column; gap:10px; }
 .dashboard-continue-content { width:100%; }
 .dashboard-course-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
 .dashboard-block { padding:14px; }
 .exam-desc { padding:22px 16px; }
}
@media (max-width:420px) {
 .dashboard-topbar { flex-wrap:wrap; }
 .dashboard-search { flex-basis:100%; }
 .dashboard-user { margin-inline-start:auto; }
 .dashboard-hero { display:block; min-height:0; padding:20px 17px 15px; }
 .dashboard-hero-copy { max-width:100%; }
 .dashboard-hero-art,.dashboard-hero::after { display:none; }
 .dashboard-streak { position:relative; inset:auto; width:max-content; max-width:100%; margin-top:13px; }
 body[lang="ar"] .dashboard-streak { inset:auto; }
 .dashboard-content .dashboard-stat { display:block; min-height:65px; padding:10px 6px; text-align:center; }
 .dashboard-continue-content { align-items:flex-start; flex-direction:column; }
 .dashboard-stat-icon { display:none; }
 .dashboard-stat .stat-number { font-size:1.22rem; }
 .dashboard-stat .stat-label { white-space:nowrap; font-size:.62rem; }
 .dashboard-stat:last-child { grid-column:1 / -1; }
 .quick-access-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
 .quick-access-card { padding:10px; }
 .quick-access-card strong { font-size:.71rem; }
 .quick-access-card small { max-width:90%; font-size:.62rem; }
}

/* ===== Loading & Error States ===== */
.loading {
    text-align: center;
    padding: 60px;
    color: var(--text-dim);
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(3) infinite;
}

@keyframes dots {
    0% { content: '.'; }
    33% { content: '..'; }
    66% { content: '...'; }
}

.error-msg {
    text-align: center;
    padding: 40px;
    color: var(--danger);
    font-size: 1.1rem;
}

/* ===== Details/Summary ===== */
details {
    border-top: 1px solid var(--glass-border);
    padding-top: 15px;
    margin-top: 15px;
}

details summary {
    color: var(--primary);
    cursor: pointer;
    font-weight: bold;
}

details[open] summary {
    margin-bottom: 15px;
}

.explanation-box {
    padding: 20px;
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    border-right: 4px solid var(--success);
}
body[lang="en"] .explanation-box, body[lang="zh"] .explanation-box {
    border-right: none;
    border-left: 4px solid var(--success);
}

.correct-answer {
    color: var(--success);
    font-weight: bold;
    margin-bottom: 10px;
}

/* ===== Subject Badges ===== */
.subject-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.badge-math { background: rgba(67, 97, 238, 0.2); color: #4361ee; }
.badge-phys { background: rgba(247, 37, 133, 0.2); color: #f72585; }
.badge-chem { background: rgba(74, 222, 128, 0.2); color: #4ade80; }

/* Shared premium study-space treatment for every page. */
:root {
    --bg-dark: #070b19;
    --bg-elevated: rgba(15, 23, 49, .78);
    --card-bg: rgba(17, 25, 53, .72);
    --primary: #6479ff;
    --primary-strong: #8591ff;
    --secondary: #45a7ff;
    --accent: #a48bff;
    --cyan: #59d9f4;
    --text-dim: #b2bfdc;
    --text-tertiary: #8492b1;
    --glass-border: rgba(172, 194, 255, .15);
    --glass-highlight: rgba(255, 255, 255, .055);
    --shadow-glass: 0 20px 56px rgba(1, 5, 22, .42);
}
body:not(.dashboard-page) {
    background-color: #070b19;
    background-image: radial-gradient(ellipse 55% 35% at 6% 0%, rgba(44, 77, 208, .21), transparent 78%),
        radial-gradient(ellipse 45% 40% at 100% 18%, rgba(119, 72, 211, .16), transparent 80%),
        linear-gradient(145deg, #070b19, #0a1025 58%, #090d1d);
}
.main-nav {
    background: rgba(8, 13, 32, .78);
    border: 1px solid rgba(172, 194, 255, .12);
    border-radius: 18px;
    width: min(1440px, calc(100% - 40px));
    margin: 12px auto;
    padding: 12px 18px;
    box-shadow: 0 12px 36px rgba(1, 4, 18, .26);
}
.main-nav .container { max-width: none; padding: 0; }
.main-nav .brand { letter-spacing: -.035em; }
.nav-links { gap: 5px; }
.nav-links a { border: 1px solid transparent; padding: 8px 12px; }
.nav-links a:hover, .nav-links a.active {
    color: #f5f7ff;
    background: linear-gradient(135deg, rgba(77, 110, 255, .2), rgba(138, 99, 241, .16));
    border-color: rgba(162, 181, 255, .2);
}
.lang-bar { background: transparent; border: 0; }
.card, .card.glass, .analytics-stat, .profile-settings, .profile-section,
.question-card, .exam-panel, .result-card, .last-attempt-card {
    background: linear-gradient(145deg, rgba(20, 30, 64, .83), rgba(12, 19, 43, .77));
    border: 1px solid rgba(174, 192, 255, .15);
    box-shadow: 0 16px 40px rgba(1, 5, 22, .24), inset 0 1px 0 rgba(255,255,255,.035);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.card.glass:hover, .question-card:hover { border-color: rgba(138, 165, 255, .32); box-shadow: 0 20px 45px rgba(25, 53, 131, .18); }
input, select, textarea, .search-container input {
    color: var(--text-main);
    background-color: rgba(7, 13, 32, .72);
    border-color: rgba(172, 194, 255, .2);
}
button, .exam-btn, .filter-btn, .option-btn, .lang-btn { transition: background-color var(--motion-standard), border-color var(--motion-standard), color var(--motion-standard), transform var(--motion-fast), box-shadow var(--motion-standard); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid #8fb9ff;
    outline-offset: 3px;
}
.dashboard-continue-link { display: inline-flex; margin-top: 12px; color: #c8d6ff; text-decoration: none; }
.dashboard-progress-list:empty, .dashboard-activity-list:empty { display: none; }
.dashboard-review-summary { margin-block: 16px; }
.dashboard-review-summary #qa-due { color: #d9d2ff; }
.search-results[hidden] { display: none; }
.search-results { inset-inline-start: 0; }
footer { color: var(--text-tertiary); border-top-color: rgba(172,194,255,.1); }

/* Collapse the shared navigation before its links and language controls overflow. */
@media (max-width: 1240px) {
    .main-nav .container { flex-direction: row; flex-wrap: wrap; gap: 10px; }
    .main-nav .container > .brand { margin-inline-end: auto; }
    .nav-toggle { display: block; order: 2; }
    .main-nav .nav-links {
        display: none; order: 3; width: 100%; flex-direction: column;
        align-items: stretch; gap: 2px; padding: 8px 0 4px;
        background: rgba(8, 13, 32, .97); border: 1px solid var(--glass-border);
        border-radius: 14px; box-shadow: var(--shadow-glass);
    }
    .main-nav .nav-links.is-open { display: flex; }
    .nav-links a { padding: 12px 14px; border-radius: 10px; }
    .nav-links a:hover, .nav-links a.active { background: rgba(118,169,255,.09); }
    .lang-switcher { margin-top: 5px; }
}

@media (max-width: 768px) {
    .main-nav { width: calc(100% - 20px); margin: 8px auto; padding: 9px 12px; border-radius: 14px; }
    .main-nav .container { gap: 10px; flex-wrap: wrap; }
    .main-nav .nav-links { background: rgba(8, 13, 32, .97); border: 1px solid var(--glass-border); border-radius: 14px; box-shadow: var(--shadow-glass); }
    .nav-links a { padding: 10px 12px; }
    .container { padding-inline: 16px; }
    .analytics-page, .profile-page { padding-top: 18px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
