/* ==========================================================================
   ZimVID Prep — dashboard, exam runner, results, review and practice
   ========================================================================== */

/* -- Dashboard ------------------------------------------------------------ */
.dash-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.2rem;
  flex-wrap: wrap;
  padding: clamp(1.6rem, 3.5vw, 2.8rem) 0 1.4rem;
}

.dash-greeting {
  margin: 0 0 0.25rem;
  font-size: clamp(1.7rem, 3.4vw, 2.5rem);
}

.dash-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.dash-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.sub-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 1.25rem 1.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(500px 200px at 100% 0%, rgba(240, 180, 41, 0.09), transparent 65%),
    var(--surface);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.2rem;
}

.sub-card.is-active {
  border-color: color-mix(in srgb, var(--gold) 45%, var(--line));
}

.sub-left {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.sub-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--gold-soft);
  color: var(--gold-strong);
  flex: none;
}

[data-theme="dark"] .sub-icon {
  color: var(--gold);
}

.sub-title {
  margin: 0 0 0.15rem;
  font-size: 1.02rem;
  font-weight: 800;
}

.sub-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.sub-meter {
  min-width: 220px;
  flex: 1;
  max-width: 360px;
}

.sub-meter-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.sub-meter-top strong {
  color: var(--ink);
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: var(--pill);
  background: var(--surface-3);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-bright), var(--brand-strong));
  transition: width 0.5s var(--ease);
}

.progress-fill.is-gold {
  background: linear-gradient(90deg, var(--gold), #e09b05);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.3rem;
}

.stat-card {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.stat-card .icon {
  color: var(--brand);
}

.stat-card .badge {
  font-size: 0.62rem;
}

.stat-num {
  font-size: 1.6rem;
  font-weight: 850;
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-name {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
}

.dash-grid {
  display: grid;
  grid-template-columns: 1.45fr 0.85fr;
  gap: 1.2rem;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.panel-body {
  padding: 1.15rem;
}

.panel-body.is-flush {
  padding: 0.4rem 1.15rem;
}

.recent-list {
  display: grid;
}

.recent-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line);
}

.recent-item:last-child {
  border-bottom: 0;
}

.recent-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  flex: none;
}

.recent-item.is-pass .recent-icon {
  background: var(--green-soft);
  color: var(--green);
}

.recent-item.is-fail .recent-icon {
  background: var(--red-soft);
  color: var(--red);
}

.recent-main {
  min-width: 0;
  flex: 1;
}

.recent-name {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
}

.recent-meta {
  color: var(--muted);
  font-size: 0.74rem;
}

.score-pill {
  min-width: 58px;
  padding: 0.25rem 0.55rem;
  border-radius: var(--pill);
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.score-pill.is-pass {
  background: var(--green-soft);
  color: var(--green);
}

.score-pill.is-fail {
  background: var(--red-soft);
  color: var(--red);
}

.quick-start {
  padding: 1.15rem;
  border: 1px solid color-mix(in srgb, var(--brand) 25%, var(--line));
  border-radius: var(--radius-lg);
  background:
    radial-gradient(400px 200px at 100% 0%, rgba(0, 110, 54, 0.12), transparent 60%),
    var(--surface);
}

.quick-start h3 {
  margin-bottom: 0.25rem;
  font-size: 1rem;
}

.quick-start p {
  color: var(--muted);
  font-size: 0.84rem;
}

.quick-start .btn {
  margin-top: 0.3rem;
}

.mini-list {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.9rem;
}

.mini-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 650;
}

.mini-item:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.mini-item .icon {
  color: var(--muted);
}

/* -- Chart ---------------------------------------------------------------- */
.chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}

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

.chart-svg .grid-line {
  stroke: var(--line);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.chart-svg .axis-label {
  fill: var(--muted-2);
  font-size: 10px;
  font-family: var(--font-sans);
}

.chart-svg .area-path {
  fill: url(#chartFill);
}

.chart-svg .line-path {
  fill: none;
  stroke: var(--brand);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-svg .dot {
  fill: var(--surface);
  stroke: var(--brand);
  stroke-width: 2.5;
}

.chart-svg .dot.is-pass {
  stroke: var(--green);
}

.chart-svg .dot.is-fail {
  stroke: var(--red);
}

.chart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 190px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
}

.legend-dot.fail {
  background: var(--red);
}

.trend-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--pill);
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 750;
}

