/* ISTQB CTFL v4.0 Exam Trainer — Design System & Layout
 * Swiss-editorial precision, warm paper light theme + slate dark theme.
 */

:root {
  --bg: #f6f5f0;
  --surface: #ffffff;
  --surface-2: #f0efe9;
  --surface-hover: #eae8e0;
  --border: #e2dfd6;
  --border-strong: #ccc8bc;

  --ink: #141923;
  --ink-2: #434b59;
  --muted: #6c7482;

  --accent: #0f6e5c;
  --accent-hover: #0b594a;
  --accent-soft: #e6f4f0;
  --accent-ink: #ffffff;

  --good: #15803d;
  --good-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #c43131;
  --bad-soft: #fdecec;

  --svg-node: #ffffff;
  --svg-stroke: #1e293b;
  --svg-grid: #d8d5cb;
  --svg-bar-est: #1e293b;
  --svg-bar-act: #0f6e5c;

  --shadow-sm: 0 1px 2px rgba(20, 25, 35, 0.05);
  --shadow-md: 0 6px 20px rgba(20, 25, 35, 0.07), 0 1px 3px rgba(20, 25, 35, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;

  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --max-w: 980px;
  --read-w: 760px;
}

[data-theme="dark"] {
  --bg: #0e1217;
  --surface: #151b23;
  --surface-2: #1c242f;
  --surface-hover: #242e3c;
  --border: #26303e;
  --border-strong: #374558;

  --ink: #eef2f6;
  --ink-2: #b8c2d0;
  --muted: #8491a4;

  --accent: #2dd4bf;
  --accent-hover: #14b8a6;
  --accent-soft: rgba(45, 212, 191, 0.13);
  --accent-ink: #07221d;

  --good: #4ade80;
  --good-soft: rgba(74, 222, 128, 0.13);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, 0.14);

  --svg-node: #1c242f;
  --svg-stroke: #dbe4f0;
  --svg-grid: #2d3848;
  --svg-bar-est: #94a3b8;
  --svg-bar-act: #2dd4bf;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.35);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

button, input, select {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

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

.mono {
  font-family: var(--font-mono);
}

/* === HEADER === */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 16px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  padding: 4px 0;
  text-align: left;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.04em;
  flex-shrink: 0;
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
  margin-left: 6px;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.nav-tab {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
  transition: background 0.15s ease, color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-tab:hover {
  color: var(--ink);
}

.nav-tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--border-strong);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* === TRACK SELECTOR BAR === */
.track-bar {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.track-bar-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 7px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.track-bar-inner::-webkit-scrollbar {
  display: none;
}

.track-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  transition: all 0.14s ease;
}

.track-pill:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

.track-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.track-lang {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--muted);
}

.track-pill.active .track-lang {
  background: rgba(255, 255, 255, 0.22);
  color: var(--accent-ink);
}

/* === MAIN CONTAINER === */
.main {
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.main.narrow {
  max-width: var(--read-w);
}

/* === CARDS & BUTTONS === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-2);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--ink);
}

.btn-danger {
  background: var(--bad-soft);
  color: var(--bad);
  border-color: transparent;
}

.btn-danger:hover:not(:disabled) {
  background: var(--bad);
  color: #ffffff;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 8px;
}

/* === BADGES === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  font-family: var(--font-mono);
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--border);
}

.badge-good {
  background: var(--good-soft);
  color: var(--good);
  border-color: transparent;
}

.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: transparent;
}

.badge-bad {
  background: var(--bad-soft);
  color: var(--bad);
  border-color: transparent;
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

/* === OVERVIEW VIEW === */
.resume-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  color: var(--ink);
}

.resume-banner-text {
  font-size: 13.5px;
  font-weight: 600;
}

.hero-card {
  padding: 22px;
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: center;
}

.hero-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.hero-title {
  margin: 0 0 6px;
  font-size: clamp(21px, 3.2vw, 27px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.hero-sub {
  margin: 0;
  font-size: 14px;
  color: var(--ink-2);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(92px, 1fr));
  gap: 10px;
}

.stat-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: left;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 24px 0 12px;
}

.section-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.section-meta {
  font-size: 12.5px;
  color: var(--muted);
  font-family: var(--font-mono);
}

/* Chapter Grid */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.chapter-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.chapter-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.chapter-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.chapter-num {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chapter-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin-top: 2px;
}

.progress-track {
  width: 100%;
  height: 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--accent);
  transition: width 0.3s ease;
}

.progress-fill.good { background: var(--good); }
.progress-fill.warn { background: var(--warn); }
.progress-fill.bad  { background: var(--bad); }

.chapter-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}

.chapter-stats {
  font-size: 12.5px;
  color: var(--muted);
  font-family: var(--font-mono);
}

