/* AnySound design system: "the cyanotype plate" (docs/BRAND.md, docs/UI.md).
   Bone paper and ink everywhere; the plate blue is the signal, REC orange the one live action,
   category inks mark what kind of source. Token names are fixed: never rename, only add.
   Sections: 1 tokens, 2 base, 3 shell (masthead, tabs, bottom bar, footer), 4 controls, 5 chips and ruler,
   6 plate, 7 ledger and tables, 8 feedback (empty, skeleton, banner, dialog, toast), 9 utilities, 10 motion. */

/* ---------- 1. tokens ---------- */
:root {
  color-scheme: light dark;

  --bg: #FAFAF7;
  --surface: #FFFFFF;
  --ink: #14131A;
  --muted: #5E5C6B;
  --line: #E6E3EC;
  --line-strong: #8D8A9C;
  --brand: #3A1FD1;
  --brand-ink: #3A1FD1;
  --accent: #E5243B;
  --accent-ink: #C41A30;
  --accent-fg: #FFFFFF;
  --ok: #1E8A4C;
  --warn: #9A6A00;
  --bad: #C41A30;
  --ok-ink: #1A7842;   /* the three as text (AA); the plain tokens are for icons, rules and fills */
  --warn-ink: #7F5700;
  --bad-ink: #C41A30;
  --plate: #0E0B1F;
  --plate-ink: #F3F0FF;
  --ring: #3A1FD1;
  --scrim: rgba(20, 19, 26, .5);

  /* category colours: fill (chips, plates, fields) and a text-safe ink */
  --cat-animal: #2FA84F; --cat-animal-ink: #1E7A38;
  --cat-vehicle: #F26B1D; --cat-vehicle-ink: #B84A0A;
  --cat-mechanical: #E0A100; --cat-mechanical-ink: #8A6200;
  --cat-music: #7B3FF2; --cat-music-ink: #5A24C8;
  --cat-everyday: #0FA3B1; --cat-everyday-ink: #0A7580;
  --cat-nature: #7CB518; --cat-nature-ink: #4F7A0A;
  --cat-alarm: #E5243B; --cat-alarm-ink: #C41A30;
  --cat-human: #E83E8C; --cat-human-ink: #B8186A;
  --cat-other: #6B7280; --cat-other-ink: #4B5563;

  /* the magma ramp: the only gradient in the product (spectrograms) */
  --ramp-0: #0E0B1F; --ramp-1: #2B1466; --ramp-2: #7A1FA2; --ramp-3: #D1327A; --ramp-4: #FF7A1A; --ramp-5: #FFD84D; --ramp-6: #FFF8D6;

  /* the page takes the colour of the sound: set data-cat="<name>" on any ancestor to tint everything inside it */
  --tint: var(--brand); --tint-ink: var(--brand-ink);
  --tint-soft: color-mix(in srgb, var(--tint) 12%, var(--surface));
  --mark: var(--ink); --mark-plate: var(--plate-ink);

  /* type */
  --display: "Avenir Next", "Segoe UI Variable Display", "Trebuchet MS", system-ui, -apple-system, sans-serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; /* italic accent word only */
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-0: .75rem; --fs-1: .875rem; --fs-2: 1rem; --fs-3: 1.25rem; --fs-4: 1.75rem; --fs-5: 2.5rem;
  --fs-6: clamp(2.75rem, 9vw, 6rem);

  /* space (4 px grid), radius, motion, widths */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 72px;
  --r: 12px;
  --r-lg: 20px;
  --r-plate: 20px;
  --r-pill: 999px;
  --dur-1: 120ms; --dur-2: 240ms; --dur-3: 600ms;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --w-page: 1180px; --w-read: 720px;
  --masthead-h: 60px; --tabbar-h: 62px; --gutter: 16px;
}
@media (min-width: 768px) { :root { --gutter: 28px; } }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D0B16; --surface: #16132A; --ink: #F2F0FA; --muted: #A5A2B8; --line: #2A2644; --line-strong: #6B668A;
    --brand: #A596FF; --brand-ink: #BDB1FF; --accent: #FF5468; --accent-fg: #14131A; --accent-ink: #FF8A98;
    --ok: #5FD08F; --warn: #E8B94F; --bad: #FF8A98; --ok-ink: #5FD08F; --warn-ink: #E8B94F; --bad-ink: #FF8A98;
    --plate: #0A0816; --ring: #BDB1FF; --scrim: rgba(4, 3, 12, .68);
    --cat-animal-ink: #6BD68B; --cat-vehicle-ink: #FF9A5C; --cat-mechanical-ink: #F2C84B; --cat-music-ink: #B79BFF; --cat-everyday-ink: #5ADBE6; --cat-nature-ink: #B6E357; --cat-alarm-ink: #FF8A98; --cat-human-ink: #FF8FC0; --cat-other-ink: #A3AAB8;
  }
}
:root[data-theme="dark"] {
  --bg: #0D0B16; --surface: #16132A; --ink: #F2F0FA; --muted: #A5A2B8; --line: #2A2644; --line-strong: #6B668A;
  --brand: #A596FF; --brand-ink: #BDB1FF; --accent: #FF5468; --accent-fg: #14131A; --accent-ink: #FF8A98;
  --ok: #5FD08F; --warn: #E8B94F; --bad: #FF8A98; --ok-ink: #5FD08F; --warn-ink: #E8B94F; --bad-ink: #FF8A98;
  --plate: #0A0816; --ring: #BDB1FF; --scrim: rgba(4, 3, 12, .68);
  --cat-animal-ink: #6BD68B; --cat-vehicle-ink: #FF9A5C; --cat-mechanical-ink: #F2C84B; --cat-music-ink: #B79BFF; --cat-everyday-ink: #5ADBE6; --cat-nature-ink: #B6E357; --cat-alarm-ink: #FF8A98; --cat-human-ink: #FF8FC0; --cat-other-ink: #A3AAB8;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* tint mechanism: --tint is the category fill, --tint-ink the text-safe ink, --tint-soft a 12 % field. Re-declared here because custom properties resolve where declared. */
[data-cat="animal"]{--tint:var(--cat-animal);--tint-ink:var(--cat-animal-ink);--tint-soft:color-mix(in srgb,var(--cat-animal) 12%,var(--surface));--mark:var(--cat-animal-ink);--mark-plate:var(--cat-animal);}
[data-cat="vehicle"]{--tint:var(--cat-vehicle);--tint-ink:var(--cat-vehicle-ink);--tint-soft:color-mix(in srgb,var(--cat-vehicle) 12%,var(--surface));--mark:var(--cat-vehicle-ink);--mark-plate:var(--cat-vehicle);}
[data-cat="mechanical"]{--tint:var(--cat-mechanical);--tint-ink:var(--cat-mechanical-ink);--tint-soft:color-mix(in srgb,var(--cat-mechanical) 12%,var(--surface));--mark:var(--cat-mechanical-ink);--mark-plate:var(--cat-mechanical);}
[data-cat="music"]{--tint:var(--cat-music);--tint-ink:var(--cat-music-ink);--tint-soft:color-mix(in srgb,var(--cat-music) 12%,var(--surface));--mark:var(--cat-music-ink);--mark-plate:var(--cat-music);}
[data-cat="everyday"]{--tint:var(--cat-everyday);--tint-ink:var(--cat-everyday-ink);--tint-soft:color-mix(in srgb,var(--cat-everyday) 12%,var(--surface));--mark:var(--cat-everyday-ink);--mark-plate:var(--cat-everyday);}
[data-cat="nature"]{--tint:var(--cat-nature);--tint-ink:var(--cat-nature-ink);--tint-soft:color-mix(in srgb,var(--cat-nature) 12%,var(--surface));--mark:var(--cat-nature-ink);--mark-plate:var(--cat-nature);}
[data-cat="alarm"]{--tint:var(--cat-alarm);--tint-ink:var(--cat-alarm-ink);--tint-soft:color-mix(in srgb,var(--cat-alarm) 12%,var(--surface));--mark:var(--cat-alarm-ink);--mark-plate:var(--cat-alarm);}
[data-cat="human"]{--tint:var(--cat-human);--tint-ink:var(--cat-human-ink);--tint-soft:color-mix(in srgb,var(--cat-human) 12%,var(--surface));--mark:var(--cat-human-ink);--mark-plate:var(--cat-human);}
[data-cat="other"]{--tint:var(--cat-other);--tint-ink:var(--cat-other-ink);--tint-soft:color-mix(in srgb,var(--cat-other) 12%,var(--surface));--mark:var(--cat-other-ink);--mark-plate:var(--cat-other);}

/* ---------- 2. base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--masthead-h) + 16px); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 var(--fs-2)/1.55 var(--sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
}
[hidden] { display: none !important; }
img, svg, canvas, video { max-width: 100%; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 800; line-height: 1.04; letter-spacing: -.02em; margin: 0 0 var(--s-3); text-wrap: balance; }
h1 { font-size: clamp(2.25rem, 6.5vw, 4rem); }
h2 { font-size: var(--fs-4); }
h3 { font-size: var(--fs-3); }
h4 { font-size: var(--fs-2); }
h1 em, h2 em, h3 em, .accent-word { font-family: var(--serif); font-style: italic; font-weight: 500; letter-spacing: 0; }
p { margin: 0 0 var(--s-3); text-wrap: pretty; }
a { color: var(--brand-ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s-5) 0; }
small, .small { font-size: var(--fs-1); }
code, kbd, samp, pre { font-family: var(--mono); font-size: .92em; }
pre { overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s-3); }
::selection { background: var(--tint-ink); color: var(--bg); }

/* two-layer focus ring: a 2 px ink outline, haloed by the page colour so it reads on paper, plate and orange */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; box-shadow: 0 0 0 5px var(--bg); border-radius: var(--r); }
.plate :focus-visible { outline-color: var(--plate-ink); box-shadow: 0 0 0 5px var(--plate); }
main:focus { outline: none; }

