/* ============================================================
   NPPE Master Prep — design system
   Reader controls live on :root and are written by settings.js
   ============================================================ */

:root {
  /* Reader-adjustable (defaults; overridden from saved settings) */
  --fs: 17px;            /* base font size            15 – 24 */
  --lh: 1.65;            /* body line height        1.35 – 2.1 */
  --ls: 0em;             /* letter spacing             0 – .06 */
  --measure: 74ch;       /* max reading width        58 – 100 */
  --font-body: "Public Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: var(--font-body);
  --weight-body: 400;
  --radius: 10px;
  --radius-lg: 14px;

  /* Type scale — all relative to --fs so one slider moves everything */
  --t-xs: calc(var(--fs) * 0.72);
  --t-sm: calc(var(--fs) * 0.84);
  --t-md: var(--fs);
  --t-lg: calc(var(--fs) * 1.16);
  --t-xl: calc(var(--fs) * 1.42);
  --t-2xl: calc(var(--fs) * 1.78);
  --t-3xl: calc(var(--fs) * 2.3);

  /* Spacing — also scales gently with type size */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  --rail-w: 264px;
  --header-h: 60px;
}

/* ---------- Themes ---------- */
:root, [data-theme="paper"] {
  --bg: #F6F5F1;
  --surface: #FFFFFF;
  --surface-2: #EFEDE7;
  --surface-3: #E5E2DA;
  --ink: #17242E;
  --ink-2: #53616C;
  --ink-3: #838E97;
  --line: rgba(23, 36, 46, 0.13);
  --line-2: rgba(23, 36, 46, 0.24);
  --anchor: #0C5C66;
  --anchor-2: #0A7480;
  --anchor-soft: #E0EFF0;
  --focus: #9C4A17;
  --focus-soft: #F7E9DE;
  --ok: #1D6F45;
  --ok-soft: #DFF0E6;
  --warn: #96690F;
  --warn-soft: #F8EDD5;
  --err: #A32F2F;
  --err-soft: #F8E4E4;
  --shadow: 0 1px 2px rgba(23, 36, 46, .06), 0 6px 18px rgba(23, 36, 46, .05);
  color-scheme: light;
}

[data-theme="sepia"] {
  --bg: #F2E8D8;
  --surface: #FBF4E7;
  --surface-2: #EBDFC9;
  --surface-3: #E0D2B8;
  --ink: #33261A;
  --ink-2: #6B5844;
  --ink-3: #93816C;
  --line: rgba(51, 38, 26, 0.15);
  --line-2: rgba(51, 38, 26, 0.28);
  --anchor: #1F5E52;
  --anchor-2: #2C7A6A;
  --anchor-soft: #DDEAE2;
  --focus: #9A4A16;
  --focus-soft: #F0DFCB;
  --ok: #2A6B41;
  --ok-soft: #DFEBD9;
  --warn: #8A6410;
  --warn-soft: #F1E4C6;
  --err: #9B3A2C;
  --err-soft: #F2DFD7;
  --shadow: 0 1px 2px rgba(51, 38, 26, .07), 0 6px 18px rgba(51, 38, 26, .06);
  color-scheme: light;
}

