/* =========================================================================
   RESULT PAGE — "REPORT"

   A rebuild of #result-view. Every id, class and onclick the result engine
   depends on is unchanged; this owns how the page looks and adds room for the
   analysis blocks resultInsights.js fills.

   Two things drove the design:

   1. The page used to be a 170-line <style> block inside the markup plus an
      inline style attribute on nearly every element. A <style> in the body wins
      over every linked sheet, so nothing could restyle it from outside. That
      block now lives here.

   2. It sits inside the normal app shell, unlike test mode — so it builds on
      the app's own tokens (--surface-solid, --line, --brand …), which already
      flip for light and dark. No parallel palette, no theme rules to maintain.

   Layout is a single measured column: hero → what-changed → charts → timeline →
   topics → insights → segments. Numbers first, then the reasons, then the
   questions themselves.
   ========================================================================= */

#result-view {
    --rs-gap: 18px;
    --rs-radius: 18px;
    --rs-radius-sm: 12px;
    --rs-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
    --rs-fast: 0.15s;

    /* Outcome colours. Semantic only — they never decorate. */
    --rs-correct: var(--success);
    --rs-wrong: var(--danger);
    --rs-skip: var(--text-muted);
    --rs-slow: var(--warning);
    --rs-never: #a97bf0;

    max-width: 1180px;
    margin: 0 auto;
    padding: 22px 20px 60px !important;
    color: var(--text-main) !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Shared card. Everything on the page is one of these, so elevation and radius
   are declared once. */
#result-view .rs-card {
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: var(--rs-radius);
    box-shadow: var(--shadow-sm);
}

#result-view .rs-section {
    margin-bottom: var(--rs-gap);
}

#result-view .rs-section-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

#result-view .rs-section-head h3 {
    margin: 0;
    font-family: 'Archivo', 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-main);
}

#result-view .rs-section-head .rs-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-left: auto;
    text-align: right;
}

/* ── HEADER ─────────────────────────────────────────────────────────────── */

#result-view .result-header-panel {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
    padding: 20px 22px;
    margin-bottom: var(--rs-gap);
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: var(--rs-radius);
    box-shadow: var(--shadow-sm);
}

#result-view #full-res-title {
    margin: 0 0 6px;
    font-family: 'Archivo', 'Inter', sans-serif;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-main) !important;
}

#result-view .rs-head-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

#result-view #full-res-date {
    margin: 0;
    font-size: 0.84rem;
    color: var(--text-muted);
}

#result-view #res-attempts-select {
    padding: 6px 30px 6px 12px;
    background: var(--surface-raised);
    color: var(--text-main);
    border: 1px solid var(--line);
    border-radius: 9px;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    appearance: none;
    outline: none;
    box-shadow: none;
}

#result-view .result-actions {
    display: flex;
    gap: 9px;
    align-items: center;
    flex-wrap: wrap;
}

/* Action buttons. One filled — Ask AI Mentor is the only thing here that does
   something the student cannot do themselves; the rest are navigation. */
#result-view .result-actions .mock-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px !important;
    background: var(--surface-raised) !important;
    border: 1px solid var(--line) !important;
    border-radius: 10px !important;
    color: var(--text-main) !important;
    font-size: 0.85rem;
    font-weight: 600 !important;
    cursor: pointer;
    transition: background var(--rs-fast) var(--rs-ease), border-color var(--rs-fast) var(--rs-ease), transform var(--rs-fast) var(--rs-ease);
}

#result-view .result-actions .mock-btn:hover {
    border-color: var(--brand) !important;
    transform: translateY(-1px);
}

#result-view .result-actions .ai-mentor-btn {
    background: var(--brand) !important;
    border-color: transparent !important;
    color: #fff !important;
    box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 35%, transparent) !important;
}

#result-view .result-actions .ai-mentor-btn .ai-tag {
    font-size: 0.62rem;
}

/* ── KPI ROW ────────────────────────────────────────────────────────────── */

