/* ------- tokens -------
   Themes attach via `:root[data-theme="<name>"]`. base.html sets the
   attribute from the `vq_theme` cookie before paint, so reloading the
   page never produces a flash. Unset attribute (or `data-theme="system"`)
   falls back to dark by default, with a prefers-color-scheme override
   for users on light OSes.

   `--on-accent` is the high-contrast text color to use on `--accent`
   backgrounds (primary buttons, etc). Without it, light themes get
   dark-on-dark-blue and become unreadable.

   `--font-body` lets themes opt into a different typeface (e.g. the
   terminal theme uses a pixel font); the default lets us share one
   `html { font-family: var(--font-body) }` line at the bottom.
*/

/* Pixel-font hook for the terminal themes. Bundled font lives at
   Assets/Static/Fonts/VT323-Regular.ttf (SIL OFL — see OFL.txt in
   that directory). Drop a `.woff2` build of the same family next to
   it later and add the matching `src` line if smaller payload matters. */
@font-face {
  font-family: 'Terminal Pixel';
  src: url('/Static/Fonts/VT323-Regular.ttf') format('truetype');
  font-display: swap;
}

:root,
:root[data-theme="dark"],
:root[data-theme="system"] {
  --bg: #0f1115;
  --bg-2: #161922;
  --panel: #1a1e29;
  --border: #2a2f3d;
  --border-strong: #3a4156;
  --fg: #e8eaed;
  --muted: #8b94a8;
  --accent: #7aa2f7;
  --accent-2: #5b8aef;
  --on-accent: #0b1020;
  --ok: #6ee7a7;
  --ok-bg: #143424;
  --no: #ff7a85;
  --no-bg: #3a1418;
  --warn: #f0b400;
  --code-bg: #0c0f15;
  --code-fg: #e8eaed;
  /* Inline code (`<code>` pills inside prose) defaults to the same bg
     and fg as block code, with no border. Light themes need a border
     so the pill stands off a pale page; sepia flips to a cream pill +
     dark text so inline code doesn't interrupt the prose flow the way
     a dark engraving block would. */
  --inline-code-bg: var(--code-bg);
  --inline-code-fg: var(--code-fg);
  --inline-code-border: transparent;
  /* Code-token colors. Defaulted to the page palette so dark themes
     stay thematic (Solarized keeps solarized tokens, terminal greens
     stay green-on-green, etc). Light + sepia override these to fixed
     light values so the always-dark code-bg keeps high contrast. */
  --code-token-comment:  var(--muted);
  --code-token-keyword:  var(--accent);
  --code-token-number:   var(--warn);
  --code-token-string:   var(--ok);
  --code-token-function: var(--code-fg);
  --diff-beginner: #6ee7a7;
  --diff-intermediate: #7aa2f7;
  --diff-advanced: #f0a060;
  --diff-expert: #ff7a85;
  --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 1px 2px rgba(0,0,0,.4);
  --radius: 10px;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
}

/* Terminal — CRT green-on-black with a pixel font. Max contrast,
   square corners, scanline-ish accent shadow. */
:root[data-theme="terminal-green"] {
  --bg: #000000;
  --bg-2: #050a05;
  --panel: #0a140a;
  --border: #144914;
  --border-strong: #1f6f1f;
  --fg: #4cff4c;
  --muted: #2db82d;
  --accent: #66ff66;
  --accent-2: #99ff99;
  --on-accent: #000000;
  --ok: #66ff66;
  --ok-bg: #002a00;
  --no: #ff6666;
  --no-bg: #2a0000;
  --warn: #ffff66;
  --code-bg: #000000;
  --code-fg: #66ff66;
  /* Monochromatic CRT — token colors are brightness gradations of the
     phosphor green plus yellow for numbers, so syntax stays legible
     without the default mapping collapsing keyword/string into code-fg. */
  --code-token-keyword:  #aaffaa;
  --code-token-string:   #33ee44;
  --diff-beginner: #66ff66;
  --diff-intermediate: #66ffff;
  --diff-advanced: #ffcc66;
  --diff-expert: #ff6666;
  --shadow: 0 0 0 1px rgba(102,255,102,.08) inset,
            0 0 8px rgba(102,255,102,.12);
  --radius: 0;
  --font-body: 'Terminal Pixel', VT323, 'Cascadia Mono',
               Consolas, Menlo, 'DejaVu Sans Mono', monospace;
}

/* Terminal amber — same idea, DEC VT320 amber phosphor. */
:root[data-theme="terminal-amber"] {
  --bg: #000000;
  --bg-2: #0a0700;
  --panel: #140e00;
  --border: #4d2f00;
  --border-strong: #7a4d00;
  --fg: #ffb000;
  --muted: #cc8800;
  --accent: #ffd24d;
  --accent-2: #ffe599;
  --on-accent: #1a0d00;
  --ok: #66ff66;
  --ok-bg: #0a2a00;
  --no: #ff6666;
  --no-bg: #2a0000;
  --warn: #ffff66;
  --code-bg: #000000;
  --code-fg: #ffd24d;
  /* Stay within the amber phosphor family for code tokens — the default
     mapping pulls in green for strings (jarring on amber) and collapses
     keyword into code-fg. */
  --code-token-keyword:  #ffec99;
  --code-token-string:   #ffaa44;
  --diff-beginner: #ffe599;
  --diff-intermediate: #ffd24d;
  --diff-advanced: #ff9933;
  --diff-expert: #ff6666;
  --shadow: 0 0 0 1px rgba(255,176,0,.08) inset,
            0 0 8px rgba(255,176,0,.14);
  --radius: 0;
  --font-body: 'Terminal Pixel', VT323, 'Cascadia Mono',
               Consolas, Menlo, 'DejaVu Sans Mono', monospace;
}

