/* ==========================================================================
   TEST HISTORY — dedicated page (was a modal)

   The old history lived in an 850px modal with inline styles, showed one row
   per attempt and nothing else. It is a full view now, so everything below is
   written against the design-system tokens (premium-ui.css / design-system.css)
   and works in both themes without a second stylesheet.

   Class prefix is th- throughout so nothing here can leak into the test
   runtime, which deliberately keeps its own look.
   ========================================================================== */

#test-history-view {
    padding: 0;
}

.th-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 4px 0 48px;
    color: var(--text-main);
    animation: th-rise 0.3s ease both;
}

@keyframes th-rise {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ── Hero ───────────────────────────────────────────────────────────────── */

.th-hero {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        radial-gradient(circle at 12% -40%, color-mix(in srgb, var(--brand) 26%, transparent), transparent 60%),
        radial-gradient(circle at 88% -10%, color-mix(in srgb, var(--brand-2) 20%, transparent), transparent 55%),
        var(--surface-solid);
    box-shadow: var(--shadow-sm);
    padding: 22px 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-4);
}

.th-hero-left {
    min-width: 240px;
    flex: 1;
}

.th-subject-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 12px 4px 8px;
    border-radius: 999px;
    background: var(--brand-soft);
    border: 1px solid color-mix(in srgb, var(--brand) 34%, transparent);
    color: var(--brand);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.th-hero h2 {
    margin: 10px 0 6px;
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.th-hero-sub {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.th-hero-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */

.th-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-raised);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

.th-btn:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--brand) 45%, transparent);
}

.th-btn:active {
    transform: translateY(0) scale(0.98);
}

.th-btn.primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #0b1220;
}

html.theme-light .th-btn.primary {
    color: #fff;
}

.th-btn.accent {
    background: color-mix(in srgb, var(--brand-2) 16%, transparent);
    border-color: color-mix(in srgb, var(--brand-2) 45%, transparent);
    color: var(--brand-2);
}

.th-btn.danger {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    border-color: color-mix(in srgb, var(--danger) 42%, transparent);
    color: var(--danger);
}

.th-btn.danger:hover {
    border-color: var(--danger);
}

.th-btn.tiny {
    padding: 6px 12px;
    font-size: 0.76rem;
}

.th-btn.icon-only {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
}

/* ── KPI strip ──────────────────────────────────────────────────────────── */

.th-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
}

.th-kpi {
    position: relative;
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 15px 16px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform 0.18s ease, border-color 0.18s ease;
}

.th-kpi::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--kpi-tint, var(--brand));
}

.th-kpi:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--kpi-tint, var(--brand)) 40%, transparent);
}

.th-kpi-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.th-kpi-label i {
    color: var(--kpi-tint, var(--brand));
}

