/*
 * Pennyrow shared stylesheet: /books/books.css
 * Used by /books/ (the app), /books/verify/ and /books/licenses/.
 *
 * Rules this file keeps (see source/books/SPEC.md):
 *   - No web fonts and no external resources: system font stacks only, no url() to anything.
 *   - Works at 390px wide with no horizontal page scroll. Wide tables scroll inside .tbl-wrap.
 *   - Dark by default (Factory family look). A light palette is available with
 *     <html data-theme="light">. Printing always switches to black on white.
 *   - WCAG 2.2 AA target: text tokens below are at least 4.5:1 on --bg, --panel and --card;
 *     focus is always visible; status is never colour-only (badges carry a symbol and words).
 *
 * Class reference (all optional; combine freely)
 *   Layout     .wrap  .wrap.doc (narrow reading width)  .stack  .row  .sp (flex spacer)  .grid  .cards
 *   Header     .top  .brand  .mark (logo square)  .back  .eyebrow  .lede  .nav (top links)
 *   Tabs       .tabs > button[aria-selected="true"]  (scrolls sideways inside itself on phones)
 *   Surfaces   .panel  .card  .box (details/summary)  .lock (privacy box)  .callout(.ok|.warn|.bad)
 *   Text       .muted  .dim  .small  .mono  .num (right-aligned tabular figures)  .nowrap  .k (small caps label)
 *   Buttons    .btn  .btn.primary  .btn.ghost  .btn.danger  .btn.sm  .btn.lg  .linkbtn (looks like a link)
 *   Forms      .field > span + input/select   .input  .check (checkbox + label)  .search
 *   Drop zone  .drop  .drop.over  .drop-ic  .drop-t  .drop-s
 *   Status     .status (put aria-live="polite" on it)  .status.err  .status.ok
 *   Badges     .badge.ok (✓ Balanced)  .badge.warn (⚠ Row 12 is off by $40.00)  .badge.bad  .badge.muted (– No balances)
 *              .badge.info  .badge.accent  .chip (pill button, e.g. File history)  .chip[aria-expanded="true"]
 *   Tables     .tbl-wrap > table.tbl ; th/td ; td.num ; tr.is-bad ; tr.is-muted ; tfoot .total ; .tbl .cell (inputs in cells)
 *   P&L        table.tbl.pnl ; tr.group (section heading row) ; tr.total ; .lineref ("Line 18")
 *   Checklist  .checks > .check-card (.ok|.warn) > .check-n + .check-t
 *   Footer     footer.site-footer
 *   Doc pages  .doc h2/h3/p/ul/ol ; ol.steps ; pre.code ; pre.license ; .toc ; dl.defs ; dl.kv ; ul.cardlist ; kbd
 *   Misc       .toast(.on)  .sr-only  .skip-link  .no-print  .print-only
 */

/* ---------- Design tokens ---------- */
:root {
  color-scheme: dark;

  /* surfaces */
  --bg: #0C0D10;
  --panel: #14161B;
  --card: #1A1D23;
  --card2: #22262E;
  --hover: #2A2F38;
  --line: #2A2E37;
  --line2: #3A3F4A;
  --field-line: #6B7280;     /* form-field outlines: at least 3:1 on bg, panel, card and card2 (WCAG 1.4.11) */

  /* text */
  --fg: #F2F3F5;
  --muted: #A3A9B5;
  --dim: #8B92A1;

  /* Pennyrow teal accent (distinct from Sub Killer's red) */
  --accent: #3ED6C0;
  --accent-hover: #6BE3D2;
  --accent-ink: #03211D;      /* text on an --accent background */
  --accent-bg: #0D2623;
  --accent-line: #1D4C45;
  --accent-text: #7EE8D8;     /* accent-coloured text on dark surfaces */

  /* status (always paired with a symbol and words, never colour alone) */
  --ok: #4ADE9B;
  --ok-bg: #102419;
  --ok-line: #1F4A37;
  --warn: #FFB547;
  --warn-bg: #2B2112;
  --warn-line: #5B4416;
  --bad: #FF8A95;
  --bad-bg: #2A1318;
  --bad-line: #5A2029;
  --info: #8FB4FF;
  --info-bg: #14223D;
  --info-line: #2A4170;

  --focus: #FFD166;

  /* type */
  --font: -apple-system, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --fs: 15px;
  --fs-sm: 13.5px;
  --fs-xs: 12.5px;

  /* shape and space */
  --r-lg: 18px;
  --r: 14px;
  --r-sm: 10px;
  --r-xs: 7px;
  --gutter: 16px;
  --maxw: 1040px;
  --maxw-doc: 760px;
  --tap: 44px;               /* comfortable touch target */
}