/* Solarized dark — Schoonover's palette, brightened to taste:
   text is base1 → base2-ish (#bdc9c9) instead of the canonical
   muted base1 (#93a1a1), background darkened a touch for clearer
   card lift, accent shifted toward solar-cyan (#42a5e2) which
   reads better on the dark background than canonical solar-blue. */
:root[data-theme="solarized-dark"] {
  --bg: #001e26;
  --bg-2: #073642;
  --panel: #0e4250;
  --border: #1e4f5b;
  --border-strong: #3a7280;
  --fg: #cad7d7;
  --muted: #819595;
  --accent: #5ab8e8;
  --accent-2: #3697d0;
  --on-accent: #001e26;
  --ok: #93b900;
  --ok-bg: #143625;
  --no: #e84a45;
  --no-bg: #3a1115;
  --warn: #cba000;
  --code-bg: #001218;
  --code-fg: #cad7d7;
  --diff-beginner: #93b900;
  --diff-intermediate: #5ab8e8;
  --diff-advanced: #d56524;
  --diff-expert: #e84a45;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 1px 2px rgba(0,0,0,.4);
  --radius: 6px;
}

:root[data-theme="light"] {
  --bg: #f6f7fb;
  --bg-2: #eef0f6;
  --panel: #ffffff;
  --border: #d8dde7;
  --border-strong: #b9c0cf;
  --fg: #1a1d24;
  --muted: #5b6373;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --on-accent: #ffffff;
  --ok: #12834a;
  --ok-bg: #d6f3df;
  --no: #c4262e;
  --no-bg: #fde0e2;
  --warn: #b45309;
  /* Light code blocks for a light page — dark code blocks sitting in a
     light document read like a foreign panel. GitHub-light-style pale
     gray block + deeply saturated tokens keeps syntax legible. */
  --code-bg: #f1f3f5;
  --code-fg: #1a1d24;
  /* Inline pills need a visible outline on a near-white page bg, or
     they fade into the prose. */
  --inline-code-border: var(--border);
  --code-token-comment:  #6b7280;
  --code-token-keyword:  #1d4ed8;
  --code-token-number:   #9a3412;
  --code-token-string:   #15803d;
  --code-token-function: #1a1d24;
  /* Saturated diff colors so chip text/border stays readable on white;
     dark-theme pastels (mint, sky blue, salmon, peach) wash out here. */
  --diff-beginner: #0f7d3f;
  --diff-intermediate: #1e5cb8;
  --diff-advanced: #c2410c;
  --diff-expert: #b91c1c;
  --shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 1px 2px rgba(0,0,0,.06);
}

/* Sepia — warm paper, easier on the eyes for long reading. */
:root[data-theme="sepia"] {
  --bg: #f5ecd7;
  --bg-2: #ece1c6;
  --panel: #fbf4e1;
  --border: #c8b894;
  --border-strong: #a3956f;
  --fg: #3d2f1a;
  --muted: #7a6849;
  --accent: #8a5a2b;
  --accent-2: #6b4422;
  --on-accent: #fbf4e1;
  --ok: #2f6b2a;
  --ok-bg: #dbe8c8;
  --no: #a93429;
  --no-bg: #f1d3cd;
  --warn: #966a17;
  --code-bg: #2a2418;
  --code-fg: #f0e6d0;
  /* Inline pills are a warm tan tag with dark text — enough lift off
     the page to spot at a glance, but stays in the parchment palette
     so it doesn't punctuate the prose the way a dark engraving does. */
  --inline-code-bg: #d8c8a3;
  --inline-code-fg: var(--fg);
  /* Warm-tinted Prism palette so code blocks feel like part of the
     parchment rather than a hard tonal break. */
  --code-token-comment:  #b09a72;
  --code-token-keyword:  #e6b87a;
  --code-token-number:   #f0c360;
  --code-token-string:   #c8d588;
  --code-token-function: #f0e6d0;
  /* Warm-tinted diff colors so chips stay on-palette with the parchment;
     the default dark-theme cool greens/blues clash with the cream bg. */
  --diff-beginner: #5d7c2a;
  --diff-intermediate: #3d6b7a;
  --diff-advanced: #a25c1a;
  --diff-expert: #933325;
  --shadow: 0 1px 0 rgba(255,255,255,.5) inset, 0 1px 2px rgba(0,0,0,.08);
}

/* `system`: dark base above, overridden to light when the OS prefers
   light. (Explicit picks ignore the OS preference.) */
@media (prefers-color-scheme: light) {
  :root[data-theme="system"] {
    --bg: #f6f7fb;
    --bg-2: #eef0f6;
    --panel: #ffffff;
    --border: #d8dde7;
    --border-strong: #b9c0cf;
    --fg: #1a1d24;
    --muted: #5b6373;
    --accent: #2563eb;
    --accent-2: #1d4ed8;
    --on-accent: #ffffff;
    --ok: #12834a;
    --ok-bg: #d6f3df;
    --no: #c4262e;
    --no-bg: #fde0e2;
    --warn: #b45309;
    --code-bg: #f1f3f5;
    --code-fg: #1a1d24;
    --inline-code-border: var(--border);
    --code-token-comment:  #6b7280;
    --code-token-keyword:  #1d4ed8;
    --code-token-number:   #9a3412;
    --code-token-string:   #15803d;
    --code-token-function: #1a1d24;
    --diff-beginner: #0f7d3f;
    --diff-intermediate: #1e5cb8;
    --diff-advanced: #c2410c;
    --diff-expert: #b91c1c;
    --shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 1px 2px rgba(0,0,0,.06);
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--fg);
  /* --font-body is theme-driven (terminal themes swap to a pixel font);
     the literal fallback covers the case where a theme block doesn't
     override it. */
  font-family: var(--font-body, -apple-system, BlinkMacSystemFont,
                   "Segoe UI", Roboto, Inter, sans-serif);
  font-size: 15px;
  line-height: 1.55;
}
.mono, code, pre, .qid, .sub-id { font-family: "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ------- layout ------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar .brand a {
  color: var(--fg); font-weight: 600;
  font-size: 16px; letter-spacing: 0.02em;
}
.topbar nav {
  margin-left: auto;
  display: flex; gap: 14px; align-items: center;
}
.topbar nav a { color: var(--muted); }
.topbar nav a:hover { color: var(--fg); text-decoration: none; }
.topbar .who {
  padding: 2px 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--fg);
}
.topbar form.inline { display: inline; margin: 0; }