.skip { position: absolute; left: var(--s-3); top: -60px; z-index: 100; background: var(--ink); color: var(--bg); padding: var(--s-2) var(--s-3); border-radius: var(--r); }
.skip:focus { top: var(--s-3); }

/* type roles */
.eyebrow { font: 700 var(--fs-0)/1.2 var(--mono); text-transform: uppercase; letter-spacing: .14em; color: var(--tint-ink); margin: 0 0 var(--s-2); display: block; }
.caption { font: 600 var(--fs-0)/1.3 var(--sans); font-variant-caps: all-small-caps; text-transform: lowercase; letter-spacing: .1em; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-feature-settings: "tnum" 1; }
.lead { font: 500 var(--fs-3)/1.45 var(--sans); color: var(--ink); max-width: 38em; }
.muted { color: var(--muted); }
.display { font: 800 var(--fs-6)/.95 var(--display); letter-spacing: -.03em; }
.cat-no { font: 600 var(--fs-0)/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; } /* AS-0042 */

/* ---------- 3. shell ---------- */
.page { width: 100%; max-width: var(--w-page); margin: 0 auto; padding: var(--s-5) var(--gutter) var(--s-7); flex: 1 0 auto; }
.page.narrow { max-width: var(--w-read); }
main { flex: 1 0 auto; display: block; }
main > #app { min-width: 0; }