#result-view .result-grid {
    display: grid;
    grid-template-columns: 1.35fr 1fr 1fr 1fr;
    gap: var(--rs-gap);
    margin-bottom: var(--rs-gap);
    align-items: stretch;
}

/* premium-ui.css gives .stat-card `grid-column: span 4` for the dashboard's
   12-column .stats-grid. This grid has four columns, so span 4 makes every card
   take a full row — invisible before, because .result-grid used to be a flexbox
   where grid-column does nothing. */
#result-view .result-grid > .stat-card {
    grid-column: auto;
}

#result-view .stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 210px;
    padding: 20px 14px;
    text-align: center;
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: var(--rs-radius);
    box-shadow: var(--shadow-sm);
    box-sizing: border-box;
    transition: border-color var(--rs-fast) var(--rs-ease);
}

#result-view .stat-card:hover {
    border-color: color-mix(in srgb, var(--brand) 40%, var(--line));
    transform: none;
}

/* The hero reads as the answer to "how did I do"; a tinted ground separates it
   from the three supporting measures without a second accent colour. */
#result-view .stat-card.hero-score-card {
    background:
        radial-gradient(120% 100% at 50% 0%, color-mix(in srgb, var(--brand) 12%, transparent), transparent 70%),
        var(--surface-solid);
    border-color: color-mix(in srgb, var(--brand) 30%, var(--line));
}

#result-view .stat-label,
#result-view .res-hero-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 0.68rem !important;
    font-weight: 700;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--text-muted) !important;
    margin-bottom: 0 !important;
}

#result-view .res-kpi-ring {
    position: relative;
    width: 104px !important;
    height: 104px !important;
    margin: 0 auto !important;
}

#result-view .res-kpi-ring-hero {
    width: 124px !important;
    height: 124px !important;
}

#result-view .res-kpi-ring > div {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    pointer-events: none;
}

/* Every number on this page is tabular monospace: the whole point is comparing
   them to each other and to last time. */
#result-view .stat-value {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-variant-numeric: tabular-nums;
    font-weight: 700 !important;
    color: var(--text-main) !important;
    text-shadow: none !important;
    letter-spacing: -0.01em;
}

#result-view #full-res-score {
    font-size: 1.5rem !important;
}

#result-view #full-res-score span {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem !important;
    color: var(--text-muted) !important;
}

#result-view #full-res-accuracy,
#result-view #full-res-attempt-rate {
    font-size: 1.3rem !important;
}

#result-view #full-res-time-taken {
    font-size: 1.12rem !important;
}

#result-view .res-kpi-sub {
    font-size: 0.72rem !important;
    color: var(--text-muted) !important;
    font-weight: 500 !important;
}

#result-view #lbl-res-score-status {
    padding: 5px 14px !important;
    border-radius: 100px !important;
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.03em !important;
    box-shadow: none !important;
    white-space: nowrap;
}

/* ── WHAT CHANGED (vs previous attempt) ─────────────────────────────────── */

#result-view #rs-delta-strip {
    display: none;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 13px 18px;
    margin-bottom: var(--rs-gap);
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: var(--rs-radius-sm);
    box-shadow: var(--shadow-sm);
}

#result-view .rs-delta-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-right: 4px;
}

#result-view .rs-delta {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 100px;
    background: var(--surface-raised);
    border: 1px solid var(--line);
    font-size: 0.78rem;
    color: var(--text-muted);
}

#result-view .rs-delta b {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-variant-numeric: tabular-nums;
    font-size: 0.84rem;
    font-weight: 700;
}

/* Up is not always good: on time taken, faster is better. The engine picks the
   class, so direction and meaning stay decided in one place. */
#result-view .rs-delta.is-up { color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); background: color-mix(in srgb, var(--success) 9%, transparent); }
#result-view .rs-delta.is-down { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: color-mix(in srgb, var(--danger) 9%, transparent); }
#result-view .rs-delta.is-flat { color: var(--text-muted); }

/* ── CHARTS ─────────────────────────────────────────────────────────────── */

#result-view .res-charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
    gap: var(--rs-gap);
    margin-bottom: var(--rs-gap);
}

