/* ==========================================================================
   Saacho Excel — app stylesheet, Ant-aligned to the Saacho brand skin v1.1.

   WHAT THIS FILE IS
   The exam-practice engine ships its own stylesheet on top of
   public/brand/css/saacho.css. This revision re-skins that sheet to the
   shared Ant design contract while keeping Saacho's editorial identity
   (teal + gold, Source Serif 4 display, grey canvas under white cards).

   TOKENS
   This sheet defines NO new global design tokens and edits nothing in
   saacho.css. It keeps the short local aliases the app's PHP/JS inline
   styles already reference (--surface, --line, --accent, --radius, …) and
   points each one at an existing saacho.css token, so a token change in the
   brand skin flows through. Anything with no brand token (--surface-3,
   --paper-2) is derived with color-mix() or a local literal.

   DARK MODE
   The site-wide <html class="theme-dark"> class is set by the shared
   layout and keyed off by excel/toolway/parent-sim/quiz. It is preserved.
   Its ramp now matches the Ant dark values saacho.css settles in
   .saacho-dark (bg #141414, card #1f1f1f, surface-2 #262626, border
   #3d3d3d, ink #f0f0f0, brand #0f8577, brand-text #4ac7b4, …). The actual
   token values live in assets/head.php, which loads after this file; this
   sheet only remaps its local aliases onto those tokens.

   ANT ADOPTION
   - 6px control radius, 8px card radius
   - 32px controls (40px for primary/large), 24px small
   - 14px control type (--fs-base), 16px prose (--fs-md)
   - hairline neutral borders, no teal-tinted 1.5px edges
   - grey canvas behind white cards, layered shadow-1/2/3
   - focus-visible rings + soft form focus glow
   - real grid/flex with 8/16/24/32 gaps; no inline-block/float layout
   - pills removed from interactive controls; only true gauges stay round
   - state is never carried by colour alone (glyph + weight + border)

   ACCESSIBILITY
   Teal text uses --brand-text (6.05:1) and gold text --gold-text (5.52:1);
   the raw --brand/--gold fills are used only behind white text or as
   non-text fills. Muted copy uses --ink-mute (4.6:1+), never Ant's light
   grey. Reduced-motion users get all transitions/animations disabled.
   ========================================================================== */

/* ---------- Local aliases → saacho.css tokens (light) ---------- */
:root {
    --paper: var(--bg);
    --paper-2: var(--surface-2);
    --surface: var(--card-bg);
    --surface-3: var(--line-soft);
    --ink-2: var(--ink-dim);
    --ink-3: var(--ink-mute);
    --ink-4: var(--ink-mute);
    --line: var(--border);
    --line-2: var(--border);
    --accent: var(--brand);
    --accent-dark: var(--brand-dark);
    --accent-deep: var(--brand-dark);
    --accent-text: var(--brand-text);
    --accent-soft: var(--brand-light);
    --accent-soft-2: var(--brand-light);
    --radius: var(--radius-md);
    --radius-pill: var(--radius-md);
    --font-display: var(--saacho-serif, "Source Serif 4", Georgia, "Times New Roman", serif);
    --font-body: var(--pico-font-family, "Inter", -apple-system, "Segoe UI", Roboto, sans-serif);
    --header-h: var(--nav-h);
    --shadow-sm: var(--shadow-1);
    --shadow: var(--shadow-2);
    --shadow-lg: var(--shadow-3);
}

/* ---------- Local aliases → saacho.css tokens (dark) ----------
   Token values themselves are set on html.theme-dark in assets/head.php
   (loaded after this sheet). These aliases only need to point at the right
   brand token; the same mapping serves both themes. The literal-only
   aliases are overridden below to the Ant dark ramp. */
html.theme-dark {
    --paper: var(--bg);
    --paper-2: #262626;
    --surface: var(--card-bg);
    --surface-3: #2b2b2b;
    --ink-2: var(--ink-dim);
    --ink-3: var(--ink-mute);
    --ink-4: var(--ink-mute);
    --line: var(--border);
    --line-2: #4a4a4a;
    --accent: var(--brand);
    --accent-dark: var(--brand);
    --accent-deep: var(--brand);
    --accent-text: var(--brand-text);
    --accent-soft: var(--brand-light);
    --accent-soft-2: #173f39;
    --shadow-sm: none;
    --shadow: var(--shadow-2);
    --shadow-lg: var(--shadow-2);
}

/* ---------- Base ---------- */
body { overflow-x: hidden; background: var(--bg); color: var(--ink); }

a { color: var(--brand-text); text-decoration: none; }
a:hover { color: var(--brand-dark); }

button { font-family: inherit; }

h1, h2, h3, h4, .serif {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

:focus-visible {
    outline: 2px solid var(--brand-text);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

html.theme-dark .excel-learn.inline { color: var(--brand-text); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: var(--control-h);
    padding: 0 15px;
    border-radius: var(--radius-md);
    border: var(--hairline);
    background: var(--card-bg);
    color: var(--ink);
    font-size: var(--fs-base); font-weight: 400; line-height: var(--lh-body);
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease),
                color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { border-color: var(--brand-text); color: var(--brand-text); }
.btn:active { background: var(--surface-2); }
.btn-primary {
    min-height: var(--control-h-lg);
    background: var(--brand); border-color: var(--brand); color: #fff;
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; box-shadow: var(--shadow-1); }
.btn-secondary { background: var(--brand-light); border-color: transparent; color: var(--brand-text); }
.btn-secondary:hover { background: var(--brand-light); border-color: var(--border); color: var(--brand-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; box-shadow: var(--shadow-1); filter: brightness(.94); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-dim); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); border-color: transparent; }
.btn-sm { min-height: var(--control-h-sm); padding: 0 10px; font-size: var(--fs-xs); }
.btn-lg { min-height: var(--control-h-lg); padding: 0 20px; }
.btn-block { width: 100%; }

/* ---------- Learn more link ---------- */
.excel-learn {
    display: inline-flex; align-items: center; gap: 6px;
    min-height: var(--control-h);
    padding: 0 12px;
    border-radius: var(--radius-md);
    border: var(--hairline);
    background: var(--brand-light);
    color: var(--brand-text);
    font-size: var(--fs-base); font-weight: 500;
    text-decoration: none; cursor: pointer;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease),
                border-color var(--dur) var(--ease);
}
.excel-learn:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.excel-learn.inline {
    min-height: auto; padding: 0; border: none; background: none;
    color: var(--brand-text); font-weight: 500;
}
.excel-learn.inline:hover { background: none; color: var(--brand-dark); }
.navbar-brand .excel-learn { font-size: var(--fs-xs); min-height: var(--control-h-sm); padding: 0 10px; }
@media (max-width: 560px) { .navbar-brand .excel-learn { display: none; } }

