/* Aazain Examination Portal — stylesheet.
   One file, no build step. Light and dark both defined via tokens.

   2026-11-09: brought onto the AAZAIN DESIGN SYSTEM
   (/srv/src/aazain-ui-standard/). Three layers:
     1. --aazain-*  source palette, from Website V2. Never themed. Components
        must NEVER read these directly.
     2. semantic tokens, defined once per theme in terms of layer 1.
     3. back-compat aliases — this file already had 130 var() uses under its
        own names, so every one of those names is kept as an alias of a
        semantic token. No rule below line 75 needed to change. This is the
        same pattern Sales Engine uses for its ~168 existing declarations.
   Theme order: light is the default (business/document portal); dark follows
   the OS and can be forced with data-theme on <html>. */

:root {
  /* ---- 1. SOURCE PALETTE — Aazain brand baseline (Website V2) ---- */
  --aazain-brand:          #000080;
  --aazain-brand-dark:     #00004d;
  --aazain-accent:         #006dbc;
  --aazain-accent-light:   #e6f2fa;
  --aazain-accent-on-dark: #4fa8e0;
  --aazain-surface-muted:  #f6f7f9;
  --aazain-border-subtle:  #e3e6eb;
  --aazain-background:     #ffffff;
  --aazain-foreground:     #0a0a0a;

  /* ---- not themed ---- */
  --radius:      10px;
  --radius-sm:   7px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
          "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --text-base: 14px;
  --line-base: 1.5;
  --sidebar-width: 230px;
  --header-height: 72px;
}

/* ================= LIGHT (default) ================= */
:root,
:root[data-theme="light"] {
  color-scheme: light;

  --app-background:    var(--aazain-surface-muted);
  --surface:           #ffffff;
  --surface-secondary: var(--aazain-surface-muted);
  --surface-elevated:  #ffffff;

  --border:        var(--aazain-border-subtle);
  --border-strong: #c7ccd6;

  --text-primary:   var(--aazain-foreground);
  --text-secondary: #5b6b8c;
  --text-muted:     #6b7686;
  --text-on-accent: #ffffff;

  --accent:      var(--aazain-accent);
  --accent-soft: var(--aazain-accent-light);

  --success: #16a34a;
  --warning: #d97706;
  --danger:  #dc2626;
  --info:    var(--aazain-accent);

  --shadow-sm: 0 1px 2px rgba(10, 10, 10, .06), 0 4px 16px rgba(10, 10, 10, .05);
  --shadow-md: 0 4px 24px rgba(10, 10, 10, .14);

  /* app-local status tints — the estate system has no -soft companions,
     so these stay as an Examination Portal extension */
  --good-soft:    #e3f5ec;
  --bad-soft:     #fdeceb;
  --warn-soft:    #fdf2dd;
  --neutral-soft: #eef1f5;

  /* ---- 3. BACK-COMPAT ALIASES (do not add new uses of these) ---- */
  --bg:          var(--app-background);
  --surface-2:   var(--surface-secondary);
  --border-firm: var(--border-strong);
  --text:        var(--text-primary);
  --text-soft:   var(--text-secondary);
  --text-faint:  var(--text-muted);
  --accent-text: var(--text-on-accent);
  --good:        var(--success);
  --bad:         var(--danger);
  --warn:        var(--warning);
  --neutral:     var(--text-secondary);
  --shadow:      var(--shadow-sm);
  --shadow-firm: var(--shadow-md);
}