#result-view .res-chart-panel {
    display: flex;
    flex-direction: column;
    padding: 20px 20px 18px !important;
    background: var(--surface-solid) !important;
    border: 1px solid var(--line) !important;
    border-radius: var(--rs-radius) !important;
    box-shadow: var(--shadow-sm) !important;
    text-align: left !important;
}

#result-view .res-chart-panel h4 {
    margin: 0;
    font-family: 'Archivo', 'Inter', sans-serif;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    color: var(--text-main) !important;
}

#result-view .rs-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 16px;
}

#result-view #lbl-res-accuracy-pill {
    padding: 4px 11px !important;
    border-radius: 100px !important;
    background: var(--brand-soft) !important;
    border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent) !important;
    color: var(--brand) !important;
    font-size: 0.72rem !important;
    font-weight: 700 !important;
}

#result-view .res-main-donut {
    width: 158px !important;
    height: 158px !important;
    margin: 2px auto 16px !important;
    position: relative;
}

#result-view #res-donut-center-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

#result-view #lbl-res-donut-acc {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-variant-numeric: tabular-nums;
    font-size: 1.45rem !important;
    font-weight: 700 !important;
    color: var(--text-main) !important;
}

/* Legend rows double as filters — they select the matching segment below — so
   they get a hover state that says so. */
#result-view .rs-legend {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#result-view .rs-legend-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 9px;
    border-radius: 9px;
    font-size: 0.83rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--rs-fast) var(--rs-ease), color var(--rs-fast) var(--rs-ease);
}

#result-view .rs-legend-row:hover {
    background: var(--surface-raised);
    color: var(--text-main);
}

#result-view .rs-legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

#result-view .rs-legend-row .rs-legend-name {
    margin-right: auto;
}

#result-view .rs-legend-row b {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-variant-numeric: tabular-nums;
    color: var(--text-main);
}

#result-view .rs-legend-row span.rs-legend-pct {
    min-width: 42px;
    text-align: right;
    font-size: 0.76rem;
    color: var(--text-muted);
}

/* Marks in, marks out. Negative marking is the single biggest score leak in
   these papers and it was previously a number with no weight given to it. */
#result-view .rs-marks {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

#result-view .rs-mark-box {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    border-radius: var(--rs-radius-sm);
    background: var(--surface-raised);
    border: 1px solid var(--line);
}

#result-view .rs-mark-box span {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
}

#result-view .rs-mark-box b {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-variant-numeric: tabular-nums;
    font-size: 1.05rem;
    font-weight: 700;
}

#result-view #lbl-res-pos-marks { color: var(--success) !important; }
#result-view #lbl-res-neg-marks { color: var(--danger) !important; }

#result-view #lbl-res-perf-badge {
    margin-top: 14px !important;
    padding: 9px 14px !important;
    border-radius: var(--rs-radius-sm) !important;
    background: var(--brand-soft) !important;
    border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent) !important;
    color: var(--brand) !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
}

/* Actual / Average toggle. Same segmented-pill vocabulary as the palette
   switch in test mode. */
#result-view .rs-toggle {
    display: flex;
    gap: 2px;
    padding: 3px;
    border-radius: 10px;
    background: var(--surface-raised);
    border: 1px solid var(--line);
}

#result-view .rs-toggle .mock-btn {
    padding: 5px 13px !important;
    border: none !important;
    border-radius: 8px !important;
    background: transparent !important;
    color: var(--text-muted) !important;
    font-size: 0.74rem !important;
    font-weight: 700 !important;
    cursor: pointer;
    transition: background var(--rs-fast) var(--rs-ease), color var(--rs-fast) var(--rs-ease);
}

#result-view .rs-toggle .mock-btn.is-on {
    background: var(--brand) !important;
    color: #fff !important;
}

#result-view .rs-bar-wrap {
    height: 168px;
    position: relative;
}

/* ── QUESTION TIMELINE ──────────────────────────────────────────────────── */

/* One column per question, in the order they were answered, height scaled to
   the time spent. Every other view on this page aggregates; this is the only
   one that shows the shape of the attempt — where the pace broke, which run of
   questions went wrong, where the paper ran out. */