/* Theme picker: small dropdown in the topbar. Uses a <details> for
   the open/close mechanics (no extra JS for that part); JS in
   base.html handles cookie set + active-state highlight. */
/* Top-bar category dropdowns (Quiz, Wikis, Workspaces). Same
   <details>-based open/close mechanic as the theme picker, but the
   trigger is styled like a regular nav link and the menu is
   left-aligned with the trigger. */
.topbar-menu {
  position: relative;
  display: inline-block;
}
.topbar-menu > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  color: var(--muted);
  padding: 2px 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.topbar-menu > summary::-webkit-details-marker { display: none; }
.topbar-menu > summary:hover { color: var(--fg); }
.topbar-menu[open] > summary { color: var(--fg); }
.topbar-menu-caret {
  font-size: 10px;
  opacity: 0.7;
  transition: transform 0.12s ease;
}
.topbar-menu[open] .topbar-menu-caret {
  transform: rotate(180deg);
}
.topbar-menu-list {
  position: absolute; top: calc(100% + 6px); left: 0;
  list-style: none;
  margin: 0; padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 170px;
  z-index: 20;
}
.topbar-menu-list li { margin: 0; }
.topbar-menu-list a {
  display: block;
  padding: 6px 10px;
  color: var(--fg);
  font-size: 13px;
  border-radius: 4px;
  white-space: nowrap;
}
.topbar-menu-list a:hover {
  background: var(--bg-2);
  color: var(--fg);
  text-decoration: none;
}

.theme-picker {
  position: relative;
  display: inline-block;
  margin-left: 6px;
}
.theme-picker > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 6px;
  opacity: 0.7;
}
.theme-picker > summary::-webkit-details-marker { display: none; }
.theme-picker > summary:hover { opacity: 1; background: var(--bg-2); }
.theme-picker[open] > summary { opacity: 1; background: var(--bg-2); }
.theme-picker-menu {
  position: absolute; top: calc(100% + 4px); right: 0;
  list-style: none;
  margin: 0; padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 170px;
  z-index: 20;
}
.theme-picker-menu li { margin: 0; }
.theme-picker-divider {
  height: 1px;
  margin: 4px 6px;
  background: var(--border);
  pointer-events: none;
}
.theme-picker-menu button {
  display: block; width: 100%;
  text-align: left;
  padding: 6px 10px;
  background: none; border: none;
  color: var(--fg);
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
  white-space: nowrap;
}
.theme-picker-menu button:hover {
  background: var(--bg-2);
  border-color: transparent;
}
.theme-picker-menu button.is-active {
  background: var(--bg-2);
  color: var(--accent);
  font-weight: 600;
}
.theme-picker-menu button.is-active::after {
  content: " ✓";
  color: var(--accent);
}
button.link {
  background: none; border: none; padding: 0;
  color: var(--muted); cursor: pointer; font: inherit;
}
button.link:hover { color: var(--fg); text-decoration: underline; }

/* ====================================================================
   Prism-highlighted code blocks — used by every page that renders
   user-authored content (questions, study pages, wiki pages, intros,
   etc.). These were originally in Quiz.css but quiz is just one of
   many surfaces; pages that don't load Quiz.css were rendering code
   blocks plain + had a default-styled (oversize) Copy button.

   The question template emits <pre class="code"> directly; the
   markdown renderer emits the same shape. Inner <code> sits
   transparent on top so Prism's tokens use the parent <pre>'s
   background as canvas. */
pre.code {
  background: var(--code-bg); color: var(--code-fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
  margin: 8px 0;
}
pre.code code { background: none; padding: 0; }

/* Prism token colors — restrained 5-color palette. Tokens use
   dedicated --code-token-* variables (defaulted to the dark theme's
   muted/accent/warn/ok in the :root block) so light/sepia can keep
   readable code colors on the dark code background without dragging
   the page-level palette along. */
pre.code .token.comment,
pre.code .token.prolog,
pre.code .token.doctype,
pre.code .token.cdata        { color: var(--code-token-comment); font-style: italic; }
pre.code .token.punctuation  { color: var(--code-token-comment); }
pre.code .token.namespace    { opacity: 0.7; }
pre.code .token.keyword,
pre.code .token.builtin,
pre.code .token.important,
pre.code .token.selector,
pre.code .token.atrule,
pre.code .token.tag,
pre.code .token.attr-name    { color: var(--code-token-keyword); }
pre.code .token.boolean,
pre.code .token.number,
pre.code .token.constant,
pre.code .token.symbol,
pre.code .token.deleted      { color: var(--code-token-number); }
pre.code .token.string,
pre.code .token.char,
pre.code .token.attr-value,
pre.code .token.regex,
pre.code .token.inserted,
pre.code .token.url          { color: var(--code-token-string); }
pre.code .token.function,
pre.code .token.class-name,
pre.code .token.variable,
pre.code .token.property     { color: var(--code-token-function); }
pre.code .token.operator,
pre.code .token.entity       { color: var(--code-token-function); }
pre.code .token.bold         { font-weight: 600; }
pre.code .token.italic       { font-style: italic; }

/* Prism toolbar plugin (copy-to-clipboard) — the plugin wraps every
   highlighted `<pre>` in `<div class="code-toolbar">` and appends
   `<div class="toolbar"><div class="toolbar-item"><button>Copy</...`
   for the copy button. We don't ship Prism's plugin CSS (it doesn't
   match the app's theme), so style the resulting DOM here:
     - the wrapper becomes a positioning context with the pre's
       original margin so layout doesn't shift
     - the toolbar floats over the pre's top-right corner
     - the button picks up theme colours instead of the global
       button rules (which produce a comically-sized full-padding
       button when left ungoverned) */
div.code-toolbar {
  position: relative;
  margin: 8px 0;
}
div.code-toolbar > pre.code {
  margin: 0;
}
div.code-toolbar > .toolbar {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  display: flex;
  gap: 4px;
  opacity: 0.55;
  transition: opacity 0.15s ease-in-out;
}
div.code-toolbar:hover > .toolbar,
div.code-toolbar:focus-within > .toolbar {
  opacity: 1;
}
div.code-toolbar > .toolbar > .toolbar-item {
  display: inline-flex;
}
div.code-toolbar > .toolbar > .toolbar-item > button,
div.code-toolbar > .toolbar > .toolbar-item > a,
div.code-toolbar > .toolbar > .toolbar-item > span {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-body);
  font-size: 11px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  box-shadow: none;
}
div.code-toolbar > .toolbar > .toolbar-item > button:hover,
div.code-toolbar > .toolbar > .toolbar-item > button:focus,
div.code-toolbar > .toolbar > .toolbar-item > a:hover,
div.code-toolbar > .toolbar > .toolbar-item > a:focus {
  color: var(--fg);
  border-color: var(--accent, var(--border));
  outline: none;
}