.th-kpi-value {
    margin-top: 8px;
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.th-kpi-value small {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
}

.th-kpi-foot {
    margin-top: 5px;
    font-size: 0.74rem;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.th-delta {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-weight: 800;
}

.th-delta.up {
    color: var(--success);
}

.th-delta.down {
    color: var(--danger);
}

.th-delta.flat {
    color: var(--text-muted);
}

/* ── Insight cards ──────────────────────────────────────────────────────── */

.th-insights {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
}

.th-insight {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid color-mix(in srgb, var(--ins-tint, var(--brand)) 30%, transparent);
    background: color-mix(in srgb, var(--ins-tint, var(--brand)) 9%, var(--surface-solid));
}

.th-insight i {
    font-size: 1rem;
    color: var(--ins-tint, var(--brand));
    margin-top: 2px;
}

.th-insight-body h5 {
    margin: 0 0 3px;
    font-size: 0.86rem;
    font-weight: 800;
}

.th-insight-body p {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--text-muted);
    font-weight: 500;
}

.th-insight-body .th-btn {
    margin-top: 9px;
}

/* ── Cards / sections ───────────────────────────────────────────────────── */

.th-card {
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
    margin-bottom: var(--sp-4);
}

.th-card-head {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.th-card-head h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
}

.th-card-head h4 i {
    color: var(--brand);
}

.th-card-head p {
    margin: 3px 0 0;
    font-size: 0.76rem;
    color: var(--text-muted);
    font-weight: 500;
}

.th-two-col {
    display: grid;
    grid-template-columns: 1.55fr 1fr;
    gap: var(--sp-4);
    align-items: start;
}

/* Grid and flex items default to min-width:auto, so the chart SVG's intrinsic
   760px viewBox and the chapter table's 640px min-width became a floor on how
   narrow this page could get — and .content-area is a flex item, so that floor
   pushed the whole app shell wider than the window and gave every screen a
   horizontal scrollbar. Nothing here should ever set the page's minimum width;
   the two boxes that genuinely need room scroll inside themselves instead. */
.th-two-col > *,
.th-card,
.th-chart-wrap,
.th-table-scroll,
.th-heat,
.th-row,
.th-row-main > * {
    min-width: 0;
}

/* min-width:0 is not enough for the two boxes that scroll internally: a plain
   block still reports its content's min-content width up the chain, so the
   640px table and the 14-week heatmap grid kept widening the shell. Inline-size
   containment cuts that link — the box sizes from its parent, and its content
   scrolls inside it. */
.th-table-scroll,
.th-heat {
    contain: inline-size;
}

/* ── Segmented control ──────────────────────────────────────────────────── */

.th-seg {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: 999px;
}

.th-seg button {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.74rem;
    font-weight: 700;
    padding: 6px 13px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease;
}

.th-seg button.active {
    background: var(--brand);
    color: #0b1220;
}

html.theme-light .th-seg button.active {
    color: #fff;
}

/* ── Trend chart ────────────────────────────────────────────────────────── */

.th-chart-wrap {
    position: relative;
    width: 100%;
}

.th-chart {
    width: 100%;
    height: auto;
    display: block;
    overflow: visible;
}

.th-chart .th-grid-line {
    stroke: var(--line);
    stroke-width: 1;
}

.th-chart .th-axis-text {
    fill: var(--text-muted);
    font-size: 9px;
    font-weight: 600;
}

.th-chart .th-line {
    fill: none;
    stroke: var(--brand);
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.th-chart .th-dot {
    fill: var(--surface-solid);
    stroke: var(--brand);
    stroke-width: 2;
    transition: r 0.15s ease;
}

.th-chart .th-dot:hover {
    r: 6;
}

.th-chart .th-avg-line {
    stroke: var(--brand-2);
    stroke-width: 1.4;
    stroke-dasharray: 5 5;
    opacity: 0.85;
}

.th-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 10px;
    font-size: 0.74rem;
    color: var(--text-muted);
    font-weight: 600;
}

.th-chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.th-swatch {
    width: 12px;
    height: 3px;
    border-radius: 2px;
    background: var(--brand);
}

.th-swatch.dashed {
    background: repeating-linear-gradient(90deg, var(--brand-2) 0 4px, transparent 4px 7px);
}

/* ── Mastery donut ──────────────────────────────────────────────────────── */

.th-donut-row {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.th-donut {
    width: 132px;
    height: 132px;
    flex-shrink: 0;
    transform: rotate(-90deg);
}

.th-donut circle {
    fill: none;
    stroke-width: 13;
    stroke-linecap: butt;
}

.th-donut-center {
    position: relative;
}

.th-donut-hole {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.th-donut-hole b {
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1;
}

.th-donut-hole span {
    font-size: 0.63rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 3px;
}

.th-legend {
    display: flex;
    flex-direction: column;
    gap: 9px;
    flex: 1;
    min-width: 150px;
}

.th-legend-row {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 0.8rem;
    font-weight: 600;
}

.th-legend-row .th-dot-key {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

.th-legend-row b {
    margin-left: auto;
    font-weight: 800;
}

/* ── Consistency heatmap ────────────────────────────────────────────────── */

.th-heat {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(7, 1fr);
    gap: 3px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.th-heat-cell {
    width: 13px;
    height: 13px;
    border-radius: 3px;
    background: color-mix(in srgb, var(--text-muted) 14%, transparent);
}

.th-heat-cell.l1 {
    background: color-mix(in srgb, var(--brand-2) 32%, transparent);
}

.th-heat-cell.l2 {
    background: color-mix(in srgb, var(--brand-2) 58%, transparent);
}

.th-heat-cell.l3 {
    background: color-mix(in srgb, var(--brand-2) 82%, transparent);
}

.th-heat-cell.l4 {
    background: var(--brand-2);
}

.th-heat-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 10px;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 600;
}

.th-heat-scale {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ── Chapter table ──────────────────────────────────────────────────────── */

.th-table-scroll {
    overflow-x: auto;
}

.th-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.83rem;
    min-width: 640px;
}

.th-table th {
    text-align: left;
    padding: 9px 12px;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.th-table td {
    padding: 12px;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
    vertical-align: middle;
}

.th-table tbody tr {
    transition: background 0.15s ease;
}

.th-table tbody tr:hover {
    background: color-mix(in srgb, var(--brand) 6%, transparent);
}

.th-chapter-name {
    font-weight: 700;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.th-meter {
    position: relative;
    height: 7px;
    width: 90px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--text-muted) 18%, transparent);
    overflow: hidden;
}

.th-meter i {
    position: absolute;
    inset: 0 auto 0 0;
    border-radius: 999px;
    background: var(--meter-tint, var(--brand));
}

.th-cell-pct {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 800;
    white-space: nowrap;
}

/* ── Status pills ───────────────────────────────────────────────────────── */

.th-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 800;
    white-space: nowrap;
    border: 1px solid transparent;
}

.th-pill.good {
    color: var(--success);
    background: color-mix(in srgb, var(--success) 14%, transparent);
    border-color: color-mix(in srgb, var(--success) 34%, transparent);
}

.th-pill.mid {
    color: var(--warning);
    background: color-mix(in srgb, var(--warning) 14%, transparent);
    border-color: color-mix(in srgb, var(--warning) 34%, transparent);
}

.th-pill.bad {
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 14%, transparent);
    border-color: color-mix(in srgb, var(--danger) 34%, transparent);
}

.th-pill.neutral {
    color: var(--text-muted);
    background: color-mix(in srgb, var(--text-muted) 12%, transparent);
    border-color: var(--line);
}

/* ── Attempts toolbar ───────────────────────────────────────────────────── */

.th-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}

.th-search {
    position: relative;
    flex: 1;
    min-width: 190px;
}

.th-search i {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.8rem;
    pointer-events: none;
}

.th-search input {
    width: 100%;
    padding: 10px 14px 10px 34px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-raised);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.83rem;
    font-weight: 500;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.18s ease;
}

