/* Palette: lichen & birch-bark ground, spruce green for structure,
   hunter's blaze orange reserved for the main action on each screen. */
:root {
  --bg: #ecefe8;
  --bg-elevated: #fafbf7;
  --ink: #1b2519;
  --ink-soft: #5b6657;
  --border: #d3d9cc;
  --accent: #2f5d3a;
  --accent-ink: #ffffff;
  --accent-soft: #dde8da;
  --blaze: #e8702a;
  --blaze-ink: #ffffff;
  --now-ring: #ff5a00;
  --seg-bad: #e8281e;
  --amber: #a8641f;
  --amber-soft: #f3e4d2;
  --danger: #a1352b;
  --danger-soft: #f5e1dc;
  --success: #2f5d3a;
  --success-soft: #dde8da;
  --shadow: 0 1px 2px rgba(27,37,25,0.06), 0 4px 14px rgba(27,37,25,0.06);
  --radius: 14px;
  color-scheme: light;
}

/* Dark theme: follows the system unless the viewer picked a theme (theme.js sets data-theme). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111711;
    --bg-elevated: #192119;
    --ink: #e6eadf;
    --ink-soft: #a0aa98;
    --border: #2c372b;
    --accent: #86b891;
    --accent-ink: #0d170f;
    --accent-soft: #1d2c20;
    --blaze: #f08a3e;
    --blaze-ink: #ffffff;
    --now-ring: var(--blaze);
    --seg-bad: #ff5a4d;
    --amber: #d99a52;
    --amber-soft: #33291a;
    --danger: #e58a7e;
    --danger-soft: #34201d;
    --success: #86b891;
    --success-soft: #1d2c20;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 6px 20px rgba(0,0,0,0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111711;
  --bg-elevated: #192119;
  --ink: #e6eadf;
  --ink-soft: #a0aa98;
  --border: #2c372b;
  --accent: #86b891;
  --accent-ink: #0d170f;
  --accent-soft: #1d2c20;
  --blaze: #f08a3e;
  --blaze-ink: #ffffff;
  --now-ring: var(--blaze);
  --seg-bad: #ff5a4d;
  --amber: #d99a52;
  --amber-soft: #33291a;
  --danger: #e58a7e;
  --danger-soft: #34201d;
  --success: #86b891;
  --success-soft: #1d2c20;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 6px 20px rgba(0,0,0,0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Onest", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-feature-settings: "tnum" 0;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--accent); }
button, input, select, textarea { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}
/* All navigation buttons sit together on the left; the page title takes the rest on the right.
   Done with `order` so every page keeps its markup (title stays first for screen readers). */
.topbar-inner h1 {
  order: 1;
  flex: 1;
  min-width: 0;
  margin: 0 0 0 8px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
  text-align: right;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@media (max-width: 420px) {
  .topbar-inner { padding: 10px 12px; gap: 2px; }
  .topbar-inner .icon-btn { width: 32px; height: 32px; font-size: 18px; }
  .topbar-inner h1 { font-size: 14px; }
}

.icon-btn {
  border: none;
  background: transparent;
  font-size: 19px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn[aria-current="page"] { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }

main#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

/* ---------- Home ---------- */

.overall-progress { margin-bottom: 16px; }
.overall-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.overall-progress-title { font-weight: 700; font-size: 16px; }
.overall-progress-sub { color: var(--ink-soft); font-size: 13px; margin-top: 4px; }
.reset-link {
  margin-top: 10px;
  padding: 4px 0;
  border: none;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.reset-link:hover,
.reset-link.armed { color: var(--danger); }
.reset-link.armed { font-weight: 600; text-decoration-style: solid; }

.ring {
  --pct: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  flex-shrink: 0;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--border) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.ring::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--bg-elevated);
}
/* Percentage sits above the ::after "hole". */
.ring {
  isolation: isolate;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.ring::after { z-index: -1; }

.search-row { margin-bottom: 14px; }
#searchInput {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--ink);
  font-size: 15px;
}
#searchInput:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.quick-actions-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 0 0 8px 2px;
}

.quick-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.quick-actions-row .btn {
  padding: 12px 10px;
  font-size: 14px;
}

.quick-actions-row-last {
  margin-bottom: 20px;
}

@media (max-width: 420px) {
  .quick-actions-row { grid-template-columns: 1fr; }
}