/* Optional light palette: <html data-theme="light"> */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F7F8FA;
  --panel: #FFFFFF;
  --card: #FFFFFF;
  --card2: #EEF0F3;
  --hover: #E4E7EC;
  --line: #D9DDE3;
  --line2: #C3C9D2;
  --field-line: #6B7280;
  --fg: #111418;
  --muted: #4B5361;
  --dim: #5C6472;
  --accent: #0F766E;
  --accent-hover: #0B5F59;
  --accent-ink: #FFFFFF;
  --accent-bg: #E3F5F2;
  --accent-line: #9ED9CF;
  --accent-text: #0B5F59;
  --ok: #146C43;
  --ok-bg: #E5F5EC;
  --ok-line: #A6D9BC;
  --warn: #8A5300;
  --warn-bg: #FFF4DE;
  --warn-line: #F0CF8C;
  --bad: #B42335;
  --bad-bg: #FDECEE;
  --bad-line: #F2B8C0;
  --info: #1F4FB3;
  --info-bg: #E8EFFD;
  --info-line: #B5C9F3;
  --focus: #B45309;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 0;
  background: var(--bg);
  color: var(--fg);
  font: var(--fs)/1.5 var(--font);
  overflow-wrap: break-word;
  -webkit-tap-highlight-color: transparent;
}

:root:not([data-theme="light"]) body {
  background:
    radial-gradient(900px 420px at 85% -160px, #0E3530 0%, rgba(12, 13, 16, 0) 70%) no-repeat,
    var(--bg);
}

a { color: var(--accent-text); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

img, svg, canvas { max-width: 100%; height: auto; }

button, input, select, textarea { font: inherit; color: inherit; }

h1, h2, h3, h4 { line-height: 1.15; margin: 0; }
h1 { font-size: 40px; font-weight: 800; letter-spacing: -1px; }
h2 { font-size: 22px; font-weight: 750; letter-spacing: -0.3px; }
h3 { font-size: 17px; font-weight: 700; }
h4 { font-size: 15px; font-weight: 700; }
p { margin: 0; }

code, kbd, pre, samp { font-family: var(--mono); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

::selection { background: var(--accent); color: var(--accent-ink); }

/* ---------- Layout ---------- */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 22px var(--gutter) 64px;
}
.wrap.doc { max-width: var(--maxw-doc); }

.stack { display: flex; flex-direction: column; gap: 14px; }
.stack.tight { gap: 8px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row.nowrap { flex-wrap: nowrap; }
.sp { flex: 1 1 auto; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
main { display: block; min-width: 0; }

/* ---------- Header ---------- */
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--fg);
  text-decoration: none;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.3px;
}
.brand:hover { color: var(--fg); }
.mark {
  display: inline-block;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background:
    linear-gradient(var(--accent-ink), var(--accent-ink)) 6px 7px / 14px 2.5px no-repeat,
    linear-gradient(var(--accent-ink), var(--accent-ink)) 6px 12px / 9px 2.5px no-repeat,
    linear-gradient(var(--accent-ink), var(--accent-ink)) 6px 17px / 12px 2.5px no-repeat,
    var(--accent);
}
.back, .nav a { font-size: var(--fs-sm); white-space: nowrap; }
.nav { display: flex; flex-wrap: wrap; gap: 4px 14px; }

.eyebrow {
  font: 600 12px/1.4 var(--mono);
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--accent-text);
}
.lede {
  color: var(--muted);
  font-size: 16px;
  margin-top: 10px;
  max-width: 600px;
}

/* ---------- Tabs (app screens) ---------- */
.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
  border-bottom: 1px solid var(--line);
  margin: 6px 0 16px;
  padding-bottom: 0;
}
.tabs button, .tabs a {
  flex: 0 0 auto;
  min-height: var(--tap);
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  font-size: 14px;
  padding: 10px 12px 8px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.tabs button:hover, .tabs a:hover { color: var(--fg); }
.tabs [aria-selected="true"], .tabs [aria-current="page"] {
  color: var(--fg);
  border-bottom-color: var(--accent);
}
.tabs .count {
  display: inline-block;
  min-width: 20px;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--card2);
  color: var(--fg);
  font-size: 12px;
  text-align: center;
}

