/* ==========================================================================
   SHULE (working name) — Design System v0.1
   "Ivory & Ink": warm paper, deep Nile ink, a marigold sun.
   One file. No framework. Built to be fast on a low-spec Android phone.
   ========================================================================== */

/* ---------- 1. Tokens ---------------------------------------------------- */
:root {
  /* Paper — the warm ground everything sits on */
  --paper:   #F5F1E8;
  --paper-2: #EDE7DA;
  --card:    #FFFDF8;
  --card-2:  #FAF6EE;

  /* Ink — deep green-black, never pure black */
  --ink:   #14201C;
  --ink-2: #46524D;
  --ink-3: #78827C;
  --ink-4: #A8AEA8;

  --line:   #E5DDCC;
  --line-2: #D5CBB6;

  /* The signature palette */
  --nile:      #0F5E54;  /* brand: deep river green  */
  --marigold:  #E9A23B;  /* the sun: focus, highlight */
  --murram:    #B5482A;  /* red earth                 */
  --jacaranda: #6E56CF;  /* Kampala's purple trees    */
  --lake:      #1F5FAD;  /* Lake Victoria blue        */
  --coffee:    #7A5230;
  --savanna:   #5E7A1F;
  --kitenge:   #A62D6B;

  /* Meaning */
  --good: #2E7D57;
  --warn: #B7791F;
  --bad:  #B23A2A;

  /* The school's own colour (tenant-configurable, Ch 7.2.6) */
  --accent: var(--nile);
  --accent-ink: #FFFDF8;
  --accent-soft: color-mix(in oklab, var(--accent) 10%, var(--card));
  --accent-line: color-mix(in oklab, var(--accent) 30%, var(--line));
  --accent-deep: color-mix(in oklab, var(--accent) 78%, #000);

  --good-soft: color-mix(in oklab, var(--good) 11%, var(--card));
  --warn-soft: color-mix(in oklab, var(--marigold) 18%, var(--card));
  --bad-soft:  color-mix(in oklab, var(--bad) 10%, var(--card));

  --dock-bg: #14201C;
  --dock-fg: rgba(245, 241, 232, .62);
  --dock-active-bg: #F5F1E8;
  --dock-active-fg: #14201C;

  --shadow-1: 0 1px 0 rgba(20, 32, 28, .03), 0 1px 2px rgba(20, 32, 28, .05);
  --shadow-2: 0 1px 2px rgba(20, 32, 28, .04), 0 10px 28px -10px rgba(20, 32, 28, .16);
  --shadow-3: 0 2px 6px rgba(20, 32, 28, .08), 0 28px 64px -18px rgba(20, 32, 28, .38);

  --r-xs: 6px;
  --r-sm: 10px;
  --r:    16px;
  --r-lg: 24px;
  --r-pill: 999px;

  --f-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --f-ui:      'Geist', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --f-mono:    'Geist Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;

  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);
  --t-fast: 120ms;
  --t: 200ms;
  --t-slow: 360ms;

  --topbar-h: 60px;
  --gutter: 32px;

  color-scheme: light;
}