.page-head { display: grid; gap: var(--s-2); margin: var(--s-4) 0 var(--s-5); }
.page-head h1 { margin: 0; }
.page-head .lead { margin: 0; color: var(--muted); }
.page-head .actions { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
@media (min-width: 768px) {
  .page-head.split { grid-template-columns: 1fr auto; align-items: end; }
  .page-head.split .eyebrow, .page-head.split h1, .page-head.split .lead { grid-column: 1; }
  .page-head.split .actions { grid-column: 2; grid-row: 1 / span 3; }
}
.section { margin: var(--s-6) 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); border-bottom: 3px solid var(--tint); padding-bottom: var(--s-2); margin-bottom: var(--s-3); }
.section-head h2, .section-head h3 { margin: 0; font-size: var(--fs-3); }
.section-head .meta { font: 500 var(--fs-0) var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* masthead: wordmark, five tabs, one quiet action, avatar. Printed-journal double rule under it. */
.masthead { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 92%, transparent); -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.masthead-in { display: flex; align-items: center; gap: var(--s-4); max-width: var(--w-page); margin: 0 auto; height: var(--masthead-h); padding: 0 var(--gutter); }
.wordmark { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font: 800 1.4rem/1 var(--display); letter-spacing: -.03em; flex: none; }
.wordmark:hover { text-decoration: none; }
.wordmark .logo { width: 30px; height: 30px; flex: none; border-radius: 9px; }
.wordmark em { font-family: var(--serif); font-style: italic; font-weight: 500; letter-spacing: 0; margin-left: 1px; }
.tabs { display: none; align-items: stretch; gap: var(--s-1); height: 100%; margin-left: var(--s-3); }
.tab { position: relative; display: inline-flex; align-items: center; align-self: center; height: 36px; padding: 0 14px; border-radius: var(--r-pill); color: var(--muted); text-decoration: none; font: 700 var(--fs-1)/1 var(--sans); white-space: nowrap; }
.tab:hover { color: var(--ink); background: var(--tint-soft); text-decoration: none; }
.tab[aria-current="page"] { color: var(--bg); background: var(--ink); }
.masthead-end { margin-left: auto; display: flex; align-items: center; gap: var(--s-3); }
.listen-link { display: none; align-items: center; gap: 7px; font: 700 var(--fs-1) var(--sans); color: var(--ink); text-decoration: none; padding: 8px 14px; border: 1.5px solid var(--ink); border-radius: var(--r-pill); }
.listen-link:hover { background: var(--tint-soft); text-decoration: none; }
.listen-link .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
@media (min-width: 768px) { .tabs { display: flex; } .listen-link { display: inline-flex; } }

.avatar-wrap { position: relative; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: var(--tint-ink); color: var(--bg); font: 800 var(--fs-1) var(--display); cursor: pointer; }
.avatar:hover, .avatar[aria-expanded="true"] { filter: brightness(1.08); }
.menu { position: absolute; right: 0; top: calc(100% + 10px); z-index: 50; width: 264px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: var(--s-2) 0; box-shadow: 0 18px 40px -16px rgba(20,19,26,.35); }
.menu-who { padding: var(--s-2) var(--s-4) var(--s-3); border-bottom: 1px solid var(--line); margin-bottom: var(--s-2); }
.menu-who b { display: block; font: 800 var(--fs-2) var(--display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-who span { display: block; font: var(--fs-0) var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu a, .menu button.item { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); width: 100%; padding: 9px var(--s-4); background: none; border: 0; border-radius: 0; color: var(--ink); text-decoration: none; font: var(--fs-1)/1.3 var(--sans); text-align: left; cursor: pointer; }
.menu a:hover, .menu button.item:hover { background: var(--tint-soft); text-decoration: none; }
.menu .rule { height: 1px; background: var(--line); margin: var(--s-2) 0; }
.menu .theme-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: 6px var(--s-4); font-size: var(--fs-1); }
.menu .phone-only { display: flex; }
@media (min-width: 768px) { .menu .phone-only { display: none; } }

/* phone bottom bar: four tabs and a big REC in the middle. On /dashboard the page owns the REC pill, so the bar drops its own. */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; display: grid; grid-template-columns: 1fr 1fr 76px 1fr 1fr; align-items: end; background: var(--surface); border-top: 1px solid var(--line); padding: 0 var(--s-1) env(safe-area-inset-bottom); min-height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
.tabbar a.t { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: var(--tabbar-h); color: var(--muted); text-decoration: none; font: 700 10.5px/1 var(--sans); letter-spacing: .04em; text-transform: uppercase; }
.tabbar a.t .i { width: 22px; height: 22px; }
.tabbar a.t[aria-current="page"] { color: var(--ink); }
.tabbar a.t[aria-current="page"] .i { color: var(--brand-ink); stroke-width: 2.2; }
.tabbar .rec-wrap { display: grid; place-items: center; height: var(--tabbar-h); position: relative; }
.tabbar .rec { position: absolute; bottom: 10px; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--accent); color: var(--accent-fg); border: 4px solid var(--surface); box-shadow: 0 8px 18px -6px color-mix(in srgb, var(--accent) 70%, transparent); text-decoration: none; }
.tabbar .rec .i { width: 28px; height: 28px; }
body[data-page="dashboard"] .tabbar { grid-template-columns: repeat(4, 1fr); }
body[data-page="dashboard"] .tabbar .rec-wrap { display: none; }
@media (min-width: 768px) { .tabbar { display: none; } }
@media (max-width: 767px) { body.has-tabbar main { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px); } .site-foot { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); } }