/* Mock History */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-row {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.history-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-sub {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.empty-note {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

/* === PRACTICE VIEW === */
.filter-bar {
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.filter-row::-webkit-scrollbar { display: none; }

.pill {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-2);
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 600;
  transition: all 0.12s ease;
}

.pill:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.filter-selects {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
}

.select-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-select {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12.5px;
  font-weight: 600;
}

.queue-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

/* === QUESTION CARD === */
.q-card {
  padding: 22px;
}

.q-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.q-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.flag-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.flag-btn:hover {
  background: var(--surface-2);
}

.flag-btn.flagged {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
  color: var(--warn);
}

.q-stem {
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--ink);
  margin-bottom: 16px;
}

.q-stem p {
  margin: 0 0 10px;
}

.q-stem p:last-child {
  margin-bottom: 0;
}

.q-stem ul {
  margin: 6px 0 10px;
  padding-left: 20px;
}

.q-stem li {
  margin-bottom: 4px;
}

/* Callout box (defect reports, logs, user stories, test charters) */
.q-callout {
  margin: 14px 0;
  padding: 13px 15px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
}

.q-callout-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 6px;
}

.q-callout-body {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-x: auto;
}

.q-callout-body.mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
}

/* Responsive tables inside questions */
.q-table-wrap {
  margin: 14px 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  -webkit-overflow-scrolling: touch;
}

.q-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-family: var(--font-mono);
}

.q-table th, .q-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: center;
  white-space: nowrap;
}

.q-table th:first-child, .q-table td:first-child {
  text-align: left;
  font-weight: 600;
  font-family: var(--font-sans);
  white-space: normal;
  min-width: 120px;
}

.q-table th:last-child, .q-table td:last-child {
  border-right: none;
}

.q-table tr:last-child td {
  border-bottom: none;
}

.q-table thead th {
  background: var(--surface-2);
  font-weight: 700;
  color: var(--ink);
}

.q-table tr.section-row td {
  background: var(--surface-2);
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
}

/* Inline SVG diagrams */
.q-diagram-wrap {
  margin: 14px 0;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: center;
  overflow-x: auto;
}

.q-svg {
  width: 100%;
  max-width: 600px;
  height: auto;
  display: block;
}

.q-svg-compact {
  max-width: 300px;
}

.svg-node-text {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  fill: var(--ink);
}

.svg-sub-text {
  font-family: var(--font-mono);
  font-size: 11.5px;
  fill: var(--ink-2);
}

.svg-edge-text {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  fill: var(--ink);
}

.svg-title-text {
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 700;
  fill: var(--ink);
}

.svg-axis-text {
  font-family: var(--font-mono);
  font-size: 11.5px;
  fill: var(--ink-2);
}

/* Select prompt */
.select-hint {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.select-hint.pick-two {
  color: var(--warn);
}

/* Options list */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.option-btn {
  width: 100%;
  text-align: left;
  padding: 13px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14.5px;
  line-height: 1.48;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.option-btn:disabled {
  cursor: default;
}

.option-key {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.option-btn.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option-btn.selected .option-key {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.option-btn.correct {
  border-color: var(--good);
  background: var(--good-soft);
}

.option-btn.correct .option-key {
  background: var(--good);
  border-color: var(--good);
  color: #ffffff;
}

.option-btn.wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
}

.option-btn.wrong .option-key {
  background: var(--bad);
  border-color: var(--bad);
  color: #ffffff;
}

.option-btn.missed {
  border-color: var(--good);
  border-style: dashed;
  background: var(--good-soft);
}

.option-btn.missed .option-key {
  border-color: var(--good);
  color: var(--good);
}

/* Explanation panel */
.feedback-box {
  margin-top: 16px;
  padding: 15px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  animation: fadeSlide 0.18s ease;
}

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.feedback-box.good {
  border-color: color-mix(in srgb, var(--good) 40%, transparent);
  background: var(--good-soft);
}

.feedback-box.bad {
  border-color: color-mix(in srgb, var(--bad) 40%, transparent);
  background: var(--bad-soft);
}

.feedback-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 7px;
}

.feedback-verdict {
  font-weight: 700;
  font-size: 14px;
}

.feedback-box.good .feedback-verdict { color: var(--good); }
.feedback-box.bad  .feedback-verdict { color: var(--bad); }

.feedback-ref {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-2);
}

.feedback-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
}

.rationale-details {
  margin-top: 10px;
  border-top: 1px solid color-mix(in srgb, var(--border-strong) 55%, transparent);
  padding-top: 8px;
}

.rationale-details summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  user-select: none;
}

.rationale-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  line-height: 1.5;
}