/* Dark — "Night on the hill" */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:   #0E1412;
    --paper-2: #0A0F0D;
    --card:    #151D1A;
    --card-2:  #1A2420;
    --ink:   #EDE8DC;
    --ink-2: #B9BDB4;
    --ink-3: #868D86;
    --ink-4: #5C645E;
    --line:   #25302C;
    --line-2: #33403B;
    --nile: #3FB39C;
    --good: #4CB884;
    --warn: #E5A645;
    --bad:  #E2685A;
    --accent-ink: #0E1412;
    --accent-deep: color-mix(in oklab, var(--accent) 60%, #000);
    --dock-bg: #1C2622;
    --dock-fg: rgba(237, 232, 220, .55);
    --dock-active-bg: #EDE8DC;
    --dock-active-fg: #0E1412;
    --shadow-1: 0 1px 0 rgba(0, 0, 0, .3);
    --shadow-2: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -10px rgba(0, 0, 0, .6);
    --shadow-3: 0 2px 6px rgba(0, 0, 0, .4), 0 28px 64px -18px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper:   #0E1412;
  --paper-2: #0A0F0D;
  --card:    #151D1A;
  --card-2:  #1A2420;
  --ink:   #EDE8DC;
  --ink-2: #B9BDB4;
  --ink-3: #868D86;
  --ink-4: #5C645E;
  --line:   #25302C;
  --line-2: #33403B;
  --nile: #3FB39C;
  --good: #4CB884;
  --warn: #E5A645;
  --bad:  #E2685A;
  --accent-ink: #0E1412;
  --accent-deep: color-mix(in oklab, var(--accent) 60%, #000);
  --dock-bg: #1C2622;
  --dock-fg: rgba(237, 232, 220, .55);
  --dock-active-bg: #EDE8DC;
  --dock-active-fg: #0E1412;
  --shadow-1: 0 1px 0 rgba(0, 0, 0, .3);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -10px rgba(0, 0, 0, .6);
  --shadow-3: 0 2px 6px rgba(0, 0, 0, .4), 0 28px 64px -18px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

/* School colours (set on <html data-accent="…">) — lighter in the dark */
:root[data-accent="jacaranda"] { --accent: var(--jacaranda); }
:root[data-accent="lake"]      { --accent: var(--lake); }
:root[data-accent="murram"]    { --accent: var(--murram); }
:root[data-accent="coffee"]    { --accent: var(--coffee); }
:root[data-accent="savanna"]   { --accent: var(--savanna); }
:root[data-accent="kitenge"]   { --accent: var(--kitenge); }
:root[data-theme="dark"][data-accent="jacaranda"] { --accent: #A08CF0; }
:root[data-theme="dark"][data-accent="lake"]      { --accent: #6AA2EC; }
:root[data-theme="dark"][data-accent="murram"]    { --accent: #E58263; }
:root[data-theme="dark"][data-accent="coffee"]    { --accent: #C99A6B; }
:root[data-theme="dark"][data-accent="savanna"]   { --accent: #A6C25A; }
:root[data-theme="dark"][data-accent="kitenge"]   { --accent: #E57AAE; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])[data-accent="jacaranda"] { --accent: #A08CF0; }
  :root:not([data-theme="light"])[data-accent="lake"]      { --accent: #6AA2EC; }
  :root:not([data-theme="light"])[data-accent="murram"]    { --accent: #E58263; }
  :root:not([data-theme="light"])[data-accent="coffee"]    { --accent: #C99A6B; }
  :root:not([data-theme="light"])[data-accent="savanna"]   { --accent: #A6C25A; }
  :root:not([data-theme="light"])[data-accent="kitenge"]   { --accent: #E57AAE; }
}

/* ---------- 2. Base ------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* Anything marked hidden stays hidden, whatever display a class gives it */
[hidden] { display: none !important; }
/* Safety net: nothing may ever widen the page sideways on a phone */
html, body { overflow-x: clip; max-width: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 14.5px;
  line-height: 1.5;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
}
img, svg { display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
h1, h2, h3, h4, p { margin: 0; }
::selection { background: color-mix(in oklab, var(--marigold) 45%, transparent); color: var(--ink); }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--marigold);
  outline-offset: 2px;
  border-radius: 6px;
}

.num, .mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.tnum { font-variant-numeric: tabular-nums; }
.serif { font-family: var(--f-display); }
.muted { color: var(--ink-3); }
.soft  { color: var(--ink-2); }
.good { color: var(--good); }
.warn { color: var(--warn); }
.bad  { color: var(--bad); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 15px; height: 15px; }
.i-lg { width: 22px; height: 22px; }

/* Smooth page-to-page navigation (Chrome 126+) */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 180ms; }
.topbar { view-transition-name: topbar; }
.dock   { view-transition-name: dock; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/* ---------- 3. Typography ------------------------------------------------ */
.eyebrow {
  font-family: var(--f-mono);
  font-size: 11.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex; align-items: center; gap: 10px;
}
.eyebrow .sep { width: 4px; height: 4px; border-radius: 50%; background: var(--ink-4); }

.display {
  font-family: var(--f-display);
  font-weight: 380;
  font-optical-sizing: auto;
  letter-spacing: -.025em;
  line-height: 1.02;
}
.h1 { font-family: var(--f-display); font-weight: 380; font-size: clamp(34px, 4.6vw, 52px); letter-spacing: -.03em; line-height: 1.02; }
.h1 em, .h2 em, .display em { font-style: italic; font-weight: 340; color: var(--accent); }
.h2 { font-family: var(--f-display); font-weight: 420; font-size: 26px; letter-spacing: -.02em; line-height: 1.15; }
.h3 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.lede { font-size: 16px; color: var(--ink-2); max-width: 60ch; }
.small { font-size: 12.5px; }
.tiny  { font-size: 11.5px; }

/* ---------- 4. App shell ------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 520px) minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding: 0 var(--gutter);
  background: color-mix(in oklab, var(--paper) 94%, transparent);
  border-bottom: 1px solid var(--line);
}
.school {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  padding: 6px 10px 6px 6px; margin-left: -6px;
  border-radius: 12px;
  transition: background var(--t-fast) var(--ease);
  justify-self: start;
  max-width: calc(100% + 6px);
}
.school:hover { background: var(--paper-2); }
.crest {
  width: 34px; height: 34px; flex: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-family: var(--f-display); font-weight: 500; font-size: 15px; letter-spacing: -.02em;
  position: relative; overflow: hidden;
  box-shadow: inset 0 0 0 1px color-mix(in oklab, #fff 14%, transparent);
}
.crest::after { /* a little marigold sun on the crest */
  content: ""; position: absolute; width: 10px; height: 10px; border-radius: 50%;
  background: var(--marigold); right: -3px; top: -3px; opacity: .95;
}
.school-txt { min-width: 0; overflow: hidden; }
.school-name { font-weight: 600; font-size: 14px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.school-meta { font-size: 11.5px; color: var(--ink-3); font-family: var(--f-mono); white-space: nowrap; }

.cmd-trigger {
  height: 40px; width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 0 8px 0 14px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink-3);
  box-shadow: var(--shadow-1);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.cmd-trigger:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); }
.cmd-trigger span { flex: 1; text-align: left; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kbd {
  font-family: var(--f-mono); font-size: 11px; color: var(--ink-3);
  padding: 2px 6px; border-radius: 6px;
  background: var(--paper); border: 1px solid var(--line);
  white-space: nowrap;
}

.top-actions { display: flex; align-items: center; gap: 6px; justify-self: end; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  color: var(--ink-2);
  position: relative;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }
.icon-btn .badge {
  position: absolute; top: 6px; right: 6px;
  min-width: 15px; height: 15px; padding: 0 4px;
  border-radius: 8px; background: var(--murram); color: #fff;
  font-size: 9.5px; font-weight: 700; display: grid; place-items: center;
  border: 2px solid var(--paper);
  box-sizing: content-box;
}
.sync-pill {
  height: 32px; display: inline-flex; align-items: center; gap: 8px;
  padding: 0 12px 0 10px; border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 500; color: var(--ink-2);
  background: var(--card); border: 1px solid var(--line);
  white-space: nowrap;
}
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.sync-pill[data-state="pending"] .sync-dot { background: var(--marigold); box-shadow: 0 0 0 3px var(--warn-soft); animation: pulse 1.4s var(--ease) infinite; }
.sync-pill[data-state="offline"] .sync-dot { background: var(--ink-4); box-shadow: 0 0 0 3px var(--paper-2); }
@keyframes pulse { 50% { transform: scale(.7); opacity: .6; } }

.avatar-btn { margin-left: 4px; }

.page {
  max-width: 1360px;
  margin: 0 auto;
  padding: 36px var(--gutter) 140px;
}

/* The Dock — our signature navigation */
.dock {
  position: fixed; z-index: 50;
  left: 50%; bottom: 18px;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px;
  padding: 6px;
  background: var(--dock-bg);
  border-radius: 22px;
  box-shadow: var(--shadow-3);
  border: 1px solid color-mix(in oklab, #fff 6%, transparent);
}
.dock-i {
  position: relative;
  width: 72px; height: 54px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border-radius: 16px;
  color: var(--dock-fg);
  font-size: 10.5px; font-weight: 500; letter-spacing: .01em;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t) var(--ease-spring);
}
.dock-i .i { width: 20px; height: 20px; }
.dock-i:hover { color: #F5F1E8; background: rgba(255, 255, 255, .07); }
.dock-i:active { transform: scale(.94); }
.dock-i[aria-current="page"] {
  background: var(--dock-active-bg);
  color: var(--dock-active-fg);
}
.dock-i[aria-current="page"]::after {
  content: ""; position: absolute; bottom: 5px; width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent);
}
.dock-i[aria-current="page"] span { opacity: 0; }
.dock-i[aria-current="page"] .i { transform: translateY(4px); }
.dock-i .i { transition: transform var(--t) var(--ease); }
.dock-sep { width: 1px; height: 28px; background: rgba(255, 255, 255, .1); margin: 0 6px; }
.dock-i .pip {
  position: absolute; top: 8px; right: 18px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--marigold); box-shadow: 0 0 0 2px var(--dock-bg);
}

/* All-modules sheet */
.apps-sheet {
  position: fixed; z-index: 49;
  left: 50%; bottom: 96px;
  width: min(720px, calc(100vw - 24px));
  transform: translateX(-50%) translateY(12px) scale(.98);
  transform-origin: bottom center;
  opacity: 0; pointer-events: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  padding: 20px;
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease);
  max-height: calc(100dvh - 140px); overflow: auto;
}
.apps-sheet.open { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0) scale(1); }
.apps-group + .apps-group { margin-top: 18px; }
.apps-group h4 { margin-bottom: 10px; }
.apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.app-tile {
  display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 10px; border-radius: 12px;
  font-size: 13px; font-weight: 500;
  transition: background var(--t-fast) var(--ease);
}
.app-tile:hover { background: var(--paper); }
.app-tile .ico {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none;
  background: var(--tint, var(--accent-soft)); color: var(--tone, var(--accent));
}
.app-tile .ico .i { width: 17px; height: 17px; }
.app-tile.off { opacity: .45; }
.app-tile small { display: block; font-size: 10.5px; color: var(--ink-3); font-weight: 400; }

/* ---------- 5. Layout helpers ------------------------------------------- */
.row { display: flex; align-items: center; gap: 12px; }
.row-top { align-items: flex-start; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: var(--stack, 16px); }
.grid { display: grid; gap: 20px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1fr) 380px; }
.span-2 { grid-column: span 2; }

/* Page header */
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 32px; flex-wrap: wrap; }
.ph .eyebrow { margin-bottom: 14px; }
.ph .lede { margin-top: 12px; }

/* ---------- 6. Surfaces -------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-1);
  min-width: 0;
}
.card-pad { padding: 22px; }
.card-h {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 22px 0;
}
.card-h .h3 { display: flex; align-items: center; gap: 8px; }
.card-b { padding: 16px 22px 22px; }
.card-f { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card.flat { box-shadow: none; }
.card.sunken { background: var(--card-2); }
.hair { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ---------- 7. Buttons --------------------------------------------------- */
.btn {
  --h: 40px;
  height: var(--h);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 16px;
  border-radius: 12px;
  font-size: 13.5px; font-weight: 550; letter-spacing: -.005em;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  user-select: none;
}
.btn:active { transform: translateY(1px) scale(.985); }
.btn .i { width: 16px; height: 16px; }
.btn-primary {
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 1px 0 color-mix(in oklab, #fff 18%, transparent) inset, 0 1px 2px rgba(0,0,0,.12), 0 6px 16px -6px color-mix(in oklab, var(--accent) 60%, transparent);
}
.btn-primary:hover { background: var(--accent-deep); }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-ink:hover { background: color-mix(in oklab, var(--ink) 86%, var(--accent)); }
.btn-ghost { background: var(--card); border-color: var(--line); color: var(--ink); box-shadow: var(--shadow-1); }
.btn-ghost:hover { border-color: var(--line-2); background: var(--card-2); }
.btn-quiet { color: var(--ink-2); }
.btn-quiet:hover { background: var(--paper-2); color: var(--ink); }
.btn-danger { background: var(--bad-soft); color: var(--bad); }
.btn-danger:hover { background: color-mix(in oklab, var(--bad) 18%, var(--card)); }
.btn-sm { --h: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 10px; }
.btn-lg { --h: 50px; padding: 0 22px; font-size: 15px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* Hold-to-confirm: consequences deserve a deliberate gesture (Ch 9.2) */
.hold {
  position: relative; overflow: hidden; isolation: isolate;
}
.hold::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--accent-deep);
  transform: scaleX(var(--p, 0)); transform-origin: left;
}
.hold.holding::before { transition: transform 1100ms linear; --p: 1; }
.hold.done::before { --p: 1; }

/* ---------- 8. Chips, tags, status -------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px;
  border-radius: var(--r-pill);
  font-size: 12px; font-weight: 500;
  background: var(--paper-2); color: var(--ink-2);
  white-space: nowrap;
}
.chip .i { width: 13px; height: 13px; }
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.chip-good { background: var(--good-soft); color: var(--good); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-bad  { background: var(--bad-soft);  color: var(--bad); }
.chip-line { background: transparent; border: 1px solid var(--line); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 500; }

/* Filter pills */
.pills { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.pills::-webkit-scrollbar { display: none; }
.pill {
  height: 32px; padding: 0 14px; border-radius: var(--r-pill);
  font-size: 13px; font-weight: 500; color: var(--ink-2);
  border: 1px solid var(--line); background: var(--card);
  white-space: nowrap;
  transition: all var(--t-fast) var(--ease);
}
.pill:hover { border-color: var(--line-2); color: var(--ink); }
.pill[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* Segmented control */
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--paper-2); border-radius: 12px;
  position: relative;
}
.seg button {
  height: 32px; padding: 0 14px; border-radius: 9px;
  font-size: 13px; font-weight: 500; color: var(--ink-3);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }

/* Tabs with a sliding ink underline */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); position: relative; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  height: 46px; padding: 0 14px;
  font-size: 14px; font-weight: 500; color: var(--ink-3);
  white-space: nowrap;
  transition: color var(--t-fast) var(--ease);
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); }
.tab .count { font-family: var(--f-mono); font-size: 11px; color: var(--ink-4); margin-left: 4px; }
.tabs-ink {
  position: absolute; bottom: -1px; height: 2px; background: var(--ink); border-radius: 2px;
  transition: transform var(--t) var(--ease), width var(--t) var(--ease);
  left: 0; width: 0;
}
.tab-panel[hidden] { display: none; }
.tab-panel { animation: rise var(--t-slow) var(--ease); }

/* ---------- 9. Data display --------------------------------------------- */
.stat { padding: 20px 22px; position: relative; overflow: hidden; }
.stat-label { font-size: 12.5px; color: var(--ink-2); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.stat-value {
  font-family: var(--f-display); font-weight: 380; font-size: 44px;
  letter-spacing: -.035em; line-height: 1; margin-top: 14px;
  font-variant-numeric: lining-nums tabular-nums;
  display: flex; align-items: baseline; gap: 6px;
}
.stat-value small { font-family: var(--f-ui); font-size: 14px; letter-spacing: 0; color: var(--ink-3); font-weight: 500; }
.stat-value .unit { font-size: 22px; color: var(--ink-3); letter-spacing: -.01em; }
.stat-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 8px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; font-family: var(--f-mono); }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.spark { width: 100%; height: 40px; margin-top: 14px; overflow: visible; }

.bar { height: 8px; border-radius: 8px; background: var(--paper-2); overflow: hidden; position: relative; }
.bar > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--accent); width: var(--w, 0%); transition: width 800ms var(--ease); }
.bar.thin { height: 5px; }