.section-heading {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 26px 0 12px 2px;
}

.category-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.category-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
}
.category-card:active { transform: scale(0.985); }

.category-card-icon {
  font-size: 26px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  border-radius: 12px;
  flex-shrink: 0;
}

.category-card-body { flex: 1; min-width: 0; }
.category-card-title { font-weight: 600; font-size: 15px; }
.category-card-meta { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }

.mini-bar-track {
  margin-top: 8px;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}
.mini-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}

.category-card-chevron { color: var(--ink-soft); font-size: 18px; }

/* Unfinished test from an earlier visit (app.js resumeBanner) */
.resume-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 18px;
  padding: 12px 14px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
}
.resume-text { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.4; }
.resume-actions { display: flex; gap: 8px; }

/* ---------- Study modes ---------- */

.mode {
  margin-bottom: 12px;
  padding: 16px;
}
.mode-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}
.mode-icon {
  font-size: 22px;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: var(--accent-soft);
}
.mode-title { font-size: 16px; font-weight: 700; margin: 0; }
.mode-desc { font-size: 13.5px; line-height: 1.45; color: var(--ink-soft); margin: 3px 0 0; }
.mode .quick-actions-row { margin-bottom: 0; }

/* Exam block: one action, text and button side by side on wider screens. */
.mode-exam { display: grid; gap: 24px; }
.mode-exam .mode-head { margin-bottom: 0; }
@media (min-width: 560px) {
  .mode-exam { grid-template-columns: 1fr auto; align-items: center; }
  .mode-exam .btn { padding-left: 28px; padding-right: 28px; }
}

/* ---------- Buttons ---------- */

.btn {
  border: none;
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--blaze); color: var(--blaze-ink); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { filter: brightness(1.08); }
.btn-outline { background: var(--bg-elevated); color: var(--ink); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-success { background: var(--success-soft); color: var(--success); border: 1px solid var(--success); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); }

/* ---------- Category detail ---------- */

.category-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}
.category-header-icon {
  font-size: 30px;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  border-radius: 14px;
  flex-shrink: 0;
}
.category-header-title { font-weight: 700; font-size: 17px; }
.category-header-sub { color: var(--ink-soft); font-size: 13px; margin-top: 3px; }

.progress-bar-track {
  height: 8px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: 16px;
}
.progress-bar-fill { height: 100%; background: var(--accent); }

.question-list {
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.question-list-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
}
.question-list-item .status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
  background: var(--border);
}
.question-list-item .status-dot.known { background: var(--success); }
.question-list-item .status-dot.unknown { background: var(--danger); }

/* ---------- Session progress ---------- */

.session-progress { margin-bottom: 18px; }
.session-progress-track {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}
.session-progress-fill { height: 100%; background: var(--accent); transition: width 0.2s ease; }
#qzProgressFill { display: flex; background: none; }
#qzProgressFill .seg { flex: 1; background: var(--accent); }
#qzProgressFill .seg.bad { background: var(--seg-bad); }
.session-progress-text {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
}

/* ---------- Flashcards ---------- */

.flashcard {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 24px 22px 22px;
}
.flashcard .flashcard-text { font-size: 20px; font-weight: 700; line-height: 1.35; letter-spacing: -0.005em; margin-bottom: 18px; }
.flashcard-text {
  font-size: 19px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 20px;
}

.flashcard-answer-text {
  font-size: 16.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.45;
  white-space: pre-line;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 4px 10px 10px 4px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.flashcard-description {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-soft);
}
.flashcard-description:empty { display: none; }
.flashcard-description a { text-decoration: underline; }
.flashcard-description hr { border: none; border-top: 1px dashed var(--border); margin: 10px 0; }
.flashcard-description q { color: var(--amber); font-style: italic; }

.fc-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.fc-controls .btn { padding: 15px 16px; font-size: 16px; }
.fc-controls .btn-danger[aria-pressed="true"] { background: var(--danger); color: var(--bg-elevated); }
.fc-controls .btn-success[aria-pressed="true"] { background: var(--success); color: var(--bg-elevated); }

.fc-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
}

.qz-nav {
  justify-content: center;
}

.qz-next-btn {
  width: 80%;
  padding: 16px;
  font-size: 16px;
}

/* ---------- Quiz ---------- */