.site-foot { border-top: 1px solid var(--line); margin-top: var(--s-6); }
.site-foot-in { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-5); max-width: var(--w-page); margin: 0 auto; padding: var(--s-4) var(--gutter) var(--s-5); font: var(--fs-0)/1.4 var(--mono); letter-spacing: .04em; color: var(--muted); }
.site-foot a { color: var(--muted); }
.site-foot a:hover { color: var(--ink); }
.site-foot .push { margin-left: auto; }

/* ---------- 4. controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 40px; padding: 0 var(--s-4); border: 1px solid transparent; border-radius: var(--r); background: transparent; color: var(--ink); font: 700 var(--fs-1)/1 var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap; transition: background var(--dur-1), border-color var(--dur-1), color var(--dur-1), transform var(--dur-1); -webkit-tap-highlight-color: transparent; user-select: none; }
.btn:hover { text-decoration: none; }
.btn .i { width: 18px; height: 18px; flex: none; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn[aria-busy="true"] { cursor: progress; opacity: .75; }
/* the single filled action: REC orange, a pill. At most one per view. */
.btn-primary { background: var(--accent); color: var(--accent-fg); border-radius: var(--r-pill); min-height: 50px; padding: 0 var(--s-6); font-weight: 800; font-size: var(--fs-2); box-shadow: 0 8px 20px -10px var(--accent); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary .rec-dot { width: 12px; height: 12px; border-radius: 50%; background: currentColor; flex: none; }
.btn-quiet { border-color: var(--line-strong); color: var(--ink); background: var(--surface); }
.btn-quiet:hover { border-color: var(--ink); background: var(--tint-soft); }
.btn-ghost { color: var(--brand-ink); padding: 0 var(--s-2); min-height: 36px; }
.btn-ghost:hover { background: var(--tint-soft); }
.btn-danger { border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: var(--bg); }
.btn-sm { min-height: 32px; padding: 0 var(--s-3); font-size: var(--fs-0); }
.btn-primary.btn-sm { min-height: 36px; padding: 0 var(--s-4); font-size: var(--fs-1); }
.btn-icon { width: 40px; padding: 0; }
.btn-block { display: flex; width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand-ink); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* the big record button: --level (0..1) is set by script from the live input level, the ring breathes with it */
.btn-rec { position: relative; display: inline-grid; place-items: center; width: 132px; height: 132px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-fg); cursor: pointer; --level: 0; box-shadow: 0 14px 30px -12px var(--accent); }
.btn-rec::before { content: ""; position: absolute; inset: calc(-8px - var(--level) * 22px); border-radius: 50%; border: 2px solid var(--accent); opacity: calc(.25 + var(--level) * .6); transition: inset 80ms linear, opacity 80ms linear; pointer-events: none; }
.btn-rec .i { width: 44px; height: 44px; }
.btn-rec[data-live="true"] { background: var(--accent); }
.btn-rec:active { transform: scale(.98); }