.trend-pill.is-down {
  background: var(--red-soft);
  color: var(--red);
}

.perf-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.6fr) 1fr auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}

.perf-row:last-child {
  border-bottom: 0;
}

.perf-name {
  font-size: 0.86rem;
  font-weight: 650;
  color: var(--ink);
}

.perf-bar {
  height: 7px;
  overflow: hidden;
  border-radius: var(--pill);
  background: var(--surface-3);
}

.perf-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-bright), var(--brand-strong));
}

.perf-score {
  min-width: 64px;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.perf-score strong {
  color: var(--ink);
}

/* -- Exam runner ---------------------------------------------------------- */
.exam-body {
  background: var(--bg);
}

.exam-wrap {
  padding-bottom: 2rem;
}

.exam-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.2rem;
}

.exam-bar-left {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.exam-bar-left .icon {
  color: var(--brand);
}

.exam-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exam-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.exam-bar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.timer {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-xs);
}

.timer .icon {
  color: var(--muted);
}

.timer.is-warning {
  border-color: color-mix(in srgb, var(--gold) 55%, var(--line));
  background: var(--gold-soft);
  color: var(--gold-strong);
}

.timer.is-warning .icon {
  color: var(--gold-strong);
}

[data-theme="dark"] .timer.is-warning {
  color: var(--gold);
}

.timer.is-danger {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
  animation: pulse 1.4s ease-in-out infinite;
}

.timer.is-danger .icon {
  color: var(--red);
}

.exam-progress {
  margin-bottom: 1rem;
}

.exam-progress-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.exam-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  gap: 1.2rem;
  align-items: start;
}

.exam-main {
  min-width: 0;
}

.q-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.q-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
}

.q-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.q-counter {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.q-body {
  padding: clamp(1.1rem, 3vw, 1.8rem);
}

.q-text {
  margin: 0 0 1rem;
  font-size: clamp(1.05rem, 1.8vw, 1.22rem);
  font-weight: 750;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.q-media {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 1.2rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
}

.q-image {
  max-height: 300px;
  width: auto;
  object-fit: contain;
  border-radius: 8px;
  background: transparent;
}

.option-list {
  display: grid;
  gap: 0.55rem;
}

.option {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.8rem 0.85rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease), box-shadow 0.16s var(--ease);
}

.option:hover {
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
  background: color-mix(in srgb, var(--brand-soft) 30%, var(--surface));
}

.option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  flex: none;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}

.option-text {
  padding-top: 2px;
  color: var(--ink-soft);
  font-size: 0.94rem;
  line-height: 1.45;
}

.option:has(input:checked),
.option.is-selected {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 0 1px var(--brand) inset;
}

.option:has(input:checked) .option-letter,
.option.is-selected .option-letter {
  background: var(--brand);
  color: #fff;
}

.option input:focus-visible + .option-letter {
  outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent);
  outline-offset: 2px;
}

.exam-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  margin-top: 1.2rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}

.exam-actions .left,
.exam-actions .right {
  display: flex;
  gap: 0.5rem;
}

.save-note {
  min-height: 1.1rem;
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.74rem;
  text-align: right;
}

.exam-side {
  position: sticky;
  top: calc(var(--header-h) + 72px);
  display: grid;
  gap: 0.9rem;
}

.side-card {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.side-card h4 {
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.qnav-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.35rem;
}

.qnav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: all 0.14s var(--ease);
}

.qnav-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.qnav-btn.is-answered {
  background: var(--brand-soft);
  border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
  color: var(--brand);
}