/* ---------- Container & layout ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 24px 24px 64px; }
.container-narrow { max-width: 820px; }

.section { margin-bottom: 32px; }
.section-heading {
    display: flex; align-items: center; gap: 8px;
    font-size: var(--fs-md); font-weight: 600;
    margin-bottom: 16px;
    color: var(--ink);
}
.section-heading::before {
    content: ""; width: 3px; height: 18px;
    border-radius: var(--radius-sm);
    background: var(--brand);
}

/* ---------- Cards ---------- */
.card {
    background: var(--card-bg);
    border: var(--hairline);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-1);
    transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.card:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }

/* ---------- Back link ---------- */
.back-link { color: var(--ink-dim); text-decoration: none; font-size: var(--fs-base); font-weight: 500; display: inline-flex; align-items: center; gap: 5px; }
.back-link:hover { color: var(--brand-text); }

/* ---------- Subject pill + dropdown ---------- */
.subject-pill {
    display: inline-flex; align-items: center; gap: 8px;
    min-height: var(--control-h);
    padding: 0 14px;
    border-radius: var(--radius-md);
    background: var(--brand-light);
    color: var(--brand-text);
    font-weight: 500; font-size: var(--fs-base); line-height: var(--lh-body);
    cursor: pointer; border: var(--hairline);
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.subject-pill:hover { background: var(--surface-2); border-color: var(--border); }
.subject-pill .arrow { transition: transform var(--dur) var(--ease); }
.subject-pill.open .arrow { transform: rotate(180deg); }
.subject-wrap { position: relative; }
.subject-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0;
    min-width: 240px;
    max-width: calc(100vw - 32px);
    background: var(--card-bg);
    border: var(--hairline);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2);
    padding: 6px;
    display: none; z-index: 200;
}
.subject-dropdown.show { display: block; }
.subject-option {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    min-height: var(--control-h-lg);
    padding: 8px 12px;
    border: none; background: none; border-radius: var(--radius-md);
    font-size: var(--fs-base); color: var(--ink); text-align: left;
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.subject-option:hover { background: var(--surface-2); }
.subject-option.active { background: var(--brand-light); color: var(--brand-text); font-weight: 600; }
.subject-option-icon { font-size: 17px; }
.subject-option-name { flex: 1; }
.subject-option-check { color: var(--brand-text); font-weight: 700; }

/* Subject rail (mobile-friendly in-page switcher) */
.subject-rail {
    display: flex; gap: 8px;
    overflow-x: auto; padding-bottom: 4px;
    scrollbar-width: none; -ms-overflow-style: none;
}
.subject-rail::-webkit-scrollbar { display: none; }
.subject-rail .subject-chip {
    flex-shrink: 0; white-space: nowrap;
    display: inline-flex; align-items: center; gap: 6px;
    min-height: var(--control-h); padding: 0 14px;
    border-radius: var(--radius-md);
    border: var(--hairline);
    background: var(--card-bg);
    color: var(--ink-dim);
    font-size: var(--fs-base); font-weight: 500;
    text-decoration: none;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.subject-rail .subject-chip:hover { border-color: var(--brand-text); color: var(--brand-text); }
.subject-rail .subject-chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- Toast ---------- */
.toast-container {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    z-index: 500;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    pointer-events: none;
}
.toast {
    background: var(--ink); color: var(--card-bg);
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: var(--fs-base); font-weight: 400; line-height: var(--lh-body);
    box-shadow: var(--shadow-2);
    opacity: 0; transform: translateY(8px);
    transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
    pointer-events: auto;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed; inset: 0; z-index: 400;
    background: rgba(0, 0, 0, .45);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    display: none; align-items: center; justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--card-bg);
    border: var(--hairline);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-3);
    width: 100%; max-width: 440px;
    padding: 24px;
}
.modal h3 { font-size: var(--fs-md); margin-bottom: 6px; }
.modal p { color: var(--ink-dim); font-size: var(--fs-base); margin-bottom: 20px; }
.modal-actions { display: flex; gap: 12px; }
.modal-actions .btn { flex: 1; }

/* ---------- Form ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: var(--fs-base); font-weight: 500; color: var(--ink-dim); margin-bottom: 6px; }
.input, .select, textarea.input {
    width: 100%;
    min-height: var(--control-h-lg);
    padding: 6px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--card-bg);
    color: var(--ink);
    font-size: var(--fs-base);
    font-family: var(--font-body);
    line-height: var(--lh-body);
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input:focus, .select:focus, textarea.input:focus {
    outline: none;
    border-color: var(--brand-text);
    box-shadow: var(--focus-ring);
}

#onboarding { align-items: flex-start; overflow-y: auto; }
#onboarding .modal { margin: auto; max-height: calc(100vh - 40px); overflow-y: auto; }

/* Onboarding picker */
.onboarding-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    min-height: 64px;
    padding: 12px 8px;
    background: var(--surface-2);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--ink);
    transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.onboarding-btn:hover { border-color: var(--brand-text); }
