/* ==========================================================================
   DSA Quiz — styles
   Tokens live on :root (light), then get overridden for dark.
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #f7f8fa;
  --bg-elev: #ffffff;
  --bg-sunken: #eef0f4;
  --border: #dfe3ea;
  --border-strong: #c6ccd8;
  --text: #14161a;
  --text-dim: #5b6472;
  --text-faint: #8b93a1;
  --accent: #4f46e5;
  --accent-soft: #ece9fe;
  --accent-text: #4338ca;
  --good: #0f7b52;
  --good-soft: #dcf5e9;
  --bad: #c02a3d;
  --bad-soft: #fde8ea;
  --warn: #9a6400;
  --warn-soft: #fdf1d6;
  --ring: 0 0 0 3px rgb(79 70 229 / 0.28);
  --shadow-sm: 0 1px 2px rgb(16 18 24 / 0.05);
  --shadow-md: 0 4px 16px rgb(16 18 24 / 0.07);
  --shadow-lg: 0 12px 40px rgb(16 18 24 / 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #0c0e12;
  --bg-elev: #14171d;
  --bg-sunken: #1a1e25;
  --border: #262b34;
  --border-strong: #363d49;
  --text: #e9ecf1;
  --text-dim: #9aa3b2;
  --text-faint: #6b7382;
  --accent: #8b83ff;
  --accent-soft: #1f1d3d;
  --accent-text: #b0aaff;
  --good: #3ddc97;
  --good-soft: #102b21;
  --bad: #ff6b7d;
  --bad-soft: #2e1418;
  --warn: #ffc14d;
  --warn-soft: #2c2109;
  --ring: 0 0 0 3px rgb(139 131 255 / 0.32);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-md: 0 4px 16px rgb(0 0 0 / 0.35);
  --shadow-lg: 0 12px 40px rgb(0 0 0 / 0.45);
  color-scheme: dark;
}

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

button {
  font: inherit;
  cursor: pointer;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  padding: 0.08em 0.36em;
  border-radius: 5px;
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------- topbar -- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 17px;
}
.brand-mark {
  color: var(--accent);
  font-size: 19px;
}
.brand-dim {
  color: var(--text-faint);
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chip {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.chip-ai {
  font-family: var(--mono);
  font-size: 11px;
}
.chip-ai.is-on {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}
.chip-ai.is-off {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 30%, transparent);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-dim);
  font-size: 15px;
  transition: color 0.15s, border-color 0.15s;
}
.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

/* ------------------------------------------------------------------ main -- */
#app {
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(24px, 5vw, 48px) clamp(16px, 4vw, 40px) 80px;
}

.screen[hidden] {
  display: none;
}

/* ------------------------------------------------------------------ hero -- */
.hero {
  margin-bottom: 28px;
}
.hero h1 {
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 700;
  margin-bottom: 10px;
}
.hero-sub {
  margin: 0;
  color: var(--text-dim);
  font-size: 16px;
  max-width: 62ch;
}
.hero-sub strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ----------------------------------------------------------- stats strip -- */
.stats-strip {
  display: flex;
  align-items: center;
  gap: clamp(16px, 4vw, 40px);
  flex-wrap: wrap;
  padding: 16px 20px;
  margin-bottom: 24px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.stat {
  display: flex;
  flex-direction: column;
}
.stat-value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat-label {
  font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}
.stat-reset {
  margin-left: auto;
}

/* ----------------------------------------------------------------- panel -- */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.panel-head h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
}
.panel-actions {
  display: flex;
  gap: 6px;
}

.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 880px) {
  .setup-grid {
    grid-template-columns: 1fr;
  }
}

/* ------------------------------------------------------------- topic grid */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
}

.topic-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  text-align: left;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.topic-card:hover {
  border-color: var(--border-strong);
}
.topic-card:active {
  transform: scale(0.99);
}
.topic-card[aria-pressed='true'] {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
}
.topic-card:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.tc-icon {
  font-size: 15px;
  line-height: 1.35;
  color: var(--text-faint);
  flex-shrink: 0;
}
.topic-card[aria-pressed='true'] .tc-icon {
  color: var(--accent);
}
.tc-body {
  min-width: 0;
}
.tc-name {
  display: block;
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: -0.01em;
}
.tc-count {
  display: block;
  font-size: 11.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.tc-check {
  margin-left: auto;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--border-strong);
  display: grid;
  place-items: center;
  font-size: 10px;
  color: transparent;
}
.topic-card[aria-pressed='true'] .tc-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------------------------------------------------------------- fields -- */
.field {
  border: 0;
  padding: 0;
  margin: 0 0 20px;
}
.field legend {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 9px;
  padding: 0;
}
.legend-value {
  font-family: var(--mono);
  color: var(--accent-text);
  text-transform: none;
  letter-spacing: 0;
  margin-left: 4px;
}
.field-hint {
  margin: 9px 0 0;
  font-size: 12.5px;
  color: var(--text-faint);
  line-height: 1.45;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.seg input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.seg span {
  display: block;
  text-align: center;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-dim);
  transition: background 0.15s, color 0.15s;
}
.seg input:checked + span {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.seg input:focus-visible + span {
  box-shadow: var(--ring);
}

.checks {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.check input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}
.check-inline {
  display: flex;
  margin-top: 10px;
  font-size: 13px;
}

.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  outline: none;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elev);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.range::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elev);
  cursor: pointer;
}
.range:focus-visible {
  box-shadow: var(--ring);
}
.range-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}