.field { display: grid; gap: 6px; margin: 0 0 var(--s-4); }
.label, .field > label { font: 600 var(--fs-0)/1.2 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.hint { font-size: var(--fs-1); color: var(--muted); margin: 0; }
.input, .select, .textarea { width: 100%; min-height: 42px; padding: 9px 12px; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--r); font: var(--fs-2)/1.4 var(--sans); }
.textarea { min-height: 96px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .8; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--ring); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.select { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.error-text { color: var(--bad-ink); font-size: var(--fs-1); margin: 0; }
input[type="search"].input { -webkit-appearance: none; appearance: none; }

.check, .switch { display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; font-size: var(--fs-1); }
.check input, .switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check .box { width: 20px; height: 20px; border: 1.5px solid var(--line-strong); border-radius: 6px; background: var(--surface); display: grid; place-items: center; flex: none; }
.check input:checked + .box { background: var(--brand); border-color: var(--brand); }
.check input:checked + .box::after { border-color: var(--bg); }
.check input:checked + .box::after { content: ""; width: 10px; height: 6px; border-left: 2px solid var(--bg); border-bottom: 2px solid var(--bg); transform: rotate(-45deg) translate(1px, -1px); }
.switch .track { width: 40px; height: 22px; border-radius: var(--r-pill); border: 1px solid var(--line-strong); background: var(--surface); position: relative; flex: none; transition: background var(--dur-1); }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform var(--dur-1), background var(--dur-1); }
.switch input:checked + .track { background: var(--brand); border-color: var(--brand); }
.switch input:checked + .track::after { transform: translateX(18px); background: var(--bg); }
.check input:focus-visible + .box, .switch input:focus-visible + .track { outline: 2px solid var(--ring); outline-offset: 2px; box-shadow: 0 0 0 5px var(--bg); }