/* Bank card grid — shared between /browse (read-only listing) and
   /admin/banks (with management actions). Admin-only extras (the
   actions row + the file-backed/db-only tag sizing) layer on top
   in Admin.css. */
.bank-grid {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.bank-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px 18px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.1s;
}
.bank-card:hover { border-color: var(--border-strong); }
.bank-card-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.bank-card-name {
  font-size: 16px; font-weight: 600;
  color: var(--accent);
}
.bank-card-stats {
  display: flex; gap: 18px;
  font-size: 13px;
}
.bank-card-stats .browse-stat strong {
  font-size: 18px; font-weight: 600;
  margin-right: 4px;
}

/* ====================================================================
   Cross-cutting utility classes — consolidated 2026-06-04 from the
   per-area sheets where they originally lived. Each of these had ≥2
   areas using it without loading the defining sheet, producing the
   "missing styles" pattern that surfaced after the Style.css split.

   What stayed in per-area sheets: area-specific widgets (rtk-heatmap,
   notes-stats, etc.). Cross-area pages that need those load the
   relevant sheet explicitly (see template head_styles blocks).
   ==================================================================== */

/* --- Generic form layout (was Study.css) --- */
.study-edit-form {
  display: flex; flex-direction: column; gap: 16px;
  max-width: 720px;
}
.study-field {
  display: flex; flex-direction: column; gap: 6px;
}
.study-field .field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
.study-field .field-readonly {
  display: flex; align-items: center; gap: 10px;
}
.study-field input[type="text"],
.study-field select {
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
}
.study-field textarea {
  font-family: "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  font-size: 13px;
}
.study-field .hint { font-size: 11px; }
.form-actions { display: flex; gap: 12px; }

/* --- Compact action button (was Study.css, descendant-scoped) ---
   Originally only worked inside .study-link-actions; Browse + Stats
   use bare class="action-btn" and got no styling. */
.action-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 4px;
  height: 26px;
  padding: 0 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.08s, border-color 0.08s, background 0.08s;
}
.action-btn:hover {
  color: var(--fg);
  border-color: var(--border-strong);
  background: var(--bg-2);
}
.action-btn .action-icon {
  font-size: 13px;
  line-height: 1;
  display: inline-block;
  width: 12px;
  text-align: center;
}

/* --- Section heading (was Wiki.css, also a dead duplicate in RTK.css) ---
   Wiki's definition wins — uppercase muted is the actual look every
   consumer (Profile, Explore, Stats, Wiki) expected. RTK.css had its
   own .section-head with a different look but no RTK template actually
   used it — that definition is deleted. */
.section-head {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 22px 0 8px;
}
/* Section-count pill — was .admin-tools h2 .section-count in Admin.css.
   Extracted as a generic small-pill for any "N items" counter sitting
   next to a section heading. */
.section-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  text-transform: none;
}

/* --- Cross-area form / list utilities --- */
.subtopic-form { padding: 10px 0 0; }

.hub-empty {
  font-size: 12px;
  margin: 0 0 14px;
  padding: 6px 10px;
  border: 1px dashed var(--border);
  border-radius: 6px;
}
.hub-empty kbd {
  font-size: 10px;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg);
  color: var(--muted);
}

/* --- Notes filter bar + variants (was Library.css) --- */
.notes-filter-bar .filter-group {
  display: flex; flex-direction: column; gap: 4px;
  margin: 0;
}
.notes-filter-bar .filter-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.notes-filter-bar select,
.notes-filter-bar input[type="search"] {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
}
.notes-filter-bar .filter-search { flex: 1 1 240px; min-width: 200px; }
.notes-filter-bar .filter-search input { width: 100%; }

/* --- Kind chip + dot (was Library.css, used by Stats too) --- */
.kind-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  font-size: 12px;
  color: var(--muted);
  text-transform: capitalize;
}
.kind-chip strong { color: var(--fg); font-weight: 600; }
.kind-chip .kind-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
}
.kind-chip.kind-mnemonic  { border-color: var(--accent); }
.kind-chip.kind-mnemonic .kind-dot { background: var(--accent); }
.kind-chip.kind-warning   { border-color: var(--warn); }
.kind-chip.kind-warning .kind-dot { background: var(--warn); }
.kind-chip.kind-reference { border-color: var(--ok); }
.kind-chip.kind-reference .kind-dot { background: var(--ok); }