.onboarding-btn.selected { border-color: var(--brand); background: var(--brand-light); font-weight: 600; }

/* ---------- Home ---------- */
.hero { text-align: center; padding: 24px 8px 32px; }
.hero-kicker {
    display: inline-block;
    font-size: var(--fs-xs); font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
    color: var(--brand-text);
    background: var(--brand-light);
    padding: 3px 12px; border-radius: var(--radius-sm);
    margin-bottom: 16px;
}
.hero h1 {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 4.5vw, 2.6rem);
    margin-bottom: 10px;
    color: var(--ink);
}
.hero p { color: var(--ink-mute); font-size: var(--fs-md); max-width: 560px; margin: 0 auto 24px; }

.greeting-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.greeting { font-size: 1.55rem; }
.greeting-date { color: var(--ink-mute); font-size: var(--fs-base); }

.today-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.today-stat { display: flex; align-items: center; gap: 16px; }
.today-stat-icon {
    width: 44px; height: 44px; border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center; font-size: 19px;
    background: var(--brand-light); flex-shrink: 0;
}
.today-stat-value { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; }
.today-stat-label { font-size: var(--fs-xs); color: var(--ink-mute); text-transform: uppercase; letter-spacing: .05em; }

.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.how-step { text-align: left; }
.how-step-num {
    font-family: var(--font-display);
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    background: var(--brand); color: #fff;
    border-radius: var(--radius-md); font-size: var(--fs-base); font-weight: 700;
    margin-bottom: 12px;
}
.how-step h4 { font-size: var(--fs-md); margin-bottom: 4px; }
.how-step p { font-size: var(--fs-base); color: var(--ink-mute); }

.continue-card {
    background: var(--brand);
    border-radius: var(--radius-lg);
    padding: 24px;
    color: #fff;
    display: flex; align-items: center; justify-content: space-between;
    gap: 24px; flex-wrap: wrap;
    box-shadow: var(--shadow-1);
}
.continue-card h2 { font-size: 1.25rem; margin-bottom: 3px; }
.continue-card p { opacity: .9; font-size: var(--fs-base); }
.continue-btn {
    min-height: var(--control-h-lg);
    padding: 0 24px;
    background: #fff; color: var(--brand-dark);
    border: none; border-radius: var(--radius-md);
    font-weight: 500; font-size: var(--fs-base); cursor: pointer; text-decoration: none;
    display: inline-flex; align-items: center; justify-content: center;
    transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.continue-btn:hover { transform: translateY(-1px); color: var(--brand-dark); box-shadow: var(--shadow-1); }

.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card {
    background: var(--card-bg);
    border: var(--hairline);
    border-radius: var(--radius-lg);
    padding: 16px;
    text-align: center;
}
.stat-value { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; }
.stat-value.dim { color: var(--ink-mute); }
.stat-label { font-size: var(--fs-xs); color: var(--ink-mute); text-transform: uppercase; letter-spacing: .06em; margin-top: 2px; }

.set-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.set-card {
    background: var(--card-bg);
    border: var(--hairline);
    border-radius: var(--radius-md);
    padding: 16px; text-align: center;
    color: var(--ink); text-decoration: none;
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.set-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); border-color: var(--brand-text); color: var(--ink); }
.set-card.completed { border-color: var(--success); }
.set-card.completed .set-status { color: var(--success); }
.set-card.in-progress { border-color: var(--warning); }
.set-card.in-progress .set-status { color: var(--warning); }
.set-num { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-base); margin-bottom: 3px; }
.set-status { font-size: var(--fs-xs); color: var(--ink-mute); }

.ongoing-alert {
    background: var(--card-bg);
    border: var(--hairline);
    border-left: 3px solid var(--brand);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
}
.ongoing-info { display: flex; align-items: center; gap: 12px; }
.ongoing-icon {
    width: 40px; height: 40px;
    background: var(--brand); color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
}
.ongoing-text h3 { font-size: var(--fs-md); margin-bottom: 1px; }
.ongoing-text p { color: var(--ink-mute); font-size: var(--fs-base); }

.weak-item {
    background: var(--card-bg);
    border: var(--hairline);
    border-left: 3px solid var(--warning);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.weak-q { font-size: var(--fs-base); flex: 1; }
.weak-pct { font-weight: 700; color: var(--danger); font-size: var(--fs-base); }

.other-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.other-card {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    background: var(--card-bg);
    border: var(--hairline);
    border-radius: var(--radius-md);
    color: var(--ink); text-decoration: none;
    font-size: var(--fs-base); font-weight: 500;
    transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.other-card:hover { border-color: var(--brand-text); transform: translateY(-1px); box-shadow: var(--shadow-2); color: var(--ink); }
.other-name { flex: 1; }
.other-icon { font-size: 19px; }

/* Guest subject tiles */
.guest-subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; margin-top: 20px; text-align: left; }
.subject-tile {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    min-height: 88px;
    padding: 16px 8px;
    background: var(--card-bg);
    border: var(--hairline);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--ink-dim);
    transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.subject-tile:hover { border-color: var(--brand-text); transform: translateY(-1px); box-shadow: var(--shadow-2); }
.subject-tile-icon { font-size: 22px; line-height: 1; }
.subject-tile-name { font-size: var(--fs-xs); font-weight: 500; text-align: center; }

/* ---------- Readiness gauge (home + exam) ---------- */
.readiness-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.gauge { position: relative; width: 150px; height: 150px; flex-shrink: 0; }
.gauge svg { transform: rotate(-90deg); }
.gauge-bg { fill: none; stroke: var(--surface-3); stroke-width: 11; }
.gauge-fill { fill: none; stroke-width: 11; stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.2, .8, .3, 1); }
.gauge-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.gauge-percent { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; }
.gauge-label { font-size: var(--fs-xs); color: var(--ink-mute); text-transform: uppercase; letter-spacing: .06em; }
.readiness-copy { flex: 1; min-width: 200px; }
.readiness-copy h3 { font-size: var(--fs-md); margin-bottom: 4px; }
.readiness-copy p { font-size: var(--fs-base); color: var(--ink-mute); }