#result-view #rs-timeline-card {
    padding: 18px 20px 16px;
}

#result-view #rs-timeline {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 96px;
    padding-top: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}

#result-view .rs-tl-bar {
    position: relative;
    flex: 1 1 0;
    min-width: 7px;
    border-radius: 3px 3px 2px 2px;
    background: var(--rs-skip);
    opacity: 0.85;
    cursor: pointer;
    transition: opacity var(--rs-fast) var(--rs-ease), transform var(--rs-fast) var(--rs-ease);
}

#result-view .rs-tl-bar:hover {
    opacity: 1;
    transform: scaleY(1.04);
}

#result-view .rs-tl-bar.is-correct { background: var(--rs-correct); }
#result-view .rs-tl-bar.is-wrong { background: var(--rs-wrong); }
#result-view .rs-tl-bar.is-skipped { background: color-mix(in srgb, var(--text-muted) 45%, transparent); }
#result-view .rs-tl-bar.is-never { background: color-mix(in srgb, var(--text-muted) 22%, transparent); }

/* A question that ate the clock gets a marker regardless of whether it was
   right — that is the point of the row. */
#result-view .rs-tl-bar.is-slow::after {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--rs-slow);
}

#result-view .rs-tl-axis {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.68rem;
    color: var(--text-muted);
}

#result-view .rs-tl-key {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    font-size: 0.73rem;
    color: var(--text-muted);
}

#result-view .rs-tl-key span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#result-view .rs-tl-key i {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    display: inline-block;
}

/* ── TOPIC BREAKDOWN ────────────────────────────────────────────────────── */

#result-view #rs-topics-card {
    padding: 18px 20px;
}

#result-view .rs-topic {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 88px 62px;
    align-items: center;
    gap: 14px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
}

#result-view .rs-topic:last-child {
    border-bottom: none;
}

#result-view .rs-topic-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#result-view .rs-topic-sub {
    display: block;
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--text-muted);
}

#result-view .rs-topic-track {
    height: 7px;
    border-radius: 4px;
    background: var(--surface-raised);
    overflow: hidden;
}

#result-view .rs-topic-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--success);
    transition: width 0.5s var(--rs-ease);
}

#result-view .rs-topic-fill.is-weak { background: var(--danger); }
#result-view .rs-topic-fill.is-mid { background: var(--warning); }

#result-view .rs-topic-pct {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-variant-numeric: tabular-nums;
    font-size: 0.85rem;
    font-weight: 700;
    text-align: right;
    color: var(--text-main);
}

/* ── INSIGHTS ───────────────────────────────────────────────────────────── */

/* The part that says what the numbers mean. Each card is a finding plus the one
   action that follows from it — never a statistic restated in a sentence. */
#result-view #rs-insights {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}

#result-view .rs-insight {
    display: flex;
    gap: 12px;
    padding: 15px 16px;
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-left: 3px solid var(--brand);
    border-radius: var(--rs-radius-sm);
    box-shadow: var(--shadow-sm);
}

#result-view .rs-insight.is-warn { border-left-color: var(--warning); }
#result-view .rs-insight.is-bad { border-left-color: var(--danger); }
#result-view .rs-insight.is-good { border-left-color: var(--success); }

#result-view .rs-insight > i {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: var(--surface-raised);
    color: var(--brand);
    font-size: 0.82rem;
}

#result-view .rs-insight.is-warn > i { color: var(--warning); }
#result-view .rs-insight.is-bad > i { color: var(--danger); }
#result-view .rs-insight.is-good > i { color: var(--success); }

#result-view .rs-insight-body h5 {
    margin: 0 0 4px;
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--text-main);
}

#result-view .rs-insight-body p {
    margin: 0;
    font-size: 0.8rem;
    line-height: 1.55;
    color: var(--text-muted);
}

#result-view .rs-insight-body b {
    color: var(--text-main);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-variant-numeric: tabular-nums;
}