/* --- Bank chip + breadcrumb (was Browse.css, both used cross-area) --- */
.bank-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-2);
  font-size: 12px;
  color: var(--fg);
  text-transform: capitalize;
}
.bank-chip strong { font-weight: 600; color: var(--fg); }
.bank-chip .bank-chip-flag {
  font-size: 11px;
  color: var(--warn);
}

.browse-crumb-link { color: var(--muted); text-decoration: none; }
.browse-crumb-link:hover { color: var(--accent); }
.browse-crumb-sep { margin: 0 6px; }
.wiki-breadcrumb-sep { color: var(--muted); }

/* --- Bank divider (was RTK.css, used by Stats between main/kanji blocks) --- */
.bank-divider {
  border: 0;
  border-top: 1px dashed var(--border-strong);
  margin: 28px 0 8px;
}

/* --- Share panel (was RTK.css, used by daily summary + session detail) --- */
.share-panel {
  margin: 18px 0 14px;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.share-panel h3 {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
pre.share-text {
  margin: 0 0 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 520px;
}
.share-toast {
  font-size: 13px;
  color: var(--ok);
  transition: opacity 0.2s;
}

/* --- Big-number summary stack (was Stats.css) --- */
.big-stats { display: flex; gap: 28px; flex-wrap: wrap; }
.big { text-align: left; }
.big-num { font-size: 28px; font-weight: 700; color: var(--fg); }
.big-lbl {
  font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* --- Data table (was Stats.css, generic table chrome) --- */
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td {
  padding: 8px 10px; text-align: left;
  border-bottom: 1px solid var(--border);
}
table.data th {
  color: var(--muted); font-weight: 500; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
table.data.compact th, table.data.compact td {
  padding: 4px 8px; font-size: 12px;
}
table.data td.num, table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

main {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

.flashes {
  max-width: 920px; margin: 12px auto 0; padding: 0 20px;
}
.flash {
  background: var(--no-bg); color: var(--no);
  border: 1px solid var(--no);
  padding: 8px 12px; border-radius: 6px; margin-bottom: 8px;
}

/* ------- cards ------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.card h3 { margin: 16px 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* ------- forms -------
   `input:not([type])` covers inputs without an explicit type — those default
   to `type=text` per HTML spec, but `input[type=text]` only matches explicit
   ones. Without this, several editor inputs render with the browser default
   (bright white). */
input:not([type]),
input[type=text], input[type=password], input[type=search],
input[type=number], input[type=email], input[type=url],
input[type=tel], input[type=date], input[type=time],
select, textarea {
  background: var(--bg-2); color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px; font: inherit;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px;
}
/* Number inputs get a sensible default width — they're rarely full-width.
   Override by adding inline style or a wrapper class when needed. */
input[type=number] { width: 5rem; }
/* Hide the spinner buttons; they look out of place and the keyboard works. */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
input[type=number] { -moz-appearance: textfield; }
label { display: block; margin: 8px 0; font-size: 13px; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; }

button {
  background: var(--panel); color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary {
  background: var(--accent); color: var(--on-accent);
  border-color: var(--accent);
  font-weight: 600;
}
button.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }

/* ------- chips (custom checkbox/radio look) ------- */
.chip-row {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 0; padding: 0; list-style: none;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-2);
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  transition: background 0.08s, border-color 0.08s, color 0.08s;
}
.chip:hover { color: var(--fg); border-color: var(--border-strong); }
.chip > input[type=checkbox],
.chip > input[type=radio] {
  /* hide the native control; the chip itself is the visual */
  position: absolute;
  width: 1px; height: 1px; opacity: 0; pointer-events: none;
}
.chip:has(input:checked) {
  background: var(--panel);
  border-color: var(--accent);
  color: var(--fg);
}
.chip:has(input:checked) .chip-label { font-weight: 600; }
.chip-meta {
  font-size: 11px; color: var(--muted);
  background: var(--bg);
  padding: 1px 7px; border-radius: 999px;
  border: 1px solid var(--border);
}
.chip:has(input:checked) .chip-meta { color: var(--accent); border-color: var(--accent); }

/* difficulty chip colour-overrides */
.diff-chip.diff-beginner:has(input:checked)    { color: var(--diff-beginner); border-color: var(--diff-beginner); }
.diff-chip.diff-intermediate:has(input:checked){ color: var(--diff-intermediate); border-color: var(--diff-intermediate); }
.diff-chip.diff-advanced:has(input:checked)    { color: var(--diff-advanced); border-color: var(--diff-advanced); }
.diff-chip.diff-expert:has(input:checked)      { color: var(--diff-expert); border-color: var(--diff-expert); }

.size-chip { min-width: 56px; justify-content: center; }
.size-chip:has(input:checked) {
  background: var(--accent); color: var(--on-accent); border-color: var(--accent);
}
.size-chip:has(input:checked) .chip-label { color: var(--on-accent); font-weight: 700; }

/* ------- native checkbox in any plain label ------- */
input[type=checkbox], input[type=radio] {
  accent-color: var(--accent);
}

/* ------- selects ------- */
select {
  background: var(--bg-2); color: var(--fg);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 28px 8px 10px; font: inherit;
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%238b94a8' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px 6px;
  cursor: pointer;
}
select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ------- editor / page heads ------- */
/* Title + actions row.
   - When both fit on one line: title on the left, actions on the
     right (margin-left:auto absorbs the slack).
   - When they don't fit: actions wrap to a new row ABOVE the title
     and stay right-aligned. `flex-wrap: wrap-reverse` reverses the
     cross-axis stacking so the wrapped row appears above the
     original row; margin-left:auto right-aligns the actions on
     their own row (only item, so all slack goes to the left).
   This shape was reached after rejecting three earlier attempts:
   `justify-content: space-between` made the wrapped actions row
   LEFT-align (only one item to space between); a 2-column grid
   forced the title column to shrink and wrap inline content at
   mid-breadcrumb breaks; and plain `flex-wrap: wrap` put actions
   BELOW the title which read as a worse version of "buttons below
   title". */
.page-head {
  display: flex;
  flex-wrap: wrap-reverse;
  align-items: center;
  gap: 12px; margin-bottom: 12px;
}
.page-head h1 { margin: 0; font-size: 22px; }
.page-head-actions {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  margin-left: auto;
}
.page-head-actions > a,
.page-head-actions > button { white-space: nowrap; }

/* Inline "Bank: <select>" label on /stats. Overrides the global
   `label { display: block; margin: 8px 0 }` so the label text and the
   dropdown sit on one row, vertically aligned with the adjacent
   action buttons. */
.bank-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.bank-switch > select { margin-top: 0; }

/* Back-breadcrumb link that sits above the page-head h1.
   Pages with "return to this list" semantics use this rather than
   stuffing the back link into page-head-actions on the right, so the
   forward action (e.g. Resume →) stays alone on the right. */
.page-back {
  display: inline-block;
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--muted);
}
.page-back:hover { color: var(--accent); text-decoration: none; }

textarea {
  background: var(--bg-2); color: var(--fg);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; font: inherit;
  width: 100%;
  resize: vertical;
}
textarea.mono, textarea[name=code_source], textarea[name=references] {
  font-family: "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  font-size: 13px;
}
.grid-two { display: grid; grid-template-columns: 1fr 2fr; gap: 14px; }
.grid-three { display: grid; grid-template-columns: 1fr 2fr 2fr; gap: 14px; }
@media (max-width: 700px) {
  .grid-two, .grid-three { grid-template-columns: 1fr; }

  /* Slight global type shrink. Body inherits to nav/links/labels;
     headings and big KPI numbers get explicit overrides because their
     base values are in px, not rem. */
  html, body { font-size: 14px; }
  .page-head h1 { font-size: 18px; }
  .auth-card h1 { font-size: 18px; }
  .big-num,
  .kpi-num { font-size: 22px; }
  .today-stat .today-num,
  .daily-lifetime .big-num,
  .new-banner-id,
  .hub-card-count,
  .rtk-reveal-keyword { font-size: 19px; }
  .rtk-keyword { font-size: 22px; }
  .rtk-glyph { font-size: 36px; }
  .briefing-subtopic-label { font-size: 24px; }

  /* Stack the kanji glyph above the meta on mobile — the side-by-side
     grid squeezes the meta column to ~120px on phone widths. */
  .rtk-reveal-grid { grid-template-columns: 1fr; gap: 12px; justify-items: center; }
  .rtk-reveal-glyph { font-size: 80px; }
  .rtk-reveal-meta { text-align: center; }

  /* Nav: let the brand stay top-left and the nav wrap underneath when
     it can't fit. Tighter padding/gap claws back ~30px horizontally;
     nowrap per link stops "New quiz" from breaking mid-label. */
  .topbar { flex-wrap: wrap; padding: 8px 14px; gap: 8px 12px; }
  .topbar nav { margin-left: 0; flex-wrap: wrap; gap: 6px 12px; }
  .topbar nav a,
  .topbar nav button.link { white-space: nowrap; }

  /* Data tables: flatten each row into a stacked card on narrow screens.
     The 5-col by-topic / by-difficulty / by-direction tables can't fit
     horizontally at 375px. Triggers only when cells carry data-label
     (so 2-col label/value tables like 'Kanji learning state' stay as
     regular tables). First cell becomes the row's header. */
  table.data:has(td[data-label]),
  table.data:has(td[data-label]) thead,
  table.data:has(td[data-label]) tbody,
  table.data:has(td[data-label]) tr,
  table.data:has(td[data-label]) td { display: block; }
  table.data:has(td[data-label]) thead { display: none; }
  table.data:has(td[data-label]) tr {
    border: 1px solid var(--border); border-radius: 4px;
    padding: 8px 10px; margin: 0 0 8px;
  }
  table.data:has(td[data-label]) td {
    padding: 2px 0; border: 0;
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
  }
  table.data:has(td[data-label]) td::before {
    content: attr(data-label);
    color: var(--muted); font-size: 12px;
    text-transform: uppercase; letter-spacing: 0.05em;
  }
  table.data:has(td[data-label]) td:first-child {
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px; margin-bottom: 4px;
    font-weight: 600;
  }
  table.data:has(td[data-label]) td:first-child::before { display: none; }
  /* Cells without data-label (e.g. action-button columns) skip the
     label pseudo-element and stretch their content right. */
  table.data:has(td[data-label]) td:not([data-label])::before { display: none; }
  table.data:has(td[data-label]) td:not([data-label]) { justify-content: flex-end; flex-wrap: wrap; }
}

label.choice-edit {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  align-items: center;  /* single-line input → vertical-center is fine */
  margin: 6px 0;
}
/* .letter rules are shared with question/reveal — no overrides needed */

button.danger {
  background: var(--no-bg); color: var(--no);
  border: 1px solid var(--no);
  font-weight: 600;
}
button.danger:hover { background: var(--no); color: #fff; }

.delete-form {
  margin-top: 28px;
  padding: 16px; border: 1px dashed var(--no); border-radius: var(--radius);
}
.delete-form h3 { color: var(--no); margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }

.error-card {
  border-color: var(--no); background: var(--no-bg);
}
.error-card h3 { color: var(--no); margin-top: 0; }
.error-card ul { margin: 6px 0 0 18px; }
.error-card .mono { color: var(--no); }

.warn-card {
  border-color: var(--warn); background: rgba(240,180,0,0.08);
}

.link-btn {
  display: inline-block;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--fg);
  font-size: 13px;
  font-family: inherit;
  background: var(--panel);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}
.link-btn:hover {
  border-color: var(--accent);
  text-decoration: none;
}
/* Destructive variant for small inline actions like "Revoke". Keeps
   the same outline-button shape so it visually aligns with the rest
   of the link-btn family but switches to the destructive palette. */
.link-btn.danger {
  color: var(--no);
  border-color: var(--no);
  background: transparent;
}
.link-btn.danger:hover {
  background: var(--no);
  color: #fff;
}

/* ------- HTMX UI bits ------- */
.htmx-indicator {
  opacity: 0;
  transition: opacity 200ms;
  font-size: 12px;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

.match-count-wrap { margin-left: 6px; }
.match-count {
  font-size: 13px; color: var(--muted);
  padding: 4px 10px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 999px;
}
.match-count strong { color: var(--accent); }
.match-count.empty { color: var(--no); border-color: var(--no); background: var(--no-bg); }

.inline-error {
  font-size: 12px; color: var(--no);
  padding: 2px 8px;
  background: var(--no-bg); border: 1px solid var(--no);
  border-radius: 4px;
  margin-left: 4px;
}
.inline-error:empty { display: none; }

.saved-card {
  border-color: var(--ok); background: var(--ok-bg);
}
.saved-card h3 { color: var(--ok); margin-top: 0; }

/* ------- notes + flags (universal annotations) ------- */

/* "Seen N times" recap on the reveal */
.attempt-recap {
  margin: 12px 0 4px;
  font-size: 12px;
  letter-spacing: 0.02em;
}
.attempt-recap .ok { color: var(--ok); }
.attempt-recap .no { color: var(--no); }

/* Notes panel container */
.notes-panel {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.notes-panel .notes-head {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 10px;
}
.notes-panel .notes-head h3 {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.notes-panel .count-pill {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  margin-left: 4px;
}
.notes-panel .note-list {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Individual note card */
.note-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
}
.note-card.note-kind-mnemonic  { border-left-color: var(--accent); }
.note-card.note-kind-warning   { border-left-color: var(--warn); }
.note-card.note-kind-reference { border-left-color: var(--ok); }
.note-card.note-kind-general   { border-left-color: var(--muted); }

.note-card .note-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 4px;
}
.note-kind-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--border);
}
.note-kind-badge.kind-mnemonic  { color: var(--accent); border-color: var(--accent); }
.note-kind-badge.kind-warning   { color: var(--warn);   border-color: var(--warn); }
.note-kind-badge.kind-reference { color: var(--ok);     border-color: var(--ok); }
.note-kind-badge.kind-general   { color: var(--muted); }
.note-time { font-size: 11px; margin-left: auto; }

.note-body {
  line-height: 1.55;
}
.note-body > *:first-child { margin-top: 0; }
.note-body > *:last-child  { margin-bottom: 0; }
.note-body p { margin: 6px 0; }
.note-body code,
.stem code,
.ctext code,
.explanation code,
.refs code,
.walk-link-note-text code,
.study-link-note code {
  background: var(--inline-code-bg);
  color: var(--inline-code-fg);
  padding: 1px 6px;
  border: 1px solid var(--inline-code-border);
  border-radius: 4px;
  font-size: 0.92em;
  font-family: "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
}
.note-body blockquote {
  margin: 10px 0;
  padding: 8px 14px;
  background: var(--bg-2);
  border-left: 3px solid var(--border-strong);
  border-radius: 0 4px 4px 0;
  color: var(--muted);
}
.note-body blockquote > *:first-child { margin-top: 0; }
.note-body blockquote > *:last-child  { margin-bottom: 0; }
.note-body ul, .note-body ol { margin: 6px 0; padding-left: 22px; }
.note-body a { color: var(--accent); }
/* Tables: mistune's `table` plugin emits standard <table>/<thead>/<tbody>.
   Dark-theme rules with subtle borders so they read as data, not flowing
   text. */
.note-body table {
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 0.95em;
}
.note-body th, .note-body td {
  border: 1px solid var(--border-strong);
  padding: 7px 12px;
  text-align: left;
  vertical-align: top;
}
.note-body th {
  background: var(--bg-2);
  font-weight: 600;
}
.note-body tr:nth-child(even) td { background: rgba(255, 255, 255, 0.02); }
/* Task lists: emit <li>-with-<input type=checkbox disabled>. The default
   list-style bullet is redundant when each row already has a checkbox. */
.note-body ul li input[type="checkbox"] {
  margin: 0 6px 0 -2px;
  vertical-align: middle;
}
.note-body ul li input[type="checkbox"]:only-child + * { margin-left: 0; }
/* Definition lists: tighten the default browser indents. */
.note-body dl { margin: 8px 0; }
.note-body dt { font-weight: 600; margin-top: 6px; }
.note-body dd { margin: 2px 0 6px 18px; color: var(--fg); }
/* Footnotes: mistune emits a <section class="footnotes"> at the end with
   a small <ol>. Visually separate it from body prose. */
.note-body section.footnotes {
  margin-top: 14px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.9em;
  color: var(--muted);
}
.note-body section.footnotes ol { padding-left: 22px; }
.note-body sup a { text-decoration: none; }

/* Note edit / add expansion */
.note-card .note-edit { margin-top: 6px; font-size: 12px; }
.note-card .note-edit > summary {
  color: var(--muted);
  cursor: pointer;
  display: inline-block;
  padding: 2px 0;
}
.note-card .note-edit[open] > summary { color: var(--fg); }

.note-add {
  margin-top: 4px;
}
.note-add > summary {
  color: var(--muted);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  font-size: 13px;
  user-select: none;
}
.note-add > summary:hover { color: var(--fg); border-color: var(--border-strong); }
.note-add[open] > summary { color: var(--fg); border-style: solid; }
.note-add > summary .plus { color: var(--accent); font-weight: 700; }
.note-add kbd {
  font-size: 10px;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg-2);
  color: var(--muted);
}

/* Note form (used for both add and edit) */
.note-form {
  margin-top: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.note-form .note-kind-picker {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted);
  margin: 0;
}
.note-form .note-kind-picker select {
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 6px;
  font: inherit;
  font-size: 12px;
}
.note-form textarea {
  min-height: 70px;
  font-family: "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  font-size: 13px;
}
.note-form-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.note-form-actions .hint { font-size: 11px; }

/* Flag button (sits in .actions alongside Next / Edit / History) */
.flag-btn-form { display: inline; margin: 0; }
.flag-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--panel);
  color: var(--fg);
  font-size: 13px;
  cursor: pointer;
}
.flag-btn .flag-icon { font-size: 15px; line-height: 1; }
.flag-btn:hover { border-color: var(--warn); color: var(--warn); }
.flag-btn.is-flagged {
  background: rgba(240, 180, 0, 0.1);
  border-color: var(--warn);
  color: var(--warn);
}
.flag-btn.is-flagged:hover { background: rgba(240, 180, 0, 0.18); }