/* Hatched "still owed" pattern */
.hatch {
  background-image: repeating-linear-gradient(135deg, color-mix(in oklab, var(--marigold) 55%, transparent) 0 2px, transparent 2px 7px);
  background-color: var(--warn-soft);
}

/* Tables */
/* Wide tables swipe sideways inside their card; the page itself never moves.
   overscroll-behavior stops a swipe at the edge from dragging the page along. */
.table-wrap {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
/* Edges fade where there is more to see (set by app.js) */
.table-wrap[data-more="right"] { -webkit-mask-image: linear-gradient(to left, transparent 0, #000 40px); mask-image: linear-gradient(to left, transparent 0, #000 40px); }
.table-wrap[data-more="left"]  { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 0); mask-image: none; }
.table-wrap[data-more="both"]  { -webkit-mask-image: linear-gradient(to left, transparent 0, #000 40px); mask-image: linear-gradient(to left, transparent 0, #000 40px); }
.swipe-hint { display: none; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 500; font-size: 11.5px; color: var(--ink-3);
  font-family: var(--f-mono); text-transform: uppercase; letter-spacing: .06em;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap; position: sticky; top: 0; background: var(--card);
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--t-fast) var(--ease); }
.table tbody tr:hover { background: var(--card-2); }
.table .r { text-align: right; }
.table tr[data-href] { cursor: pointer; }

/* Avatar */
.av {
  --size: 34px;
  width: var(--size); height: var(--size); flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: calc(var(--size) * .36); font-weight: 600; letter-spacing: .01em;
  background: color-mix(in oklab, var(--tone, var(--nile)) 16%, var(--card));
  color: color-mix(in oklab, var(--tone, var(--nile)) 85%, var(--ink));
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--tone, var(--nile)) 22%, transparent);
}
.av-lg { --size: 84px; font-family: var(--f-display); font-weight: 450; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who b { font-weight: 550; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: var(--ink-3); font-size: 12px; display: block; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 14px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; padding-top: 4px; }

/* ---------- 10. Forms ---------------------------------------------------- */
.field { display: block; }
.field + .field { margin-top: 16px; }
.label { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 550; margin-bottom: 7px; }
.label a { font-weight: 500; color: var(--accent); font-size: 12.5px; }
.input {
  width: 100%; height: 48px; padding: 0 14px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line-2);
  font-size: 15px;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.input::placeholder { color: var(--ink-4); }
.input:hover { border-color: color-mix(in oklab, var(--ink) 30%, var(--line-2)); }
.input:focus { border-color: var(--marigold); box-shadow: 0 0 0 4px color-mix(in oklab, var(--marigold) 22%, transparent); outline: none; }
.input-sm { height: 38px; font-size: 13.5px; border-radius: 10px; }
.input-group { position: relative; }
.input-group .input { padding-right: 46px; }
.input-group .addon { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-family: var(--f-mono); font-size: 13px; color: var(--ink-3); pointer-events: none; }
.input-prefix .input { padding-left: 56px; }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 6px; }

.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box {
  width: 20px; height: 20px; border-radius: 6px; flex: none; margin-top: 1px;
  border: 1.5px solid var(--line-2); background: var(--card);
  display: grid; place-items: center; color: transparent;
  transition: all var(--t-fast) var(--ease);
}
.check input:checked + .box { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.check input:focus-visible + .box { outline: 2px solid var(--marigold); outline-offset: 2px; }
.check .box .i { width: 13px; height: 13px; stroke-width: 2.5; }

.search { position: relative; }
.search .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 16px; height: 16px; }
.search .input { padding-left: 38px; }

/* Toggle switch */
.switch { position: relative; width: 40px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; z-index: 1; margin: 0; }
.switch span { position: absolute; inset: 0; border-radius: 12px; background: var(--line-2); transition: background var(--t) var(--ease); }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform var(--t) var(--ease-spring); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--marigold); outline-offset: 2px; }