.quiz-question { margin-bottom: 16px; }
.quiz-question .flashcard-text { margin-bottom: 0; }

.qz-hint-btn {
  width: 100%;
  margin-top: 16px;
  padding: 10px 16px;
  font-size: 13px;
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-option {
  position: relative;
  text-align: left;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 15px;
  line-height: 1.4;
  cursor: pointer;
  color: var(--ink);
}
.quiz-option:active { transform: scale(0.99); }
.quiz-option.correct { background: var(--success-soft); border-color: var(--success); color: var(--success); font-weight: 600; }
.quiz-option.correct,
.quiz-option.incorrect { padding-right: 48px; }
/* Option number (matches the 1-9 keyboard shortcut). */
.quiz-option[data-key] { padding-left: 52px; }
.quiz-option[data-key]::before {
  content: attr(data-key);
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--bg);
  border: 1px solid var(--border);
}
.quiz-option.correct::before { color: var(--success); border-color: var(--success); background: transparent; }
.quiz-option.incorrect::before { color: var(--danger); border-color: var(--danger); background: transparent; }
.quiz-option.correct::after,
.quiz-option.incorrect::after {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}
.quiz-option.correct::after { content: "✓"; background: var(--success); color: var(--bg-elevated); }
.quiz-option.incorrect::after { content: "✕"; background: var(--danger); color: var(--bg-elevated); }
.quiz-option.incorrect { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); font-weight: 600; }
.quiz-option.disabled { cursor: default; }

.quiz-description {
  margin-top: 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-soft);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.quiz-description a { text-decoration: underline; }
.quiz-description hr { border: none; border-top: 1px dashed var(--border); margin: 10px 0; }

/* ---------- Results ---------- */

.results-card {
  text-align: center;
  margin-bottom: 18px;
}
.results-score {
  font-size: 40px;
  font-weight: 800;
  color: var(--accent);
}
.results-sub {
  color: var(--ink-soft);
  margin-top: 6px;
  font-size: 14px;
}
.results-perfect {
  margin-top: 14px;
  font-size: 20px;
  font-weight: 700;
  color: var(--success);
}

.empty-state {
  text-align: center;
  padding: 40px 20px 0;
  color: var(--ink-soft);
}
.empty-state-icon { font-size: 40px; margin-bottom: 10px; }
.empty-state-title { font-size: 18px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.empty-state + .quick-actions { margin-top: 20px; }



/* ---------- Reference pages (calendar / redbook / info) ---------- */

main.page {
  max-width: 780px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}
.page .lede {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
  margin: 0 0 22px;
}
.page .lede a { color: var(--accent); }
.page section.block { margin-bottom: 34px; }
.page h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.005em;
}
.block-sub {
  color: var(--ink-soft);
  font-size: 13px;
  margin: 0 0 14px;
  line-height: 1.5;
}
.block-sub a { color: var(--accent); }

.footnote-box {
  margin-top: 12px;
  padding: 11px 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.55;
}
.footnote-box b { color: var(--ink); font-weight: 600; }

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--bg-elevated);
}
.page table { width: 100%; border-collapse: collapse; min-width: 540px; font-size: 13px; }
.page thead th {
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--bg);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.page tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; line-height: 1.4; }
.page tbody tr:last-child td { border-bottom: none; }