.qnav-btn.is-current {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.side-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.8rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.side-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.legend-swatch.is-answered {
  background: var(--brand-soft);
  border-color: var(--brand);
}

.legend-swatch.is-current {
  background: var(--brand);
  border-color: var(--brand);
}

.side-summary {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.7rem;
  margin-top: 0.7rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
}

.side-summary strong {
  color: var(--ink);
}

.exam-mobile-bar {
  display: none;
  position: sticky;
  bottom: 0;
  z-index: 55;
  gap: 0.5rem;
  padding: 0.7rem;
  margin: 1rem -16px -2rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 -8px 24px rgba(10, 27, 20, 0.08);
}

.exam-mobile-bar .btn {
  flex: 1;
}

/* -- Results -------------------------------------------------------------- */
.result-hero {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: clamp(1.2rem, 3vw, 2.2rem);
  align-items: center;
  padding: clamp(1.4rem, 3.5vw, 2.4rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(500px 260px at 100% 0%, rgba(240, 180, 41, 0.09), transparent 60%),
    var(--surface);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.result-hero.is-pass {
  border-color: color-mix(in srgb, var(--green) 35%, var(--line));
}

.result-hero.is-fail {
  border-color: color-mix(in srgb, var(--red) 25%, var(--line));
}

.score-ring {
  position: relative;
  width: clamp(140px, 22vw, 180px);
  height: clamp(140px, 22vw, 180px);
  flex: none;
}

.score-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-ring .track {
  fill: none;
  stroke: var(--surface-3);
  stroke-width: 12;
}

.score-ring .meter {
  fill: none;
  stroke: var(--brand);
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s var(--ease);
}

.score-ring.is-pass .meter {
  stroke: var(--green);
}

.score-ring.is-fail .meter {
  stroke: var(--red);
}

.score-value {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.score-value strong {
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  font-weight: 850;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.score-value span {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.result-title {
  margin: 0.5rem 0 0.35rem;
  font-size: clamp(1.7rem, 3.4vw, 2.5rem);
}

.result-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.96rem;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
  margin: 1.2rem 0;
}

.rstat {
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-align: center;
}

.rstat strong {
  display: block;
  font-size: 1.2rem;
  font-weight: 850;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.rstat span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.rstat.is-good strong { color: var(--green); }
.rstat.is-bad strong { color: var(--red); }
.rstat.is-warn strong { color: var(--gold-strong); }

[data-theme="dark"] .rstat.is-warn strong { color: var(--gold); }

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.result-note {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.82rem;
}

/* -- Review --------------------------------------------------------------- */
.review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
}

.review-list {
  display: grid;
  gap: 0.9rem;
}

.review-item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.review-item.correct { border-left-color: var(--green); }
.review-item.wrong { border-left-color: var(--red); }
.review-item.unanswered { border-left-color: var(--gold); }

.review-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-2) 45%, transparent);
}

.review-num {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.review-body {
  padding: 1rem;
}

.review-q {
  margin: 0 0 0.8rem;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.45;
}

.review-media {
  display: flex;
  justify-content: center;
  margin-bottom: 0.9rem;
}

.review-media img {
  max-height: 220px;
  width: auto;
  border-radius: 8px;
  background: transparent;
}

.answer-list {
  display: grid;
  gap: 0.4rem;
}

.answer {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.answer .letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  flex: none;
}

.answer.is-correct {
  border-color: color-mix(in srgb, var(--green) 45%, var(--line));
  background: var(--green-soft);
  color: var(--green);
  font-weight: 650;
}

.answer.is-correct .letter {
  background: var(--green);
  color: #fff;
}

.answer.is-selected-wrong {
  border-color: color-mix(in srgb, var(--red) 45%, var(--line));
  background: var(--red-soft);
  color: var(--red);
}

.answer.is-selected-wrong .letter {
  background: var(--red);
  color: #fff;
}

.answer-tag {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.review-explain {
  margin-top: 0.8rem;
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.84rem;
}

/* -- Practice ------------------------------------------------------------- */
.practice-toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
}

.searchbar {
  position: relative;
  flex: 1;
  min-width: 220px;
}

.searchbar .icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.searchbar .input {
  padding-left: 2.5rem;
}

.practice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.practice-list-card {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  height: 100%;
  padding: 1.05rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}

.practice-list-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--brand) 30%, var(--line));
  box-shadow: var(--shadow-sm);
}