/* ---------- 11. Overlays ------------------------------------------------- */
.scrim {
  position: fixed; inset: 0; z-index: 80;
  background: color-mix(in oklab, #0A0F0D 42%, transparent);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t) var(--ease);
}
.scrim.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; z-index: 90; top: 10px; right: 10px; bottom: 10px;
  width: min(520px, calc(100vw - 20px));
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  display: flex; flex-direction: column;
  transform: translateX(calc(100% + 24px));
  /* Closed drawers are invisible too, so a resize or rotation never shows one gliding past */
  visibility: hidden;
  transition: transform var(--t-slow) var(--ease), visibility 0s linear var(--t-slow);
  overflow: hidden;
}
.drawer.open { transform: none; visibility: visible; transition: transform var(--t-slow) var(--ease), visibility 0s; }
.drawer-h { padding: 22px 24px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.drawer-b { padding: 22px 24px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.drawer-f { padding: 16px 24px; border-top: 1px solid var(--line); background: var(--card-2); display: flex; gap: 10px; align-items: center; }

/* Command palette */
.cmdk {
  position: fixed; z-index: 100; left: 50%; top: 12vh;
  width: min(640px, calc(100vw - 24px));
  transform: translateX(-50%) translateY(-8px) scale(.985);
  opacity: 0; pointer-events: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-3);
  overflow: hidden;
  transition: opacity var(--t-fast) var(--ease), transform var(--t) var(--ease);
}
.cmdk.open { opacity: 1; pointer-events: auto; transform: translateX(-50%); }
.cmdk-in { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.cmdk-in input { flex: 1; height: 60px; border: 0; background: transparent; font-size: 17px; outline: none; }
.cmdk-in input::placeholder { color: var(--ink-4); }
.cmdk-list { max-height: min(420px, 56vh); overflow-y: auto; padding: 8px; }
.cmdk-group { font-family: var(--f-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); padding: 12px 12px 6px; }
.cmdk-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border-radius: 12px; text-align: left;
  font-size: 14px;
}
.cmdk-item .ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--paper); color: var(--ink-2); flex: none; }
.cmdk-item .ico .i { width: 16px; height: 16px; }
.cmdk-item .meta { margin-left: auto; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.cmdk-item[aria-selected="true"] { background: var(--accent-soft); }
.cmdk-item[aria-selected="true"] .ico { background: var(--accent); color: var(--accent-ink); }
.cmdk-item mark { background: none; color: var(--accent); font-weight: 650; }
.cmdk-foot { display: flex; gap: 16px; padding: 10px 18px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--ink-3); background: var(--card-2); }
.cmdk-empty { padding: 36px; text-align: center; color: var(--ink-3); }