/* Section navigation on reference pages (theme.js builds it from [data-toc] in main) */
.toc {
  position: sticky;
  top: var(--topbar-h, 61px);
  z-index: 5;
  margin: -16px -16px 22px;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.toc::-webkit-scrollbar { display: none; }
.toc a {
  flex: none;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.toc a:hover { color: var(--accent); border-color: var(--accent); }
.toc a.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
main [data-toc] { scroll-margin-top: calc(var(--topbar-h, 61px) + 64px); }

/* ---------- Floating controls (theme.js) ---------- */

.fab-stack {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(100px, env(safe-area-inset-bottom));
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.theme-toggle,
.scroll-top {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.scroll-top { font-weight: 700; }
.theme-toggle:hover,
.scroll-top:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle:active,
.scroll-top:active { transform: scale(0.94); }
body { padding-bottom: 64px; }

/* ---------- Search results ---------- */

.search-results { margin-top: 8px; }
.search-list { margin: 0 0 8px; }
.search-all { width: 100%; }
.search-empty { margin: 4px 2px 0; font-size: 14px; color: var(--ink-soft); }

/* Question rows: the text is a real button so rows work with the keyboard. */
.question-list-text {
  flex: 1;
  border: none;
  background: none;
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.question-list-item:hover { border-color: var(--accent); }

/* ---------- Toast (notify) ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  z-index: 60;
  max-width: min(92vw, 480px);
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg-elevated);
  font-size: 14px;
  line-height: 1.4;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Keyboard hints (only where there is a keyboard) ---------- */

.kbd-hint { display: none; margin: 18px 0 0; text-align: center; font-size: 12.5px; color: var(--ink-soft); }
.kbd-hint kbd {
  font: inherit;
  font-weight: 600;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg-elevated);
  color: var(--ink);
}
@media (hover: hover) and (pointer: fine) {
  .kbd-hint { display: block; }
}

/* ---------- Mock exam ---------- */

.session-progress-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 6px;
}
.session-progress-row .session-progress-text { margin-top: 0; }
.exam-timer {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--ink);
}
.exam-timer.low { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

.results-verdict {
  display: inline-block;
  margin-bottom: 10px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
}
.results-verdict.pass { background: var(--success-soft); color: var(--success); }
.results-verdict.fail { background: var(--danger-soft); color: var(--danger); }
.results-score.fail { color: var(--danger); }
.results-time { margin-top: 4px; font-size: 14px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.exam-fail-notice {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--danger);
  background: var(--danger-soft);
  text-align: center;
}
.exam-fail-title { margin: 0 0 12px; font-size: 16px; font-weight: 700; color: var(--danger); }
.exam-fail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Login / setup ---------- */

.auth-body { min-height: 100vh; }
.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 96px;
}
.auth-card { width: 100%; max-width: 400px; padding: 28px 24px; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--accent-soft);
  font-size: 30px;
  margin-bottom: 12px;
}
.auth-title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.auth-sub { margin: 6px 0 0; font-size: 14px; line-height: 1.45; color: var(--ink-soft); }
.auth-notice {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  line-height: 1.45;
}
.auth-notice.warn { background: var(--amber-soft); color: var(--amber); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-step { margin: 0; font-size: 14px; line-height: 1.5; color: var(--ink-soft); }
.auth-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
  line-height: 1.45;
}
.auth-submit { width: 100%; margin-top: 4px; }
.auth-submit:disabled { opacity: 0.6; cursor: progress; }
.auth-link {
  align-self: center;
  border: none;
  background: none;
  padding: 4px;
  color: var(--ink-soft);
  font-size: 13.5px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 14px; font-weight: 600; }
.field-hint { font-size: 12.5px; color: var(--ink-soft); line-height: 1.4; }
.field-input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--ink);
  font-size: 16px; /* 16px keeps iOS from zooming into the field */
}
.field-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.pw-wrap { position: relative; display: block; }
.pw-wrap .field-input { padding-right: 48px; }
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pw-toggle:hover { color: var(--accent); background: var(--accent-soft); }
.pw-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
/* Hide the browser's own reveal button (Edge) so there is only one eye. */
.pw-wrap input::-ms-reveal { display: none; }
.field-code { font-size: 22px; letter-spacing: 0.3em; text-align: center; font-variant-numeric: tabular-nums; }

.totp-qr {
  align-self: center;
  width: 200px;
  height: 200px;
  padding: 8px;
  border-radius: 12px;
  background: #ffffff; /* QR codes need a light background in both themes */
}
.totp-qr svg { display: block; width: 100%; height: 100%; }
.totp-key-label { margin: 0; font-size: 13px; color: var(--ink-soft); text-align: center; }
.totp-key {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  text-align: center;
  font-size: 14px;
  letter-spacing: 0.04em;
  word-break: break-all;
  user-select: all;
}

/* ---------- Account menu (auth.js) ---------- */