.start-row {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.pool-note {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--text-faint);
}
.pool-note.is-warn {
  color: var(--warn);
}

/* --------------------------------------------------------------- buttons -- */
.primary-btn,
.secondary-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.primary-btn {
  width: 100%;
  padding: 11px 18px;
  font-size: 14.5px;
  color: #fff;
  background: var(--accent);
  border: 1px solid transparent;
}
:root[data-theme='dark'] .primary-btn {
  color: #0c0e12;
}
.primary-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 88%, #000);
}
.primary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.secondary-btn {
  padding: 10px 16px;
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
}
.secondary-btn:hover {
  background: var(--bg-sunken);
}
.ghost-btn {
  padding: 5px 10px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
}
.ghost-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.ghost-btn.is-active {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}
.primary-btn:focus-visible,
.secondary-btn:focus-visible,
.ghost-btn:focus-visible,
.ai-btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgb(255 255 255 / 0.18);
  border: 1px solid rgb(255 255 255 / 0.22);
}
:root[data-theme='dark'] .kbd {
  background: rgb(0 0 0 / 0.18);
  border-color: rgb(0 0 0 / 0.2);
}

/* ------------------------------------------------------------- quiz head -- */
.quiz-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.progress-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-dim);
}
.q-counter {
  font-variant-numeric: tabular-nums;
}
.q-counter strong {
  color: var(--text);
}
.dot-sep {
  color: var(--text-faint);
}
.topic-tag {
  font-weight: 600;
  color: var(--text);
}
.diff-tag {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--text-faint);
}
.diff-tag[data-d='easy'] {
  color: var(--good);
  background: var(--good-soft);
  border-color: color-mix(in srgb, var(--good) 30%, transparent);
}
.diff-tag[data-d='medium'] {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 30%, transparent);
}
.diff-tag[data-d='hard'] {
  color: var(--bad);
  background: var(--bad-soft);
  border-color: color-mix(in srgb, var(--bad) 30%, transparent);
}

.quiz-head-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.score-live,
.timer {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.timer.is-low {
  color: var(--bad);
}

.progress-track {
  height: 4px;
  background: var(--bg-sunken);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 20px;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ----------------------------------------------------------------- qcard -- */
.qcard {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(18px, 3vw, 28px);
  box-shadow: var(--shadow-md);
}
.qcard-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 20px;
}
.qtext {
  font-size: clamp(17px, 2.4vw, 21px);
  font-weight: 600;
  line-height: 1.42;
  letter-spacing: -0.015em;
  flex: 1;
}
.flag-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-faint);
  font-size: 14px;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.flag-btn:hover {
  color: var(--warn);
  border-color: var(--border-strong);
}
.flag-btn.is-on {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 40%, transparent);
}

.options {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.opt {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 13px 15px;
  text-align: left;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-sunken);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, background 0.15s, transform 0.08s;
}
.opt:not(:disabled):hover {
  border-color: var(--border-strong);
}
.opt:not(:disabled):active {
  transform: scale(0.995);
}
.opt:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.opt-key {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-faint);
}
.opt-text {
  flex: 1;
  min-width: 0;
}
.opt-mark {
  flex-shrink: 0;
  font-size: 15px;
  font-weight: 700;
  opacity: 0;
}

.opt.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.opt.is-selected .opt-key {
  border-color: var(--accent);
  color: var(--accent-text);
}
.opt.is-correct {
  border-color: var(--good);
  background: var(--good-soft);
}
.opt.is-correct .opt-key {
  background: var(--good);
  border-color: var(--good);
  color: var(--bg-elev);
}
.opt.is-correct .opt-mark {
  opacity: 1;
  color: var(--good);
}
.opt.is-wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
}
.opt.is-wrong .opt-key {
  background: var(--bad);
  border-color: var(--bad);
  color: var(--bg-elev);
}
.opt.is-wrong .opt-mark {
  opacity: 1;
  color: var(--bad);
}
.opt:disabled {
  cursor: default;
}
.opt:disabled:not(.is-correct):not(.is-wrong):not(.is-selected) {
  opacity: 0.55;
}