#result-view .rs-insight-act {
    display: inline-block;
    margin-top: 8px;
    padding: 0;
    background: none;
    border: none;
    color: var(--brand);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

#result-view .rs-insight-act:hover {
    text-decoration: underline;
}

/* ── SEGMENTS ───────────────────────────────────────────────────────────── */

#result-view .res-segments-card-container {
    padding: 20px !important;
    background: var(--surface-solid) !important;
    border: 1px solid var(--line) !important;
    border-radius: var(--rs-radius) !important;
    box-shadow: var(--shadow-sm);
    margin-bottom: 0 !important;
}

#result-view .res-segments-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

#result-view .segment-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    min-height: 0;
    padding: 14px 8px 10px !important;
    background: var(--surface-raised) !important;
    border: 1px solid var(--line) !important;
    border-radius: var(--rs-radius-sm) !important;
    text-align: center;
    cursor: pointer;
    box-sizing: border-box;
    transition: border-color var(--rs-fast) var(--rs-ease), background var(--rs-fast) var(--rs-ease), transform var(--rs-fast) var(--rs-ease);
}

#result-view .segment-card:hover {
    transform: translateY(-2px);
}

#result-view .segment-card .seg-title {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.25;
}

#result-view .segment-card .badge {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-variant-numeric: tabular-nums;
    padding: 2px 10px !important;
    border-radius: 100px !important;
    font-size: 0.78rem !important;
    font-weight: 700 !important;
    margin: 0 !important;
}

/* Category colour lives here, not in selectResultSegment()'s inline styles —
   which is what let the old page hard-code #151515 and break every theme. */
#result-view #seg-card-all.active { border-color: var(--brand) !important; background: var(--brand-soft) !important; }
#result-view #seg-card-correct.active { border-color: var(--success) !important; background: color-mix(in srgb, var(--success) 10%, transparent) !important; }
#result-view #seg-card-incorrect.active { border-color: var(--danger) !important; background: color-mix(in srgb, var(--danger) 10%, transparent) !important; }
#result-view #seg-card-skipped.active { border-color: var(--text-muted) !important; background: color-mix(in srgb, var(--text-muted) 12%, transparent) !important; }
#result-view #seg-card-timetaking.active { border-color: var(--warning) !important; background: color-mix(in srgb, var(--warning) 10%, transparent) !important; }
#result-view #seg-card-neverreached.active { border-color: var(--rs-never) !important; background: color-mix(in srgb, var(--rs-never) 12%, transparent) !important; }

#result-view .segment-card.active .seg-title {
    color: var(--text-main);
}

/* Practice / Test / Video launchers inside each card. */
#result-view .seg-actions {
    display: flex;
    gap: 4px;
    width: 100%;
    margin-top: auto;
}

#result-view .seg-actions .mock-btn {
    flex: 1;
    padding: 5px 2px !important;
    background: var(--surface-solid) !important;
    border: 1px solid var(--line) !important;
    border-radius: 7px !important;
    color: var(--text-muted) !important;
    font-size: 0.64rem !important;
    font-weight: 700 !important;
    cursor: pointer;
    transition: color var(--rs-fast) var(--rs-ease), border-color var(--rs-fast) var(--rs-ease);
}

#result-view .seg-actions .mock-btn:hover {
    color: var(--text-main) !important;
    border-color: var(--brand) !important;
}

#result-view .seg-actions .seg-video:hover {
    color: var(--danger) !important;
    border-color: var(--danger) !important;
}

/* ── SELECTED SEGMENT LIST ──────────────────────────────────────────────── */

#result-view #res-selected-segment-list-container {
    border-top: 1px solid var(--line) !important;
    padding-top: 18px !important;
}

/* selectResultSegment() sets data-cat instead of writing a hex into
   style.color, so the heading matches its card in both themes. */
#result-view #res-selected-segment-title {
    margin: 0;
    font-family: 'Archivo', 'Inter', sans-serif;
    font-size: 0.9rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.09em !important;
    text-transform: uppercase;
    color: var(--text-main);
}