.th-search input:focus {
    border-color: color-mix(in srgb, var(--brand) 55%, transparent);
}

.th-select {
    padding: 9px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-raised);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.79rem;
    font-weight: 700;
    cursor: pointer;
    outline: none;
}

/* ── Attempt rows ───────────────────────────────────────────────────────── */

.th-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.th-row {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-raised);
    transition: border-color 0.18s ease, transform 0.18s ease;
    overflow: hidden;
}

.th-row:hover {
    border-color: color-mix(in srgb, var(--brand) 38%, transparent);
}

.th-row-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    cursor: pointer;
}

.th-row-id {
    flex: 1;
    min-width: 190px;
}

.th-row-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.th-row-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
}

.th-row-meta span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.th-split {
    display: flex;
    height: 7px;
    width: 138px;
    border-radius: 999px;
    overflow: hidden;
    background: color-mix(in srgb, var(--text-muted) 18%, transparent);
}

.th-split i {
    display: block;
    height: 100%;
}

.th-split .c {
    background: var(--success);
}

.th-split .w {
    background: var(--danger);
}

.th-split .s {
    background: color-mix(in srgb, var(--text-muted) 45%, transparent);
}

.th-split-legend {
    margin-top: 6px;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 700;
    display: flex;
    gap: 9px;
}

.th-split-legend .c {
    color: var(--success);
}

.th-split-legend .w {
    color: var(--danger);
}

.th-row-score {
    text-align: right;
    min-width: 96px;
}

.th-row-score b {
    display: block;
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1.1;
}

.th-row-score span {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 700;
}

.th-row-actions {
    display: flex;
    gap: 7px;
    align-items: center;
}

.th-chevron {
    color: var(--text-muted);
    transition: transform 0.22s ease;
    font-size: 0.8rem;
}

.th-row.open .th-chevron {
    transform: rotate(180deg);
}

/* Expanded per-question detail */

.th-row-detail {
    display: none;
    padding: 0 16px 16px;
    border-top: 1px dashed var(--line);
}

.th-row.open .th-row-detail {
    display: block;
    animation: th-rise 0.22s ease both;
}

.th-detail-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 14px 0;
}

.th-mini {
    flex: 1;
    min-width: 118px;
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
}