/* --------------------------------------------------------------- explain -- */
.explain {
  margin-top: 18px;
  padding: 15px 17px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  animation: rise 0.25s ease;
}
.explain.is-correct {
  border-left-color: var(--good);
}
.explain.is-wrong {
  border-left-color: var(--bad);
}
.explain-head {
  margin-bottom: 5px;
}
.explain-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
}
.explain.is-correct .explain-label {
  color: var(--good);
}
.explain.is-wrong .explain-label {
  color: var(--bad);
}
.explain-body {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-dim);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* -------------------------------------------------------------------- ai -- */
.ai {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  overflow: hidden;
}
.ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 11px 14px;
}
.ai-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent-text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ai-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.ai-btn {
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 6px;
  color: var(--text-dim);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  transition: color 0.15s, border-color 0.15s;
}
.ai-btn:hover:not(:disabled) {
  color: var(--accent-text);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.ai-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.ai-btn.is-active {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.ai-body {
  padding: 0 14px 14px;
  font-size: 14px;
  line-height: 1.62;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  padding-top: 13px;
  overflow-wrap: anywhere;
}
.ai-body > *:first-child {
  margin-top: 0;
}
.ai-body > *:last-child {
  margin-bottom: 0;
}
.ai-body p {
  margin: 0 0 0.7em;
}
.ai-body strong {
  color: var(--text);
  font-weight: 600;
}
.ai-body ul,
.ai-body ol {
  margin: 0 0 0.7em;
  padding-left: 1.35em;
}
.ai-body li {
  margin-bottom: 0.3em;
}
.ai-body h3,
.ai-body h4 {
  font-size: 13.5px;
  color: var(--text);
  margin: 1em 0 0.4em;
}
.ai-body pre {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 11px 13px;
  overflow-x: auto;
  margin: 0 0 0.7em;
}
.ai-body pre code {
  background: none;
  border: 0;
  padding: 0;
  white-space: pre;
  font-size: 12.5px;
  line-height: 1.55;
}
.ai-err {
  color: var(--bad);
  font-size: 13.5px;
}
.cursor-blink {
  display: inline-block;
  width: 7px;
  height: 1em;
  vertical-align: text-bottom;
  background: var(--accent);
  animation: blink 1s steps(2) infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}
.ai-review {
  margin-bottom: 20px;
}

/* ------------------------------------------------------------ qcard foot -- */
.qcard-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.hint {
  font-size: 12.5px;
  color: var(--text-faint);
}
.hint b {
  font-family: var(--mono);
  color: var(--text-dim);
  font-weight: 500;
}
.qcard-foot .primary-btn {
  width: auto;
  min-width: 130px;
}

/* --------------------------------------------------------------- results -- */
.result-hero {
  display: flex;
  align-items: center;
  gap: clamp(20px, 5vw, 44px);
  flex-wrap: wrap;
  padding: clamp(20px, 4vw, 32px);
  margin-bottom: 20px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.score-ring {
  position: relative;
  width: 132px;
  height: 132px;
  flex-shrink: 0;
}
.score-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.ring-bg,
.ring-fg {
  fill: none;
  stroke-width: 9;
  stroke-linecap: round;
}
.ring-bg {
  stroke: var(--bg-sunken);
}
.ring-fg {
  stroke: var(--accent);
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset 0.9s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.3s;
}
.score-ring-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}
.score-pct {
  display: block;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.score-frac {
  display: block;
  font-size: 12.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.result-copy {
  flex: 1;
  min-width: 260px;
}
.result-copy h1 {
  font-size: clamp(22px, 3.6vw, 30px);
  margin-bottom: 7px;
}
.result-copy p {
  margin: 0 0 18px;
  color: var(--text-dim);
  font-size: 14.5px;
}
.result-actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}
.result-actions .primary-btn {
  width: auto;
}

.topic-bars {
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.tbar {
  display: grid;
  grid-template-columns: minmax(120px, 1.5fr) minmax(0, 3fr) auto;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.tbar-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tbar-track {
  height: 7px;
  background: var(--bg-sunken);
  border-radius: 999px;
  overflow: hidden;
}
.tbar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}
.tbar-val {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  min-width: 52px;
  text-align: right;
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.rev {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  overflow: hidden;
}
.rev[hidden] {
  display: none;
}
.rev-head {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
.rev-head:hover {
  background: color-mix(in srgb, var(--bg-elev) 55%, transparent);
}
.rev-badge {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
}
.rev-badge.ok {
  color: var(--good);
  background: var(--good-soft);
}
.rev-badge.no {
  color: var(--bad);
  background: var(--bad-soft);
}
.rev-badge.skip {
  color: var(--text-faint);
  background: var(--bg-elev);
}
.rev-q {
  flex: 1;
  min-width: 0;
}
.rev-chev {
  flex-shrink: 0;
  color: var(--text-faint);
  font-size: 11px;
  transition: transform 0.2s;
}
.rev.is-open .rev-chev {
  transform: rotate(90deg);
}
.rev-body {
  padding: 0 14px 14px 45px;
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.6;
}
.rev-body[hidden] {
  display: none;
}
.rev-line {
  margin: 0 0 5px;
}
.rev-line b {
  color: var(--text-faint);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 6px;
}
.rev-line.ok span {
  color: var(--good);
}
.rev-line.no span {
  color: var(--bad);
}
.rev-exp {
  margin: 9px 0 0;
  padding-top: 9px;
  border-top: 1px solid var(--border);
}

/* ----------------------------------------------------------------- toast -- */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: rise 0.2s ease;
}
.toast[hidden] {
  display: none;
}

/* --------------------------------------------------------------- loading -- */
.skeleton {
  color: var(--text-faint);
  font-size: 14px;
}