/* segmented control: aria-pressed buttons (range 7 / 30 / 90 days, theme Auto / Light / Dark) */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-pill); overflow: hidden; background: var(--tint-soft); }
.seg button { min-height: 30px; padding: 0 var(--s-3); border: 0; border-radius: var(--r-pill); background: transparent; color: var(--muted); font: 700 var(--fs-0) var(--sans); cursor: pointer; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg button:focus-visible { outline-offset: -3px; box-shadow: none; }

/* ---------- 5. chips and the ruler ---------- */
.chip { display: inline-flex; align-items: center; gap: 7px; min-height: 28px; padding: 0 12px 0 10px; border: 1px solid color-mix(in srgb, var(--tint) 32%, transparent); border-radius: var(--r-pill); background: color-mix(in srgb, var(--tint) 14%, var(--surface)); color: var(--tint-ink); font: 700 var(--fs-0)/1 var(--sans); letter-spacing: .02em; white-space: nowrap; }
.chip::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--tint); flex: none; }
.chip.solid { background: var(--tint-ink); border-color: var(--tint-ink); color: var(--bg); }
.chip.solid::before { background: var(--bg); }
.chip.plain::before { display: none; }
.chip.tag { font-weight: 600; color: var(--muted); background: var(--surface); border-color: var(--line); }
.chip.tag::before { display: none; }
button.chip, a.chip { cursor: pointer; text-decoration: none; }
button.chip[aria-pressed="true"], a.chip[aria-current="true"] { background: var(--tint-ink); color: var(--bg); border-color: var(--tint-ink); }
button.chip[aria-pressed="true"]::before { background: var(--bg); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.state { font: 700 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.state.ok { color: var(--ok-ink); } .state.warn { color: var(--warn-ink); } .state.bad { color: var(--bad-ink); }

/* ruler: a 0-10 scale with a marker, for confidence. <div class="ruler" style="--v:7.2" role="img" aria-label="...">. No marker when unknown. */
.ruler { --v: 0; position: relative; display: block; width: 100%; min-width: 96px; height: 24px; color: var(--ink); }
.ruler::before { /* baseline */ content: ""; position: absolute; left: 0; right: 0; bottom: 6px; height: 1px; background: currentColor; }
.ruler .ticks { position: absolute; left: 0; right: 0; bottom: 6px; height: 9px; pointer-events: none;
  background:
    repeating-linear-gradient(90deg, currentColor 0 1px, transparent 1px 10%) left bottom / calc(100% - 1px) 9px no-repeat,
    repeating-linear-gradient(90deg, currentColor 0 1px, transparent 1px 5%) left bottom / calc(100% - 1px) 4px no-repeat; }
.ruler .ticks::after { content: ""; position: absolute; right: 0; bottom: 0; width: 1px; height: 9px; background: currentColor; }
.ruler .fill { position: absolute; left: 0; bottom: 4px; height: 4px; border-radius: 2px; width: calc(var(--v) * 10%); max-width: 100%; background: var(--mark); }
.ruler .mark { position: absolute; bottom: 7px; left: calc(var(--v) * 10%); width: 0; height: 0; margin-left: -5px; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 9px solid var(--mark); }
.ruler .mark::after { content: ""; position: absolute; left: -1px; top: -9px; width: 2px; height: 17px; background: var(--mark); }
.ruler[data-unknown="true"] .fill, .ruler[data-unknown="true"] .mark { display: none; }
.ruler[data-unknown="true"] { color: var(--muted); opacity: .7; }
.ruler.sm { height: 18px; min-width: 72px; }
.ruler.lg { height: 34px; }
.ruler-ends { display: flex; justify-content: space-between; font: 600 10px/1 var(--mono); letter-spacing: .08em; color: var(--muted); margin-top: 2px; }
.plate .ruler { color: var(--plate-ink); }
.plate .ruler .fill { background: var(--mark-plate); }
.plate .ruler .mark { border-top-color: var(--mark-plate); }
.plate .ruler .mark::after { background: var(--mark-plate); }

/* ---------- 6. the plate ---------- */
/* A plate is a printed rectangle: plate blue, no radius, no shadow, one keyline, a caption row in small caps with the catalogue number in mono.
   Always --plate, in both themes. <figure class="plate"><div class="plate-art"><canvas></canvas></div><figcaption class="plate-cap">...</figcaption></figure> (see plate.js plateFigure). */
.plate { margin: 0; background: var(--plate); color: var(--plate-ink); border-radius: var(--r-plate); padding: 12px 12px 0; position: relative; box-shadow: inset 0 0 0 1px rgba(255,255,255,.09), 0 18px 40px -22px rgba(14,11,31,.6); }
.plate-art { position: relative; background: var(--plate); line-height: 0; border-radius: 12px; overflow: hidden; }
.plate-art canvas { display: block; width: 100%; height: auto; image-rendering: auto; }
.plate-art::after { content: ""; position: absolute; inset: 0; border-radius: 12px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); pointer-events: none; }
.plate-cap { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px var(--s-4); padding: 10px 4px 13px; font: 700 11px/1.3 var(--sans); font-variant-caps: all-small-caps; letter-spacing: .1em; }
.plate-cap .cat-no { font-family: var(--mono); font-variant-caps: normal; color: var(--plate-ink); }
.plate-cap .title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .92; }
.plate-cap .meta { font-family: var(--mono); font-variant-caps: normal; font-size: 11px; letter-spacing: .04em; opacity: .75; }
.plate-cap a, .plate-cap button { color: var(--plate-ink); }
.plate.sm { padding: 6px 6px 0; border-radius: 14px; }
.plate.sm .plate-art { border-radius: 9px; }
.plate.sm .plate-cap { padding: 6px 1px 7px; }
.plate.flush { padding: 0; }
.plate-key { display: grid; gap: var(--s-1); padding: var(--s-3) 2px 12px; border-top: 1px solid rgba(255,255,255,.14); font: var(--fs-0)/1.4 var(--mono); }
/* the thumbnail used in ledger rows: a miniature plate */
.thumb { display: block; width: 88px; height: 44px; background: var(--plate); border-radius: 10px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255,255,255,.1); flex: none; }
.thumb canvas { display: block; width: 100%; height: 100%; }
/* scan line drawn by plate.js scanReveal is canvas-only; this is the playhead for DOM overlays */
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; pointer-events: none; transform: translateX(-1px); }
.playhead::before { content: ""; position: absolute; top: -1px; left: -4px; border: 5px solid transparent; border-top-color: #fff; }

/* ---------- 7. ledger and tables ---------- */
/* the ledger: ranked rows set between hairlines, like the key of a field-guide plate */
.ledger { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.ledger-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s-1) var(--s-4); align-items: center; padding: var(--s-3) var(--s-2); border-bottom: 1px solid var(--line); border-radius: 0; color: var(--ink); text-decoration: none; position: relative; }
.ledger-row .rank { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--tint-soft); color: var(--tint-ink); font: 800 var(--fs-1) var(--display); }
.ledger-row .what { display: grid; gap: 4px; min-width: 0; }
.ledger-row .name { font: 800 var(--fs-3)/1.15 var(--display); letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; }
.ledger-row .sub { font-size: var(--fs-1); color: var(--muted); }
.ledger-row .score { font: 600 var(--fs-1) var(--mono); }
a.ledger-row:hover, button.ledger-row:hover { background: var(--tint-soft); text-decoration: none; }
.ledger-row[aria-current="true"], .ledger-row.is-lit { background: var(--tint-soft); box-shadow: inset 4px 0 0 var(--tint); }
.ledger-row.has-thumb { grid-template-columns: auto minmax(0, 1fr) auto; }
.ledger-row .keybar { grid-column: 2 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-3); align-items: end; }
@media (min-width: 768px) { .ledger-row.wide { grid-template-columns: 3ch minmax(0, 1.4fr) minmax(160px, 1fr) auto; } .ledger-row.wide .keybar { grid-column: auto; display: contents; } }
.ledger.compact .ledger-row { padding: var(--s-2) 2px; }