[data-theme="ink"] {
  --bg: #0F151A;
  --surface: #161E25;
  --surface-2: #1D272F;
  --surface-3: #26323B;
  --ink: #E6E9EB;
  --ink-2: #A6B2BB;
  --ink-3: #74828C;
  --line: rgba(255, 255, 255, 0.12);
  --line-2: rgba(255, 255, 255, 0.22);
  --anchor: #59B8C4;
  --anchor-2: #7ACCD6;
  --anchor-soft: #16333A;
  --focus: #E0995C;
  --focus-soft: #38271A;
  --ok: #62C08C;
  --ok-soft: #16301F;
  --warn: #DDB055;
  --warn-soft: #332816;
  --err: #E8807C;
  --err-soft: #371E1E;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .28);
  color-scheme: dark;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--t-md);
  font-weight: var(--weight-body);
  line-height: var(--lh);
  letter-spacing: var(--ls);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 {
  font-family: var(--font-head);
  font-weight: 600;
  line-height: 1.25;
  margin: 0;
  letter-spacing: -0.01em;
}
p { margin: 0 0 var(--sp-4); }
p:last-child { margin-bottom: 0; }
button, input, select, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--anchor); }
ul, ol { margin: 0 0 var(--sp-4); padding-left: 1.35em; }
li { margin-bottom: var(--sp-2); }
li:last-child { margin-bottom: 0; }
img, svg { max-width: 100%; }
:focus-visible {
  outline: 3px solid var(--anchor);
  outline-offset: 2px;
  border-radius: 4px;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============================================================
   Shell
   ============================================================ */
.app { display: flex; min-height: 100vh; }

.rail {
  width: var(--rail-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.rail__brand {
  padding: var(--sp-5) var(--sp-4) var(--sp-4);
  border-bottom: 1px solid var(--line);
}
.rail__mark {
  font-size: var(--t-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.rail__seal {
  width: 26px; height: 26px; flex-shrink: 0;
  border: 1.5px solid var(--anchor);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: var(--anchor);
  letter-spacing: 0;
}
.rail__sub { font-size: var(--t-xs); color: var(--ink-3); margin-top: var(--sp-1); }

.rail__group { padding: var(--sp-4) var(--sp-3) 0; }
.rail__label {
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 600;
  color: var(--ink-3);
  padding: 0 var(--sp-2) var(--sp-2);
}
.navitem {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 0; background: none;
  border-radius: var(--radius);
  color: var(--ink-2);
  font-size: var(--t-sm);
  text-align: left;
  margin-bottom: 2px;
  transition: background .12s, color .12s;
}
.navitem:hover { background: var(--surface-2); color: var(--ink); }
.navitem[aria-current="page"] {
  background: var(--anchor-soft);
  color: var(--anchor);
  font-weight: 600;
}
[data-theme="ink"] .navitem[aria-current="page"] { color: var(--anchor-2); }
.navitem__icon { width: 20px; flex-shrink: 0; display: grid; place-items: center; }
.navitem__icon svg { width: 17px; height: 17px; stroke-width: 1.7; }
.navitem__text { flex: 1; min-width: 0; }
.navitem__badge {
  font-size: var(--t-xs); font-weight: 600;
  background: var(--surface-2); color: var(--ink-3);
  padding: 1px 7px; border-radius: 20px;
}
.navitem[aria-current="page"] .navitem__badge { background: var(--surface); color: var(--anchor); }

.chaprow {
  display: flex; align-items: center; gap: var(--sp-2);
  width: 100%; padding: var(--sp-2) var(--sp-3);
  border: 0; background: none; border-radius: var(--radius);
  text-align: left; font-size: var(--t-sm); color: var(--ink-2);
}
.chaprow:hover { background: var(--surface-2); }
.chaprow__dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.chaprow__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chaprow__pct { font-weight: 600; font-variant-numeric: tabular-nums; font-size: var(--t-xs); }
.rail__foot { margin-top: auto; padding: var(--sp-4) var(--sp-3); }

/* ---------- Main column ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--header-h);
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-5);
  position: sticky; top: 0; z-index: 40;
}
.topbar__title { font-size: var(--t-lg); font-weight: 600; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__menu { display: grid; }

.view { padding: var(--sp-6) var(--sp-5) var(--sp-7); }
.wrap { max-width: 1080px; margin: 0 auto; }
.wrap--read { max-width: var(--measure); margin: 0 auto; }

/* ============================================================
   Primitives
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
}
.card--flat { box-shadow: none; }
.card--pad-sm { padding: var(--sp-4); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--t-sm);
  font-weight: 500;
  transition: background .12s, border-color .12s, opacity .12s;
  text-decoration: none;
  line-height: 1.3;
}
.btn:hover { background: var(--surface-2); }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; stroke-width: 1.8; }
.btn--primary { background: var(--anchor); border-color: var(--anchor); color: #fff; }
.btn--primary:hover { background: var(--anchor-2); border-color: var(--anchor-2); }
[data-theme="ink"] .btn--primary { color: #08161A; font-weight: 600; }
.btn--focus { background: var(--focus); border-color: var(--focus); color: #fff; }
[data-theme="ink"] .btn--focus { color: #1E1207; font-weight: 600; }
.btn--ghost { background: none; border-color: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn--danger { border-color: var(--err); color: var(--err); background: none; }
.btn--danger:hover { background: var(--err-soft); }
.btn--sm { padding: 5px 11px; font-size: var(--t-xs); }
.btn--lg { padding: 13px 22px; font-size: var(--t-md); }
.btn--block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.icon-btn {
  width: 36px; height: 36px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: none; color: var(--ink-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; stroke-width: 1.8; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 30px;
  font-size: var(--t-xs); font-weight: 600;
  background: var(--surface-2); color: var(--ink-2);
  white-space: nowrap;
}
.pill--ok { background: var(--ok-soft); color: var(--ok); }
.pill--warn { background: var(--warn-soft); color: var(--warn); }
.pill--err { background: var(--err-soft); color: var(--err); }
.pill--anchor { background: var(--anchor-soft); color: var(--anchor); }
.pill--focus { background: var(--focus-soft); color: var(--focus); }

.eyebrow {
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .1em;
  font-weight: 600; color: var(--ink-3);
}
.muted { color: var(--ink-2); }
.dim { color: var(--ink-3); }
.stack > * + * { margin-top: var(--sp-4); }
.stack-sm > * + * { margin-top: var(--sp-2); }
.stack-lg > * + * { margin-top: var(--sp-6); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row--wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: var(--sp-4); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.page-head { margin-bottom: var(--sp-6); }
.page-head h1 { font-size: var(--t-2xl); margin-bottom: var(--sp-2); }
.page-head p { color: var(--ink-2); max-width: 62ch; margin: 0; }

.divider { height: 1px; background: var(--line); border: 0; margin: var(--sp-5) 0; }

.meter { height: 6px; background: var(--surface-2); border-radius: 20px; overflow: hidden; }
.meter__fill { height: 100%; border-radius: 20px; transition: width .35s ease; }

.field { display: block; }
.field__label { display: block; font-size: var(--t-sm); font-weight: 600; margin-bottom: var(--sp-2); }
.field__hint { font-size: var(--t-xs); color: var(--ink-3); margin-top: var(--sp-2); }
.input, .select, .textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font-size: var(--t-sm);
}
.textarea { min-height: 120px; resize: vertical; font-family: var(--font-mono, ui-monospace, monospace); }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; background: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 20px; background: var(--surface-3);
}
input[type="range"]::-moz-range-track { height: 5px; border-radius: 20px; background: var(--surface-3); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--anchor); border: 2px solid var(--surface);
  margin-top: -7px; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
input[type="range"]::-moz-range-thumb {
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--anchor); border: 2px solid var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.25);
}

.seg { display: inline-flex; background: var(--surface-2); border-radius: var(--radius); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg__btn {
  padding: 6px 13px; border: 0; background: none; border-radius: 7px;
  font-size: var(--t-sm); color: var(--ink-2); font-weight: 500;
}
.seg__btn[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }

.swatchset { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.swatch {
  border: 2px solid var(--line-2); border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4); background: var(--surface); text-align: left;
  font-size: var(--t-sm); min-width: 96px;
}
.swatch[aria-pressed="true"] { border-color: var(--anchor); }
.swatch__preview { font-size: var(--t-lg); margin-bottom: 2px; }

/* ============================================================
   Question / answer
   ============================================================ */
.qcard { max-width: var(--measure); margin: 0 auto; }
.qtext { font-size: var(--t-lg); line-height: calc(var(--lh) * 0.95); margin-bottom: var(--sp-5); }
.opts { display: grid; gap: var(--sp-3); }
.opt {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  width: 100%; text-align: left;
  padding: var(--sp-4);
  border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font-size: var(--t-md); line-height: var(--lh);
  transition: border-color .12s, background .12s;
}
.opt:hover:not(:disabled) { border-color: var(--anchor); background: var(--anchor-soft); }
.opt:disabled { cursor: default; }
.opt__key {
  width: 27px; height: 27px; flex-shrink: 0;
  border-radius: 50%; border: 1.5px solid var(--line-2);
  display: grid; place-items: center;
  font-size: var(--t-sm); font-weight: 600; color: var(--ink-2);
  margin-top: 1px;
}
.opt--picked { border-color: var(--anchor); background: var(--anchor-soft); }
.opt--picked .opt__key { border-color: var(--anchor); background: var(--anchor); color: #fff; }
.opt--right { border-color: var(--ok); background: var(--ok-soft); }
.opt--right .opt__key { border-color: var(--ok); background: var(--ok); color: #fff; }
.opt--wrong { border-color: var(--err); background: var(--err-soft); }
.opt--wrong .opt__key { border-color: var(--err); background: var(--err); color: #fff; }

.explain {
  margin-top: var(--sp-5); padding: var(--sp-4);
  border-left: 3px solid var(--anchor);
  background: var(--surface-2);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.explain--ok { border-left-color: var(--ok); background: var(--ok-soft); }
.explain--err { border-left-color: var(--err); background: var(--err-soft); }
.explain__head { font-weight: 600; margin-bottom: var(--sp-2); display: flex; align-items: center; gap: var(--sp-2); }

.scenario-box {
  background: var(--surface-2); border-radius: var(--radius);
  padding: var(--sp-4); margin-bottom: var(--sp-5);
  border-left: 3px solid var(--ink-3);
}

/* ============================================================
   Pomodoro
   ============================================================ */
.pomo-pill {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 5px 12px 5px 8px; border-radius: 30px;
  border: 1px solid var(--line-2); background: var(--surface);
  font-size: var(--t-sm); font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pomo-pill[data-state="focus"] { border-color: var(--focus); color: var(--focus); background: var(--focus-soft); }
.pomo-pill[data-state="break"] { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }
.pomo-pill__dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pomo-pill[data-running="true"] .pomo-pill__dot { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.pomo-panel {
  position: fixed; right: var(--sp-5); top: calc(var(--header-h) + 8px);
  width: 320px; z-index: 60;
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: var(--sp-5);
}
/* ---------- clock ---------- */
.pomo-clock {
  position: relative;
  width: min(220px, 82%);
  aspect-ratio: 1;
  margin: var(--sp-2) auto 0;
  display: grid;
  place-items: center;
}
.pomo-clock__ring { width: 100%; height: 100%; display: block; overflow: visible; }
.pomo-clock__inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 0 18%;
}
.pomo-clock__label {
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: .13em;
  font-weight: 600;
  color: var(--ink-3);
  line-height: 1.2;
}
.pomo-clock__time {
  font-size: calc(var(--fs) * 2.35);
  font-weight: 500;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--ink);
}

.pomo-task {
  display: block;
  width: 100%;
  margin: var(--sp-4) 0 0;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink);
  font-size: var(--t-sm);
  text-align: center;
}
.pomo-task::placeholder { color: var(--ink-3); }
.pomo-task:hover { border-color: var(--line-2); }
.pomo-task:focus { outline: none; border-color: var(--anchor); background: var(--surface); }

.pomo-dots { display: flex; gap: 7px; justify-content: center; margin-top: var(--sp-3); }
.pomo-dots i {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--surface-3);
  transition: background .2s;
}
.pomo-dots i.on { background: var(--focus); }

/* ============================================================
   Misc components
   ============================================================ */
.next-up {
  border: 1px solid var(--anchor);
  border-radius: var(--radius-lg);
  background: var(--anchor-soft);
  padding: var(--sp-5);
}
[data-theme="ink"] .next-up { background: var(--anchor-soft); }

.stat { padding: var(--sp-4); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.stat__val { font-size: var(--t-2xl); font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat__label { font-size: var(--t-xs); color: var(--ink-3); margin-top: var(--sp-1); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }

.tile {
  display: block; width: 100%; text-align: left;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); padding: var(--sp-4);
  transition: border-color .12s, transform .12s;
}
.tile:hover { border-color: var(--anchor); }
.tile__title { font-weight: 600; font-size: var(--t-md); }
.tile__meta { font-size: var(--t-sm); color: var(--ink-2); margin-top: var(--sp-1); }
.tile__bar { margin-top: var(--sp-3); }

.flashcard {
  perspective: 1600px; width: 100%; max-width: 620px; margin: 0 auto;
  min-height: 300px; cursor: pointer; background: none; border: 0; padding: 0;
  display: block;
}
.flashcard__inner {
  position: relative; width: 100%; min-height: 300px;
  transition: transform .5s cubic-bezier(.4,.2,.2,1); transform-style: preserve-3d;
}
.flashcard[data-flipped="true"] .flashcard__inner { transform: rotateY(180deg); }
.flashcard__face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); padding: var(--sp-6);
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center; gap: var(--sp-3);
}
.flashcard__face--back { transform: rotateY(180deg); background: var(--surface-2); }
.flashcard__term { font-size: var(--t-xl); font-weight: 600; }
.flashcard__body { font-size: var(--t-md); color: var(--ink); text-align: left; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  padding: var(--sp-3) 0 var(--sp-3) var(--sp-5);
  border-left: 2px solid var(--line); position: relative; margin: 0;
}
.timeline li::before {
  content: ""; position: absolute; left: -5px; top: 20px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--anchor);
}

.branch { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.branch__head {
  width: 100%; display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); background: var(--surface);
  border: 0; text-align: left; font-weight: 600; font-size: var(--t-md);
}
.branch__head:hover { background: var(--surface-2); }
.branch__dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.branch__body { padding: 0 var(--sp-4) var(--sp-4) calc(var(--sp-4) + 22px); background: var(--surface); }
.branch__leaf { padding: var(--sp-3) 0; border-top: 1px solid var(--line); }
.branch__leaf b { display: block; font-weight: 600; }
.branch__caret { transition: transform .2s; color: var(--ink-3); }
.branch[open] .branch__caret { transform: rotate(90deg); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
th, td { padding: var(--sp-3) var(--sp-4); text-align: left; border-bottom: 1px solid var(--line); }
th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

.callout {
  border-left: 3px solid var(--warn); background: var(--warn-soft);
  padding: var(--sp-4); border-radius: 0 var(--radius) var(--radius) 0;
}

.toast {
  position: fixed; bottom: var(--sp-5); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 11px 20px; border-radius: 30px; font-size: var(--t-sm); font-weight: 500;
  z-index: 200; box-shadow: var(--shadow); max-width: 90vw;
}

.empty { text-align: center; padding: var(--sp-7) var(--sp-4); color: var(--ink-2); }
.empty h3 { font-size: var(--t-lg); margin-bottom: var(--sp-2); color: var(--ink); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: grid; place-items: center; z-index: 150; padding: var(--sp-4);
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  max-width: 520px; width: 100%; padding: var(--sp-6);
  box-shadow: var(--shadow); max-height: 85vh; overflow-y: auto;
}

.exam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; }
.exam-grid button {
  aspect-ratio: 1; border: 1px solid var(--line-2); border-radius: 7px;
  background: var(--surface); font-size: var(--t-xs); font-weight: 600;
  display: grid; place-items: center; font-variant-numeric: tabular-nums;
}
.exam-grid button.answered { background: var(--anchor); border-color: var(--anchor); color: #fff; }
.exam-grid button.flagged { border-color: var(--warn); border-width: 2px; }
.exam-grid button.current { outline: 2px solid var(--ink); outline-offset: 1px; }

.progress-rail { height: 4px; background: var(--surface-2); position: sticky; top: var(--header-h); z-index: 30; }
.progress-rail__fill { height: 100%; background: var(--anchor); transition: width .3s; }


/* ============================================================
   Mind map canvas
   ============================================================ */
.mm-shell {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  /* Fill whatever is left below the header and the map's own title row. */
  height: clamp(440px, calc(100dvh - 210px), 940px);
}

.mm-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
  background-image: radial-gradient(circle at 1px 1px, var(--line) 1px, transparent 0);
  background-size: 26px 26px;
}
.mm-canvas.is-dragging { cursor: grabbing; }

.mm-node { cursor: pointer; }
.mm-node rect { transition: stroke-width .12s; }
.mm-node:hover rect:first-of-type { filter: brightness(1.04); stroke-width: 2.4; }
.mm-node:focus { outline: none; }
.mm-node:focus-visible rect:first-of-type { stroke-width: 3; }

.mm-toolbar {
  position: absolute; top: var(--sp-3); right: var(--sp-3); z-index: 5;
  display: flex; align-items: center; gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 3px;
  box-shadow: var(--shadow);
}
.mm-sep { width: 1px; height: 20px; background: var(--line); margin: 0 3px; }

.mm-hint {
  position: absolute; bottom: var(--sp-3); left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 30px; padding: 5px 14px;
  font-size: var(--t-xs); color: var(--ink-2);
  pointer-events: none; transition: opacity .8s; white-space: nowrap;
  max-width: 92%; overflow: hidden; text-overflow: ellipsis;
}
.mm-hint.fade { opacity: 0; }

.mm-detail {
  position: absolute; left: var(--sp-3); bottom: var(--sp-3); z-index: 5;
  width: min(340px, calc(100% - var(--sp-5)));
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: var(--sp-4);
  box-shadow: var(--shadow);
  font-size: var(--t-sm);
  max-height: 45%;
  overflow-y: auto;
}


.mm-legend {
  position: absolute; top: var(--sp-3); left: var(--sp-3); z-index: 4;
  display: flex; flex-wrap: wrap; gap: var(--sp-3);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 6px 11px;
  font-size: var(--t-xs); color: var(--ink-2);
}
.mm-legend[hidden] { display: none; }
.icon-btn[aria-pressed="true"] { background: var(--anchor-soft); color: var(--anchor); }

/* ============================================================
   Responsive layer

   Breakpoints follow real devices rather than round numbers:
     ≤ 400px   small phones (iPhone SE, compact Android)
     ≤ 640px   phones
     ≤ 1024px  tablets and small laptops — navigation becomes a drawer
     > 1024px  laptops and desktops — persistent rail
   ============================================================ */

/* Nothing may push the page sideways. */
html, body { max-width: 100%; overflow-x: hidden; }
.app, .main, .view, .wrap { min-width: 0; }
.row > * { min-width: 0; }
img, svg, table, pre { max-width: 100%; }

/* Real viewport height on mobile, where browser chrome moves. */
.app { min-height: 100vh; min-height: 100dvh; }
.rail { height: 100vh; height: 100dvh; }

/* Respect notches and home indicators. */
.rail { padding-left: env(safe-area-inset-left); }
.topbar { padding-right: max(var(--sp-5), env(safe-area-inset-right)); }
.view { padding-bottom: calc(var(--sp-7) + env(safe-area-inset-bottom)); }

.scrim { display: none; }

/* ---------- tablets, small laptops and below ---------- */
@media (max-width: 1024px) {
  .rail {
    position: fixed; left: 0; top: 0; z-index: 100;
    width: min(86vw, 300px);
    transform: translateX(-100%);
    transition: transform .24s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.28);
  }
  body.nav-open { overflow: hidden; }
  body.nav-open .rail { transform: translateX(0); }
  body.nav-open .scrim {
    display: block; position: fixed; inset: 0;
    background: rgba(0,0,0,.45); z-index: 90;
    backdrop-filter: blur(2px);
  }
  .topbar__menu { display: grid; }
  .topbar { padding-left: var(--sp-4); }
  .view { padding: var(--sp-5) var(--sp-4) var(--sp-7); }
  .pomo-panel { right: var(--sp-3); left: auto; width: min(320px, calc(100vw - var(--sp-5))); }
  .mm-shell { height: clamp(420px, calc(100dvh - 190px), 760px); }
}

/* ---------- phones ---------- */
@media (max-width: 640px) {
  :root { --header-h: 54px; }

  .view { padding: var(--sp-4) var(--sp-3) var(--sp-7); }
  .topbar { padding-left: var(--sp-3); padding-right: max(var(--sp-3), env(safe-area-inset-right)); gap: var(--sp-2); }
  .topbar__title { font-size: var(--t-md); }

  .card { padding: var(--sp-4); }
  .next-up { padding: var(--sp-4); }
  .page-head h1 { font-size: var(--t-xl); }

  /* One column everywhere — two 150px cards side by side is unreadable. */
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
  .grid { gap: var(--sp-3); }

  /* Stats stay two-up: they are short enough to pair. */
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: var(--sp-3); }
  .stat__val { font-size: var(--t-xl); }

  .btn { padding: 10px 14px; }
  .btn--lg { padding: 12px 18px; font-size: var(--t-sm); }
  .btn--block, .row--wrap > .btn { flex: 1 1 auto; }

  .opt { padding: var(--sp-3); gap: var(--sp-2); }
  .opt__key { width: 24px; height: 24px; }
  .qtext { font-size: var(--t-md); }

  .seg { width: 100%; }
  .seg__btn { flex: 1 1 auto; padding: 8px 10px; }
  .select, .input { min-width: 0; width: 100%; }
  .row label.row { width: 100%; }

  th, td { padding: var(--sp-2) var(--sp-3); }

  .flashcard, .flashcard__inner, .flashcard__face { min-height: 260px; }
  .flashcard__face { padding: var(--sp-4); }
  .flashcard__term { font-size: var(--t-lg); }

  .modal { padding: var(--sp-4); max-height: 88dvh; }
  .toast { left: var(--sp-3); right: var(--sp-3); transform: none; text-align: center; }

  .pomo-panel { left: var(--sp-3); right: var(--sp-3); width: auto; }

  .mm-shell { height: clamp(380px, calc(100dvh - 170px), 640px); }
  .mm-hint { display: none; }
  .mm-legend { position: static; margin-bottom: var(--sp-2); border: 0; background: none; padding: 0; justify-content: center; }
  .mm-detail { left: var(--sp-2); right: var(--sp-2); bottom: var(--sp-2); width: auto; max-height: 52%; }
  .mm-toolbar { top: var(--sp-2); right: var(--sp-2); }

  .exam-grid { grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); }
}

/* ---------- small phones ---------- */
@media (max-width: 400px) {
  .grid--4 { grid-template-columns: 1fr; }
  .rail { width: 90vw; }
  .pill { font-size: 11px; padding: 2px 8px; }
  .mm-toolbar { padding: 2px; }
  .icon-btn { width: 34px; height: 34px; }
}

/* ---------- phones held sideways ---------- */
@media (max-height: 520px) and (orientation: landscape) {
  .mm-shell { height: calc(100dvh - 130px); min-height: 260px; }
  .flashcard, .flashcard__inner, .flashcard__face { min-height: 200px; }
  .view { padding-top: var(--sp-3); }
}

/* ---------- touch devices ---------- */
@media (pointer: coarse) {
  .btn, .seg__btn, .navitem, .chaprow, .opt { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .mm-toolbar .icon-btn { width: 40px; height: 40px; }
  input[type="range"] { height: 34px; }
  input[type="range"]::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: -9px; }
  input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; }
  /* Hover styling sticks after a tap on touch screens. */
  .tile:hover { border-color: var(--line); }
  .opt:hover:not(:disabled) { border-color: var(--line); background: var(--surface); }
}

/* ---------- very wide screens ---------- */
@media (min-width: 1600px) {
  .wrap { max-width: 1180px; }
  .mm-shell { height: clamp(560px, calc(100dvh - 220px), 1040px); }
}

/* ---------- print ---------- */
@media print {
  .rail, .topbar, .scrim, .pomo-panel, .mm-toolbar, .mm-hint, .toast,
  .btn, .icon-btn, .progress-rail { display: none !important; }
  .app { display: block; }
  .view { padding: 0; }
  .card, .mm-shell { break-inside: avoid; border-color: #999; }
  body { background: #fff; color: #000; }
  a[href]::after { content: ""; }
}

/* ============================================================
   Collapsible sidebar (wide screens)
   ============================================================ */
.rail {
  transition: width .22s ease, opacity .18s ease;
}
body.rail-collapsed .rail {
  width: 0;
  min-width: 0;
  opacity: 0;
  overflow: hidden;
  border-right: 0;
  pointer-events: none;
}
/* Below the drawer breakpoint the rail is already an overlay, so collapsing
   it there would fight the drawer. Let the drawer rules win. */
@media (max-width: 1024px) {
  body.rail-collapsed .rail {
    width: min(86vw, 300px);
    min-width: 0;
    opacity: 1;
    overflow-y: auto;
    pointer-events: auto;
  }
}

/* ============================================================
   Pinned focus timer
   ============================================================ */
.pomo-panel--docked {
  position: fixed;
  right: 0;
  top: var(--header-h);
  bottom: 0;
  left: auto;
  width: 312px;
  border-radius: 0;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  border-left: 1px solid var(--line-2);
  box-shadow: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: calc(var(--sp-5) + env(safe-area-inset-bottom));
}
/* Make room so the timer sits beside the work rather than over it. */
body.pomo-docked .main { padding-right: 312px; }

/* Not enough width to give up 312px — overlay instead, still pinned open. */
@media (max-width: 1180px) {
  body.pomo-docked .main { padding-right: 0; }
  .pomo-panel--docked { box-shadow: var(--shadow); width: min(312px, 90vw); }
}
@media (max-width: 640px) {
  .pomo-panel--docked {
    top: auto;
    left: 0; right: 0;
    width: auto;
    max-height: 76dvh;
    border-left: 0;
    border-top: 1px solid var(--line-2);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}

/* ============================================================
   Inline duration controls
   ============================================================ */
.pomo-chip {
  padding: 7px 4px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--t-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: border-color .12s, background .12s, color .12s;
}
.pomo-chip:hover { background: var(--surface-2); color: var(--ink); }
.pomo-chip[aria-pressed="true"] {
  border-color: var(--focus);
  background: var(--focus-soft);
  color: var(--focus);
}
.pomo-custom {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 0 10px;
  background: var(--surface);
}
.pomo-custom input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  padding: 8px 0;
  font-size: var(--t-md);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  -moz-appearance: textfield;
}
.pomo-custom input::-webkit-outer-spin-button,
.pomo-custom input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pomo-custom input:focus { outline: none; }
.pomo-custom:focus-within { border-color: var(--anchor); }
.pomo-custom span { font-size: var(--t-xs); color: var(--ink-3); }

/* The pill is the way in, so make it read as a control. */
.pomo-pill { cursor: pointer; transition: border-color .12s, background .12s; }
.pomo-pill:hover { border-color: var(--focus); }

/* ============================================================
   Tile layout — footers pinned to the bottom so cards in a row
   line up regardless of how long their descriptions are, and
   pills wrap instead of spilling past the card edge.
   ============================================================ */
.tile--col {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.tile__eyebrow {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-2);
  min-width: 0;
}
/* Keep descriptions to a fixed depth so the footers align. */
.tile__clamp {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile__foot {
  margin-top: auto;
  padding-top: var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  min-width: 0;
}
.tile__counts {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--t-xs);
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile__foot .pill { flex: 0 0 auto; }

/* Nothing in a pill row may push past its container. */
.pill { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.row--wrap { flex-wrap: wrap; }

/* Grid children stretch so .tile--col can fill its track. */
.grid > .tile { align-self: stretch; }

@media (max-width: 640px) {
  .tile__clamp { -webkit-line-clamp: 4; line-clamp: 4; }
  .tile__foot { padding-top: var(--sp-3); }
}

/* ============================================================
   Focus timer panel — sections, chips, options, swatches
   ============================================================ */
.pomo-section { margin-top: var(--sp-4); }
.pomo-section__head {
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: .11em;
  font-weight: 600;
  color: var(--ink-3);
  margin-bottom: var(--sp-2);
}

.pomo-chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
  gap: 6px;
}
.pomo-chip {
  padding: 8px 4px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--t-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: border-color .12s, background .12s, color .12s;
}
.pomo-chip:hover { background: var(--surface-2); color: var(--ink); }
.pomo-chip[aria-pressed="true"] {
  border-color: var(--focus);
  background: var(--focus-soft);
  color: var(--focus);
}

.pomo-step {
  width: 36px; height: 36px;
  flex-shrink: 0;
  border: 1px solid var(--line-2);
  font-size: var(--t-lg);
  line-height: 1;
}

.pomo-option {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  margin-bottom: 6px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  transition: border-color .12s, background .12s;
}
.pomo-option:last-child { margin-bottom: 0; }
.pomo-option:hover { background: var(--surface-2); }
.pomo-option > span { flex: 1; min-width: 0; }
.pomo-option b { display: block; font-size: var(--t-sm); font-weight: 600; }
.pomo-option em {
  display: block;
  font-style: normal;
  font-size: var(--t-xs);
  color: var(--ink-3);
}
.pomo-option[aria-pressed="true"] {
  border-color: var(--ok);
  background: var(--ok-soft);
}
.pomo-option[aria-pressed="true"] b { color: var(--ok); }
.pomo-option svg { color: var(--ok); flex-shrink: 0; }

.pomo-swatches { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.pomo-swatch {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: 0 0 0 1px var(--line) inset;
  display: grid;
  place-items: center;
  color: #fff;
  transition: transform .12s, border-color .12s;
}
.pomo-swatch:hover { transform: scale(1.08); }
.pomo-swatch[aria-pressed="true"] { border-color: var(--ink); }

.pomo-more {
  margin-top: var(--sp-4);
  border-top: 1px solid var(--line);
  padding-top: var(--sp-3);
}
.pomo-more > summary {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--ink-2);
  list-style: none;
  padding: 4px 0;
}
.pomo-more > summary::-webkit-details-marker { display: none; }
.pomo-more > summary::after {
  content: "";
  margin-left: auto;
  width: 7px; height: 7px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg);
  transition: transform .2s;
}
.pomo-more[open] > summary::after { transform: rotate(-135deg); }
.pomo-more > summary:hover { color: var(--ink); }

/* The panel is taller now, so let it scroll when floating on a short window. */
.pomo-panel { max-height: calc(100dvh - var(--header-h) - 24px); overflow-y: auto; overscroll-behavior: contain; }

/* ============================================================
   Timer controls: the whole button must be clickable

   Without this, clicking the icon inside a button makes the icon the event
   target. That mostly works, but the moment a control redraws itself — Pause
   swapping its label, a preset rebuilding the panel — the icon is detached
   and the click can no longer be traced back to its button. The result is a
   button that responds in some places and not others. Making the contents
   pointer-transparent means the target is always the control.
   ============================================================ */
.pomo-pill > *,
.pomo-panel [data-pomo] > *,
.pomo-panel [data-pomo] svg,
.pomo-panel [data-pomo] svg * {
  pointer-events: none;
}

/* The panel's own inputs must stay interactive. */
.pomo-panel input,
.pomo-panel summary,
.pomo-panel summary * {
  pointer-events: auto;
}

/* Nothing overlaps the clock's controls. */
.pomo-clock__inner { pointer-events: none; }
.pomo-clock__ring { pointer-events: none; }

/* ============================================================
   Diagnostic banner
   ============================================================ */
.app-banner {
  position: fixed;
  left: 50%;
  bottom: max(var(--sp-4), env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  width: min(680px, calc(100vw - var(--sp-5)));
  padding: var(--sp-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-2);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: var(--t-sm);
  line-height: 1.5;
  max-height: 40dvh;
  overflow-y: auto;
}
.app-banner__body { flex: 1; min-width: 0; }
.app-banner__body strong { display: block; margin-bottom: 4px; }
.app-banner code {
  font-size: var(--t-xs);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  word-break: break-all;
}
.app-banner ul { padding-left: 1.2em; }
.app-banner--warn { border-left: 4px solid var(--warn); }
.app-banner--warn strong { color: var(--warn); }
.app-banner--err { border-left: 4px solid var(--err); }
.app-banner--err strong { color: var(--err); }

/* ============================================================
   Flashcard hit-testing

   The two faces are stacked in the same box and flipped in 3D. Browsers do
   not agree on whether a hidden backface should still receive clicks, and
   when it does, the face you cannot see swallows every tap and the card
   appears frozen. Only the face currently showing is clickable.
   ============================================================ */
.flashcard__face { pointer-events: none; }
.flashcard[data-flipped="false"] .flashcard__face:not(.flashcard__face--back),
.flashcard[data-flipped="true"] .flashcard__face--back { pointer-events: auto; }
.flashcard__face * { pointer-events: none; }

/* Nothing decorative may sit over a control. */
.tile > *, .stat > * { pointer-events: none; }
.pomo-clock { pointer-events: none; }

/* ============================================================
   Sign-in gate
   ============================================================ */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  background: var(--bg);
  overflow-y: auto;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  box-shadow: var(--shadow);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.auth-brand strong { display: block; font-size: var(--t-lg); }
.auth-brand span { display: block; font-size: var(--t-sm); color: var(--ink-2); }
.auth-note {
  font-size: var(--t-sm);
  color: var(--ink-2);
  background: var(--surface-2);
  padding: var(--sp-3);
  border-radius: var(--radius);
  margin-bottom: var(--sp-4);
}
.auth-error {
  margin-top: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--radius);
  background: var(--err-soft);
  color: var(--err);
  font-size: var(--t-sm);
  border-left: 3px solid var(--err);
}
.auth-error[hidden] { display: none; }
.auth-foot {
  margin: var(--sp-5) 0 0;
  font-size: var(--t-xs);
  color: var(--ink-3);
  text-align: center;
}
.auth-card code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: .92em;
}

/* ============================================================
   Sync indicator
   ============================================================ */
.sync-badge {
  font-size: var(--t-xs);
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 30px;
  white-space: nowrap;
  border: 1px solid var(--line-2);
  color: var(--ink-3);
  background: var(--surface);
}
.sync-badge[data-state="saved"],
.sync-badge[data-state="idle"] { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.sync-badge[data-state="saving"] { color: var(--anchor); border-color: var(--anchor); background: var(--anchor-soft); }
.sync-badge[data-state="error"] { color: var(--err); border-color: var(--err); background: var(--err-soft); }
.sync-badge[hidden] { display: none; }

@media (max-width: 640px) {
  .sync-badge { display: none; }
  .auth-card { padding: var(--sp-5); }
}

/* ============================================================
   Account block in the sidebar
   ============================================================ */
.rail__account {
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line);
}
.rail__account[hidden] { display: none; }

.rail__who {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  min-width: 0;
}
.rail__avatar {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--anchor);
  color: #fff;
  font-size: var(--t-sm);
  font-weight: 700;
}
[data-theme="ink"] .rail__avatar { color: #08161A; }
.rail__whotext { min-width: 0; line-height: 1.3; }
.rail__whotext strong {
  display: block;
  font-size: var(--t-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail__whotext span {
  display: block;
  font-size: var(--t-xs);
  color: var(--ink-3);
}
.rail__whotext span[data-state="saving"] { color: var(--anchor); }
.rail__whotext span[data-state="error"] { color: var(--err); }
.rail__account .navitem { color: var(--ink-2); }
.rail__account .navitem:hover { color: var(--err); background: var(--err-soft); }