.practice-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.practice-list-q {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.practice-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 0.65rem;
  border-top: 1px solid var(--line);
}

.practice-card {
  padding: clamp(1rem, 2.5vw, 1.4rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.practice-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.6rem;
}

.practice-q {
  margin: 0 0 0.8rem;
  font-size: clamp(1rem, 1.6vw, 1.12rem);
  font-weight: 700;
  line-height: 1.45;
}

.practice-media {
  display: flex;
  justify-content: center;
  margin-bottom: 0.9rem;
  padding: 0.7rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
}

.practice-media img {
  max-height: 240px;
  width: auto;
  object-fit: contain;
  border-radius: 6px;
  background: transparent;
}

.reveal {
  margin-top: 0.8rem;
  border-top: 1px solid var(--line);
  padding-top: 0.7rem;
}

.reveal summary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  color: var(--brand);
  font-size: 0.86rem;
  font-weight: 700;
  list-style: none;
}

.reveal summary::-webkit-details-marker {
  display: none;
}

.reveal[open] summary .icon {
  transform: rotate(180deg);
}

.reveal summary .icon {
  transition: transform 0.18s var(--ease);
}

.answer-key {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-top: 0.7rem;
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius-xs);
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.88rem;
  font-weight: 600;
}

.practice-detail {
  max-width: 780px;
  margin-inline: auto;
}

.practice-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 1rem;
}

/* -- Payment history ------------------------------------------------------ */
.history-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1.2rem;
  align-items: start;
}

/* -- Responsive ----------------------------------------------------------- */
@media (max-width: 1080px) {
  .exam-layout {
    grid-template-columns: minmax(0, 1fr) 240px;
  }
}

@media (max-width: 980px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dash-grid,
  .history-grid {
    grid-template-columns: 1fr;
  }

  .exam-layout {
    grid-template-columns: 1fr;
  }

  .exam-side {
    position: static;
  }

  .exam-side .side-card {
    padding: 0.8rem;
  }

  .qnav-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }

  .result-hero {
    grid-template-columns: 1fr;
    text-align: center;
    justify-items: center;
  }

  .result-actions,
  .result-stats {
    width: 100%;
  }

  .result-actions {
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .stat-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
  }

  .stat-num {
    font-size: 1.3rem;
  }

  .dash-head {
    padding-top: 1.2rem;
  }

  .sub-card {
    padding: 1rem;
  }

  .sub-meter {
    min-width: 100%;
    max-width: none;
  }

  .result-stats {
    grid-template-columns: 1fr 1fr;
  }

  .qnav-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .exam-bar {
    flex-wrap: wrap;
  }

  .exam-bar-right {
    width: 100%;
    justify-content: space-between;
  }

  .exam-actions {
    display: none;
  }

  .exam-mobile-bar {
    display: flex;
  }

  body.exam-body .flashes {
    top: auto;
    bottom: 84px;
  }

  .q-body {
    padding: 1rem;
  }

  .option {
    padding: 0.7rem;
  }

  .perf-row {
    grid-template-columns: 1fr auto;
  }

  .perf-bar {
    display: none;
  }

  .practice-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .searchbar {
    min-width: 0;
  }

  .review-top {
    flex-wrap: wrap;
  }
}

/* -- Print ---------------------------------------------------------------- */
@media print {
  .site-header,
  .site-footer,
  .exam-bar,
  .exam-side,
  .exam-mobile-bar,
  .result-actions,
  .flashes,
  .review-head .btn {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .card,
  .review-item,
  .result-hero {
    box-shadow: none;
    break-inside: avoid;
  }
}

/* -- Password reveal + invalid fields (shared form partial) ---------------- */
.input-group {
  position: relative;
}

.input-group .input {
  padding-right: 3rem;
}

.input-group .input-action {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.input-group .input-action:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.field.has-error .input {
  border-color: var(--red);
  background: color-mix(in srgb, var(--red-soft) 45%, var(--surface));
}


/* -- Compact practice list ------------------------------------------------- */
@media (max-width: 980px) {
  .practice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .practice-grid {
    grid-template-columns: 1fr;
  }
}

/* -- Guest practice banner ------------------------------------------------- */
.guest-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid color-mix(in srgb, var(--brand) 25%, var(--line));
  border-radius: var(--radius);
  background: var(--brand-soft);
  color: var(--brand-ink);
}

.guest-banner strong {
  display: block;
  font-weight: 750;
}

.guest-banner span {
  color: var(--muted);
  font-size: 0.9rem;
}

.guest-banner.is-compact {
  margin-bottom: 0.9rem;
  padding: 0.65rem 0.9rem;
  font-size: 0.85rem;
}

.guest-banner a {
  font-weight: 700;
  text-decoration: underline;
}

/* -- Highway Code study guide --------------------------------------------- */
.study-guide {
  padding-top: 0;
}

.study-topics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: start;
}