.th-mini span {
    display: block;
    font-size: 0.66rem;
    color: var(--text-muted);
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.th-mini b {
    font-size: 0.98rem;
    font-weight: 800;
}

.th-qdots {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.th-qdot {
    position: relative;
    width: 24px;
    height: 24px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.63rem;
    font-weight: 800;
    border: 1px solid transparent;
    cursor: default;
}

.th-qdot.c {
    background: color-mix(in srgb, var(--success) 20%, transparent);
    color: var(--success);
    border-color: color-mix(in srgb, var(--success) 40%, transparent);
}

.th-qdot.w {
    background: color-mix(in srgb, var(--danger) 20%, transparent);
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}

.th-qdot.s {
    background: color-mix(in srgb, var(--text-muted) 14%, transparent);
    color: var(--text-muted);
    border-color: var(--line);
}

/* A dot the student sat on far longer than their own average for that attempt.
   Slow-but-correct is the pattern worth seeing, so it is marked separately
   from right/wrong rather than folded into the colour. */
.th-qdot.slow::after {
    content: '';
    position: absolute;
    top: -3px;
    right: -3px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--warning);
    border: 1px solid var(--surface-raised);
}

/* ── Empty state ────────────────────────────────────────────────────────── */

.th-empty {
    text-align: center;
    padding: 54px 20px;
}

.th-empty-icon {
    width: 76px;
    height: 76px;
    margin: 0 auto 16px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.9rem;
    color: var(--brand);
    background: var(--brand-soft);
    border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
}

.th-empty h4 {
    margin: 0 0 7px;
    font-size: 1.1rem;
    font-weight: 800;
}

.th-empty p {
    margin: 0 auto 18px;
    max-width: 420px;
    color: var(--text-muted);
    font-size: 0.86rem;
    line-height: 1.55;
    font-weight: 500;
}

/* ── Reset modal ────────────────────────────────────────────────────────── */

.th-modal-back {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(4, 7, 12, 0.72);
    backdrop-filter: blur(7px);
    animation: th-fade-in 0.18s ease both;
}

@keyframes th-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.th-modal {
    width: 100%;
    max-width: 470px;
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 22px;
    animation: th-rise 0.22s ease both;
}

.th-modal h4 {
    margin: 0 0 6px;
    font-size: 1.08rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 9px;
}

.th-modal h4 i {
    color: var(--danger);
}

.th-modal > p {
    margin: 0 0 16px;
    color: var(--text-muted);
    font-size: 0.84rem;
    line-height: 1.55;
    font-weight: 500;
}

.th-choice {
    width: 100%;
    text-align: left;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 13px 14px;
    margin-bottom: 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface-raised);
    color: var(--text-main);
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.18s ease, transform 0.15s ease;
}

.th-choice:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}

.th-choice i {
    color: var(--danger);
    margin-top: 2px;
}

.th-choice b {
    display: block;
    font-size: 0.87rem;
    font-weight: 800;
    margin-bottom: 3px;
}

.th-choice span {
    display: block;
    font-size: 0.76rem;
    color: var(--text-muted);
    font-weight: 500;
    line-height: 1.45;
}

.th-modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 6px;
}

.th-safe-note {
    margin: 14px 0 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--success) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--success) 26%, transparent);
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.5;
    font-weight: 600;
}

/* ── Toast ──────────────────────────────────────────────────────────────── */

.th-toast {
    position: fixed;
    left: 50%;
    bottom: 34px;
    transform: translateX(-50%) translateY(14px);
    z-index: 100000;
    padding: 11px 20px;
    border-radius: 999px;
    background: var(--surface-solid);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-md);
    color: var(--text-main);
    font-size: 0.83rem;
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.th-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* The mobile tab bar owns the bottom of the screen — sit above it. */
@media (max-width: 900px) {

    body:not(.test-taking-mode):not(.practice-taking-mode) .th-toast {
        bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 14px);
    }
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 980px) {
    .th-two-col {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .th-hero {
        padding: 18px;
    }

    .th-hero h2 {
        font-size: 1.35rem;
    }

    .th-hero-actions {
        width: 100%;
    }

    .th-hero-actions .th-btn {
        flex: 1;
    }

    .th-kpis {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .th-kpi-value {
        font-size: 1.3rem;
    }

    .th-card {
        padding: 15px;
        border-radius: 14px;
    }

    .th-row-main {
        padding: 13px 14px;
        gap: 10px;
    }

    .th-row-id {
        min-width: 100%;
    }

    .th-split {
        width: 100%;
    }

    .th-row-score {
        text-align: left;
        min-width: 0;
        flex: 1;
    }

    .th-row-actions {
        margin-left: auto;
    }

    .th-toolbar .th-select {
        flex: 1;
    }
}