/* Popover */
.pop {
  position: fixed; z-index: 70;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow-3);
  padding: 16px; width: 300px;
  opacity: 0; pointer-events: none; transform: translateY(-6px);
  transition: opacity var(--t-fast) var(--ease), transform var(--t) var(--ease);
}
.pop.open { opacity: 1; pointer-events: auto; transform: none; }
.swatches { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.swatch {
  aspect-ratio: 1; border-radius: 50%; background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
  position: relative;
  transition: transform var(--t) var(--ease-spring);
}
.swatch:hover { transform: scale(1.08); }
.swatch[aria-pressed="true"]::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--ink);
}

/* Toast */
.toasts { position: fixed; z-index: 120; left: 50%; bottom: 96px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px 12px 12px; border-radius: 14px;
  background: var(--ink); color: var(--paper);
  font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-3);
  animation: toast-in var(--t-slow) var(--ease-spring);
  pointer-events: auto;
  max-width: calc(100vw - 32px);
}
.toast .ico { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--marigold); color: #14201C; flex: none; }
.toast .ico .i { width: 15px; height: 15px; stroke-width: 2.2; }
.toast.out { animation: toast-out var(--t) var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- 12. Motion -------------------------------------------------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.rise { animation: rise 520ms var(--ease) both; }
.rise-1 { animation-delay: 40ms; } .rise-2 { animation-delay: 90ms; } .rise-3 { animation-delay: 140ms; }
.rise-4 { animation-delay: 190ms; } .rise-5 { animation-delay: 240ms; } .rise-6 { animation-delay: 290ms; }

/* ---------- 13. Kitenge motif ------------------------------------------- */
.kitenge {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23fff' stroke-opacity='.13' stroke-width='1.2'%3E%3Cpath d='M28 4 52 28 28 52 4 28Z'/%3E%3Cpath d='M28 14 42 28 28 42 14 28Z'/%3E%3C/g%3E%3Cpath d='M28 23 33 28 28 33 23 28Z' fill='%23fff' fill-opacity='.16'/%3E%3Cg fill='%23fff' fill-opacity='.08'%3E%3Cpath d='M0 0h10L0 10z'/%3E%3Cpath d='M56 0v10L46 0z'/%3E%3Cpath d='M0 56V46l10 10z'/%3E%3Cpath d='M56 56H46l10-10z'/%3E%3C/g%3E%3C/svg%3E");
}
.kitenge-band {
  height: 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='10' viewBox='0 0 20 10'%3E%3Cpath d='M0 10 5 0 10 10Z' fill='%23E9A23B'/%3E%3Cpath d='M10 10 15 0 20 10Z' fill='%23B5482A'/%3E%3C/svg%3E");
  background-size: 20px 10px;
}

/* ---------- 14. Responsive ---------------------------------------------- */
@media (max-width: 1180px) {
  .g-main { grid-template-columns: minmax(0, 1fr); }
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  :root { --gutter: 20px; }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; }
  .topbar .cmd-wrap { display: none; }
  .sync-pill .label-txt { display: none; }
  .sync-pill { padding: 0 10px; }
  .g-2, .g-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .page { padding-top: 24px; }
}
@media (max-width: 640px) {
  :root { --gutter: 16px; --topbar-h: 56px; }
  body { font-size: 14px; }
  .g-4 { grid-template-columns: minmax(0, 1fr); }
  .school-meta { display: none; }
  .top-actions .hide-sm { display: none; }
  .dock {
    left: 0; right: 0; bottom: 0; transform: none;
    border-radius: 20px 20px 0 0; justify-content: space-around;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-left: 0; border-right: 0; border-bottom: 0;
  }
  .dock-i { width: auto; flex: 1; max-width: 80px; height: 58px; gap: 4px; border-radius: 14px; }
  .dock-i:hover { background: transparent; }
  /* Phone: labels always visible; the active tab gets a pill behind its icon */
  .dock-i[aria-current="page"] { background: transparent; color: #F5F1E8; }
  [data-theme="dark"] .dock-i[aria-current="page"] { color: var(--ink); }
  .dock-i[aria-current="page"] span { opacity: 1; font-weight: 650; }
  .dock-i[aria-current="page"]::after { display: none; }
  .dock-i .i { width: 52px; height: 30px; padding: 5px 16px; border-radius: 15px; box-sizing: border-box; transition: background var(--t) var(--ease), color var(--t) var(--ease); }
  .dock-i[aria-current="page"] .i { transform: none; background: var(--dock-active-bg); color: var(--dock-active-fg); }
  .dock-i .pip { top: 7px; right: calc(50% - 22px); }
  .dock-i[aria-current="page"] .pip { display: none; }
  .dock-sep { display: none; }
  .dock .hide-sm { display: none; }
  .apps-sheet { bottom: 84px; }
  .toasts { bottom: 90px; }
  .drawer { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 92dvh; border-radius: 24px 24px 0 0; transform: translateY(calc(100% + 24px)); }
  .drawer.open { transform: none; }
  .stat-value { font-size: 38px; }
  /* Tables on phones: keep every column, swipe to see them, name column stays put */
  .table-wrap .table { min-width: 600px; }
  .table-wrap .table th:first-child,
  .table-wrap .table td:first-child {
    position: sticky; left: 0; z-index: 1;
    background: var(--card);
    box-shadow: 1px 0 0 var(--line);
    max-width: 168px;
  }
  .table-wrap .table th:first-child { z-index: 3; }
  .table-wrap .table tbody tr:hover td:first-child { background: var(--card-2); }
  .table-wrap .table td:first-child .who b { max-width: 112px; }
  .swipe-hint {
    display: flex; align-items: center; gap: 6px;
    font-size: 11.5px; color: var(--ink-3); padding: 0 18px 8px;
  }
  .swipe-hint .i { width: 14px; height: 14px; animation: nudge 1.6s var(--ease) 3; }
  @keyframes nudge { 50% { transform: translateX(4px); } }
  .card-pad, .stat { padding: 18px; }
  .card-h { padding: 16px 18px 0; }
  .card-b { padding: 14px 18px 18px; }
  .ph { margin-bottom: 24px; }
}

/* ==========================================================================
   v0.2 additions — new building blocks (nothing above this line changed)
   ========================================================================== */

/* Native select, dressed to match .input */
.select {
  appearance: none; -webkit-appearance: none;
  width: 100%; height: 48px; padding: 0 40px 0 14px;
  border-radius: 12px; border: 1px solid var(--line-2); background-color: var(--card);
  font-size: 15px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2378827C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.select:focus { border-color: var(--marigold); box-shadow: 0 0 0 4px color-mix(in oklab, var(--marigold) 22%, transparent); outline: none; }
.select-sm { height: 38px; font-size: 13.5px; border-radius: 10px; }
textarea.input { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; line-height: 1.5; }

/* Form grid */
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.fgrid .full { grid-column: 1 / -1; }
.fgrid .field + .field { margin-top: 0; }
.req { color: var(--murram); margin-left: 2px; }
.opt { color: var(--ink-4); font-weight: 400; font-size: 12px; margin-left: 4px; }

/* Stepper (admissions, budget setup) */
.stepper { display: flex; gap: 6px; list-style: none; margin: 0 0 24px; padding: 0; counter-reset: st; overflow-x: auto; scrollbar-width: none; }
.stepper::-webkit-scrollbar { display: none; }
.stepper li {
  flex: 1; min-width: 120px; counter-increment: st;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  font-size: 13px; font-weight: 550; color: var(--ink-3);
  background: var(--card); border: 1px solid var(--line);
  cursor: pointer; white-space: nowrap;
  transition: all var(--t) var(--ease);
}
.stepper li::before {
  content: counter(st); width: 22px; height: 22px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-family: var(--f-mono); font-size: 11px;
  background: var(--paper-2); color: var(--ink-3);
}
.stepper li[aria-current="step"] { color: var(--ink); border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.stepper li[aria-current="step"]::before { background: var(--ink); color: var(--paper); }
.stepper li.done { color: var(--ink-2); }
.stepper li.done::before { content: "✓"; background: var(--good); color: #fff; }

/* Choice cards (big tappable options) */
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.choice {
  text-align: left; padding: 18px; border-radius: 16px;
  border: 1.5px solid var(--line); background: var(--card);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.choice:hover { border-color: var(--line-2); }
.choice:active { transform: scale(.99); }
.choice b { display: block; font-size: 15px; font-weight: 600; }
.choice span { display: block; font-size: 12.5px; color: var(--ink-3); margin-top: 4px; }
.choice[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.choice[aria-pressed="true"] b { color: var(--accent); }

/* Sticky action bar at the bottom of forms (sits above the dock) */
.actionbar {
  position: sticky; bottom: 96px; z-index: 5; margin-top: 20px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 12px 12px 18px; border-radius: 18px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-3);
}

/* Section nav (settings) */
.side-nav { position: sticky; top: calc(var(--topbar-h) + 24px); display: grid; gap: 2px; }
.side-nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  font-size: 13.5px; font-weight: 500; color: var(--ink-2);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.side-nav a:hover { background: var(--paper-2); color: var(--ink); }
.side-nav a[aria-current="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
.side-nav a .i { width: 16px; height: 16px; color: var(--ink-3); }

/* Setting rows */
.set-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 16px 0; border-top: 1px solid var(--line); }
.set-row:first-child { border-top: 0; padding-top: 4px; }
.set-row b { font-size: 14px; font-weight: 600; display: block; }
.set-row p { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }

/* Notice */
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; font-size: 13px; background: var(--card-2); border: 1px solid var(--line); color: var(--ink-2); }
.notice .i { flex: none; margin-top: 1px; color: var(--accent); }
.notice.warn { background: var(--warn-soft); border-color: color-mix(in oklab, var(--marigold) 35%, var(--line)); }
.notice.warn .i { color: var(--warn); }
.notice.bad { background: var(--bad-soft); border-color: color-mix(in oklab, var(--bad) 30%, var(--line)); }
.notice.bad .i { color: var(--bad); }

@media (max-width: 640px) {
  .fgrid, .choices { grid-template-columns: minmax(0, 1fr); }
  .actionbar { bottom: 82px; padding-left: 14px; }
  .actionbar .grow { flex-basis: 100%; }
  .actionbar .btn { flex: 1; }
}