.rationale-item {
  display: flex;
  gap: 8px;
}

.rationale-key {
  font-family: var(--font-mono);
  font-weight: 700;
  min-width: 24px;
  color: var(--muted);
}

.rationale-item.is-correct .rationale-key {
  color: var(--good);
}

/* Action bar under question */
.q-actions {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.kbd-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

/* === EXAM LAUNCH & LIVE EXAM === */
.exam-setup {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.exam-setup h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.025em;
}

.exam-spec-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.spec-cell {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 11px 12px;
}

.spec-val {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
}

.spec-lbl {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.choice-group-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: var(--font-mono);
}

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

.mode-card {
  text-align: left;
  padding: 13px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  transition: all 0.12s ease;
}

.mode-card:hover {
  border-color: var(--border-strong);
}

.mode-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.mode-card-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 2px;
}

.mode-card-desc {
  font-size: 12.5px;
  color: var(--ink-2);
}

.timer-toggle {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Live Exam Top HUD */
.exam-hud {
  position: sticky;
  top: 66px;
  z-index: 30;
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.timer-pill {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.timer-pill.warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: transparent;
}

.timer-pill.danger {
  background: var(--bad-soft);
  color: var(--bad);
  border-color: transparent;
}

.exam-hud-mid {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 10px;
}

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

/* Exam Navigator Drawer / Panel */
.nav-panel {
  padding: 14px;
  margin-bottom: 14px;
}

.nav-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.nav-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
}

.nav-cell {
  height: 34px;
  border-radius: 7px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  position: relative;
  display: grid;
  place-items: center;
}

.nav-cell:hover {
  border-color: var(--border-strong);
}

.nav-cell.answered {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
}

.nav-cell.current {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ink) 20%, transparent);
}

.nav-cell.flagged::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warn);
}

/* === RESULTS VIEW === */
.result-hero {
  padding: 24px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.result-verdict {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.result-score {
  font-family: var(--font-mono);
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.breakdown-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}

.breakdown-card {
  padding: 16px;
}

.breakdown-row {
  display: grid;
  grid-template-columns: 130px 1fr 56px;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
}

.breakdown-lbl {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breakdown-val {
  font-family: var(--font-mono);
  font-size: 12.5px;
  text-align: right;
  font-weight: 600;
}

.review-card {
  padding: 16px;
  margin-bottom: 10px;
}

.review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

/* === MODAL === */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 22, 0.55);
  backdrop-filter: blur(4px);
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: 100%;
  max-width: 500px;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: var(--shadow-md);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-head h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.setting-row:last-of-type {
  border-bottom: none;
}

.setting-title {
  font-size: 14px;
  font-weight: 600;
}

.setting-sub {
  font-size: 12px;
  color: var(--muted);
}

.date-input {
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.blueprint-mini {
  margin-top: 14px;
  padding: 12px;
  border-radius: 9px;
  background: var(--surface-2);
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.55;
}

.footer {
  border-top: 1px solid var(--border);
  padding: 14px 16px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* === MOBILE RESPONSIVE === */
@media (max-width: 720px) {
  .topbar-inner {
    height: 54px;
    padding: 0 10px;
    gap: 8px;
  }

  .brand-sub {
    display: none;
  }

  .nav-tab {
    padding: 6px 10px;
    font-size: 13px;
  }

  .main {
    padding: 14px 12px 92px;
  }

  .hero-card {
    grid-template-columns: 1fr;
    padding: 18px;
    gap: 14px;
  }

  .stat-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .chapter-grid,
  .mode-grid,
  .breakdown-grid {
    grid-template-columns: 1fr;
  }

  .exam-spec-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .q-card {
    padding: 16px;
  }

  .q-stem {
    font-size: 15px;
  }

  .option-btn {
    padding: 12px;
    font-size: 14px;
  }

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

  .kbd-hint {
    display: none;
  }

  /* Thumb-friendly sticky bottom bar on phones during practice & exam */
  .q-actions.sticky-mobile {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    z-index: 35;
  }

  .exam-hud {
    top: 58px;
  }
}

@media (max-width: 500px) {
  .brand-title {
    display: none;
  }
  .topbar-inner {
    gap: 6px;
  }
  .nav-tab {
    padding: 6px 9px;
    font-size: 12.5px;
  }
  .icon-btn {
    width: 32px;
    height: 32px;
  }
  .icon-btn svg {
    width: 16px;
    height: 16px;
  }
  .stat-box {
    padding: 10px 10px;
  }
  .stat-value {
    font-size: 18px;
  }
  .nav-grid {
    grid-template-columns: repeat(5, 1fr);
  }
  .breakdown-row {
    grid-template-columns: 104px 1fr 48px;
  }
}