/* ---------- Surfaces ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  min-width: 0;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  min-width: 0;
}
.panel > h2 + *, .card > h3 + * { margin-top: 8px; }

details.box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 14px;
}
details > summary {
  cursor: pointer;
  font-weight: 650;
  list-style: none;
  min-height: 28px;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸ "; color: var(--muted); }
details[open] > summary::before { content: "▾ "; }
details.box[open] > summary { margin-bottom: 8px; }

.lock {
  background: var(--ok-bg);
  border: 1px solid var(--ok-line);
  border-radius: var(--r);
  padding: 12px 14px;
  font-size: 14px;
  color: var(--fg);
}
.lock b, .lock strong { color: var(--fg); }
.lock a { color: var(--ok); }

.callout {
  background: var(--info-bg);
  border: 1px solid var(--info-line);
  border-radius: var(--r);
  padding: 12px 14px;
  font-size: 14px;
}
.callout.ok { background: var(--ok-bg); border-color: var(--ok-line); }
.callout.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.callout.bad { background: var(--bad-bg); border-color: var(--bad-line); }
.callout.accent { background: var(--accent-bg); border-color: var(--accent-line); }
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }

/* ---------- Text helpers ---------- */
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: var(--fs-sm); }
.xsmall { font-size: var(--fs-xs); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--ok); }
.neg { color: var(--fg); }
.k {
  font: 600 12px/1.4 var(--mono);
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--muted);
}
.big {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 16px;
  background: var(--card2);
  color: var(--fg);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.15;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--hover); color: var(--fg); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: var(--line2); color: var(--fg); }
.btn.ghost:hover { background: var(--card); }
.btn.danger { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
.btn.danger:hover { background: var(--bad-line); color: var(--fg); }
.btn.danger.armed { background: var(--bad); color: #1B0508; }
.btn.sm { min-height: 36px; padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn.lg { min-height: 52px; padding: 14px 22px; font-size: 16px; border-radius: 13px; }
.btn.block { display: flex; width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.linkbtn {
  border: 0;
  padding: 2px 0;
  background: none;
  color: var(--accent-text);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  font-size: inherit;
}
.linkbtn:hover { color: var(--accent-hover); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span, .field > label { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.input,
.field input, .field select, .field textarea,
input[type="text"], input[type="search"], input[type="number"], input[type="password"], input[type="date"],
select, textarea {
  min-height: 40px;
  width: 100%;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--field-line);
  border-radius: 9px;
  padding: 8px 10px;
  color: var(--fg);
}
[aria-invalid="true"], .tbl .cell[aria-invalid="true"] { border-color: var(--bad) !important; background: var(--bad-bg) !important; }
/* iPhone Safari zooms into any field under 16px and doesn't zoom back */
@media (max-width: 600px) {
  input, select, textarea, .tbl .cell { font-size: 16px; }
}
textarea { min-height: 80px; resize: vertical; }
select { padding-right: 28px; }
input::placeholder, textarea::placeholder { color: var(--dim); opacity: 1; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--accent); }
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  font-size: var(--fs-sm);
  cursor: pointer;
}
.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
.search { max-width: 360px; }

/* ---------- Drop zone ---------- */
.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  border: 2px dashed var(--line2);
  border-radius: var(--r-lg);
  padding: 30px 16px;
  background: var(--panel);
  transition: border-color .2s, background-color .2s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-bg); }
.drop-ic { font-size: 30px; line-height: 1; }
.drop-t { font-weight: 800; font-size: 19px; }
.drop-s { color: var(--muted); font-size: var(--fs-sm); }

/* ---------- Status line ---------- */
.status { min-height: 20px; font-size: var(--fs-sm); color: var(--muted); }
.status.err { color: var(--bad); }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }

