/* AntiqueLens: the accession-card design system. Tokens and rules: docs/BRAND.md (binding) and docs/UI.md.
   Geometry: 2px corners, hairline double rules, no soft shadows. Light on :root, dark on
   prefers-color-scheme and on html[data-theme="dark"]; html[data-theme="light"] forces light. */

:root {
  color-scheme: light dark;
  --bg: #F2ECDF; --surface: #FBF8F1; --ink: #1D1B16; --muted: #6B6558; --line: #D9CFBA;
  --brand: #1F3E8C; --brand-ink: #17306E; --brass: #A9812F;
  --ok: #3F6B3A; --warn: #B7791F; --bad: #8E2B2B;
  --on-brand: #FFFFFF;
  --brass-ink: #7A5A17;
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --body: -apple-system, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 2px;
  --page-w: 1180px; --gutter: 32px; --bar-h: 60px;
  --loupe-size: 132px; --loupe-zoom: 2.4; --loupe-ring: 2px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14120F; --surface: #1D1A15; --ink: #EFE8D8; --muted: #A89F8A; --line: #383227;
    --brand: #7F9BE6; --brand-ink: #A9BDF0; --brass: #D2A94E;
    --ok: #86B77F; --warn: #E0A94A; --bad: #E08A7E;
    --on-brand: #14120F; --brass-ink: #D2A94E;
  }
}
:root[data-theme="dark"] {
  --bg: #14120F; --surface: #1D1A15; --ink: #EFE8D8; --muted: #A89F8A; --line: #383227;
  --brand: #7F9BE6; --brand-ink: #A9BDF0; --brass: #D2A94E;
  --ok: #86B77F; --warn: #E0A94A; --bad: #E08A7E;
  --on-brand: #14120F; --brass-ink: #D2A94E;
}
:root {
  --line-2: color-mix(in srgb, var(--ink) 30%, var(--line));
  --brand-soft: color-mix(in srgb, var(--brand) 11%, var(--surface));
  --brass-soft: color-mix(in srgb, var(--brass) 14%, var(--surface));
  --bad-soft: color-mix(in srgb, var(--bad) 10%, var(--surface));
  --ok-soft: color-mix(in srgb, var(--ok) 11%, var(--surface));
  --warn-soft: color-mix(in srgb, var(--warn) 13%, var(--surface));
  --drawer: color-mix(in srgb, var(--ink) 5%, var(--bg));
  --focus: var(--brand-ink);
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--focus);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--body); -webkit-font-smoothing: antialiased; min-height: 100vh; }
img, svg { max-width: 100%; }
a { color: var(--brand-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
::selection { background: color-mix(in srgb, var(--brand) 28%, transparent); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius); }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; padding: 10px 14px; background: var(--ink); color: var(--bg); }
.skip-link:focus { top: 10px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- type ---- */
h1, h2, h3, h4 { margin: 0; font-family: var(--display); font-weight: 600; letter-spacing: -.012em; line-height: 1.12; text-wrap: balance; }
h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); font-weight: 500; letter-spacing: -.025em; }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.85rem); }
h3 { font-size: 1.12rem; }
h1 em, h2 em, h3 em, .serif { font-style: italic; font-weight: 400; color: var(--brand-ink); }
p { margin: 0 0 .8em; }
.lede { font-size: 1.1rem; line-height: 1.55; color: var(--muted); max-width: 56ch; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.mono, .acc-no { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }
.eyebrow, .field-label { font: 600 .76rem/1.2 var(--body); font-variant-caps: all-small-caps; letter-spacing: .09em; text-transform: lowercase; color: var(--muted); }
.eyebrow { font-size: .85rem; }
.acc-no { font-size: .8rem; letter-spacing: .04em; color: var(--brand-ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.acc-no::before { content: "№\00a0"; color: var(--muted); font-family: var(--display); }

/* ---- rules ---- */
.rule { border: 0; border-top: 1px solid var(--line-2); margin: 0; }
.rule-double { border: 0; height: 5px; margin: 0; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); }

/* ---- page frame ---- */
.main { max-width: var(--page-w); margin: 0 auto; padding: 0 var(--gutter) 72px; outline: none; }
.page { padding-top: 34px; display: grid; gap: 34px; }
.page-head { display: grid; gap: 10px; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.sect { position: relative; margin-top: 6px; border-top: 1px solid var(--line-2); padding-top: 16px; display: grid; gap: 16px; }
.sect::before { content: ""; position: absolute; left: 0; right: 0; top: -6px; border-top: 1px solid var(--line-2); }
.sect-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 14px; }
.stack.sm { gap: 8px; }
.grow { flex: 1 1 0; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.split { display: grid; grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); gap: 40px; align-items: start; }
@media (max-width: 900px) { .grid3, .split { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

/* ---- the accession card ---- */
.card-sheet { position: relative; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 22px 24px; }
.card-sheet::before { content: ""; position: absolute; inset: 4px; border: 1px solid var(--line); border-radius: 1px; pointer-events: none; }
.card-sheet > * { position: relative; }
.card-sheet.punched { padding-bottom: 46px; }
.card-sheet.punched::after { content: ""; position: absolute; left: 50%; bottom: 14px; width: 11px; height: 11px; margin-left: -5px; border-radius: 50%; background: var(--bg); border: 1px solid var(--line-2); }
.card-sheet.flat::before { display: none; }
.card-sheet.sm { padding: 14px 16px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 10px; margin-bottom: 14px; border-bottom: 1px solid var(--brass); }

/* fields: label + value, or the ruled "not stated" line */
.field-value { font-family: var(--display); font-size: 1.05rem; }
.field-unknown { display: inline-block; min-width: 8ch; border-bottom: 1px solid var(--line-2); color: var(--muted); font: italic .9rem var(--display); line-height: 1.1; padding: 0 .5ch; }
dl.fields { display: grid; grid-template-columns: max-content 1fr; gap: 10px 22px; margin: 0; align-items: baseline; }
dl.fields dt { margin: 0; } dl.fields dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.field-line { display: flex; gap: 12px; align-items: baseline; }
@media (max-width: 540px) { dl.fields { grid-template-columns: 1fr; gap: 2px; } dl.fields dd { margin-bottom: 10px; } }

/* register: ruled rows. Set --cols on the element: style="--cols: 7rem 1fr 7rem" */
.register { display: block; border-top: 2px solid var(--ink); }
.register > .reg-head, .register > .reg-row { display: grid; grid-template-columns: var(--cols, 1fr); gap: 4px 18px; align-items: baseline; padding: 11px 6px; border-bottom: 1px solid var(--line-2); }
.register > .reg-head { padding-top: 7px; padding-bottom: 7px; background: var(--drawer); }
a.reg-row { color: inherit; text-decoration: none; }
a.reg-row:hover { background: var(--brand-soft); }
a.reg-row:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); border-radius: 0; }
.reg-row .title { font-family: var(--display); font-size: 1.04rem; font-weight: 600; overflow-wrap: anywhere; }
.reg-row .chip { justify-self: start; }
.reg-row .meta { color: var(--muted); font-size: .84rem; }
.reg-foot { padding: 10px 6px; color: var(--muted); font-size: .84rem; border-bottom: 1px solid var(--line-2); }
@media (max-width: 700px) { .register > .reg-head { display: none; } .register > .reg-row { grid-template-columns: 1fr; padding: 13px 4px; } }

/* figure with caption */
.fig { margin: 0; }
.fig-plate { position: relative; background: var(--surface); border: 1px solid var(--line-2); padding: 7px; border-radius: var(--radius); }
.fig-plate::before { content: ""; position: absolute; inset: 3px; border: 1px solid var(--line); pointer-events: none; }
.fig-plate img, .fig-plate svg { display: block; width: 100%; height: auto; position: relative; }
.fig figcaption { margin-top: 8px; font-size: .84rem; color: var(--muted); }
.fig figcaption b { font: italic 600 .9rem var(--display); color: var(--ink); margin-right: .6ch; }
.fig.live .fig-plate { overflow: hidden; }

/* loupe: container reserved for lib/loupe.js (engineer B). The lens element is
   <span class="lens"> appended inside .loupe; the script sets left/top and background-position. */
.loupe { position: relative; overflow: hidden; cursor: zoom-in; touch-action: pan-y; }
.loupe .lens { position: absolute; width: var(--loupe-size); height: var(--loupe-size); margin: calc(var(--loupe-size) / -2) 0 0 calc(var(--loupe-size) / -2); border-radius: 50%; pointer-events: none; opacity: 0; transform: scale(.85); transition: opacity .12s, transform .12s; background-repeat: no-repeat; border: var(--loupe-ring) solid var(--brand); outline: 1px solid var(--surface); outline-offset: -3px; box-shadow: 0 0 0 1px var(--bg); }
.loupe.on .lens { opacity: 1; transform: none; }

/* ---- drawer tabs ---- */
.drawer-tabs { display: flex; align-items: flex-end; gap: 0; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 9px 20px 8px; margin-left: -1px; border: 1px solid transparent; border-bottom: 0; background: transparent; color: var(--muted); font: 600 .8rem/1 var(--body); font-variant-caps: all-small-caps; letter-spacing: .1em; text-transform: lowercase; text-decoration: none; cursor: pointer; border-radius: var(--radius) var(--radius) 0 0; position: relative; }
.tab { font-size: .95rem; }
.tab:hover { color: var(--ink); background: color-mix(in srgb, var(--surface) 55%, transparent); }
.tab[aria-current="page"], .tab[aria-selected="true"] { background: var(--bg); color: var(--ink); border-color: var(--line-2); margin-bottom: -1px; padding-bottom: 9px; box-shadow: inset 0 2px 0 var(--brass); }
.tabs-inline { border-bottom: 1px solid var(--line-2); }

/* ---- the shell ---- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: flex-end; gap: 28px; padding: env(safe-area-inset-top) max(var(--gutter), calc((100vw - var(--page-w)) / 2 + var(--gutter))) 0; min-height: var(--bar-h); background: var(--drawer); border-bottom: 1px solid var(--line-2); }
.topbar .brand { align-self: center; }
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); }
.wm { font: 600 1.4rem/1 var(--display); letter-spacing: -.02em; }
.wm em { font-style: italic; font-weight: 400; color: var(--brand-ink); }
.topnav { margin-left: 6px; margin-bottom: -1px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; align-self: center; padding: 8px 0; }
.wallet-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line-2); border-radius: var(--radius); color: var(--ink); text-decoration: none; font-size: .82rem; font-variant-numeric: tabular-nums; background: var(--surface); }
.wallet-chip:hover { border-color: var(--ink); }
.wallet-chip.low { border-color: var(--warn); }
.wallet-chip .i { width: 16px; height: 16px; color: var(--brass-ink); }
.wallet-chip .wl { color: var(--muted); }
.user-menu { position: relative; }
.avatar { width: 34px; height: 34px; border: 1px solid var(--ink); border-radius: 50%; background: var(--surface); color: var(--ink); font: 600 .78rem var(--display); letter-spacing: .04em; cursor: pointer; }
.avatar:hover { background: var(--ink); color: var(--bg); }
.pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; padding: 6px; background: var(--surface); border: 1px solid var(--ink); border-radius: var(--radius); z-index: 40; display: grid; }
.pop .who { padding: 8px 10px 10px; display: grid; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.pop .who span { color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }
.pop a, .pop button { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; background: none; color: var(--ink); font: inherit; font-size: .92rem; text-align: left; text-decoration: none; cursor: pointer; border-radius: var(--radius); }
.pop a:hover, .pop button:hover { background: var(--brand-soft); }
.pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.tabbar, .more-sheet { display: none; }

@media (max-width: 860px) {
  :root { --gutter: 18px; --bar-h: 52px; }
  .topbar { align-items: center; padding-bottom: 0; }
  .topnav, .top-cta, .wallet-chip { display: none !important; }
  .main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .tabbar { position: fixed; z-index: 35; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; padding: 0 6px env(safe-area-inset-bottom); background: var(--drawer); border-top: 1px solid var(--line-2); }
  .tabbar a, .tabbar button { display: grid; justify-items: center; gap: 3px; padding: 9px 2px 8px; border: 0; background: none; color: var(--muted); font: 600 .76rem/1 var(--body); font-variant-caps: all-small-caps; letter-spacing: .06em; text-transform: lowercase; text-decoration: none; cursor: pointer; }
  .tabbar a[aria-current="page"], .tabbar button.current { color: var(--ink); box-shadow: inset 0 2px 0 var(--brass); }
  .tabbar .tab-identify { margin-top: -14px; }
  .tabbar .tab-identify .i { width: 46px; height: 46px; padding: 11px; background: var(--brand); color: var(--on-brand); border: 1px solid var(--ink); border-radius: var(--radius); }
  .tabbar .tab-identify[aria-current="page"] { box-shadow: none; }
  .more-sheet { position: fixed; inset: 0; z-index: 50; display: none; align-items: flex-end; background: color-mix(in srgb, var(--ink) 45%, transparent); }
  .more-sheet.open { display: flex; }
  .more-sheet .sheet { width: 100%; display: grid; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 2px solid var(--ink); }
  .more-sheet .sheet::before { content: ""; justify-self: center; width: 40px; height: 4px; margin: -8px 0 12px; background: var(--line-2); }
  .more-sheet .eyebrow { margin-bottom: 6px; }
  .more-sheet a, .more-sheet button { display: flex; align-items: center; gap: 14px; padding: 14px 4px; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--ink); font: inherit; font-size: 1rem; text-decoration: none; text-align: left; cursor: pointer; }
}
@media (min-width: 861px) { .more-sheet { display: none !important; } }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border: 1px solid var(--ink); border-radius: var(--radius); background: var(--surface); color: var(--ink); font: 600 .92rem/1.2 var(--body); text-decoration: none; cursor: pointer; transition: background .12s, color .12s; min-height: 40px; }
.btn:hover { background: var(--ink); color: var(--bg); text-decoration: none; }
.btn .i { width: 18px; height: 18px; }
.btn.cta { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.cta:hover { background: var(--brand-ink); border-color: var(--brand-ink); color: var(--on-brand); }
:root[data-theme="dark"] .btn.cta:hover { background: #fff; color: #14120F; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.cta:hover { background: #fff; color: #14120F; } }
.btn.ghost { background: transparent; border-color: var(--line-2); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.quiet { background: transparent; border-color: transparent; padding-inline: 8px; color: var(--brand-ink); text-decoration: underline; text-underline-offset: 3px; }
.btn.quiet:hover { background: var(--brand-soft); color: var(--brand-ink); }
.btn.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.danger:hover { background: var(--bad); color: var(--bg); }
.btn.sm { padding: 6px 12px; min-height: 32px; font-size: .84rem; }
.btn.lg { padding: 14px 24px; font-size: 1.02rem; min-height: 50px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn[aria-busy="true"] { position: relative; color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"]::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid var(--muted); border-top-color: var(--ink); border-radius: 50%; animation: spin .7s linear infinite; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 1px solid transparent; border-radius: var(--radius); background: transparent; color: var(--ink); cursor: pointer; }
.icon-btn:hover { border-color: var(--line-2); background: var(--surface); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- chips, stamp ---- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border: 1px solid var(--line-2); border-radius: var(--radius); background: transparent; color: var(--ink); font: 600 .76rem/1.5 var(--body); font-variant-caps: all-small-caps; letter-spacing: .07em; font-size: .86rem; white-space: nowrap; }
.chip.ok { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.chip.warn { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
.chip.bad { color: var(--bad); border-color: var(--bad); background: var(--bad-soft); }
.chip.brass { color: var(--brass-ink); border-color: var(--brass); background: var(--brass-soft); }
.chip.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.stamp { display: inline-block; padding: 8px 16px; border: 3px double var(--bad); color: var(--bad); font: 700 1.1rem/1.1 var(--body); letter-spacing: .14em; text-transform: uppercase; transform: rotate(-4deg); border-radius: var(--radius); opacity: .92; text-align: center; mix-blend-mode: normal; }
.stamp.sm { font-size: .78rem; padding: 4px 9px; border-width: 2px; }
.stamp.ink { color: var(--brand-ink); border-color: var(--brand-ink); }
.stamp small { display: block; margin-top: 4px; font: 500 .72rem var(--body); letter-spacing: .06em; text-transform: none; }

/* ---- forms ---- */
.field { display: grid; gap: 6px; }
.field > label, .field > .field-label { font: 600 .9rem var(--body); font-variant-caps: all-small-caps; letter-spacing: .08em; text-transform: lowercase; color: var(--muted); }
.field .hint { font-size: .82rem; color: var(--muted); } .field .err { font-size: .84rem; color: var(--bad); }
.input, .select, .textarea { width: 100%; padding: 10px 12px; font: inherit; font-size: 16px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); min-height: 42px; }
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--focus); }
.input::placeholder { color: var(--muted); opacity: .8; }
.input[aria-invalid="true"] { border-color: var(--bad); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.seg button { padding: 8px 14px; border: 0; border-right: 1px solid var(--line-2); background: transparent; color: var(--muted); font: 600 .86rem var(--body); cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"], .seg button[aria-checked="true"] { background: var(--ink); color: var(--bg); }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; width: 38px; height: 22px; margin: 0; border: 1px solid var(--ink); border-radius: var(--radius); background: var(--surface); position: relative; cursor: pointer; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: var(--ink); transition: transform .15s; }
.switch input:checked { background: var(--brand); border-color: var(--brand); } .switch input:checked::after { transform: translateX(16px); background: var(--on-brand); }
.chips-input { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border: 1px solid var(--line-2); background: var(--surface); border-radius: var(--radius); }
.chips-input:focus-within { border-color: var(--focus); }
.chips-input input { flex: 1 1 8ch; min-width: 8ch; border: 0; outline: 0; background: transparent; font: inherit; font-size: 16px; color: var(--ink); padding: 4px; }
.chips-input .chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 0 0 2px; font-size: 1rem; line-height: 1; }
.pick { display: inline-flex; padding: 7px 12px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface); cursor: pointer; font-size: .9rem; }
.pick[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand-ink); color: var(--brand-ink); }