.table-wrap { overflow-x: auto; border-top: 3px solid var(--tint); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-1); }
.table caption { text-align: left; padding: var(--s-2) 0; color: var(--muted); font: var(--fs-0) var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: baseline; }
.table th { font: 600 var(--fs-0) var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; background: var(--bg); position: sticky; top: 0; }
.table th button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.table th button:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.table th[aria-sort="ascending"] button::after { content: "\25B2"; font-size: 8px; }
.table th[aria-sort="descending"] button::after { content: "\25BC"; font-size: 8px; }
.table td.r, .table th.r { text-align: right; }
.table td.num, .table .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.table tbody tr:hover { background: var(--surface); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--s-5); margin: 0; font-size: var(--fs-1); }
.kv dt { color: var(--muted); font: 600 var(--fs-0) var(--mono); letter-spacing: .08em; text-transform: uppercase; padding-top: 2px; }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.stat { display: grid; gap: 2px; }
.stat .v { font: 800 var(--fs-5)/1 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat .k { font: 600 var(--fs-0) var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; border-top: 3px solid var(--tint); border-bottom: 1px solid var(--line); }
.stats > .stat { padding: var(--s-4) var(--s-4) var(--s-4) 0; border-right: 1px solid var(--line); padding-left: var(--s-4); }
.stats > .stat:first-child { padding-left: 0; }
.stats > .stat:last-child { border-right: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); }
.checks { list-style: none; margin: 0; padding: 0; display: grid; }
.check-row { display: grid; grid-template-columns: 20px 1fr auto; gap: var(--s-3); align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-1); }
.check-row .i { width: 16px; height: 16px; align-self: center; }
.check-row[data-state="pass"] .i { color: var(--ok); } .check-row[data-state="fail"] .i { color: var(--bad); } .check-row[data-state="warn"] .i { color: var(--warn); }

/* ---------- 8. feedback: empty, skeleton, banner, dialog, toast ---------- */
.empty { display: grid; justify-items: start; gap: var(--s-3); padding: var(--s-6) var(--s-5); border-radius: var(--r-lg); background: var(--tint-soft); }
.empty .plate-ghost { width: min(320px, 100%); aspect-ratio: 5 / 2; border-radius: 14px; background: var(--plate) repeating-linear-gradient(90deg, transparent 0 11px, rgba(255,255,255,.08) 11px 12px); }
.empty h3 { margin: 0; }
.empty p { margin: 0; color: var(--muted); max-width: 40em; }