/* ---------- Badges and chips ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line2);
  background: var(--card2);
  color: var(--fg);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.badge.ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.badge.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.badge.bad { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
.badge.info { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }
.badge.accent { background: var(--accent-bg); border-color: var(--accent-line); color: var(--accent-text); }
.badge.muted { background: transparent; border-color: var(--line2); color: var(--muted); }
.badge.wrap { white-space: normal; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  border: 1px solid var(--line2);
  background: var(--card);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-expanded="true"], .chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-bg); }
.chip small { color: var(--muted); font-weight: 500; font-size: 12px; }

/* ---------- Tables ---------- */
.tbl-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
}
.tbl-wrap:focus-visible { outline-offset: 0; }
.tbl-wrap.tall { max-height: 70vh; overflow-y: auto; }
table.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.tbl caption {
  caption-side: top;
  text-align: left;
  padding: 10px 12px 4px;
  color: var(--muted);
  font-size: var(--fs-sm);
}
.tbl th, .tbl td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.tbl thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--card);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
}
.tbl tbody th { font-weight: 600; }
.tbl tbody tr:hover > * { background: var(--card); }
.tbl tbody tr:last-child > * { border-bottom: 0; }
.tbl th.num, .tbl td.num { text-align: right; }
.tbl tr.is-bad > * { background: var(--bad-bg); }
.tbl tr.is-bad > :first-child { box-shadow: inset 3px 0 0 var(--bad); }
.tbl tr.is-warn > * { background: var(--warn-bg); }
.tbl tr.is-muted > * { color: var(--muted); }
.tbl tr.is-muted .strike, .tbl .strike { text-decoration: line-through; }
.tbl .desc { min-width: 180px; }
.tbl .cell {
  min-height: 34px;
  padding: 5px 7px;
  border-radius: 7px;
  background: transparent;
  border: 1px solid transparent;
}
.tbl .cell:hover { border-color: var(--line2); }
/* touch screens have no hover: show the editable cells as fields */
@media (hover: none) {
  .tbl .cell { border-color: var(--field-line); background: var(--bg); }
}
.tbl .cell:focus-visible { background: var(--bg); border-color: var(--accent); }
.tbl .cell.num { text-align: right; }
.tbl tfoot td, .tbl tfoot th, .tbl tr.total > * {
  font-weight: 800;
  border-top: 2px solid var(--line2);
  border-bottom: 0;
  background: var(--card);
}

/* P&L */
.tbl.pnl tr.group > * {
  background: var(--card2);
  color: var(--fg);
  font-weight: 750;
  font-size: var(--fs-sm);
}
.tbl.pnl tr.sub > * { color: var(--muted); font-size: var(--fs-sm); }
.lineref {
  display: inline-block;
  min-width: 64px;
  font: 600 12px/1.6 var(--mono);
  color: var(--muted);
}

/* ---------- Checklist cards ---------- */
.checks { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.check-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line2);
  border-radius: var(--r);
  padding: 12px 14px;
  min-width: 0;
}
.check-card.ok { border-left-color: var(--ok); }
.check-card.warn { border-left-color: var(--warn); }
.check-card.bad { border-left-color: var(--bad); }
.check-n { font-size: 28px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.check-t { color: var(--muted); font-size: var(--fs-sm); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  max-width: calc(100vw - 2 * var(--gutter));
  transform: translateX(-50%) translateY(20px);
  background: var(--fg);
  color: var(--bg);
  font-weight: 700;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  text-align: center;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 44px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: 1.65;
}
.site-footer p { margin: 0; }
.site-footer a { color: var(--muted); text-decoration: underline; }
.site-footer a:hover { color: var(--fg); }
.site-footer .sep { color: var(--dim); }

/* ---------- Document pages (verify, licenses) ---------- */
.doc h1 { margin-top: 6px; }
.doc h2 {
  margin: 38px 0 10px;
  padding-top: 6px;
  scroll-margin-top: 12px;
}
.doc h3 { margin: 22px 0 8px; }
.doc p, .doc ul, .doc ol, .doc dl { margin: 10px 0; }
.doc p, .doc li, .doc dd { color: var(--fg); }
.doc ul, .doc ol { padding-left: 22px; }
.doc li { margin: 6px 0; }
.doc li::marker { color: var(--muted); }
.doc .muted { color: var(--muted); }
.doc .updated { color: var(--muted); font-size: var(--fs-sm); margin-top: 8px; }

.toc {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 16px;
  margin: 20px 0;
}
.toc ol { margin: 6px 0 0; padding-left: 20px; columns: 2 220px; column-gap: 24px; }
.toc li { margin: 0; padding: 3px 0; break-inside: avoid; }

ol.steps { list-style: none; counter-reset: step; padding-left: 0; }
ol.steps > li {
  counter-increment: step;
  position: relative;
  padding-left: 40px;
  margin: 12px 0;
  min-height: 28px;
}
ol.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -1px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-bg);
  border: 1px solid var(--accent-line);
  color: var(--accent-text);
  font-weight: 800;
  font-size: 13px;
  line-height: 26px;
  text-align: center;
}