.study-topic {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.study-topic--road-signs {
  grid-column: 1 / -1;
}

.study-topic summary {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1rem 1.1rem;
  cursor: pointer;
  list-style: none;
}

.study-topic summary::-webkit-details-marker {
  display: none;
}

.study-topic[open] {
  border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
  box-shadow: var(--shadow-sm);
}

.study-num {
  width: 34px;
  height: 34px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 850;
}

.study-summary {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.study-summary strong {
  font-size: 0.98rem;
}

.study-summary small {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.study-chevron {
  display: inline-flex;
  color: var(--muted);
  transition: transform 0.18s var(--ease);
}

.study-topic[open] .study-chevron {
  transform: rotate(180deg);
}

.study-body {
  padding: 0 1.1rem 1.1rem;
  border-top: 1px solid var(--line);
}

.study-class h3,
.study-section h3 {
  margin: 1rem 0 0.3rem;
  font-size: 1rem;
}

.study-class h4 {
  margin: 0.9rem 0 0.4rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.study-intro {
  margin: 0.3rem 0 0.6rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.study-points {
  display: grid;
  gap: 0.45rem;
  margin: 0.5rem 0 0.8rem;
  padding-left: 1.1rem;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.study-tip {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-xs);
  background: var(--gold-soft);
  color: var(--gold-strong);
  font-size: 0.82rem;
}

.sign-table-wrap {
  overflow-x: auto;
  margin-bottom: 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.sign-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.sign-table th {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.sign-table td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  vertical-align: top;
}

.sign-table tr:last-child td {
  border-bottom: 0;
}

.sign-cell {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 200px;
}

.sign-cell img {
  width: 56px;
  height: 56px;
  flex: none;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 3px;
}

.sign-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 800;
}

@media (max-width: 900px) {
  .study-topics {
    grid-template-columns: 1fr;
  }

  .study-topic--road-signs {
    grid-column: auto;
  }
}

/* -- Exam runner: keep question, image and answers in the viewport -------- */
.exam-body {
  overflow: hidden;
}

.exam-body .site-footer {
  display: none;
}

.exam-body main {
  height: calc(100vh - var(--header-h));
  height: calc(100dvh - var(--header-h));
  overflow: hidden;
}

.exam-body .exam-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-top: 0;
  padding-bottom: 0.35rem;
}

.exam-body .exam-bar {
  position: static;
  flex: none;
  padding: 0.45rem 0;
  margin-bottom: 0.55rem;
}

.exam-body .exam-progress {
  flex: none;
  margin-bottom: 0.55rem;
}

.exam-body .exam-progress-top {
  margin-bottom: 0.25rem;
  font-size: 0.72rem;
}

.exam-body .guest-banner.is-compact {
  flex: none;
  margin-bottom: 0.55rem;
  padding: 0.42rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
}

.exam-body .guest-banner.is-compact span {
  font-size: 0.78rem;
}

.exam-body .exam-layout {
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

.exam-body .exam-main {
  display: flex;
  min-height: 0;
}

.exam-body #exam-form {
  display: flex;
  flex: 1;
  min-height: 0;
}

.exam-body .q-card {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  height: auto;
}

.exam-body .q-card[hidden] {
  display: none;
}

.exam-body .q-head {
  flex: none;
  padding: 0.5rem 0.85rem;
}

.exam-body .q-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  padding: clamp(0.65rem, 1.4vw, 1rem);
  overflow-y: auto;
  scrollbar-width: thin;
}

.exam-body .q-text {
  flex: none;
  margin-bottom: 0.55rem;
  font-size: clamp(0.97rem, 1.35vw, 1.1rem);
  line-height: 1.35;
}

.exam-body .q-media {
  flex: 0 1 auto;
  min-height: 0;
  margin-bottom: 0.6rem;
  padding: 0.4rem;
}

.exam-body .q-image {
  max-height: clamp(110px, 23dvh, 230px);
  max-width: 100%;
}

.exam-body .option-list {
  flex: none;
  gap: 0.4rem;
}

.exam-body .option {
  gap: 0.55rem;
  padding: 0.5rem 0.65rem;
}

.exam-body .option-letter {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  font-size: 0.72rem;
}

.exam-body .option-text {
  padding-top: 1px;
  font-size: 0.88rem;
  line-height: 1.35;
}

.exam-body .exam-actions {
  flex: none;
  margin-top: 0;
  padding: 0.65rem clamp(0.65rem, 1.4vw, 1rem) 0.7rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.exam-body .save-note {
  flex: none;
  min-height: 0.8rem;
  margin-top: 0.2rem;
  font-size: 0.7rem;
}

.exam-body .exam-side {
  position: static;
  max-height: 100%;
  overflow-y: auto;
  scrollbar-width: thin;
}

.exam-body .side-card {
  padding: 0.8rem;
}

.exam-body .qnav-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.3rem;
}

.exam-body .qnav-btn {
  height: 30px;
  font-size: 0.74rem;
}

@media (max-width: 980px) {
  .exam-body .exam-layout {
    grid-template-columns: 1fr;
  }

  .exam-body .exam-side {
    display: none;
  }
}

@media (max-width: 640px) {
  .exam-body .exam-wrap {
    padding-bottom: 68px;
  }

  .exam-body .exam-bar {
    flex-wrap: nowrap;
    gap: 0.4rem;
  }

  .exam-body .exam-bar-left {
    gap: 0.4rem;
  }

  .exam-body .exam-bar-left > .icon {
    display: none;
  }

  .exam-body .exam-title {
    font-size: 0.82rem;
  }

  .exam-body .exam-sub {
    display: none;
  }

  .exam-body .exam-bar-right {
    width: auto;
    gap: 0.35rem;
  }

  .exam-body .timer {
    padding: 0.35rem 0.55rem;
    font-size: 0.8rem;
  }

  .exam-body .exam-bar-right .btn {
    padding: 0.4rem 0.55rem;
    font-size: 0.76rem;
  }

  .exam-body .guest-banner.is-compact {
    padding: 0.35rem 0.55rem;
  }

  .exam-body .guest-banner.is-compact span {
    font-size: 0.72rem;
    line-height: 1.3;
  }

  .exam-body .q-head {
    padding: 0.42rem 0.7rem;
  }

  .exam-body .q-body {
    padding: 0.6rem 0.7rem;
  }

  .exam-body .q-text {
    margin-bottom: 0.45rem;
    font-size: 0.95rem;
  }

  .exam-body .q-media {
    margin-bottom: 0.45rem;
    padding: 0.3rem;
  }

  .exam-body .q-image {
    max-height: clamp(90px, 18dvh, 150px);
  }

  .exam-body .option {
    gap: 0.45rem;
    padding: 0.45rem 0.55rem;
  }

  .exam-body .option-text {
    font-size: 0.82rem;
    line-height: 1.3;
  }

  .exam-body .option-letter {
    width: 24px;
    height: 24px;
    font-size: 0.68rem;
  }

  .exam-body .exam-actions {
    display: none;
  }

  .exam-body .save-note {
    display: none;
  }

  .exam-body .exam-mobile-bar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 80;
    display: flex;
    margin: 0;
    padding: 0.55rem 0.7rem calc(0.55rem + env(safe-area-inset-bottom));
  }
}

/* Never let a toast cover a question or answer during an exam. */
.exam-body .flashes {
  display: none;
}

@media (max-width: 640px) {
  .exam-body .exam-bar-right .hide-sm {
    display: none;
  }
}

/* -- Study guide: stack sign rows on small screens ------------------------ */
@media (max-width: 720px) {
  .study-topic summary {
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.9rem;
  }

  .study-num {
    margin-top: 0.05rem;
  }

  .study-chevron {
    margin-top: 0.2rem;
  }

  .study-body {
    padding: 0 0.9rem 1rem;
  }

  .sign-table-wrap {
    overflow: visible;
  }

  .sign-table,
  .sign-table tbody,
  .sign-table tr,
  .sign-table td {
    display: block;
    width: 100%;
  }

  .sign-table thead {
    display: none;
  }

  .sign-table tr {
    padding: 0.8rem 0.85rem;
    border-bottom: 1px solid var(--line);
  }

  .sign-table tr:last-child {
    border-bottom: 0;
  }

  .sign-table td {
    padding: 0;
    border: 0;
  }

  .sign-table td + td {
    margin-top: 0.55rem;
  }

  .sign-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.15rem;
    color: var(--muted);
    font-size: 0.63rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
  }

  .sign-cell {
    min-width: 0;
    gap: 0.6rem;
  }

  .sign-cell img,
  .sign-code {
    width: 56px;
    height: 56px;
  }

  .study-class h3 {
    margin-top: 0.9rem;
  }

  .study-class h4 {
    margin-top: 0.8rem;
  }
}

/* -- History: turn the results table into cards on phones ------------------ */
@media (max-width: 720px) {
  .table-wrap--cards {
    overflow: visible;
  }

  .history-table {
    min-width: 0;
  }

  .history-table thead {
    display: none;
  }

  .history-table,
  .history-table tbody,
  .history-table tr,
  .history-table td {
    display: block;
    width: 100%;
  }

  .history-table tr {
    display: flex;
    flex-direction: column;
    padding: 0.85rem 0.9rem;
    border-bottom: 1px solid var(--line);
  }

  .history-table tr:last-child {
    border-bottom: 0;
  }

  .history-table td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.16rem 0;
    border: 0;
    text-align: right;
  }

  .history-table td[data-label]::before {
    content: attr(data-label);
    flex: none;
    color: var(--muted);
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-align: left;
    text-transform: uppercase;
  }

  .history-table td.cell-test {
    order: -1;
    display: block;
    padding: 0 0 0.35rem;
    text-align: left;
    font-size: 1rem;
    font-weight: 750;
  }

  .history-table td.cell-test::before {
    display: none;
  }

  .history-table td.cell-action {
    justify-content: flex-start;
    padding-top: 0.55rem;
    text-align: left;
  }

  .history-table td.cell-action::before {
    display: none;
  }

  .history-table td.cell-action .link-arrow {
    font-weight: 700;
  }
}