/* ---- tables (lib/table.js) ---- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; border-top: 2px solid var(--ink); }
table.t th { text-align: left; padding: 8px 10px; background: var(--drawer); font: 600 .84rem var(--body); font-variant-caps: all-small-caps; letter-spacing: .08em; text-transform: lowercase; color: var(--muted); border-bottom: 1px solid var(--line-2); white-space: nowrap; }
table.t td { padding: 10px; border-bottom: 1px solid var(--line-2); vertical-align: baseline; }
table.t .num { text-align: right; font-variant-numeric: tabular-nums; }
table.t th.sortable { cursor: pointer; } table.t th[aria-sort]::after { content: " ↓"; } table.t th[aria-sort="ascending"]::after { content: " ↑"; }
table.t tr.clickable { cursor: pointer; } table.t tr.clickable:hover { background: var(--brand-soft); }
.pagebar { padding: 12px 0; display: flex; justify-content: center; }
@media (max-width: 640px) { table.t.stackable thead { display: none; } table.t.stackable tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--line-2); } table.t.stackable td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 3px 4px; } table.t.stackable td::before { content: attr(data-label); color: var(--muted); font-size: .82rem; } }

/* ---- feedback ---- */
.banner { display: flex; align-items: center; gap: 14px; margin: 16px 0 -6px; padding: 12px 16px; border: 1px solid var(--line-2); border-left: 4px solid var(--brass); background: var(--surface); border-radius: var(--radius); flex-wrap: wrap; }
.banner.warn { border-left-color: var(--warn); background: var(--warn-soft); } .banner.bad { border-left-color: var(--bad); background: var(--bad-soft); } .banner.ok { border-left-color: var(--ok); background: var(--ok-soft); }
.callout { padding: 12px 16px; border-left: 3px solid var(--brass); background: var(--brass-soft); font-size: .92rem; }
.empty { display: grid; justify-items: start; gap: 8px; padding: 34px 24px; border: 1px dashed var(--line-2); border-radius: var(--radius); }
.empty h3 { font-size: 1.25rem; } .empty p { color: var(--muted); max-width: 52ch; margin: 0; }
.empty .big { color: var(--brass); } .empty .big .i { width: 34px; height: 34px; }
.toasts { position: fixed; z-index: 90; right: 18px; bottom: 18px; display: grid; gap: 8px; width: min(380px, calc(100vw - 36px)); pointer-events: none; }
@media (max-width: 860px) { .toasts { bottom: calc(86px + env(safe-area-inset-bottom)); right: 18px; left: 18px; width: auto; } }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; background: var(--ink); color: var(--bg); border-radius: var(--radius); border-left: 4px solid var(--brass); font-size: .9rem; }
.toast.ok { border-left-color: var(--ok); } .toast.bad { border-left-color: var(--bad); } .toast.warn { border-left-color: var(--warn); }
.toast .body { flex: 1; } .toast a { color: inherit; font-weight: 600; }
.toast .x { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; opacity: .7; } .toast .x .i { width: 16px; height: 16px; }
.scrim { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 18px; background: color-mix(in srgb, var(--ink) 50%, transparent); }
.dialog { width: min(480px, 100%); max-height: 90vh; overflow: auto; padding: 22px 24px; background: var(--surface); border: 1px solid var(--ink); outline: 1px solid var(--line-2); outline-offset: -6px; border-radius: var(--radius); }
.dialog.wide { width: min(720px, 100%); }
.dialog .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.dialog .err { color: var(--bad); font-size: .88rem; }
.secret { display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: var(--drawer); border: 1px dashed var(--line-2); font: .86rem var(--mono); word-break: break-all; }
@media (max-width: 640px) { .scrim { align-items: end; padding: 0; } .dialog { width: 100%; border-radius: 0; border-width: 2px 0 0; padding-bottom: calc(22px + env(safe-area-inset-bottom)); } }
.skel { background: linear-gradient(90deg, var(--drawer), color-mix(in srgb, var(--surface) 70%, var(--drawer)), var(--drawer)); background-size: 220% 100%; animation: shimmer 1.4s linear infinite; border-radius: var(--radius); }
.skel.line { height: 16px; } .skel.block { height: 220px; } .skel.chart { height: 160px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---- charts (lib/charts.js) ---- */
.spark { display: block; width: 100%; height: 56px; overflow: visible; }
.spark .ln { fill: none; stroke: var(--brand-ink); stroke-width: 1.6; stroke-linejoin: round; }
.spark .ar { fill: var(--brand-soft); stroke: none; }
.spark .dt { fill: var(--surface); stroke: var(--brand-ink); stroke-width: 1.6; }
.spark .base { stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 2 3; }
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(7ch, 14ch) 1fr 4ch; gap: 10px; align-items: center; font-size: .88rem; }
.bar-row .track { height: 8px; background: var(--drawer); border: 1px solid var(--line); } .bar-row .fill { display: block; height: 100%; background: var(--brand); }
.bar-row .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ---- motion: staggered reveal ("blur fade"), only where script has run ---- */
@media (prefers-reduced-motion: no-preference) {
  .js .reveal { opacity: 0; filter: blur(5px); transform: translateY(8px); transition: opacity .5s ease, filter .5s ease, transform .5s ease; transition-delay: calc(var(--i, 0) * 70ms); }
  .js .reveal.in { opacity: 1; filter: none; transform: none; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; } }

/* ---- error page ---- */
.err-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.err-sheet { width: min(520px, 100%); display: grid; gap: 14px; justify-items: start; }
.err-sheet .brand { margin-bottom: 10px; }

@media print { .topbar, .tabbar, .toasts { display: none !important; } body { background: #fff; } }

.brand-logo { display: block; width: 26px; height: 26px; border-radius: 6px; flex: none; }