.skeleton { position: relative; overflow: hidden; background: var(--line); border-radius: 6px; min-height: 1em; color: transparent; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--bg) 70%, transparent), transparent); transform: translateX(-100%); animation: shimmer 1.3s infinite; }
.skeleton.plate-sk { background: var(--plate); aspect-ratio: 5 / 2; border-radius: var(--r-plate); }
.skeleton.plate-sk::after { background: linear-gradient(90deg, transparent, rgba(234, 241, 251, .18), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }

.banner { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border: 1px solid var(--line); border-left: 5px solid var(--line-strong); border-radius: var(--r); background: var(--surface); font-size: var(--fs-1); margin: 0 0 var(--s-4); }
.banner .i { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.banner > div { flex: 1; min-width: 0; }
.banner b { font-weight: 700; }
.banner[data-tone="ok"] { border-left-color: var(--ok); } .banner[data-tone="ok"] .i { color: var(--ok); }
.banner[data-tone="warn"] { border-left-color: var(--warn); } .banner[data-tone="warn"] .i { color: var(--warn); }
.banner[data-tone="bad"] { border-left-color: var(--bad); } .banner[data-tone="bad"] .i { color: var(--bad); }
.banner[data-tone="info"] { border-left-color: var(--brand); } .banner[data-tone="info"] .i { color: var(--brand-ink); }
.alert { color: var(--bad-ink); font-size: var(--fs-1); }

dialog.dlg { padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); border: 0; border-radius: var(--r-lg); background: var(--surface); color: var(--ink); overflow: auto; box-shadow: 0 30px 80px -20px rgba(14,11,31,.55); }
dialog.dlg::backdrop { background: var(--scrim); }
.dlg-in { padding: var(--s-5); display: grid; gap: var(--s-3); }
.dlg h2 { font-size: var(--fs-4); margin: 0; }
.dlg p { margin: 0; color: var(--muted); }
.dlg-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: flex-end; margin-top: var(--s-3); }
.dlg-x { position: absolute; right: 8px; top: 8px; }
dialog.dlg.sheet { width: min(640px, 100vw); }
@media (max-width: 599px) {
  dialog.dlg { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 24px 24px 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); }
  .dlg-in::before { content: ""; justify-self: center; width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: -8px 0 4px; }
  .dlg-actions { flex-direction: column-reverse; } .dlg-actions .btn { width: 100%; }
}

.toasts { position: fixed; z-index: 90; left: 50%; transform: translateX(-50%); bottom: calc(var(--s-5) + env(safe-area-inset-bottom)); display: grid; gap: var(--s-2); width: min(420px, calc(100vw - 24px)); pointer-events: none; }
@media (max-width: 767px) { body.has-tabbar .toasts { bottom: calc(var(--tabbar-h) + 22px + env(safe-area-inset-bottom)); } }
.toast { pointer-events: auto; display: flex; gap: var(--s-3); align-items: flex-start; padding: 11px 14px; background: var(--ink); color: var(--bg); border-left: 5px solid var(--tint); border-radius: var(--r); font: 600 var(--fs-1)/1.4 var(--sans); animation: toast-in var(--dur-2) var(--ease); }
.toast[data-tone="ok"] { border-left-color: var(--ok); } .toast[data-tone="warn"] { border-left-color: var(--warn); } .toast[data-tone="bad"] { border-left-color: var(--bad); }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; text-decoration: underline; font: inherit; cursor: pointer; padding: 0; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity var(--dur-2), transform var(--dur-2); }

/* ---------- 9. utilities ---------- */
.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: middle; }
.i.fill { fill: currentColor; stroke: none; }
.sr-only { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.stack { display: grid; gap: var(--s-4); }
.row { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); }
.grow { flex: 1 1 auto; min-width: 0; }
.cols { display: grid; gap: var(--s-5); }
@media (min-width: 900px) { .cols.two { grid-template-columns: 1fr 1fr; } .cols.plate-side { grid-template-columns: minmax(0, 1.25fr) minmax(300px, 1fr); align-items: start; } }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.noscript { padding: var(--s-5) var(--gutter); }

/* the shared team sign-in page (/team/login) renders in this stylesheet too */
body.auth-page { display: grid; place-items: center; min-height: 100vh; margin: 0; padding: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); }

/* ---------- 10. motion (all of it optional) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .ledger-row.settle { animation: settle var(--dur-2) var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); }
  @keyframes settle { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
  .fade-in { animation: fade var(--dur-2) var(--ease) both; }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
  .live-dot { animation: pulse 1.2s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: .35; } }
  dialog.dlg[open] { animation: dlg-in var(--dur-2) var(--ease); }
  @keyframes dlg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  @keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .skeleton::after { display: none; }
}
@media print { .masthead, .tabbar, .site-foot, .toasts { display: none !important; } body { background: #fff; } }
.menu-who span + span { margin-top: 2px; }