/* -- SEO / long-form content ---------------------------------------------- */
.seo-section {
  padding-top: 0;
}

.seo-copy {
  max-width: 760px;
  margin-inline: auto;
}

.seo-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1.6rem, 4vw, 3.2rem);
  max-width: 1040px;
  margin-inline: auto;
  align-items: start;
}

.seo-columns > .seo-copy {
  max-width: none;
  margin-inline: 0;
}

.seo-columns > .seo-copy > :first-child {
  margin-top: 0;
}

@media (min-width: 861px) {
  .seo-columns {
    position: relative;
  }

  .seo-columns::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    background: var(--line);
    transform: translateX(-50%);
  }
}

@media (max-width: 860px) {
  .seo-columns {
    grid-template-columns: 1fr;
  }
}

.seo-copy h2 {
  margin: 1.8rem 0 0.6rem;
  font-size: clamp(1.25rem, 2.4vw, 1.6rem);
}

.seo-copy h2:first-child {
  margin-top: 0;
}

.seo-copy p,
.seo-copy li {
  color: var(--ink-soft);
  line-height: 1.7;
}

.seo-copy ol,
.seo-copy ul {
  margin: 0.6rem 0 1rem 1.2rem;
  padding-left: 0.4rem;
}

.seo-copy li {
  margin-bottom: 0.45rem;
}