:not(pre) > code {
  font-size: .92em;
  background: var(--card2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 5px;
  overflow-wrap: anywhere;
}
kbd {
  display: inline-block;
  font-size: .85em;
  line-height: 1.4;
  padding: 0 6px;
  border: 1px solid var(--line2);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--card);
  color: var(--fg);
  white-space: nowrap;
}
pre {
  margin: 12px 0;
  max-width: 100%;
  overflow-x: auto;
}
pre.code {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: var(--fg);
}
pre.license {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 14px;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--fg);
}

ul.cardlist { list-style: none; padding-left: 0; display: flex; flex-direction: column; gap: 10px; }
ul.cardlist > li { margin: 0; }
ul.cardlist h3 { margin: 0 0 8px; }
dl.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--muted); font-weight: 600; }
dl.kv dd { margin: 0; min-width: 0; }

dl.defs { display: grid; gap: 4px 0; }
dl.defs dt { margin-top: 10px; font-family: var(--mono); font-size: 13.5px; color: var(--accent-text); overflow-wrap: anywhere; }
dl.defs dd { margin: 0 0 0 14px; }

.files { list-style: none; padding-left: 0 !important; }
.files li {
  font-family: var(--mono);
  font-size: 13.5px;
  overflow-wrap: anywhere;
}

/* ---------- Accessibility helpers ---------- */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 30;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { top: 8px; color: var(--accent-ink); }
.print-only { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- Small screens (390px phones) ---------- */
@media (max-width: 600px) {
  :root { --fs: 15px; }
  h1 { font-size: 32px; }
  h2 { font-size: 20px; }
  .lede { font-size: 15.5px; }
  .panel { padding: 14px 12px; border-radius: var(--r); }
  .tbl { font-size: 13.5px; }
  .tbl th, .tbl td { padding: 7px 8px; }
  .big { font-size: 28px; }
  .doc h2 { margin-top: 32px; }
  ol.steps > li { padding-left: 36px; }
  .toc ol { columns: 1; }
  dl.kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  dl.kv dd + dt { margin-top: 6px; }
}

/* ---------- Print (P&L, statements) ---------- */
@media print {
  :root, :root[data-theme="light"] {
    color-scheme: light;
    --bg: #FFFFFF;
    --panel: #FFFFFF;
    --card: #FFFFFF;
    --card2: #F1F1F1;
    --hover: #FFFFFF;
    --line: #BBBBBB;
    --line2: #888888;
    --fg: #000000;
    --muted: #333333;
    --dim: #444444;
    --accent: #000000;
    --accent-ink: #FFFFFF;
    --accent-bg: #FFFFFF;
    --accent-line: #888888;
    --accent-text: #000000;
    --ok: #000000;
    --ok-bg: #FFFFFF;
    --ok-line: #888888;
    --warn: #000000;
    --warn-bg: #FFFFFF;
    --warn-line: #888888;
    --bad: #000000;
    --bad-bg: #F1F1F1;
    --bad-line: #888888;
    --info: #000000;
    --info-bg: #FFFFFF;
    --info-line: #888888;
  }
  html, body, :root:not([data-theme="light"]) body { background: #FFFFFF !important; color: #000000; }
  body { font-size: 11pt; }
  .wrap { max-width: none; padding: 0; }
  .no-print, .tabs, .btn, .drop, .toast, .skip-link, .status:empty, .back, .nav { display: none !important; }
  .print-only { display: block; }
  .panel, .card, .check-card, .callout, details.box { break-inside: avoid; }
  .tbl-wrap { overflow: visible; border: 0; max-height: none; }
  .tbl-wrap.tall { max-height: none; overflow: visible; }
  table.tbl { font-size: 9.5pt; }
  .tbl thead { display: table-header-group; }
  .tbl thead th { position: static; }
  .tbl tr { break-inside: avoid; }
  .badge, .chip { border-color: #888888; }
  a { color: #000000; text-decoration: underline; }
  .site-footer { margin-top: 18pt; color: #000000; font-size: 8.5pt; break-inside: avoid; }
  .site-footer a { color: #000000; }
  pre.license, pre.code { white-space: pre-wrap; border-color: #BBBBBB; }
  h2, h3 { break-after: avoid; }
}