/* ================= DARK ================= */
/* Multi-step navy hierarchy from the brand family, per the standard:
   darkest recessed -> deep navy workspace -> lighter navy cards ->
   lightest elevated. The accent LIGHTENS on dark; #006dbc fails contrast. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --app-background:    #0a0a35;
    --surface:           #11123f;
    --surface-secondary: #07081f;
    --surface-elevated:  #171853;

    --border:        #22295a;
    --border-strong: #343b72;

    --text-primary:   #e7edf7;
    --text-secondary: #8fa2c2;
    --text-muted:     #6c7a99;
    --text-on-accent: #071725;

    --accent:      var(--aazain-accent-on-dark);
    --accent-soft: rgba(79, 168, 224, .16);

    --success: #22c55e;
    --warning: #f59e0b;
    --danger:  #ef4444;
    --info:    var(--aazain-accent-on-dark);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-md: 0 4px 24px rgba(0, 0, 0, .5);

    --good-soft:    #14301f;
    --bad-soft:     #351715;
    --warn-soft:    #322412;
    --neutral-soft: #222c38;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --app-background:    #0a0a35;
  --surface:           #11123f;
  --surface-secondary: #07081f;
  --surface-elevated:  #171853;

  --border:        #22295a;
  --border-strong: #343b72;

  --text-primary:   #e7edf7;
  --text-secondary: #8fa2c2;
  --text-muted:     #6c7a99;
  --text-on-accent: #071725;

  --accent:      var(--aazain-accent-on-dark);
  --accent-soft: rgba(79, 168, 224, .16);

  --success: #22c55e;
  --warning: #f59e0b;
  --danger:  #ef4444;
  --info:    var(--aazain-accent-on-dark);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, .5);

  --good-soft:    #14301f;
  --bad-soft:     #351715;
  --warn-soft:    #322412;
  --neutral-soft: #222c38;
}


* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--text-base)/var(--line-base) var(--font);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.55rem; font-weight: 650; }
h2 { font-size: 1.15rem; font-weight: 640; }
h3 { font-size: 1rem; font-weight: 620; }
p  { margin: 0; }

/* ---------------------------------------------------------------- layout */
.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 72px;
}
.wrap.narrow { max-width: 460px; padding-top: 8vh; }