/* ------- difficulty ------- */
.diff {
  padding: 1px 8px; border-radius: 999px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  border: 1px solid currentColor;
  display: inline-block;
}
.diff-beginner { color: var(--diff-beginner); }
.diff-intermediate { color: var(--diff-intermediate); }
.diff-advanced { color: var(--diff-advanced); }
.diff-expert { color: var(--diff-expert); }
.chip-label.diff-beginner:has(input:checked) { color: var(--diff-beginner); border-color: var(--diff-beginner); }
.chip-label.diff-intermediate:has(input:checked) { color: var(--diff-intermediate); border-color: var(--diff-intermediate); }
.chip-label.diff-advanced:has(input:checked) { color: var(--diff-advanced); border-color: var(--diff-advanced); }
.chip-label.diff-expert:has(input:checked) { color: var(--diff-expert); border-color: var(--diff-expert); }

/* ------- choices (question + reveal + editor) ------- */

/* Single source of truth for the letter pill — used by .choice, .choice-row,
   and label.choice-edit. Flexbox centers the glyph regardless of font. */
.letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  flex-shrink: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: lowercase;
  user-select: none;
}

/* Shared row geometry: 28px letter + 12px gap + flexible text. align-items
   is start so the letter pins to the top of multi-line choices instead of
   floating to the middle. .ctext gets a small padding-top so its first
   line baseline-aligns with the letter's vertical centre. */
