/* JewelLens console. Tokens are docs/BRAND.md verbatim; components are listed in docs/UI.md.
   The page is bone (light) or velvet (dark) with hairline rules and a serif display face; colour is
   data: patina teal = Confirmed and the one filled button, amber = Possible, slate = Not verifiable.
   Cartouches live in cartouche.css. Build on token NAMES only; raw hex belongs to this file
   (and to the four metal swatches). */
:root {
  color-scheme: light;
  --bg: #F4EFE6; --surface: #FBF8F2; --ink: #17201F; --muted: #5E6A68; --line: #D9D1C1;
  --brand: #0F6B66; --brand-ink: #0A4F4B; --warn: #B86E00; --nv: #6B7280; --bad: #A3262A; --ok: #2F7D4F;
  /* derived, same hues */
  --bg-2: #EBE5D8; --bg-3: #E0D9C8; --surface-2: #F6F2E9; --ink-2: #2B3735; --faint: #8A9390; --line-2: #BFB5A0;
  --brand-soft: rgba(15,107,102,.10); --warn-soft: rgba(184,110,0,.12); --nv-soft: rgba(107,114,128,.12);
  --bad-soft: rgba(163,38,42,.09); --ok-soft: rgba(47,125,79,.12);
  --warn-ink: #8A5200; --nv-ink: #565D6A; --bad-ink: #8F1F23; --ok-ink: #236640;
  --on-brand: #FFFFFF; --focus: #0F6B66; --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--focus);
  --scrim: rgba(12,21,20,.55); --shadow-lg: 0 24px 60px -24px rgba(12,21,20,.45);
  /* constants: the velvet is the same in both themes */
  --velvet: #0C1514; --velvet-2: #121D1C; --velvet-3: #1B2B29; --on-velvet: #EDE8DC; --on-velvet-2: #9AA8A5; --velvet-line: #243331;
  --metal-yellow: #D9B44A; --metal-white: #D5D9DC; --metal-rose: #D99A8B; --metal-dark: #3A3A3C;
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font: ui-sans-serif, system-ui, -apple-system, "SF Pro Text", "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 10px; --radius-sm: 6px; --radius-xs: 2px;
  --page-w: 1200px; --gutter: 32px; --bar-h: 56px; --tab-h: 60px;
  --info: var(--nv); --info-ink: var(--nv-ink); --info-soft: var(--nv-soft);
  --accent: var(--brand); --accent-ink: var(--brand-ink); --text: var(--ink); --surface-solid: var(--surface);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0C1514; --surface: #121D1C; --ink: #EDE8DC; --muted: #9AA8A5; --line: #243331;
  --brand: #3FC1B5; --brand-ink: #7FE0D6; --warn: #E7A53A; --nv: #8A94A3; --bad: #F0716F; --ok: #58C28A;
  --bg-2: #101B1A; --bg-3: #172624; --surface-2: #162422; --ink-2: #D6D1C5; --faint: #70807D; --line-2: #35504C;
  --brand-soft: rgba(63,193,181,.14); --warn-soft: rgba(231,165,58,.14); --nv-soft: rgba(138,148,163,.16);
  --bad-soft: rgba(240,113,111,.14); --ok-soft: rgba(88,194,138,.14);
  --warn-ink: #E7A53A; --nv-ink: #A9B2BF; --bad-ink: #F0716F; --ok-ink: #58C28A;
  --on-brand: #06201E; --focus: #7FE0D6; --scrim: rgba(0,0,0,.62); --shadow-lg: 0 24px 60px -24px rgba(0,0,0,.8);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0C1514; --surface: #121D1C; --ink: #EDE8DC; --muted: #9AA8A5; --line: #243331;
    --brand: #3FC1B5; --brand-ink: #7FE0D6; --warn: #E7A53A; --nv: #8A94A3; --bad: #F0716F; --ok: #58C28A;
    --bg-2: #101B1A; --bg-3: #172624; --surface-2: #162422; --ink-2: #D6D1C5; --faint: #70807D; --line-2: #35504C;
    --brand-soft: rgba(63,193,181,.14); --warn-soft: rgba(231,165,58,.14); --nv-soft: rgba(138,148,163,.16);
    --bad-soft: rgba(240,113,111,.14); --ok-soft: rgba(88,194,138,.14);
    --warn-ink: #E7A53A; --nv-ink: #A9B2BF; --bad-ink: #F0716F; --ok-ink: #58C28A;
    --on-brand: #06201E; --focus: #7FE0D6; --scrim: rgba(0,0,0,.62); --shadow-lg: 0 24px 60px -24px rgba(0,0,0,.8);
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--bar-h) + 16px); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; min-height: 100vh; overflow-wrap: anywhere; }
body.public { overflow-wrap: normal; }
img, svg, canvas, video { max-width: 100%; }
a { color: var(--brand-ink); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-xs); }
.velvet :focus-visible, .public :focus-visible { --ring: 0 0 0 2px var(--velvet), 0 0 0 4px var(--focus); }
::selection { background: var(--brand); color: var(--on-brand); }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
h1, h2, h3, h4 { margin: 0; line-height: 1.12; font-weight: 600; letter-spacing: -.01em; }
h1 { font: 500 clamp(2.1rem, 5.2vw, 3.6rem)/1.04 var(--display); letter-spacing: -.02em; }
h2 { font: 500 1.5rem/1.15 var(--display); letter-spacing: -.01em; }
h3 { font-size: 1.05rem; }
h1 em, h2 em, .serif-em { font-style: italic; font-weight: 400; color: var(--brand-ink); }
p { margin: 0; }
.i { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.eyebrow { font: 600 .68rem/1.2 var(--font); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.display { font: 500 clamp(2.6rem, 7vw, 4.6rem)/1 var(--display); letter-spacing: -.03em; font-variant-numeric: lining-nums tabular-nums; }
.display.md { font-size: clamp(1.9rem, 4vw, 2.7rem); } .display.sm { font-size: 1.6rem; }
.serif { font-family: var(--display); }
.mono, .stamp-text { font-family: var(--mono); }
.stamp-text { letter-spacing: .18em; text-transform: uppercase; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: .85rem; } .nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 100; padding: 10px 14px; background: var(--ink); color: var(--bg); border-radius: var(--radius-sm); }
.skip-link:focus { top: 8px; }
[hidden] { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } .row.between { justify-content: space-between; flex-wrap: nowrap; }
.stack { display: grid; gap: 16px; } .stack.sm { gap: 10px; } .stack.lg { gap: 28px; }
.grow { flex: 1; min-width: 0; } .right { margin-left: auto; }

/* ---------- shell: top bar, tab bar, More sheet ---------- */
.topbar { position: sticky; top: 0; z-index: 40; height: calc(var(--bar-h) + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top);
  display: flex; align-items: center; gap: 28px; padding-inline: var(--gutter);
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent; transition: border-color .2s; }
.topbar.scrolled { border-bottom-color: var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; flex: none; }
.brand:hover { text-decoration: none; }
.brand-mark img { display: block; width: 28px; height: 28px; }
.wm { font: 500 1.28rem/1 var(--display); letter-spacing: -.02em; }
.wm em { font-style: italic; font-weight: 400; color: var(--brand-ink); }
.topnav { display: flex; gap: 6px; flex: 1; }
.topnav a { position: relative; padding: 8px 10px; color: var(--muted); text-decoration: none; font-size: .92rem; font-weight: 500; }
.topnav a:hover { color: var(--ink); text-decoration: none; }
.topnav a[aria-current="page"] { color: var(--ink); }
.topnav a[aria-current="page"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 2px; height: 2px; background: var(--brand); }
.topbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
body[data-page="dashboard"] .top-examine, body[data-page="analyze"] .top-examine { display: none; }
.wallet-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--line-2); border-radius: 999px; color: var(--ink); text-decoration: none; font-size: .82rem; font-variant-numeric: tabular-nums; }
.wallet-chip .wl { font-size: .74rem; } .wallet-chip.low { border-color: var(--warn); color: var(--warn-ink); }
.user-menu { position: relative; }
.avatar { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: 600 .78rem var(--font); letter-spacing: .04em; cursor: pointer; }
.avatar:hover { border-color: var(--ink); }
.pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; min-width: 240px; padding: 6px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.pop .who { display: grid; padding: 10px 12px 8px; font-size: .86rem; } .pop .who span { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; }
.pop a, .pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; background: none; border-radius: var(--radius-sm); color: var(--ink); text-align: left; text-decoration: none; cursor: pointer; font-size: .9rem; }
.pop a:hover, .pop button:hover, .more-sheet a:hover { background: var(--bg-2); text-decoration: none; }
.pop hr { margin: 6px 0; }
.main { max-width: var(--page-w); margin: 0 auto; padding: 8px var(--gutter) 96px; min-height: calc(100vh - var(--bar-h)); }
.main:focus { outline: none; }
.tabbar, .more-sheet { display: none; }
@media (max-width: 860px) {
  :root { --gutter: 18px; --bar-h: 52px; }
  .topnav, .topbar .top-examine, .topbar .wallet-chip, .topbar .user-menu { display: none; }
  .topbar { gap: 12px; }
  .main { padding-bottom: calc(var(--tab-h) + 40px + env(safe-area-inset-bottom)); }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px); border-top: 1px solid var(--line); }
  .tabbar a, .tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 44px; border: 0; background: none; color: var(--muted); text-decoration: none; font-size: .68rem; font-weight: 600; letter-spacing: .02em; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .tabbar .i { width: 22px; height: 22px; }
  .tabbar [aria-current="page"], .tabbar .current { color: var(--brand-ink); }
  .tabbar [aria-current="page"]::before, .tabbar .current::before { content: ""; position: absolute; top: 0; width: 22px; height: 2px; background: var(--brand); }
  .tabbar .tab-examine { color: var(--ink); }
  .tabbar .tab-examine .ring { display: grid; place-items: center; width: 46px; height: 46px; margin-top: -22px; border-radius: 50%; background: var(--velvet); color: var(--on-velvet); border: 2px solid var(--brand); }
  .tabbar .tab-examine::before { display: none; }
  .tabbar .tab-examine span.t { margin-top: 1px; }
  .more-sheet { position: fixed; inset: 0; z-index: 60; background: var(--scrim); align-items: flex-end; }
  .more-sheet:not([hidden]) { display: flex; }
  .more-sheet .sheet { width: 100%; max-height: 80vh; overflow: auto; padding: 18px 12px calc(18px + env(safe-area-inset-bottom)); background: var(--surface); border-radius: 18px 18px 0 0; border: 1px solid var(--line-2); border-bottom: 0; animation: sheet-up .22s ease-out; }
  .more-sheet .eyebrow { display: block; padding: 0 12px 8px; }
  .more-sheet a, .more-sheet button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 10px 12px; border: 0; background: none; color: var(--ink); border-radius: var(--radius-sm); text-decoration: none; font-size: 1rem; text-align: left; cursor: pointer; }
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.toasts { position: fixed; z-index: 90; right: 16px; bottom: 16px; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
@media (max-width: 860px) { .toasts { left: 16px; right: 16px; width: auto; bottom: calc(var(--tab-h) + 14px + env(safe-area-inset-bottom)); } }

/* ---------- page structure: 12 columns with a margin rail for small labels ---------- */
.page { padding-top: 28px; }
.page-head { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 0 24px; align-items: end; padding: 22px 0 26px; }
.page-head > .eyebrow { grid-column: 1 / span 3; align-self: start; padding-top: .7em; }
.page-head > h1, .page-head > .ph-title { grid-column: 4 / span 6; }
.page-head > .sub { grid-column: 4 / span 6; margin-top: 12px; color: var(--muted); max-width: 60ch; }
.page-head > .actions { grid-column: 10 / span 3; justify-self: end; display: flex; gap: 10px; flex-wrap: wrap; align-self: end; }
.page-head.plain > .eyebrow, .page-head.plain > h1, .page-head.plain > .sub, .page-head.plain > .actions { grid-column: 1 / -1; justify-self: start; }
.grid12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 24px; }
.grid12 > .rail { grid-column: span 3; } .grid12 > .col-3 { grid-column: span 3; } .grid12 > .col-4 { grid-column: span 4; } .grid12 > .col-5 { grid-column: span 5; }
.grid12 > .col-6 { grid-column: span 6; } .grid12 > .col-7 { grid-column: span 7; } .grid12 > .col-8 { grid-column: span 8; } .grid12 > .col-9 { grid-column: span 9; } .grid12 > .col-12 { grid-column: 1 / -1; }
.grid12 > .start-4 { grid-column-start: 4; } .grid12 > .start-7 { grid-column-start: 7; }
.rail { font-size: .8rem; color: var(--muted); }
.rail .eyebrow { display: block; margin-bottom: 6px; }
.sect { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px 24px; padding: 26px 0; border-top: 1px solid var(--line); }
.sect-head { grid-column: span 3; } .sect-body { grid-column: span 9; min-width: 0; }
.sect-head h2 { font: 600 .74rem/1.3 var(--font); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.sect-head p { margin-top: 8px; font-size: .85rem; color: var(--muted); max-width: 26ch; }
.sect.full .sect-head, .sect.full .sect-body { grid-column: 1 / -1; }
.rule { height: 1px; background: var(--line); border: 0; margin: 0; } .rule.thick { height: 2px; background: var(--ink); }
@media (max-width: 900px) {
  .page { padding-top: 10px; }
  .page-head { display: block; padding: 14px 0 18px; }
  .page-head > .eyebrow { display: block; margin-bottom: 10px; padding: 0; }
  .page-head > .actions { margin-top: 16px; justify-content: flex-start; }
  .grid12 { grid-template-columns: 1fr; gap: 18px; } .grid12 > * { grid-column: 1 / -1 !important; }
  .sect { display: block; padding: 20px 0; } .sect-head { margin-bottom: 14px; } .sect-head p { max-width: none; }
}

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 9px 16px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: transparent; color: var(--ink); font-weight: 600; font-size: .92rem; line-height: 1.2; text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background .15s, border-color .15s, transform .08s; }
.btn:hover { border-color: var(--ink); text-decoration: none; background: var(--bg-2); }
.btn:active { transform: translateY(1px); }
.btn.primary, .btn.cta { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover, .btn.cta:hover { background: var(--brand-ink); border-color: var(--brand-ink); color: var(--on-brand); }
:root[data-theme="dark"] .btn.primary:hover, :root[data-theme="dark"] .btn.cta:hover { background: color-mix(in srgb, var(--brand) 88%, #fff); border-color: transparent; }
.btn.ghost { border-color: transparent; } .btn.ghost:hover { background: var(--bg-2); border-color: transparent; }
.btn.danger { color: var(--bad-ink); border-color: color-mix(in srgb, var(--bad) 55%, var(--line)); } .btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.danger.fill { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.sm { min-height: 32px; padding: 5px 11px; font-size: .84rem; } .btn.lg { min-height: 50px; padding: 13px 24px; font-size: 1rem; }
.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(--ink); border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn.primary[aria-busy="true"]::after, .btn.cta[aria-busy="true"]::after { border-color: var(--on-brand); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }
.link { background: none; border: 0; padding: 0; color: var(--brand-ink); text-decoration: underline; text-underline-offset: .18em; cursor: pointer; font-size: inherit; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; } .field > label, .field > .lbl { font: 600 .68rem/1.2 var(--font); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.field .hint { font-size: .82rem; color: var(--muted); } .field .err, .err { font-size: .84rem; color: var(--bad-ink); }
.input, select.input, textarea.input { width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-size: 16px; }
textarea.input { min-height: 88px; resize: vertical; line-height: 1.45; }
.input:hover { border-color: var(--muted); } .input:focus-visible { border-color: var(--brand); box-shadow: var(--ring); }
.input.invalid, .input[aria-invalid="true"] { border-color: var(--bad); }
.input::placeholder { color: var(--faint); }
select.input { 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) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; } .form-grid .wide { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track { position: relative; flex: none; width: 42px; height: 24px; border-radius: 999px; background: var(--line-2); transition: background .15s; }
.switch .track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.switch input:checked + .track { background: var(--brand); } .switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: var(--ring); }
.check { display: inline-flex; align-items: flex-start; gap: 10px; cursor: pointer; } .check input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { padding: 7px 14px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-weight: 600; font-size: .86rem; } .seg button + button { border-left: 1px solid var(--line-2); }
.seg button[aria-pressed="true"], .seg button[aria-checked="true"] { background: var(--ink); color: var(--bg); }
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button, .tabs a { padding: 10px 0; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; color: var(--muted); cursor: pointer; font-weight: 600; text-decoration: none; white-space: nowrap; }
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--ink); border-bottom-color: var(--brand); }
.setting { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 20px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; } .setting .t { font-weight: 600; } .setting .d { font-size: .86rem; color: var(--muted); max-width: 56ch; margin-top: 2px; }
@media (max-width: 640px) { .setting:has(.range-field) { grid-template-columns: 1fr; } }
.pick { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border: 1px solid var(--line-2); border-radius: 999px; background: transparent; cursor: pointer; font-size: .86rem; }
.pick[aria-pressed="true"] { border-color: var(--ink); background: var(--bg-2); }

/* ---------- chips, badges, banners, callouts ---------- */
.chip, .badge, .tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border: 1px solid var(--line-2); border-radius: 999px; font-size: .78rem; font-weight: 600; line-height: 1.4; color: var(--ink-2); background: transparent; white-space: nowrap; }
.badge.ok { color: var(--ok-ink); border-color: color-mix(in srgb, var(--ok) 50%, transparent); background: var(--ok-soft); }
.badge.warn { color: var(--warn-ink); border-color: color-mix(in srgb, var(--warn) 50%, transparent); background: var(--warn-soft); }
.badge.bad { color: var(--bad-ink); border-color: color-mix(in srgb, var(--bad) 50%, transparent); background: var(--bad-soft); }
.badge.brand, .badge.info { color: var(--brand-ink); border-color: color-mix(in srgb, var(--brand) 45%, transparent); background: var(--brand-soft); }
.badge.nv { color: var(--nv-ink); background: var(--nv-soft); }
.badge.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip button { border: 0; background: none; padding: 0; cursor: pointer; color: var(--muted); line-height: 1; }
.banner, .alert, .callout { display: flex; align-items: center; gap: 14px; padding: 12px 16px; margin: 12px 0; border: 1px solid var(--line-2); border-left-width: 3px; border-radius: var(--radius-sm); background: var(--surface); font-size: .92rem; }
.banner.warn, .alert.warn { border-color: var(--warn); background: var(--warn-soft); } .banner.bad, .alert.bad { border-color: var(--bad); background: var(--bad-soft); }
.banner.ok, .alert.ok { border-color: var(--ok); background: var(--ok-soft); } .banner.info, .callout { border-color: var(--nv); background: var(--nv-soft); }
.callout { display: block; }
@media (max-width: 640px) { .banner { flex-wrap: wrap; } }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--velvet); color: var(--on-velvet); border: 1px solid var(--velvet-line); box-shadow: var(--shadow-lg); font-size: .9rem; pointer-events: auto; animation: toast-in .2s ease-out; }
.toast .body { flex: 1; } .toast a { color: #7FE0D6; } .toast.bad { border-color: #F0716F; } .toast.ok { border-color: #58C28A; } .toast.warn { border-color: #E7A53A; }
.toast .x { border: 0; background: none; color: var(--on-velvet-2); cursor: pointer; padding: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- dialog ---------- */
.scrim { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: var(--scrim); animation: fade .15s ease-out; }
.dialog { width: min(480px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 22px 22px 18px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: rise .2s ease-out; }
.dialog.wide { width: min(720px, 100%); } .dialog h2 { font-size: 1.35rem; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.secret { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px dashed var(--line-2); border-radius: var(--radius-sm); font: .86rem var(--mono); word-break: break-all; background: var(--bg-2); }
@keyframes fade { from { opacity: 0; } } @keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@media (max-width: 640px) { .scrim { align-items: end; padding: 0; } .dialog, .dialog.wide { width: 100%; border-radius: 18px 18px 0 0; border-bottom: 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); animation: sheet-up .22s ease-out; } }

/* ---------- data: tables, facts, kpis, rows, cards ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th { padding: 8px 12px 8px 0; border-bottom: 1px solid var(--ink); text-align: left; font: 600 .68rem/1.2 var(--font); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
table.t th.sortable { cursor: pointer; } table.t th.sortable:hover { color: var(--ink); }
table.t th[aria-sort="ascending"]::after { content: " ↑"; } table.t th[aria-sort="descending"]::after { content: " ↓"; }
table.t td { padding: 11px 12px 11px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t .num { text-align: right; padding-right: 0; } table.t td.td-actions { text-align: right; white-space: nowrap; }
table.t tr.clickable { cursor: pointer; } table.t tr.clickable:hover td { background: var(--bg-2); }
.pagebar { display: flex; justify-content: center; padding: 14px 0 0; }
@media (max-width: 640px) {
  table.t.stackable thead { display: none; } table.t.stackable tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.t.stackable td { display: flex; justify-content: space-between; gap: 16px; border: 0; padding: 3px 0; text-align: right; }
  table.t.stackable td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .1em; text-align: left; }
}
.facts { margin: 0; display: grid; } .facts > div { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(0, 2fr); gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--muted); font-size: .86rem; } .facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.rows > * { padding: 12px 0; border-bottom: 1px solid var(--line); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 24px; } .kpi .v { font: 500 2rem/1 var(--display); font-variant-numeric: tabular-nums; } .kpi .l { margin-top: 6px; font-size: .8rem; color: var(--muted); }
.obj, .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 12px; } .card-head .sub { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.crumbs { display: flex; gap: 8px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.sub { color: var(--muted); }
/* the velvet plate: where photographs and specimens sit, the same in both themes */
.velvet { background: radial-gradient(120% 90% at 50% 0%, var(--velvet-3), var(--velvet) 70%); color: var(--on-velvet); border-radius: var(--radius); }
/* the four apparent metal colours, as flat measured swatches */
.metal { display: inline-block; width: 1em; height: 1em; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); vertical-align: -.12em; }
.metal.yellow { --sw: var(--metal-yellow); } .metal.white { --sw: var(--metal-white); } .metal.rose { --sw: var(--metal-rose); } .metal.dark { --sw: var(--metal-dark); }
.band { display: flex; height: 44px; } .band.tall { height: 80px; } .band.slim { height: 14px; } .band > * { flex: var(--w, 1) 1 0; min-width: 0; background: var(--sw); }

/* ---------- states: skeleton, empty, error ---------- */
.skel { border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 37%, var(--bg-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
.skel.chart { height: 240px; } .skel.line { height: 14px; margin: 8px 0; } .skel.kpi-s { height: 90px; } .skel.block { height: 120px; } .skel.photo { aspect-ratio: 1; }
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
.empty { display: grid; justify-items: start; gap: 8px; padding: 28px 0; color: var(--muted); }
.empty .big { display: grid; place-items: center; width: 52px; height: 52px; border: 1px dashed var(--line-2); border-radius: 50% / 40%; color: var(--muted); } .empty .big .i { width: 24px; height: 24px; }
.empty h3 { color: var(--ink); font: 500 1.3rem/1.2 var(--display); } .empty p { max-width: 50ch; }

/* ---------- motion ---------- */
@keyframes blur-fade { from { opacity: 0; transform: translateY(8px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
#app:not(.settled) .stagger > *, .blur-fade { animation: blur-fade .5s ease-out both; }
.stagger > :nth-child(2) { animation-delay: .06s; } .stagger > :nth-child(3) { animation-delay: .12s; } .stagger > :nth-child(4) { animation-delay: .18s; } .stagger > :nth-child(n+5) { animation-delay: .24s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ---------- charts (lib/charts.js, lib/usagechart.js): hand-drawn SVG, tokens only ---------- */
.ch { position: relative; width: 100%; } .ch-box { outline: none; } .ch-box:focus-visible { box-shadow: var(--ring); }
.ch-svg { display: block; width: 100%; height: auto; overflow: visible; }
.ch-grid line { stroke: var(--line); stroke-width: 1; } .ch-grid text, .ch-xaxis text { fill: var(--muted); font: 11px var(--mono); }
.ch-line { fill: none; stroke: var(--c); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ch-dot { fill: var(--bg); stroke: var(--c); stroke-width: 1.75; } .ch-dot.sm { fill: var(--c); stroke: none; }
.ch-cross { stroke: var(--ink); stroke-width: 1; } .ch-ring { fill: var(--bg); stroke: var(--c); stroke-width: 2.5; } .ch-hit { cursor: crosshair; }
.ch-msg { margin: 0; padding: 28px 0; color: var(--muted); }
.ch-tip { position: absolute; z-index: 3; pointer-events: none; min-width: 150px; max-width: 240px; padding: 9px 12px; border-radius: var(--radius-sm); background: var(--velvet); color: var(--on-velvet); font-size: .8rem; }
.ch-tip-h { font-weight: 700; margin-bottom: 5px; } .ch-tip-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; } .ch-tip-row b { font-variant-numeric: tabular-nums; }
.ch-key { display: inline-block; width: 10px; height: 10px; background: var(--c); flex: none; border-radius: 1px; }
.ch-key.dashed { width: 18px; height: 3px; background: repeating-linear-gradient(90deg, var(--c) 0 5px, transparent 5px 8px); }
.ch-legend { display: flex; flex-wrap: wrap; gap: 6px 22px; list-style: none; margin: 0 0 14px; padding: 0; font-size: .86rem; color: var(--ink-2); } .ch-legend li { display: inline-flex; align-items: center; gap: 8px; }
.ch-stack-wrap { display: grid; gap: 14px; } .ch-stack { display: flex; gap: 2px; height: clamp(44px, 9vw, 64px); }
.ch-stack > i { display: block; flex-basis: 0; min-width: 4px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); position: relative; }
.ch-stack > i:hover::after, .ch-stack > i:focus-visible::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); white-space: nowrap; padding: 5px 9px; border-radius: var(--radius-sm); background: var(--velvet); color: var(--on-velvet); font-size: .76rem; z-index: 5; }
.ch-stack > i:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; box-shadow: none; }
.ch-stack-key { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: 10px 22px; list-style: none; margin: 0; padding: 0; }
.ch-stack-key li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 9px; align-items: center; font-size: .9rem; } .ch-stack-key span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-sw { display: block; width: 12px; height: 12px; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); } .ch-stack-key small { color: var(--muted); font-size: .78rem; min-width: 3ch; text-align: right; }
.ch-tape { display: none; }
.ch-rank { list-style: none; margin: 0; padding: 0; } .ch-rank li { display: grid; grid-template-columns: 2.4rem minmax(0, 1fr) auto; align-items: baseline; gap: 8px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.ch-rank-n { font: 500 .78rem var(--mono); color: var(--muted); } .ch-rank-name { font: 500 1.2rem/1.15 var(--display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .ch-rank-v { font: 600 .9rem var(--mono); }
.ch-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 11px; } .ch-bars li { display: grid; grid-template-columns: minmax(84px, 138px) minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.ch-bar-track { height: 8px; background: var(--bg-3); overflow: hidden; border-radius: 2px; } .ch-bar-fill { display: block; height: 100%; background: var(--c); border-radius: 2px; } .ch-bar-val { font-variant-numeric: tabular-nums; font-size: .9rem; text-align: right; }
.ch-bar-hint { grid-column: 2 / -1; color: var(--muted); font-size: .78rem; }
.ch-mini { display: inline-block; vertical-align: middle; } .ch-mini-bar { fill: var(--c); } .ch-mini-na { fill: var(--line-2); }
.chart { position: relative; width: 100%; } .chart svg { display: block; overflow: visible; max-width: 100%; } .chart text { fill: var(--muted); font-size: 11px; font-family: var(--mono); }
.chart .grid-line { stroke: var(--line); shape-rendering: crispEdges; } .chart .axis-line { stroke: var(--ink); shape-rendering: crispEdges; }
.chart .bar { transition: opacity .15s; } .chart .bar:focus-visible { outline: 2px solid var(--brand); }
.chart-tip { position: absolute; pointer-events: none; z-index: 5; min-width: 130px; padding: 8px 10px; border-radius: var(--radius-sm); font-size: .8rem; background: var(--velvet); color: var(--on-velvet); opacity: 0; transition: opacity .12s; } .chart-tip.on { opacity: 1; }
.chart-tip b { display: block; margin-bottom: 3px; } .chart-tip .tr { display: flex; justify-content: space-between; gap: 14px; }
.chart-msg { display: grid; place-items: center; text-align: center; color: var(--muted); min-height: 140px; padding: 20px; }

/* ---------- public shell bar (landing, error, shared) ---------- */
.pubbar { position: absolute; z-index: 5; left: 0; right: 0; top: 0; display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top)) clamp(18px, 4vw, 40px) 14px; color: var(--on-velvet); }
.pubbar .brand { color: var(--on-velvet); } .pubbar .wm em { color: #7FE0D6; }
.pubbar-actions { display: flex; align-items: center; gap: 8px; } .pub-link { color: var(--on-velvet); text-decoration: none; padding: 8px 12px; font-weight: 600; font-size: .9rem; } .pub-link:hover { text-decoration: underline; }
.pubbar .icon-btn { color: var(--on-velvet-2); } .pubbar .icon-btn:hover { background: var(--velvet-3); color: var(--on-velvet); }
.err-page { min-height: 100vh; display: grid; align-content: center; gap: 22px; padding: 120px clamp(22px, 8vw, 120px) 80px; background: radial-gradient(120% 100% at 80% 0%, var(--velvet-3), var(--velvet) 65%); color: var(--on-velvet); }
.err-page h1 { font-size: clamp(2.6rem, 8vw, 6rem); max-width: 14ch; } .err-page h1 em { color: #7FE0D6; } .err-page p { max-width: 52ch; color: var(--on-velvet-2); font-size: 1.1rem; }
.err-page .btn.primary { justify-self: start; } .err-page .code { font: .78rem var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--on-velvet-2); }