.stack    { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row      { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow     { flex: 1 1 auto; min-width: 0; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto;
  padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  border-radius: 7px;
  background: var(--accent); color: var(--accent-text);
  font-weight: 700; font-size: 15px;
}
.brand-text { font-size: .95rem; color: var(--text-soft); white-space: nowrap; }
.brand-text strong { color: var(--text); font-weight: 640; }
.topbar-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.who { font-size: .85rem; color: var(--text-soft); margin-right: 4px; }
.env-chip {
  font-size: .7rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px;
  background: var(--warn-soft); color: var(--warn);
}

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card-tight { padding: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }

/* ---------------------------------------------------------------- buttons */
.btn {
  font: inherit; font-weight: 550;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-firm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent); color: var(--accent-text); border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-soft); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { border-color: var(--bad); color: var(--bad); background: transparent; }
.btn-sm { padding: 5px 10px; font-size: .85rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---------------------------------------------------------------- forms */
label.field { display: flex; flex-direction: column; gap: 5px; font-size: .85rem; color: var(--text-soft); font-weight: 550; }
input[type=email], input[type=password], input[type=text], select {
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--border-firm);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
select:focus-visible,
input:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

.alert {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  border: 1px solid transparent;
}
.alert-bad  { background: var(--bad-soft);  color: var(--bad);  border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert-info { background: var(--accent-soft); color: var(--accent); }

/* ---------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .72rem; font-weight: 650; letter-spacing: .03em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px;
  background: var(--neutral-soft); color: var(--neutral);
  white-space: nowrap;
}
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-bad  { background: var(--bad-soft);  color: var(--bad); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

.muted { color: var(--text-soft); font-size: .88rem; }
.faint { color: var(--text-faint); font-size: .82rem; }
.mono  { font-family: var(--mono); font-size: .85em; }

/* ---------------------------------------------------------------- test list */
.exam-card { display: flex; flex-direction: column; gap: 12px; }
.exam-meta { display: flex; gap: 8px 16px; flex-wrap: wrap; font-size: .85rem; color: var(--text-soft); }
.exam-meta span { display: inline-flex; align-items: center; gap: 5px; }

/* ---------------------------------------------------------------- timer */
.timerbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(23,32,46,.09);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.timerbar-inner {
  max-width: 1080px; margin: 0 auto;
  padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.timer-left { display: flex; align-items: baseline; gap: 9px; }
.timer-label { font-size: .78rem; color: var(--text-soft); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.timer-clock {
  font-family: var(--mono);
  font-size: 1.5rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.timer-clock.warn   { color: var(--warn); }
.timer-clock.danger { color: var(--bad); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .timer-clock.danger { animation: none; } }
.timer-right { display: flex; align-items: center; gap: 12px; }
.timer-progress-count { font-size: .85rem; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.timer-track { height: 3px; background: var(--border); }
.timer-fill  { height: 100%; background: var(--accent); width: 100%; transition: width 1s linear; }
.timer-fill.warn   { background: var(--warn); }
.timer-fill.danger { background: var(--bad); }

/* ---------------------------------------------------------------- palette */
.palette { display: flex; flex-wrap: wrap; gap: 6px; }
.pal {
  width: 36px; height: 36px; flex: none;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-firm);
  background: var(--surface);
  color: var(--text-soft);
  font: inherit; font-size: .85rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.pal:hover { border-color: var(--accent); }
.pal:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pal.answered { background: var(--good-soft); color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.pal.review   { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.pal.current  { outline: 2px solid var(--accent); outline-offset: 1px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--text-soft); }
.legend-key { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--border-firm); display: inline-block; }
.swatch.answered { background: var(--good-soft); border-color: var(--good); }
.swatch.review   { background: var(--warn-soft); border-color: var(--warn); }
.swatch.untouched{ background: var(--surface); }

/* ---------------------------------------------------------------- question */
.qhead { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.qnum { font-size: .8rem; font-weight: 650; color: var(--text-soft); text-transform: uppercase; letter-spacing: .05em; }
.qstem { font-size: 1.05rem; line-height: 1.6; margin: 10px 0 16px; }

.options { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 12px 14px;
  border: 1px solid var(--border-firm);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.opt:hover { border-color: var(--accent); background: var(--surface-2); }
.opt:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.opt input { margin: 0; flex: none; margin-top: 4px; accent-color: var(--accent); }
.opt.selected { border-color: var(--accent); background: var(--accent-soft); }
.opt-label { font-weight: 650; flex: none; min-width: 1.1em; }
.opt-body  { flex: 1 1 auto; min-width: 0; }

/* review states */
.opt.is-correct { border-color: var(--good); background: var(--good-soft); }
.opt.is-wrong   { border-color: var(--bad);  background: var(--bad-soft); }
.opt-tag { font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; margin-left: auto; flex: none; }
.opt.is-correct .opt-tag { color: var(--good); }
.opt.is-wrong   .opt-tag { color: var(--bad); }

.explain {
  margin-top: 14px; padding: 13px 15px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: .92rem; line-height: 1.6;
}
.explain h4 { margin: 0 0 5px; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-soft); font-weight: 650; }

/* ---------------------------------------------------------------- score */
.scoreboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}
.tile {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.tile-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-soft); font-weight: 650; }
.tile-value { font-size: 1.7rem; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 3px; letter-spacing: -0.02em; }
.tile-sub   { font-size: .78rem; color: var(--text-faint); }
.tile.good  .tile-value { color: var(--good); }
.tile.bad   .tile-value { color: var(--bad); }
.tile.hero  { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.tile.hero .tile-value { color: var(--accent); font-size: 2rem; }

/* ---------------------------------------------------------------- tables */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: 9px 11px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-soft); font-weight: 650;
  background: var(--surface-2); position: sticky; top: 0;
}
tbody tr:hover { background: var(--surface-2); }
td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
td.wrap-cell { white-space: normal; min-width: 180px; }

/* ---------------------------------------------------------------- modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(15, 20, 28, .55);
  display: grid; place-items: center;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-firm);
  padding: 20px;
  max-width: 420px; width: 100%;
  display: flex; flex-direction: column; gap: 12px;
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  left: 50%; transform: translateX(-50%);
  z-index: 80;
  background: var(--text); color: var(--bg);
  padding: 9px 16px; border-radius: 999px;
  font-size: .86rem; font-weight: 550;
  box-shadow: var(--shadow-firm);
  max-width: calc(100vw - 32px);
}

.loading { padding: 48px 0; text-align: center; color: var(--text-soft); }

.sample-banner {
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: .86rem;
  font-weight: 550;
}

/* bottom padding so the fixed timer bar never covers content */
body.testing .wrap { padding-bottom: 130px; }

@media (max-width: 560px) {
  .timer-clock { font-size: 1.25rem; }
  .brand-text { display: none; }
  .wrap { padding-left: 16px; padding-right: 16px; }
  .tile-value { font-size: 1.45rem; }
}

/* ---------------------------------------------------------------- users (admin) */
.user-form {
  display: grid;
  grid-template-columns: 1.4fr 1.6fr .8fr auto;
  gap: 12px;
  align-items: end;
  margin-top: 12px;
}
.user-form > .alert { grid-column: 1 / -1; }
.user-form-actions { display: flex; }
.pw-box {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  line-height: 1.9;
}
.pw-box code { font-size: 1rem; user-select: all; }
.actions-cell { white-space: nowrap; text-align: right; }
.actions-cell .btn + .btn { margin-left: 6px; }
@media (max-width: 720px) {
  .user-form { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- schools / dashboard */
.user-form-wide { grid-template-columns: 1.3fr 1.5fr .9fr 1.2fr auto; }
.school-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  align-items: end;
  margin-top: 12px;
}
.school-form > .alert, .school-form > .form-section, .school-form > .user-form-actions { grid-column: 1 / -1; }
.form-section { font-weight: 600; font-size: .9rem; color: var(--text-soft); padding-top: 6px; border-top: 1px solid var(--border); }
.field-inline { flex-direction: row; align-items: center; gap: 8px; }
.field-inline select { width: auto; min-width: 180px; }
.user-form-actions { gap: 8px; }
@media (max-width: 720px) {
  .user-form-wide { grid-template-columns: 1fr; }
}

/* ---- chapter tests and progress ---- */
.chapter-group { margin-top: 14px; }
.chapter-group h3 { font-size: .95rem; margin: 0; }
.chapter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px; margin-top: 8px; }
.chapter-pick {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; font-size: .92rem;
}
.chapter-pick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.chapter-pick.is-empty { cursor: default; color: var(--text-faint); background: var(--surface-2); }
.chapter-pick input { margin: 0; flex: none; }
.builder-fields { display: grid; grid-template-columns: 120px 120px 1fr; gap: 12px; align-items: end; margin-top: 10px; }
.builder-fields:has(#b-audience) { grid-template-columns: 120px 120px 1fr 1fr; }
@media (max-width: 640px) {
  .builder-fields, .builder-fields:has(#b-audience) { grid-template-columns: 1fr 1fr; }
  .builder-title { grid-column: 1 / -1; }
}
.tile-of { font-size: 1rem; color: var(--text-faint); font-weight: 500; }
.spark {
  position: relative; display: inline-flex; align-items: flex-end; gap: 2px;
  height: 28px; min-width: 40px; padding: 0 2px; border-bottom: 1px solid var(--border-firm);
}
.spark-bar { width: 7px; background: var(--border-firm); border-radius: 2px 2px 0 0; }
.spark-bar.is-hit { background: var(--good); }
.spark-target { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed var(--text-faint); }
.meter-cell { white-space: nowrap; }
.meter {
  display: inline-block; width: 80px; height: 8px; border-radius: 4px; background: var(--neutral-soft);
  vertical-align: middle; margin-right: 8px; overflow: hidden;
}
.meter-fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

/* ---- question bank editor ---- */
.tile-btn { text-align: left; font: inherit; color: inherit; cursor: pointer; }
.tile-btn:hover { border-color: var(--accent); }
.q-filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1.4fr; gap: 12px; align-items: end; }
.q-meta-fields { display: grid; grid-template-columns: 2fr 1.4fr 1fr; gap: 12px; align-items: end; }
@media (max-width: 720px) {
  .q-filters, .q-meta-fields { grid-template-columns: 1fr; }
}
.q-card { display: flex; flex-direction: column; gap: 10px; }
.q-stem { font-size: 1rem; line-height: 1.55; margin: 0; white-space: pre-wrap; }
.q-opts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.q-opts li { padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.q-opts li.is-correct { border-color: var(--good); background: var(--good-soft); }
.q-option-fields { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.q-option-fields legend { font-size: .9rem; font-weight: 600; margin-bottom: 6px; padding: 0; }
.q-option-row { display: flex; align-items: center; gap: 10px; }
.q-option-row input[type="text"] { flex: 1 1 auto; min-width: 0; }
.q-option-row input[type="radio"] { width: 18px; height: 18px; flex: none; margin: 0; }
textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--border-firm); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); width: 100%; resize: vertical; }

/* ---- phones and small tablets ---- */
@media (max-width: 720px) {
  /* The question comes first; the jump-to-question grid follows it. */
  .palette-card { order: 2; }
}
@media (max-width: 560px) {
  /* Two rows of buttons would eat a quarter of a phone screen if pinned. */
  .topbar { position: static; }
  .topbar-inner { padding: 8px 12px; gap: 6px; }
  .topbar-right { gap: 4px; }
  .topbar-right .btn { padding: 6px 9px; font-size: .85rem; }
  .who { flex-basis: 100%; margin: 0 0 2px; }
}

/* small inline text button (e.g. unlink a child) */
.btn-link { background: none; border: 0; padding: 0 3px; color: var(--bad, #b42318); cursor: pointer; font: inherit; }
.btn-link:hover { text-decoration: underline; }