.choices { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

button.choice,
.choice-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  border-radius: 8px;
  font: inherit;
  text-align: left;
}
.choice .ctext,
.choice-row .ctext { padding-top: 4px; line-height: 1.5; }

button.choice {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  color: var(--fg);
  cursor: pointer;
  transition: border-color 0.08s, background 0.08s;
}
button.choice:hover { border-color: var(--accent); background: var(--bg-2); }
button.choice:hover .letter { border-color: var(--accent); color: var(--accent); }

.question.revealed { border-color: var(--border-strong); }
.question.is-correct { box-shadow: 0 0 0 1px var(--ok) inset; }
.question.is-wrong   { box-shadow: 0 0 0 1px var(--no) inset; }

.verdict {
  margin-left: auto;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.verdict.ok { background: var(--ok-bg); color: var(--ok); }
.verdict.no { background: var(--no-bg); color: var(--no); }

ul.revealed-list {
  list-style: none; padding: 0; margin: 0 0 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.choice-row {
  border: 1px solid var(--border);
  background: var(--bg-2);
}
.choice-row .letter { background: var(--panel); }
.choice-row.is-answer        { border-color: var(--ok); background: var(--ok-bg); }
.choice-row.is-answer .letter        { color: var(--ok); border-color: var(--ok); }
.choice-row.is-chosen-wrong  { border-color: var(--no); background: var(--no-bg); }
.choice-row.is-chosen-wrong .letter  { color: var(--no); border-color: var(--no); }
.choice-row.is-chosen-right .letter  { color: var(--ok); border-color: var(--ok); }

.explanation p { margin: 6px 0 0; }
.refs ul { margin: 6px 0 0 18px; padding: 0; }
.refs li { margin: 4px 0; }
.warn-tag {
  margin-left: 6px; padding: 1px 6px;
  background: var(--bg-2); color: var(--warn);
  border: 1px solid var(--warn); border-radius: 4px;
  font-size: 11px;
}

/* ============================================================
   Today card — daily-goal + answered/correct + streak. Lives in
   _TodayCard.html, included by both /setup (Quiz.css) and
   /rtk/setup (RTK.css). Stylesheet placement was originally
   RTK-only, which caused the goal bar to render with zero height
   on /setup. Moved here so it applies everywhere.
   ============================================================ */
.today-card {
  border-left: 3px solid var(--accent);
}
.today-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 10px;
}
.today-head h2 { margin: 0; }
.today-streak {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 13px;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.today-stats {
  display: flex; gap: 28px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.today-stat .today-num {
  font-size: 22px; font-weight: 700; line-height: 1.1;
}
.today-stat .today-lbl {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.today-goal-row {
  display: flex; align-items: center; gap: 12px;
  margin: 10px 0 6px;
}
.today-goal-bar {
  flex: 1; height: 6px;
  border-radius: 999px;
  background:
    linear-gradient(to right, var(--ok) 0%, var(--ok) var(--p, 0%),
                              transparent var(--p, 0%), transparent 100%),
    var(--bg-2);
  border: 1px solid var(--border);
}
.today-goal-label {
  font-size: 12px; color: var(--muted); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.today-goal-met { color: var(--ok); margin-left: 6px; font-weight: 600; }
.today-goal-edit {
  display: flex; align-items: center; gap: 8px;
  margin: 8px 0 0;
}
.today-goal-edit label { margin: 0; font-size: 12px; }