#result-view #res-selected-segment-title[data-cat="all"] { color: var(--brand); }
#result-view #res-selected-segment-title[data-cat="correct"] { color: var(--success); }
#result-view #res-selected-segment-title[data-cat="incorrect"] { color: var(--danger); }
#result-view #res-selected-segment-title[data-cat="skipped"] { color: var(--text-muted); }
#result-view #res-selected-segment-title[data-cat="timetaking"] { color: var(--warning); }
#result-view #res-selected-segment-title[data-cat="neverreached"] { color: var(--rs-never); }

#result-view #btn-res-launch-category-video {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 14px !important;
    background: var(--danger) !important;
    border: none !important;
    border-radius: 9px !important;
    color: #fff !important;
    font-size: 0.78rem !important;
    font-weight: 700 !important;
    box-shadow: none !important;
    cursor: pointer;
}

#result-view #res-video-playlist-bar {
    background: var(--surface-raised) !important;
    border: 1px solid var(--line) !important;
    border-radius: var(--rs-radius-sm) !important;
    padding: 10px 14px !important;
}

#result-view #res-video-playlist-bar .mock-btn {
    background: var(--surface-solid) !important;
    border: 1px solid var(--line) !important;
    border-radius: 8px !important;
    color: var(--text-main) !important;
    padding: 5px 11px !important;
    font-size: 0.75rem !important;
}

/* Question rows in the selected segment. */
#result-view .res-q-item {
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: var(--rs-radius-sm);
    margin-bottom: 8px;
    overflow: hidden;
    transition: border-color var(--rs-fast) var(--rs-ease);
}

#result-view .res-q-item:hover {
    border-color: color-mix(in srgb, var(--brand) 40%, var(--line));
}

#result-view .res-q-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
}

#result-view .res-q-text {
    flex: 1;
    min-width: 0;
    font-size: 0.87rem;
    line-height: 1.5;
    color: var(--text-main);
}

#result-view .res-q-text strong {
    color: var(--brand);
    margin-right: 4px;
}

#result-view .res-q-summary > span:not(.res-q-text) {
    flex-shrink: 0;
    background: var(--surface-solid) !important;
    border: 1px solid var(--line);
    color: var(--text-muted) !important;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.72rem !important;
    padding: 2px 9px !important;
    border-radius: 100px !important;
}

#result-view .res-q-detail {
    padding: 0 14px 14px;
    border-top: 1px solid var(--line);
}

#result-view .res-opt-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 13px;
    margin-top: 8px;
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text-main);
    font: inherit;
    font-size: 0.84rem;
    cursor: pointer;
    transition: border-color var(--rs-fast) var(--rs-ease), background var(--rs-fast) var(--rs-ease);
}

#result-view .res-opt-btn:hover {
    border-color: var(--brand);
}

#result-view .res-opt-btn.correct {
    background: color-mix(in srgb, var(--success) 12%, transparent);
    border-color: var(--success);
    color: var(--success);
    font-weight: 600;
}

#result-view .res-opt-btn.wrong {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    border-color: var(--danger);
    color: var(--danger);
    font-weight: 600;
}

/* ── RESPONSIVE ─────────────────────────────────────────────────────────── */

@media (max-width: 980px) {
    #result-view .result-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    #result-view .res-segments-row {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* The phone layout for the header, the KPI board and the charts is already
   tuned in responsive/mobile-premium.css — hero score full width, three gauges
   beneath, 2x2 action chips — and it declares those with !important. Repeating
   any of it here would be dead code that only looks authoritative. Only the
   blocks this file introduced are adjusted. */
@media (max-width: 640px) {
    #result-view .res-segments-row {
        grid-template-columns: repeat(2, 1fr);
    }

    #result-view .rs-topic {
        grid-template-columns: minmax(0, 1fr) 56px 48px;
        gap: 10px;
    }

    /* Below this width a 25-column strip is thinner than a fingertip, so it
       scrolls at a readable bar width instead of compressing further. */
    #result-view #rs-timeline .rs-tl-bar {
        flex: 0 0 11px;
    }

    #result-view #rs-insights {
        grid-template-columns: 1fr;
    }
}