/* ---------- Trend ---------- */
.trend-bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; margin-top: 16px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.trend-bar-wrap { width: 100%; flex: 1; display: flex; align-items: flex-end; }
.trend-bar {
    width: 100%; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: var(--brand); min-height: 4px; opacity: .85;
    transition: height .6s cubic-bezier(.2, .8, .3, 1);
}
.trend-bar.latest { opacity: 1; background: var(--success); }
.trend-bar.under50 { background: var(--warning); }
.trend-val { font-size: var(--fs-xs); color: var(--ink-mute); font-weight: 600; font-variant-numeric: tabular-nums; }
.trend-label { font-size: var(--fs-xs); color: var(--ink-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.trend-empty { color: var(--ink-mute); font-size: var(--fs-base); text-align: center; padding: 28px 10px; }
.trend-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.trend-dir { font-size: var(--fs-base); font-weight: 600; }
.trend-dir.up { color: var(--success); }
.trend-dir.down { color: var(--danger); }

/* ---------- Score list (exam) ---------- */
.score-list { display: flex; flex-direction: column; gap: 8px; }
.score-row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    background: var(--card-bg); border: var(--hairline);
    border-radius: var(--radius-md); font-size: var(--fs-base);
}
.score-set { font-weight: 600; min-width: 52px; }
.score-bar-bg { flex: 1; height: 8px; background: var(--surface-3); border-radius: var(--radius-sm); overflow: hidden; }
.score-bar { height: 100%; border-radius: var(--radius-sm); }
.score-pct { font-weight: 700; min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.score-date { color: var(--ink-mute); font-size: var(--fs-xs); min-width: 44px; text-align: right; }

/* ---------- Tabs (exam) ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: var(--hairline); }
.tab {
    padding: 0 18px; min-height: var(--control-h-lg);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--ink-dim);
    font-size: var(--fs-base); font-weight: 500;
    cursor: pointer;
    transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tab:hover { color: var(--brand-text); }
.tab.active { color: var(--brand-text); border-bottom-color: var(--brand); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.analytics-empty { color: var(--ink-mute); font-size: var(--fs-base); text-align: center; padding: 32px 16px; }

/* ---------- Exam page ---------- */
.exam-hero { text-align: center; padding: 16px 8px 8px; margin-bottom: 24px; }
.exam-hero-icon { font-size: 34px; margin-bottom: 4px; }
.exam-hero h1 { font-family: var(--font-display); font-size: 1.7rem; margin-bottom: 3px; }
.exam-hero p { color: var(--ink-mute); font-size: var(--fs-base); max-width: 520px; margin: 0 auto; }

.queue-item { display: flex; align-items: center; gap: 12px; }
.queue-item .weak-q { font-size: var(--fs-base); }

.progress-section { margin-bottom: 24px; }
.progress-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.progress-label { font-size: var(--fs-base); font-weight: 600; }
.progress-count { font-size: var(--fs-base); color: var(--ink-mute); }
.progress-bar-bg { height: 8px; background: var(--surface-3); border-radius: var(--radius-sm); overflow: hidden; }
.progress-bar-fill {
    height: 100%;
    background: var(--brand);
    border-radius: var(--radius-sm);
    transition: width .6s cubic-bezier(.2, .8, .3, 1);
}

.quick-actions { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }

.ongoing-banner {
    background: var(--brand);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 16px 20px; margin-bottom: 24px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.ongoing-banner-text h3 { font-size: var(--fs-md); margin-bottom: 2px; }
.ongoing-banner-text p { font-size: var(--fs-base); opacity: .92; }
.ongoing-banner-btn {
    min-height: var(--control-h-lg);
    padding: 0 20px; background: #fff;
    color: var(--brand-dark);
    border: none; border-radius: var(--radius-md);
    font-weight: 500; font-size: var(--fs-base); cursor: pointer; text-decoration: none;
    display: inline-flex; align-items: center;
    white-space: nowrap;
}

.filter-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-tab {
    min-height: var(--control-h);
    padding: 0 14px; border-radius: var(--radius-md);
    font-size: var(--fs-base); font-weight: 500;
    border: var(--hairline);
    background: var(--card-bg); color: var(--ink-dim);
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.filter-tab:hover { border-color: var(--brand-text); color: var(--brand-text); }
.filter-tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.set-list { display: flex; flex-direction: column; gap: 8px; }
.set-row {
    display: flex; align-items: center; gap: 16px;
    min-height: 60px;
    padding: 14px 16px;
    background: var(--card-bg);
    border: var(--hairline);
    border-radius: var(--radius-lg);
    color: var(--ink); text-decoration: none;
    transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.set-row:hover { border-color: var(--brand-text); transform: translateY(-1px); box-shadow: var(--shadow-2); color: var(--ink); }
.set-row.completed { border-left: 3px solid var(--success); }
.set-row.in-progress { border-left: 3px solid var(--warning); }
.set-row.next-up { border-left: 3px solid var(--brand); background: var(--brand-light); }

.set-num-badge {
    width: 40px; height: 40px; border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700; font-size: var(--fs-base);
    flex-shrink: 0;
}
.set-num-badge.default { background: var(--surface-2); color: var(--ink-dim); }
.set-num-badge.completed { background: var(--success-soft); color: var(--success); }
.set-num-badge.in-progress { background: var(--warning-soft); color: var(--warning); }
.set-num-badge.next-up { background: var(--brand-light); color: var(--brand-text); }

.set-info { flex: 1; min-width: 0; }
.set-name { font-weight: 600; font-size: var(--fs-base); }
.set-meta { font-size: var(--fs-xs); color: var(--ink-mute); }

.set-score { display: flex; align-items: center; gap: 8px; }
.score-mini-bar { width: 60px; height: 6px; background: var(--surface-3); border-radius: var(--radius-sm); overflow: hidden; }
.score-mini-fill { height: 100%; border-radius: var(--radius-sm); }
.score-mini-fill.pass { background: var(--success); }
.score-mini-fill.fail { background: var(--danger); }
.score-mini-text { font-size: var(--fs-base); font-weight: 600; min-width: 34px; }

.set-action {
    min-height: var(--control-h);
    padding: 0 14px; border-radius: var(--radius-md);
    font-size: var(--fs-base); font-weight: 500;
    border: none; cursor: pointer; text-decoration: none;
    display: inline-flex; align-items: center;
    white-space: nowrap;
}
.action-start { background: var(--brand); color: #fff; }
.action-start:hover { background: var(--brand-dark); color: #fff; }
.action-review { background: var(--surface-2); color: var(--ink-dim); }
.action-resume { background: var(--warning); color: #fff; }
.action-next { background: var(--brand-light); color: var(--brand-text); }
.action-next:hover { opacity: .9; }

.load-more { text-align: center; padding: 16px; }

/* ---------- FAQ ---------- */
.excel-faq { margin: 24px auto 0; padding: 8px 0 32px; max-width: 760px; }
.excel-faq h2 { font-size: 1.25rem; margin-bottom: 16px; }
.excel-faq details {
    border: var(--hairline); border-radius: var(--radius-md);
    background: var(--card-bg); margin-bottom: 12px; padding: 16px;
}
.excel-faq summary { cursor: pointer; font-weight: 600; font-size: var(--fs-md); }
.excel-faq p { margin: 8px 0 0; color: var(--ink-mute); font-size: var(--fs-base); line-height: 1.65; }

.empty-msg { text-align: center; padding: 40px 20px; color: var(--ink-mute); font-size: var(--fs-base); }

/* ---------- Test page ---------- */
.test-layout { display: flex; gap: 24px; align-items: flex-start; width: 100%; max-width: 1100px; margin: 0 auto; padding: 24px; }
.test-main { flex: 1; min-width: 0; overflow-x: hidden; }
.test-side { width: 300px; flex-shrink: 0; position: sticky; top: calc(var(--header-h) + 16px); }

.test-main, .test-side { overflow-wrap: break-word; word-wrap: break-word; }
.question-card { overflow-wrap: break-word; word-wrap: break-word; }

.header-center { display: flex; align-items: center; gap: 12px; }
.test-title { font-size: var(--fs-base); font-weight: 500; color: var(--ink-dim); max-width: 380px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.review-banner {
    background: var(--brand); color: #fff;
    padding: 12px 16px; border-radius: var(--radius-md);
    margin-bottom: 16px; text-align: center; font-weight: 500; font-size: var(--fs-base);
}

.feedback-card {
    background: var(--card-bg); border: var(--hairline);
    border-left: 3px solid var(--brand);
    border-radius: var(--radius-lg);
    padding: 20px; margin-bottom: 16px;
    overflow-wrap: break-word; word-wrap: break-word;
}
.feedback-card h4 { font-size: var(--fs-md); color: var(--brand-text); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.feedback-card .explanation-content { font-size: var(--fs-base); overflow-wrap: break-word; word-wrap: break-word; hyphens: auto; }

.side-card {
    background: var(--card-bg);
    border: var(--hairline);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}
.side-title {
    font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
    color: var(--ink-mute); margin-bottom: 12px;
}

.timer-display { text-align: center; }
.timer-value {
    font-family: var(--font-display);
    font-size: 2.2rem; font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: .02em;
}
.timer-value.warning { color: var(--warning); }
.timer-value.danger { color: var(--danger); }
.timer-label { font-size: var(--fs-xs); color: var(--ink-mute); text-transform: uppercase; letter-spacing: .06em; }
.timer-mode { display: flex; gap: 8px; margin-top: 12px; }
.timer-mode button {
    flex: 1; min-height: var(--control-h); padding: 0 6px;
    font-size: var(--fs-xs);
    background: var(--surface-2);
    border: var(--hairline);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--ink-dim);
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.timer-mode button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.q-navigator { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.q-num {
    position: relative;
    aspect-ratio: 1;
    min-height: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface-2);
    border: var(--hairline);
    border-radius: var(--radius-md);
    font-size: var(--fs-base); font-weight: 600;
    cursor: pointer;
    color: var(--ink-dim);
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
    min-width: 0;
}
.q-num:hover { border-color: var(--brand-text); }
/* Answered: an inset underline (not colour alone). */
.q-num.answered { background: var(--brand-light); border-color: var(--brand); color: var(--brand-text); }
.q-num.answered::after {
    content: ""; position: absolute; left: 50%; bottom: 3px; transform: translateX(-50%);
    width: 12px; height: 2px; border-radius: 1px; background: currentColor; opacity: .75;
}
/* Current: heavier ring + filled, so it reads in greyscale. */
.q-num.current { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: inset 0 0 0 2px #fff; }
.q-num.current.answered::after { background: #fff; }
/* Flagged: corner triangle (shape cue) plus warning fill. */
.q-num.flagged { background: var(--warning); border-color: var(--warning); color: #fff; }
.q-num.flagged::before {
    content: ""; position: absolute; top: 0; right: 0;
    border: 6px solid transparent; border-top-color: rgba(0, 0, 0, .35); border-right-color: rgba(0, 0, 0, .35);
    border-top-right-radius: var(--radius-md);
}

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-item { text-align: center; padding: 12px; background: var(--surface-2); border-radius: var(--radius-md); }
.stat-item-value { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; }
.stat-item-label { font-size: var(--fs-xs); color: var(--ink-mute); text-transform: uppercase; letter-spacing: .05em; }

.test-progress { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.test-progress .progress-bar-bg { flex: 1; }
.test-progress-count { font-size: var(--fs-base); color: var(--ink-mute); font-weight: 600; white-space: nowrap; }

.view-toggle {
    display: flex; background: var(--surface-2);
    border-radius: var(--radius-md); padding: 3px; gap: 3px;
}
.view-toggle button {
    min-height: var(--control-h);
    padding: 0 12px; border: none; background: transparent;
    border-radius: var(--radius-sm); cursor: pointer;
    font-size: var(--fs-base); font-weight: 500; color: var(--ink-dim);
}
.view-toggle button.active { background: var(--card-bg); color: var(--ink); box-shadow: var(--shadow-1); }

.question-card {
    background: var(--card-bg);
    border: var(--hairline);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-1);
    transition: box-shadow var(--dur) var(--ease);
}
.question-card:hover { box-shadow: var(--shadow-2); }
.question-card.hidden { display: none; }

.question-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px; gap: 12px;
}
.question-number {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 2px 10px;
    background: var(--brand-light);
    color: var(--brand-text);
    border-radius: var(--radius-sm);
    font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
}
.question-actions { display: flex; gap: 8px; }
.flag-btn, .explain-btn {
    min-height: var(--control-h);
    border: var(--hairline);
    background: var(--card-bg);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    font-size: var(--fs-base); font-weight: 500; color: var(--ink-dim);
    padding: 0 12px;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.flag-btn { width: var(--control-h); padding: 0; }
.flag-btn:hover { border-color: var(--warning); color: var(--warning); }
.flag-btn.flagged { background: var(--warning); border-color: var(--warning); color: #fff; }
.flag-btn.loading, .explain-btn.loading { opacity: .65; pointer-events: none; }
.explain-btn:hover { border-color: var(--brand-text); color: var(--brand-text); }

.question-text {
    font-family: var(--font-display);
    font-size: 1.15rem; font-weight: 500;
    line-height: 1.55;
    margin-bottom: 24px;
    color: var(--ink);
    overflow-wrap: break-word; word-wrap: break-word; hyphens: auto;
}

.options { display: flex; flex-direction: column; gap: 12px; }
.option {
    display: flex; align-items: center; gap: 16px;
    min-height: 52px;
    padding: 12px 16px;
    border: var(--hairline);
    border-radius: var(--radius-md);
    cursor: pointer;
    background: var(--card-bg);
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
    overflow-wrap: break-word; word-wrap: break-word;
}
.option:hover { border-color: var(--brand-text); background: var(--surface-2); }
/* Selected: 2px border + brand wash + a check glyph (not colour alone). */
.option.selected { border: 2px solid var(--brand); background: var(--brand-light); }
.option.selected::after { content: "\2713"; margin-left: auto; font-weight: 700; color: var(--brand-text); }
.option.correct { border: 2px solid var(--success); background: var(--success-soft); }
.option.correct::after { content: "\2713"; margin-left: auto; font-weight: 700; color: var(--success); }
.option.incorrect { border: 2px solid var(--danger); background: var(--danger-soft); }
.option.incorrect::after { content: "\2715"; margin-left: auto; font-weight: 700; color: var(--danger); }
.option-letter {
    width: 30px; height: 30px; flex-shrink: 0;
    background: var(--surface-2);
    border: var(--hairline);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700; font-size: var(--fs-base);
    color: var(--ink-dim);
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.option.selected .option-letter { background: var(--brand); border-color: var(--brand); color: #fff; }
.option.correct .option-letter { background: var(--success); border-color: var(--success); color: #fff; }
.option.incorrect .option-letter { background: var(--danger); border-color: var(--danger); color: #fff; }
.option-label { flex: 1; line-height: 1.55; overflow-wrap: break-word; word-wrap: break-word; hyphens: auto; }

/* Explanation */
.explanation-box {
    margin-top: 20px;
    padding: 20px;
    background: var(--surface-2);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--brand);
    overflow-wrap: break-word; word-wrap: break-word;
}
.explanation-box h4 {
    font-size: var(--fs-base); color: var(--brand-text);
    margin-bottom: 8px;
    display: flex; align-items: center; gap: 6px;
}
.explanation-content { font-size: var(--fs-md); line-height: 1.7; color: var(--ink-dim); overflow-wrap: break-word; word-wrap: break-word; hyphens: auto; }
.explanation-content strong { color: var(--brand-text); }
.explanation-content ul { margin: 8px 0; padding-left: 20px; }
.explanation-content li { margin-bottom: 4px; }
.explanation-content h4 { margin-top: 12px; margin-bottom: 8px; }

.chat-followup { margin-top: 16px; border-top: var(--hairline); padding-top: 16px; overflow-wrap: break-word; word-wrap: break-word; }
.chat-followup-label { font-size: var(--fs-base); color: var(--ink-mute); margin-bottom: 8px; }
.chat-followup-input { display: flex; gap: 8px; flex-wrap: wrap; }
.chat-followup-input input {
    flex: 1; min-width: 0; min-height: var(--control-h-lg); padding: 6px 14px;
    border: 2px solid var(--border); border-radius: var(--radius-md);
    background: var(--card-bg); color: var(--ink); font-size: var(--fs-base);
}
.chat-followup-input input:focus { outline: none; border-color: var(--brand-text); box-shadow: var(--focus-ring); }
.chat-followup-input button {
    min-height: var(--control-h-lg);
    padding: 0 16px;
    background: var(--brand); color: #fff;
    border: none; border-radius: var(--radius-md); font-size: var(--fs-base); cursor: pointer;
    white-space: nowrap;
}
.chat-messages { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; overflow-wrap: break-word; word-wrap: break-word; }
.chat-msg { padding: 10px 14px; border-radius: var(--radius-md); font-size: var(--fs-base); line-height: 1.6; overflow-wrap: break-word; word-wrap: break-word; hyphens: auto; }
.chat-msg.user { background: var(--brand); color: #fff; align-self: flex-end; max-width: 85%; }
.chat-msg.ai { background: var(--card-bg); color: var(--ink-dim); border-left: 3px solid var(--brand); }

.ai-loading { padding: 16px 0; }
.skeleton-line {
    height: 13px; border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    margin-bottom: 10px;
}
.skeleton-line:nth-child(1) { width: 40%; }
.skeleton-line:nth-child(2) { width: 90%; }
.skeleton-line:nth-child(3) { width: 75%; }
.skeleton-line:nth-child(4) { width: 60%; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.nav-buttons { display: flex; justify-content: space-between; gap: 12px; margin-top: 24px; }
.nav-buttons .btn { padding: 0 22px; }

/* Results */
.results-section {
    background: var(--card-bg);
    border: var(--hairline);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    text-align: center;
    box-shadow: var(--shadow-2);
    overflow-wrap: break-word; word-wrap: break-word;
}
.score-circle {
    width: 160px; height: 160px;
    border-radius: 50%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    margin: 0 auto 20px;
    border: 8px solid var(--brand);
}
.score-value { font-family: var(--font-display); font-size: 2.6rem; font-weight: 800; }
.score-label { font-size: var(--fs-xs); color: var(--ink-mute); text-transform: uppercase; letter-spacing: .06em; }
.results-stats { display: flex; justify-content: center; gap: 32px; margin: 24px 0; flex-wrap: wrap; }
.result-stat { text-align: center; }
.result-stat-value { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; }
.result-stat-label { font-size: var(--fs-base); color: var(--ink-mute); }
.pass-fail {
    font-size: var(--fs-md); font-weight: 600;
    padding: 8px 20px; border-radius: var(--radius-md);
    display: inline-block; margin-bottom: 20px;
}
.pass-fail.pass { background: var(--success-soft); color: var(--success); }
.pass-fail.fail { background: var(--danger-soft); color: var(--danger); }

/* Mobile bottom bar */
.mobile-bottom-bar {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--card-bg);
    border-top: var(--hairline);
    padding: 8px 16px;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
    z-index: 90;
    align-items: center; justify-content: space-between; gap: 8px;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}
.mobile-bar-left { display: flex; align-items: center; gap: 12px; }
.mobile-timer { font-size: var(--fs-base); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-dim); }
.mobile-stats { display: flex; gap: 8px; font-size: var(--fs-base); color: var(--ink-mute); }
.mobile-bar-right { display: flex; align-items: center; gap: 8px; }
.mobile-nav-btn {
    width: var(--control-h-lg); height: var(--control-h-lg);
    border: var(--hairline);
    background: var(--card-bg);
    border-radius: var(--radius-md); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
    color: var(--ink);
}
.mobile-nav-btn:disabled { opacity: .35; cursor: not-allowed; }
.mobile-submit-btn {
    min-height: var(--control-h-lg);
    padding: 0 16px; background: var(--brand); color: #fff;
    border: none; border-radius: var(--radius-md); font-weight: 500; font-size: var(--fs-base); cursor: pointer;
}

/* Slide-out navigator */
.navigator-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 200;
}
.navigator-overlay.open { display: block; }
.navigator-panel {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--card-bg);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
    z-index: 201;
    max-height: 72vh; overflow-y: auto;
    overflow-x: hidden;
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.3, .9, .4, 1);
}
.navigator-panel.open { transform: translateY(0); }
.navigator-handle { width: 40px; height: 4px; background: var(--surface-3); border-radius: var(--radius-full); margin: 0 auto 16px; }
.navigator-panel .side-title { margin-bottom: 12px; }
.navigator-panel .timer-display { margin-bottom: 16px; }

.abandon-btn {
    width: 100%;
    min-height: var(--control-h-lg);
    padding: 0 10px;
    background: transparent;
    border: var(--hairline);
    border-color: var(--danger);
    color: var(--danger);
    border-radius: var(--radius-md);
    font-weight: 500; font-size: var(--fs-base);
    cursor: pointer;
    margin-top: 16px;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.abandon-btn:hover { background: var(--danger); color: #fff; }

/* Skeleton rows */
.skeleton-row {
    height: 64px;
    border-radius: var(--radius-lg);
    background: linear-gradient(90deg, var(--card-bg) 25%, var(--surface-2) 50%, var(--card-bg) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    margin-bottom: 8px;
    border: var(--hairline);
}

/* Demo notice */
.demo-notice {
    max-width: 1100px; margin: 16px auto 0;
    background: var(--brand-light);
    border: var(--hairline);
    border-color: var(--brand-border);
    color: var(--brand-text);
    padding: 10px 16px; border-radius: var(--radius-md);
    font-size: var(--fs-base); font-weight: 500;
}
.demo-notice a { color: inherit; font-weight: 700; text-decoration: underline; }

/* Ad container */
.ad-container { background: var(--surface-2); border-bottom: var(--hairline); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .test-layout { flex-direction: column; }
    .test-side { width: 100%; position: static; order: -1; }
    .test-side .side-card { display: none; }
    .test-main { min-width: 0; overflow-wrap: break-word; }
    .test-title { display: none; }
}

@media (max-width: 640px) {
    .container { padding: 16px 16px 88px; }
    .test-layout { padding: 12px; gap: 12px; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .how-grid { grid-template-columns: 1fr; gap: 16px; }
    .set-grid { grid-template-columns: repeat(3, 1fr); }
    .other-grid { grid-template-columns: 1fr; }
    .quick-actions { flex-direction: column; }
    .quick-actions .btn { width: 100%; }
    .set-score { display: none; }
    .ongoing-banner { flex-direction: column; text-align: center; }
    .nav-buttons .btn { flex: 1; }
    .mobile-bottom-bar { display: flex; }
    .question-card { padding: 16px; }
    .question-text { font-size: 1.05rem; }
    .results-section { padding: 28px 16px; }
    .q-navigator { grid-template-columns: repeat(4, 1fr); }
    .navigator-panel .q-navigator { grid-template-columns: repeat(4, 1fr); }
    .today-grid { grid-template-columns: 1fr 1fr; }
    .greeting { font-size: 1.3rem; }
}

@media (max-width: 480px) {
    .q-navigator { grid-template-columns: repeat(4, 1fr); gap: 6px; }
    .navigator-panel .q-navigator { grid-template-columns: repeat(4, 1fr); gap: 6px; }
    .q-num { font-size: var(--fs-xs); }
    .stats-row { grid-template-columns: 1fr 1fr; }
}

/* Mobile: present the active question as a stable modal-style sheet. */
body.modal-lock { overflow: hidden; }

@media (max-width: 640px) {
    .test-main.modal-mode {
        display: flex;
        flex-direction: column;
        position: fixed;
        inset: calc(var(--header-h) + 8px) 0 calc(64px + env(safe-area-inset-bottom, 0px));
        z-index: 80;
        padding: 0 !important;
        margin: 0 !important;
        max-width: none !important;
        overflow: hidden;
        background: var(--surface-2);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, .16);
    }
    .test-main.modal-mode .test-progress {
        flex-shrink: 0;
        margin: 0;
        padding: 10px 14px 12px;
        border-bottom: var(--hairline);
        background: var(--card-bg);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
    .test-main.modal-mode .nav-buttons { display: none; }
    .test-main.modal-mode #questions-container {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding: 12px;
        box-sizing: border-box;
    }
    .test-main.modal-mode .question-card {
        flex: 1 1 auto;
        min-height: 0;
        margin: 0;
        box-sizing: border-box;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

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

/* ---------- Start intro screen ---------- */
.intro-overlay {
    position: fixed; inset: 0; z-index: 600;
    background: rgba(0, 0, 0, .45);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    display: none; align-items: center; justify-content: center;
    padding: 20px;
}
.intro-overlay.open { display: flex; }
.intro-card {
    background: var(--card-bg);
    border: var(--hairline);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-3);
    width: 100%; max-width: 440px;
    padding: 32px 24px;
    text-align: center;
}
.intro-icon { font-size: 40px; line-height: 1; margin-bottom: 10px; }
.intro-card h3 { font-size: 1.3rem; margin-bottom: 4px; }
.intro-sub { color: var(--ink-mute); font-size: var(--fs-base); margin-bottom: 20px; }
.intro-mode { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.intro-mode-btn {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 16px 10px;
    background: var(--surface-2);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    color: var(--ink);
    transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.intro-mode-btn:hover { border-color: var(--brand-text); }
.intro-mode-btn.active { border-color: var(--brand); background: var(--brand-light); }
.intro-mode-btn .im-icon { font-size: 24px; }
.intro-mode-btn .im-title { font-weight: 700; font-size: var(--fs-md); }
.intro-mode-btn .im-desc { font-size: var(--fs-xs); color: var(--ink-mute); }
.intro-note { margin-top: 16px; font-size: var(--fs-xs); color: var(--ink-mute); }

/* ---------- Auto-advance toggle ---------- */
.auto-adv-row { display: flex; align-items: center; margin-top: 12px; }
.auto-adv {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: var(--fs-base); color: var(--ink-dim);
    cursor: pointer;
}
.auto-adv input { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }

/* ---------- Pre-submit summary ---------- */
.submit-summary { text-align: left; }
.summary-counts { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.summary-counts .sc { font-size: var(--fs-base); color: var(--ink-dim); }
.summary-counts .sc strong { font-family: var(--font-display); font-size: 1.15rem; margin-right: 2px; }
.summary-counts .sc strong.ok { color: var(--success); }
.summary-counts .sc strong.warn { color: var(--warning); }
.summary-counts .sc strong.flag { color: var(--brand-text); }
.summary-hint { font-size: var(--fs-base); color: var(--ink-mute); margin-bottom: 8px; }
.u-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.u-chip {
    min-width: 36px; min-height: var(--control-h); padding: 4px 10px;
    border-radius: var(--radius-md);
    border: var(--hairline);
    background: var(--surface-2);
    color: var(--warning);
    font-size: var(--fs-xs); font-weight: 700;
    cursor: pointer;
    transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.u-chip:hover { border-color: var(--warning); background: var(--warning-soft); }
.u-more { font-size: var(--fs-xs); color: var(--ink-mute); align-self: center; }
.summary-note { font-size: var(--fs-xs); color: var(--ink-mute); }

/* ---------- Guest completion CTA ---------- */
.guest-cta {
    background: var(--brand);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-top: 20px;
    text-align: left;
}
.guest-cta h4 { font-size: var(--fs-md); margin-bottom: 4px; }
.guest-cta p { font-size: var(--fs-base); opacity: .96; margin-bottom: 12px; }
.guest-cta-btns { display: flex; gap: 12px; flex-wrap: wrap; }
.guest-cta .btn-white,
.guest-cta .btn-white.ghost {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: var(--control-h-lg); padding: 0 18px;
    background: #fff; color: var(--brand-dark);
    border: none; border-radius: var(--radius-md);
    font-weight: 500; font-size: var(--fs-base);
    text-decoration: none;
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.guest-cta .btn-white.ghost { background: transparent; border: 2px solid rgba(255, 255, 255, .8); color: #fff; }
.guest-cta .btn-white:hover { transform: translateY(-1px); box-shadow: var(--shadow-1); }

/* ---------- Continue-trial strip (home) ---------- */
.guest-continue {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    background: var(--brand-light);
    border: var(--hairline);
    border-color: var(--brand-border);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    margin-bottom: 24px;
    font-size: var(--fs-base); color: var(--brand-text);
}

/* ---------- Reduced motion (explicit) ---------- */
@media (prefers-reduced-motion: reduce) {
    .card:hover,
    .set-card:hover,
    .set-row:hover,
    .other-card:hover,
    .subject-tile:hover,
    .continue-btn:hover,
    .guest-cta .btn-white:hover { transform: none; }
}