.account { position: relative; }
.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  min-width: 230px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}
@media (max-width: 420px) {
  /* Full-width dropdown under the header so it never runs off a narrow screen. */
  .account-menu { position: fixed; top: 58px; left: 12px; right: 12px; min-width: 0; }
}
.account-who { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.account-name { font-weight: 700; font-size: 15px; }
.account-meta { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.account-item {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--ink);
  font-size: 14.5px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.account-item:hover { background: var(--accent-soft); color: var(--accent); }

.account-dialog {
  width: min(92vw, 400px);
  padding: 22px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.account-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.account-dialog-title { margin: 0 0 4px; font-size: 18px; }
.account-dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }

/* ---------- Admin (/admin) ---------- */

.admin-section { margin-bottom: 18px; padding: 20px; }
.admin-h { margin: 0 0 14px; font-size: 18px; }
.admin-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.admin-form .auth-error,
.admin-create { grid-column: 1 / -1; }
.admin-create { justify-self: end; padding-left: 28px; padding-right: 28px; }
@media (max-width: 560px) {
  .admin-form { grid-template-columns: 1fr; }
  .admin-create { justify-self: stretch; }
}

.credentials {
  margin: 0 0 22px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent-soft);
}
.credentials-title { margin: 0 0 10px; font-weight: 700; color: var(--accent); }
.credentials-row { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.credentials-hint { font-weight: 500; font-size: 13px; color: var(--ink-soft); }
.credentials-text {
  align-self: stretch;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  user-select: all;
}

.admin-list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.admin-list-head .admin-h { margin: 0; }
.admin-filter { max-width: 280px; font-size: 15px; padding: 9px 12px; }
.admin-summary { margin: 8px 0 14px; font-size: 13.5px; color: var(--ink-soft); }
.admin-users { display: flex; flex-direction: column; gap: 12px; }
.admin-empty { color: var(--ink-soft); font-size: 14px; }

.user-card { padding: 16px; }
.user-head {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: -16px;
  padding: 16px;
  width: calc(100% + 32px);
  border: none;
  border-radius: var(--radius);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.user-head:hover .user-name { color: var(--accent); }
.user-who { flex: 1; min-width: 0; }
.user-summary { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 3px; font-size: 13px; color: var(--ink-soft); }
.user-chevron { flex: none; font-size: 22px; line-height: 1; color: var(--ink-soft); transition: transform 0.15s ease; }
.user-head[aria-expanded="true"] .user-chevron { transform: rotate(90deg); }
.user-body { margin-top: 16px; }
.user-body > .user-section:first-child { margin-top: 0; }
.user-name { font-size: 16px; font-weight: 700; }
.user-status {
  flex: none;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}
.user-status.active { background: var(--success-soft); color: var(--success); }
.user-status.blocked { background: var(--danger-soft); color: var(--danger); }
.user-status.expired { background: var(--amber-soft); color: var(--amber); }
.user-status.admin { background: var(--accent-soft); color: var(--accent); }
.user-section { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.user-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.user-section-title { margin: 0; font-size: 14px; font-weight: 700; }
.user-line { margin: 0; font-size: 14px; line-height: 1.5; }
.user-line.muted { color: var(--ink-soft); font-size: 13.5px; }
.user-date { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.user-date .field-input { width: auto; flex: 0 1 190px; min-width: 150px; padding: 7px 10px; font-size: 15px; }
.user-progress { height: 6px; margin-top: 8px; border-radius: 3px; background: var(--border); overflow: hidden; }
.user-progress-fill { height: 100%; background: var(--accent); }
.user-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.btn-sm { padding: 7px 12px; font-size: 13.5px; border-radius: 10px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.armed { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.btn-danger.armed { background: var(--danger); color: var(--bg-elevated); }

/* ---------- Loading states (questions come from the server) ---------- */

.loading-row { list-style: none; padding: 14px 4px; color: var(--ink-soft); font-size: 14px; }
.app-loading { text-align: center; padding: 48px 0; }
.quiz-option.pending { opacity: 0.7; cursor: progress; }

/* Admin: devices where a user is signed in */
.user-sessions-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.user-sessions-list li { display: flex; flex-direction: column; gap: 1px; font-size: 14px; }
.user-session-device { font-weight: 600; }
.user-session-meta { font-size: 12.5px; color: var(--ink-soft); }

/* Inactivity warning (auth.js) */
.idle-warning {
  position: fixed;
  left: 50%;
  top: 76px;
  transform: translateX(-50%);
  z-index: 80;
  width: min(92vw, 440px);
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--amber);
  background: var(--amber-soft);
  color: var(--ink);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.idle-warning-text { margin: 0; font-size: 14.5px; line-height: 1.45; font-variant-numeric: tabular-nums; }
.idle-warning .btn { align-self: flex-start; }
