/* RoomAnalyzer: the drafting sheet.  Tokens, shell, component kit. Binding brief: docs/BRAND.md. Kit docs: docs/UI.md.
   Measured = ink (solid hairlines). Suggested = pencil (dashed). Teal is the only filled accent. Page CSS lives in css/<page>.css. */

:root {
  color-scheme: light;
  /* paper */
  --bg: #F4EFE6; --surface: #FBF8F2; --surface-2: #EFE9DD; --paper-glow: rgba(255,255,255,.55);
  --ink: #23201C; --ink-2: #4A443C; --muted: #6E655A; --faint: #9A9084;
  --line: #D9D0C1; --line-2: #BDB19D; --dot: #D3C9B7; --rule: #B9D3CE;
  /* accent + status */
  --brand: #1F6F6B; --brand-ink: #17524F; --brand-fg: #FFFFFF; --brand-soft: #DCEBE8;
  --ok: #2E7D4F; --warn: #B7791F; --bad: #B4432F;
  --ok-soft: #E1EFE5; --warn-soft: #F5E8CF; --bad-soft: #F5DDD6;
  --warn-ink: #7A5000; --bad-ink: #8F3221; --ok-ink: #1F6038;
  /* data colours: fixed meaning everywhere */
  --c-light: #C28A1E; --c-light-ink: #755000; --c-light-soft: #F3E6C6;
  --c-colour: #A8577A; --c-colour-ink: #823F5D; --c-colour-soft: #F1DCE4;
  --c-layout: #4A6C8C; --c-layout-ink: #35506B; --c-layout-soft: #DCE5EE;
  --c-calm: #7C9A7B; --c-calm-ink: #476346; --c-calm-soft: #E1EAE0;
  --c-comfort: #B5684F; --c-comfort-ink: #8A4630; --c-comfort-soft: #F2DED6;
  --brass-lo: #2B2217; --brass-hi: #FFF0C4;
  /* type */
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --display: var(--serif);
  --fs-2xs: .6875rem; --fs-xs: .75rem; --fs-sm: .8125rem; --fs-md: .9375rem; --fs-lg: 1.125rem; --fs-xl: 1.5rem; --fs-2xl: 2.125rem; --fs-3xl: clamp(2.4rem, 5vw, 3.6rem);
  /* geometry */
  --r-sm: 4px; --r: 7px; --r-lg: 10px; --radius: var(--r); --radius-sm: var(--r-sm);
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 72px;
  --shadow: 0 1px 0 rgba(35,32,28,.04); --shadow-pop: 0 10px 30px -8px rgba(35,32,28,.28), 0 0 0 1px var(--line-2);
  --ease: cubic-bezier(.2,.7,.2,1); --t-fast: 120ms; --t: 220ms; --t-slow: 900ms;
  --page: 1180px; --dock-h: 64px; --tb-h: 56px;
  --scrim: rgba(35,32,28,.45);
}
[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }

/* dark tokens, written twice (OS preference until a toggle stores html[data-theme]) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14110F; --surface: #1D1916; --surface-2: #25201C; --paper-glow: rgba(255,255,255,.02);
    --ink: #F1EBE1; --ink-2: #CFC7BA; --muted: #A89F93; --faint: #7A7166;
    --line: #34302B; --line-2: #4D463E; --dot: #2A2622; --rule: #254A47;
    --brand: #5CC4BC; --brand-ink: #7AD6CE; --brand-fg: #0B1F1E; --brand-soft: #1B3532;
    --ok: #5BBE86; --warn: #E0A94B; --bad: #E27B66;
    --ok-soft: #1A2E22; --warn-soft: #33281A; --bad-soft: #3A211B; --ok-ink: #7FD6A5; --warn-ink: #EDBE6E; --bad-ink: #F0A08E;
    --c-light: #E3B14F; --c-light-ink: #EDC470; --c-light-soft: #33291A;
    --c-colour: #D98BA8; --c-colour-ink: #E7A8BF; --c-colour-soft: #351F28;
    --c-layout: #8FB0CF; --c-layout-ink: #A9C4DC; --c-layout-soft: #1E2A36;
    --c-calm: #A5C3A4; --c-calm-ink: #B9D3B8; --c-calm-soft: #222E22;
    --c-comfort: #E0957C; --c-comfort-ink: #EBAE98; --c-comfort-soft: #38231C;
    --brass-lo: #0E0B08; --brass-hi: #F3D68A;
    --shadow-pop: 0 14px 34px -8px rgba(0,0,0,.7), 0 0 0 1px var(--line-2); --scrim: rgba(0,0,0,.6);
  }
}
[data-theme="dark"] {
  --bg: #14110F; --surface: #1D1916; --surface-2: #25201C; --paper-glow: rgba(255,255,255,.02);
  --ink: #F1EBE1; --ink-2: #CFC7BA; --muted: #A89F93; --faint: #7A7166;
  --line: #34302B; --line-2: #4D463E; --dot: #2A2622; --rule: #254A47;
  --brand: #5CC4BC; --brand-ink: #7AD6CE; --brand-fg: #0B1F1E; --brand-soft: #1B3532;
  --ok: #5BBE86; --warn: #E0A94B; --bad: #E27B66;
  --ok-soft: #1A2E22; --warn-soft: #33281A; --bad-soft: #3A211B; --ok-ink: #7FD6A5; --warn-ink: #EDBE6E; --bad-ink: #F0A08E;
  --c-light: #E3B14F; --c-light-ink: #EDC470; --c-light-soft: #33291A;
  --c-colour: #D98BA8; --c-colour-ink: #E7A8BF; --c-colour-soft: #351F28;
  --c-layout: #8FB0CF; --c-layout-ink: #A9C4DC; --c-layout-soft: #1E2A36;
  --c-calm: #A5C3A4; --c-calm-ink: #B9D3B8; --c-calm-soft: #222E22;
  --c-comfort: #E0957C; --c-comfort-ink: #EBAE98; --c-comfort-soft: #38231C;
  --brass-lo: #0E0B08; --brass-hi: #F3D68A;
  --shadow-pop: 0 14px 34px -8px rgba(0,0,0,.7), 0 0 0 1px var(--line-2); --scrim: rgba(0,0,0,.6);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--tb-h) + 24px); }
body {
  margin: 0; min-height: 100vh; color: var(--ink); background-color: var(--bg);
  /* dot-grid paper: 1px dots every 24px */
  background-image: radial-gradient(circle at 1px 1px, var(--dot) 1px, transparent 1.4px);
  background-size: 24px 24px; background-position: -1px -1px;
  font: 400 var(--fs-md)/1.55 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--serif); font-weight: 600; line-height: 1.15; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: var(--fs-3xl); } h2 { font-size: var(--fs-xl); } h3 { font-size: var(--fs-lg); } h4 { font-size: var(--fs-md); font-family: var(--sans); }
h1 em, h2 em, .wm em { font-style: italic; font-weight: 500; color: var(--brand-ink); }
p { margin: 0; text-wrap: pretty; }
a { color: var(--brand-ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
img, svg { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s-4) 0; }
code, kbd, samp { font-family: var(--mono); font-size: .92em; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 .3em; }
::selection { background: var(--brand); color: var(--brand-fg); }
.muted { color: var(--muted); } .faint { color: var(--faint); } .grow { flex: 1 1 0; min-width: 0; } .nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; } .row.between { justify-content: space-between; } .row.nowrap { flex-wrap: nowrap; }
.stack { display: grid; gap: var(--s-5); } .stack.sm { gap: var(--s-3); } .stack.lg { gap: var(--s-6); }
.grid { display: grid; gap: var(--s-4); } .grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 720px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }
/* the tiny uppercase label that sits on every sheet */
.eyebrow, .sheet-label, .k { font: 600 var(--fs-2xs)/1.2 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

/* two-layer focus ring: a paper gap, then teal */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; box-shadow: 0 0 0 4px var(--bg); border-radius: var(--r-sm); }
.btn:focus-visible, .input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-radius: var(--r); }
.skip-link { position: absolute; left: 12px; top: -80px; z-index: 300; padding: 10px 14px; background: var(--ink); color: var(--bg); border-radius: var(--r); }
.skip-link:focus { top: 10px; }

/* ---------- the title block (header) ---------- */
.tb { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(10px) saturate(1.2); backdrop-filter: blur(10px) saturate(1.2);
  border-bottom: 1px solid var(--ink); }
.tb-in { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: stretch; max-width: calc(var(--page) + 48px); margin: 0 auto; min-height: var(--tb-h);
  border-left: 1px solid var(--line-2); border-right: 1px solid var(--line-2); }
.tb-in > * { border-left: 1px solid var(--line-2); } .tb-in > :first-child { border-left: 0; }
.tb-brand { display: flex; align-items: center; gap: 10px; padding: 0 20px 0 14px; color: var(--ink); text-decoration: none; font: 600 1.18rem/1 var(--serif); letter-spacing: -.02em; }
.tb-brand:hover { text-decoration: none; }
.tb-brand img { width: 30px; height: 30px; border-radius: 7px; display: block; }
.wm { white-space: nowrap; }
.tb-sheet { display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 0 20px; min-width: 156px; }
.tb-sheet .k { font-size: .625rem; }
.tb-sheet b { font: 600 var(--fs-sm)/1.1 var(--mono); letter-spacing: .02em; white-space: nowrap; }
.tb-sheet b i { font-style: normal; color: var(--brand-ink); margin-right: 2px; }
.tb-nav { display: flex; align-items: stretch; padding: 0 8px; gap: 2px; }
.tb-nav a { position: relative; display: flex; align-items: center; padding: 0 14px; color: var(--ink-2); text-decoration: none; font-size: var(--fs-md); font-weight: 500; }
.tb-nav a:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 4%, transparent); text-decoration: none; }
.tb-nav a[aria-current="page"] { color: var(--ink); font-weight: 650; }
.tb-nav a[aria-current="page"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; background: var(--brand); border-radius: 2px 2px 0 0; }
.tb-nav a:focus-visible { box-shadow: inset 0 0 0 2px var(--bg); outline-offset: -4px; }
.tb-act { display: flex; align-items: center; gap: 10px; padding: 0 14px; }
.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: 600 var(--fs-xs)/1 var(--mono); white-space: nowrap; background: var(--surface); }
.wallet-chip:hover { border-color: var(--ink); text-decoration: none; }
.wallet-chip .i { width: 14px; height: 14px; color: var(--brand-ink); }
.wallet-chip.low { border-color: var(--warn); } .wallet-chip.low .i { color: var(--warn); }
.wallet-chip .wl { color: var(--muted); font-weight: 500; }
/* the scale ruler along the foot of the title block */
.tb-ruler { display: flex; overflow: hidden; height: 14px; max-width: calc(var(--page) + 48px); margin: 0 auto; padding-left: 14px; position: relative; counter-reset: m -1; user-select: none;
  background:
    repeating-linear-gradient(90deg, var(--line-2) 0 1px, transparent 1px 10px) left top / 100% 4px no-repeat,
    repeating-linear-gradient(90deg, var(--ink-2) 0 1px, transparent 1px 100px) left top / 100% 8px no-repeat;
  background-position: 14px 0, 14px 0; }
.tb-ruler i { flex: none; width: 100px; counter-increment: m; font: 500 8.5px/1 var(--mono); color: var(--muted); padding: 5px 0 0 3px; }
.tb-ruler i::before { content: counter(m); }
.tb-ruler em { position: absolute; right: 14px; top: 4px; padding-left: 8px; font: 500 8.5px/1 var(--mono); font-style: normal; letter-spacing: .1em; color: var(--muted); background: var(--bg); }

/* user menu */
.user-menu { position: relative; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--ink); background: var(--surface); color: var(--ink); font: 700 var(--fs-xs)/1 var(--mono); cursor: pointer; }
.avatar:hover { background: var(--ink); color: var(--bg); }
.pop { position: absolute; right: 0; top: calc(100% + 10px); z-index: 60; min-width: 232px; padding: 6px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); }
.pop .who { display: grid; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; } .pop .who b { font-weight: 650; } .pop .who span { color: var(--muted); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; }
.pop a, .pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: var(--r); background: none; color: var(--ink); font: 500 var(--fs-md)/1.2 var(--sans); text-align: left; text-decoration: none; cursor: pointer; }
.pop a:hover, .pop button:hover { background: var(--surface-2); text-decoration: none; }
.pop hr { margin: 4px 0; }
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* ---------- paper: the page body ---------- */
.main { position: relative; max-width: calc(var(--page) + 48px); margin: 0 auto; padding: var(--s-6) 24px calc(var(--s-8) + 24px); min-height: calc(100vh - var(--tb-h)); outline: none; }
/* the left margin rule, doubled like ruled drafting paper */
.main::before, .main::after { content: ""; position: absolute; top: 0; bottom: 0; width: 1px; background: var(--rule); pointer-events: none; }
.main::before { left: 10px; } .main::after { left: 14px; opacity: .55; }
#app > * { animation: blur-in .5s var(--ease) both; }
#app.settled > * { animation: none; }
#app > *:nth-child(2) { animation-delay: 60ms; } #app > *:nth-child(3) { animation-delay: 120ms; } #app > *:nth-child(4) { animation-delay: 180ms; } #app > *:nth-child(n+5) { animation-delay: 240ms; }
@keyframes blur-in { from { opacity: 0; transform: translateY(8px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4) var(--s-5); flex-wrap: wrap; margin-bottom: var(--s-6); }
.page-head h1 { max-width: 20ch; } .page-head .sub { margin-top: 8px; color: var(--muted); max-width: 60ch; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.crumbs { display: flex; gap: 8px; align-items: center; font: 600 var(--fs-2xs)/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; } .crumbs a { color: var(--muted); }

/* a sheet: a hairline panel with its label on the top edge. .pencil = suggested (dashed); default = measured (ink). */
.sheet, .card { position: relative; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg); padding: var(--s-5); box-shadow: var(--shadow); }
.sheet.flat { background: transparent; }
.sheet.pencil, .pencil { border-style: dashed; }
.sheet-h { display: flex; align-items: center; gap: 10px; margin: calc(var(--s-5) * -1) calc(var(--s-5) * -1) var(--s-4); padding: 9px var(--s-5); border-bottom: 1px solid var(--line); min-height: 40px; }
.sheet-h .no { font: 700 var(--fs-2xs)/1 var(--mono); color: var(--brand-fg); background: var(--ink); padding: 3px 6px 2px; border-radius: 3px; letter-spacing: .06em; }
.sheet-h .no.pencilno { background: transparent; color: var(--muted); border: 1px dashed var(--muted); }
.sheet-h .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: var(--s-4); } .card-head .sub, .sub { color: var(--muted); font-size: var(--fs-sm); }
/* dimension tick used as a section divider */
.dimline { display: flex; align-items: center; gap: 10px; color: var(--muted); font: 600 var(--fs-2xs)/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.dimline::before, .dimline::after { content: ""; height: 7px; flex: 1; border-left: 1px solid var(--line-2); border-right: 1px solid var(--line-2); background: linear-gradient(var(--line-2), var(--line-2)) center / 100% 1px no-repeat; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); color: var(--ink);
  font: 600 var(--fs-md)/1 var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap; transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast); }
.btn:hover { border-color: var(--ink); text-decoration: none; } .btn:active { transform: translateY(1px); }
.btn .i { width: 17px; height: 17px; }
.btn.cta, .btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-fg); }
.btn.cta:hover, .btn.primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); color: var(--brand-fg); }
[data-theme="dark"] .btn.cta:hover, [data-theme="dark"] .btn.primary:hover { background: color-mix(in srgb, var(--brand) 82%, white); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.cta:hover, :root:not([data-theme="light"]) .btn.primary:hover { background: color-mix(in srgb, var(--brand) 82%, white); } }
.btn.ghost { background: transparent; } .btn.ghost:hover { background: var(--surface); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--brand-ink); padding: 0 10px; } .btn.quiet:hover { background: var(--brand-soft); border-color: transparent; }
.btn.danger { color: var(--bad-ink); border-color: color-mix(in srgb, var(--bad) 50%, var(--line-2)); background: transparent; } .btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.field-err:empty { display: none; }
.btn.sm { min-height: 32px; padding: 0 12px; font-size: var(--fs-sm); } .btn.lg { min-height: 48px; padding: 0 22px; font-size: 1rem; } .btn.block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn[aria-busy="true"] { opacity: .75; pointer-events: none; } .btn[aria-busy="true"]::after { content: ""; width: 13px; height: 13px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 1px solid transparent; border-radius: var(--r); background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface); border-color: var(--line-2); color: var(--ink); } .icon-btn.sm { width: 32px; height: 32px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--brand-ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.label, .field > label { font: 600 var(--fs-sm)/1.3 var(--sans); color: var(--ink); }
.label .opt { color: var(--muted); font-weight: 400; margin-left: 6px; }
.hint { color: var(--muted); font-size: var(--fs-sm); } .field-err { color: var(--bad-ink); font-size: var(--fs-sm); display: flex; gap: 6px; align-items: flex-start; }
.field-err::before { content: "!"; flex: none; display: grid; place-items: center; width: 15px; height: 15px; margin-top: 2px; border-radius: 50%; background: var(--bad); color: var(--bg); font: 700 10px/1 var(--mono); }
.form-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-grid > .wide { grid-column: 1 / -1; } @media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.input, .select, .textarea { width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); color: var(--ink); font: 400 var(--fs-md)/1.4 var(--sans); }
.textarea { min-height: 96px; resize: vertical; }
.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% - 18px) 54%, calc(100% - 13px) 54%; background-size: 5px 5px; background-repeat: no-repeat; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-2); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--brand); }
[aria-invalid="true"] { border-color: var(--bad) !important; } .input[disabled], .select[disabled], .textarea[disabled] { opacity: .55; }
/* number with a unit suffix, like a dimension on a drawing */
.unit-input { display: flex; align-items: stretch; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); overflow: hidden; } .unit-input:focus-within { border-color: var(--brand); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--brand); }
.unit-input .input { border: 0; border-radius: 0; min-width: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; } .unit-input .input:focus-visible { outline: none; box-shadow: none; }
.unit-input .unit { display: grid; place-items: center; padding: 0 12px; border-left: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font: 600 var(--fs-xs)/1 var(--mono); letter-spacing: .06em; }
/* segmented control: one choice */
.seg { display: inline-flex; max-width: 100%; padding: 3px; gap: 2px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface-2); overflow-x: auto; }
.seg label { position: relative; flex: 1 0 auto; } .seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 0 14px; border-radius: 5px; color: var(--ink-2); font: 600 var(--fs-sm)/1 var(--sans); white-space: nowrap; }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.seg input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 1px; }
.seg.block { display: flex; }
/* chip toggle group: several choices */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-t { position: relative; } .chip-t input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; width: 100%; height: 100%; }
.chip-t span { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); color: var(--ink-2); font: 500 var(--fs-sm)/1 var(--sans); }
.chip-t:hover span { border-color: var(--ink); }
.chip-t input:checked + span { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); font-weight: 650; }
.chip-t input:checked + span::before { content: ""; width: 5px; height: 9px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(40deg) translateY(-1px); }
.chip-t input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; box-shadow: 0 0 0 4px var(--bg); }
.chip-t input:disabled + span { opacity: .5; }
/* range */
.range { display: grid; gap: 6px; } .range-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; } .range output { font: 600 var(--fs-sm)/1 var(--mono); color: var(--ink); }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 26px; background: transparent; margin: 0; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--brand) var(--fill, 0%), var(--line-2) var(--fill, 0%)); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line-2); } input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--brand); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%; background: var(--surface); border: 2px solid var(--ink); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 2px solid var(--ink); }
/* toggle switch */
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; position: relative; } .switch input { position: absolute; opacity: 0; width: 44px; height: 26px; margin: 0; cursor: pointer; }
.switch .track { flex: none; width: 44px; height: 26px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface-2); position: relative; transition: background var(--t-fast); }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--ink); transition: transform var(--t) var(--ease); }
.switch input:checked + .track { background: var(--brand); border-color: var(--brand); } .switch input:checked + .track::after { transform: translateX(18px); border-color: var(--brand-fg); }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; box-shadow: 0 0 0 4px var(--bg); }
.switch .txt { display: grid; } .switch .txt small { color: var(--muted); font-size: var(--fs-sm); }
/* file drop zone */
.drop { display: grid; place-items: center; gap: 6px; text-align: center; padding: var(--s-6) var(--s-4); border: 1.5px dashed var(--line-2); border-radius: var(--r-lg); background: var(--surface); color: var(--muted); cursor: pointer; position: relative; transition: border-color var(--t-fast), background var(--t-fast); }
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); }
.drop input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; } .drop b { color: var(--ink); } .drop .i { width: 28px; height: 28px; color: var(--brand-ink); }
.drop:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; } legend { padding: 0; margin-bottom: 8px; font: 600 var(--fs-sm)/1.3 var(--sans); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-2); overflow-x: auto; scrollbar-width: none; } .tabs::-webkit-scrollbar { display: none; }
.tabs [role="tab"] { position: relative; flex: none; padding: 11px 16px; border: 0; background: none; color: var(--muted); font: 600 var(--fs-md)/1 var(--sans); cursor: pointer; }
.tabs [role="tab"]:hover { color: var(--ink); } .tabs [role="tab"][aria-selected="true"] { color: var(--ink); }
.tabs [role="tab"][aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; background: var(--brand); border-radius: 2px 2px 0 0; }
.tabs .count { margin-left: 6px; font: 600 var(--fs-2xs)/1 var(--mono); color: var(--muted); }

/* ---------- badges, chips, status dots ---------- */
.badge, .chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); color: var(--ink-2); font: 600 var(--fs-xs)/1.2 var(--sans); white-space: nowrap; }
.badge .i, .chip .i { width: 13px; height: 13px; }
.badge.ok, .chip.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok-ink); } .badge.warn, .chip.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn-ink); }
.badge.bad, .chip.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad-ink); } .badge.brand, .chip.brand { background: var(--brand-soft); border-color: transparent; color: var(--brand-ink); }
.badge.dot::before, .chip.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.pencil { border-style: dashed; background: transparent; }
.sdot { display: inline-flex; align-items: center; gap: 7px; font: 600 var(--fs-xs)/1 var(--mono); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.sdot::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--faint); }
.sdot[data-s="good"]::before, .sdot[data-s="ok"]::before, .sdot[data-s="succeeded"]::before { background: var(--ok); } .sdot[data-s="fair"]::before, .sdot[data-s="warn"]::before, .sdot[data-s="running"]::before, .sdot[data-s="queued"]::before { background: var(--warn); }
.sdot[data-s="poor"]::before, .sdot[data-s="bad"]::before, .sdot[data-s="failed"]::before { background: var(--bad); } .sdot[data-s="na"]::before { background: transparent; border: 1.5px dashed var(--faint); }
/* swatches */
.sw { display: inline-block; width: 18px; height: 18px; border-radius: 4px; background: var(--sw, #888); box-shadow: inset 0 0 0 1px rgba(0,0,0,.22), 0 0 0 1px var(--bg); flex: none; } .sw.lg { width: 36px; height: 36px; border-radius: 6px; }
.sw-wrap { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); }
/* numbered annotation pin */
.pin { display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; border-radius: 50%; background: var(--ink); color: var(--bg); font: 700 11px/1 var(--mono); border: 0; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--ink); }
button.pin { cursor: pointer; } button.pin:hover, .pin.active { background: var(--brand); color: var(--brand-fg); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--brand); }
.pin.pencil-pin { background: var(--surface); color: var(--ink); border: 1.5px dashed var(--ink); box-shadow: none; }

/* ---------- banner, empty, skeleton ---------- */
.banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: var(--s-5); padding: 12px 16px; border: 1px solid var(--line-2); border-left-width: 4px; border-radius: var(--r); background: var(--surface); }
.banner.warn { border-color: var(--warn); background: var(--warn-soft); } .banner.bad { border-color: var(--bad); background: var(--bad-soft); } .banner.ok { border-color: var(--ok); background: var(--ok-soft); } .banner.info { border-color: var(--brand); background: var(--brand-soft); }
.banner .grow { min-width: 200px; }
.empty { display: grid; justify-items: center; gap: 10px; text-align: center; padding: var(--s-7) var(--s-5); border: 1.5px dashed var(--line-2); border-radius: var(--r-lg); color: var(--muted); }
.empty .big { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; border: 1.5px dashed var(--line-2); color: var(--brand-ink); } .empty .big .i { width: 26px; height: 26px; }
.empty h3 { color: var(--ink); } .empty p { max-width: 44ch; }
.skel { position: relative; overflow: hidden; border-radius: var(--r); background: var(--surface-2); min-height: 14px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 70%, transparent), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.skel.chart { height: 240px; } .skel.line { height: 14px; margin: 8px 0; } .skel.kpi-s { height: 96px; } .skel.block { height: 160px; } .skel.photo { aspect-ratio: 4 / 3; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--surface); }
table.t { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.t th { padding: 10px 14px; text-align: left; font: 600 var(--fs-2xs)/1.2 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--ink); white-space: nowrap; background: var(--surface-2); }
.t th.sortable { cursor: pointer; } .t th.sortable:hover { color: var(--ink); } .t th[aria-sort]::after { content: " \2193"; } .t th[aria-sort="ascending"]::after { content: " \2191"; }
.t td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; } .t tr:last-child td { border-bottom: 0; }
.t .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); } .t tr.clickable { cursor: pointer; } .t tr.clickable:hover td { background: var(--surface-2); }
.t .td-actions { text-align: right; white-space: nowrap; } .table-wrap .empty { border: 0; } .pagebar { display: flex; justify-content: center; padding: 12px; border-top: 1px solid var(--line); }
@media (max-width: 640px) {
  .t.stackable thead { display: none; } .t.stackable tr { display: grid; gap: 4px; padding: 12px 14px; border-bottom: 1px solid var(--line); } .t.stackable td { display: flex; justify-content: space-between; gap: 12px; padding: 0; border: 0; text-align: right; }
  .t.stackable td[data-label]::before { content: attr(data-label); color: var(--muted); font: 600 var(--fs-2xs)/1.6 var(--mono); letter-spacing: .1em; text-transform: uppercase; text-align: left; }
}

/* ---------- dialog / bottom sheet / toasts ---------- */
.scrim { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: var(--scrim); animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } }
.dialog { width: min(480px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: var(--s-5); background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); animation: pop .22s var(--ease); } .dialog.wide { width: min(720px, 100%); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.dialog .actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: var(--s-5); }
.dialog-key { display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: var(--surface-2); border: 1px dashed var(--line-2); border-radius: var(--r); font-family: var(--mono); word-break: break-all; } .secret-box { display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: var(--surface-2); border: 1px dashed var(--line-2); border-radius: var(--r); font-family: var(--mono); font-size: var(--fs-sm); }
@media (max-width: 640px) { .scrim { align-items: end; padding: 0; } .dialog, .dialog.wide { width: 100%; max-height: 88vh; border-radius: var(--r-lg) var(--r-lg) 0 0; padding-bottom: calc(var(--s-5) + env(safe-area-inset-bottom)); animation: sheet-up .28s var(--ease); } .dialog::before { content: ""; display: block; width: 36px; height: 4px; margin: -8px auto 14px; border-radius: 2px; background: var(--line-2); } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 120; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--ink); border-left-width: 4px; border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-pop); animation: pop .22s var(--ease); }
.toast.ok { border-left-color: var(--ok); } .toast.bad { border-left-color: var(--bad); } .toast.warn { border-left-color: var(--warn); } .toast.info { border-left-color: var(--brand); }
.toast .body { flex: 1; font-size: var(--fs-sm); line-height: 1.45; } .toast .x { display: grid; place-items: center; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px; } .toast .x .i { width: 14px; height: 14px; }

@media (max-width: 1120px) { .tb-sheet { min-width: 0; padding: 0 14px; } .tb-nav { padding: 0 2px; min-width: 0; } .tb-nav a { padding: 0 10px; } .wallet-chip .wl { display: none; } .tb-brand { padding-right: 14px; } .tb-act { gap: 8px; padding: 0 10px; } }
/* ---------- phone: bottom dock and the More sheet ---------- */
.dock, .more-sheet { display: none; }
@media (max-width: 860px) {
  :root { --tb-h: 52px; }
  .main { padding: var(--s-5) 16px calc(var(--dock-h) + var(--s-7) + env(safe-area-inset-bottom)); } .main::before { left: 5px; } .main::after { left: 8px; }
  .tb-in { grid-template-columns: auto minmax(0, 1fr) auto; border: 0; } .tb-nav { display: none; } .top-cta { display: none; }
  .tb-brand { padding: 0 12px 0 14px; } .tb-brand .wm { display: none; } .tb-sheet { min-width: 0; padding: 0 12px; border-left: 0; } .tb-act { padding: 0 14px 0 4px; border-left: 0; }
  .tb-ruler { height: 10px; } .tb-ruler i { color: transparent; padding: 0; } .tb-ruler em { display: none; }
  .wallet-chip .wl { display: none; }
  .dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; height: calc(var(--dock-h) + env(safe-area-inset-bottom)); padding: 0 6px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--bg) 90%, transparent); -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2); border-top: 1px solid var(--ink); }
  .dock a, .dock button { position: relative; display: grid; justify-items: center; align-content: center; gap: 3px; height: var(--dock-h); padding: 0; border: 0; background: none; color: var(--muted); font: 600 10px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; text-decoration: none; cursor: pointer; }
  .dock .i { width: 22px; height: 22px; }
  .dock a[aria-current="page"], .dock button.current { color: var(--ink); } .dock a[aria-current="page"]::before, .dock button.current::before { content: ""; position: absolute; top: -1px; left: 26%; right: 26%; height: 3px; background: var(--brand); border-radius: 0 0 2px 2px; }
  .dock .dock-new { color: var(--brand-fg); } .dock .dock-new .dk-disc { display: grid; place-items: center; width: 54px; height: 54px; margin-top: -22px; border-radius: 50%; background: var(--brand); border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--ink); }
  .dock .dock-new { height: calc(var(--dock-h) - 4px); align-content: start; color: var(--muted); gap: 4px; } .dock .dock-new .dk-disc .i { width: 25px; height: 25px; color: var(--brand-fg); } .dock .dock-new::before { display: none; }
  .more-sheet { position: fixed; inset: 0; z-index: 70; background: var(--scrim); align-items: end; } .more-sheet:not([hidden]) { display: grid; }
  .more-sheet .sheet-in { display: grid; gap: 2px; padding: 16px 14px calc(18px + var(--dock-h) + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--ink); border-radius: var(--r-lg) var(--r-lg) 0 0; animation: sheet-up .28s var(--ease); }
  .more-sheet .eyebrow { padding: 0 8px 8px; }
  .more-sheet a, .more-sheet button { display: flex; align-items: center; gap: 14px; min-height: 48px; padding: 0 10px; border: 0; border-radius: var(--r); background: none; color: var(--ink); font: 500 1rem/1 var(--sans); text-align: left; text-decoration: none; cursor: pointer; }
  .more-sheet a:hover, .more-sheet button:hover { background: var(--surface-2); } .more-sheet a[aria-current="page"] { color: var(--brand-ink); font-weight: 650; }
  .toasts { right: 12px; left: 12px; width: auto; bottom: calc(var(--dock-h) + 16px + env(safe-area-inset-bottom)); }
  .btn { min-height: 44px; } .btn.sm { min-height: 36px; } .input, .select { min-height: 46px; font-size: 16px; } .textarea { font-size: 16px; }
}

/* ---------- domain primitives (lib/ui.js) ---------- */
/* scoreMeter: a drafting scale that fills like a ruler */
.meter { --mc: var(--ink); display: grid; gap: 8px; }
.meter[data-status="good"] { --mc: var(--ok); } .meter[data-status="fair"] { --mc: var(--warn); } .meter[data-status="poor"] { --mc: var(--bad); } .meter[data-status="na"] { --mc: var(--faint); }
.meter-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.meter-num { font: 600 2.6rem/1 var(--serif); letter-spacing: -.03em; font-variant-numeric: tabular-nums; } .meter-of { font: 500 var(--fs-xs)/1 var(--mono); color: var(--muted); } .meter-label { margin-left: auto; }
.meter.lg .meter-num { font-size: clamp(4rem, 12vw, 6.5rem); line-height: .9; } .meter.sm .meter-num { font-size: 1.5rem; } .meter.sm .meter-scale { height: 10px; }
.meter-scale { position: relative; height: 18px; border: 1px solid var(--ink); border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.meter-fill { position: absolute; inset: 0; background: var(--mc); transform-origin: left center; transform: scaleX(var(--v, 0)); transition: transform var(--t-slow) var(--ease); }
.meter-scale::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(2% - 1px), var(--surface) calc(2% - 1px) 2%); pointer-events: none; opacity: .9; }
.meter-axis { display: flex; justify-content: space-between; font: 500 9.5px/1 var(--mono); color: var(--muted); letter-spacing: .04em; } .meter-axis span { position: relative; padding-top: 6px; } .meter-axis span::before { content: ""; position: absolute; top: 0; left: 50%; height: 4px; border-left: 1px solid var(--ink-2); } .meter-axis span:first-child::before { left: 0; } .meter-axis span:last-child::before { left: 100%; }
.meter.sm .meter-axis { display: none; }
/* dimensionBar */
.dim { --dc: var(--c-light); --dci: var(--c-light-ink); display: grid; grid-template-columns: minmax(78px, 112px) minmax(0, 1fr) 3.2ch; align-items: center; gap: 12px; }
.dim[data-dim="light"] { --dc: var(--c-light); --dci: var(--c-light-ink); } .dim[data-dim="colour"] { --dc: var(--c-colour); --dci: var(--c-colour-ink); } .dim[data-dim="layout"] { --dc: var(--c-layout); --dci: var(--c-layout-ink); }
.dim[data-dim="calm"] { --dc: var(--c-calm); --dci: var(--c-calm-ink); } .dim[data-dim="comfort"] { --dc: var(--c-comfort); --dci: var(--c-comfort-ink); }
.dim-name { font-weight: 600; font-size: var(--fs-sm); color: var(--dci); display: flex; align-items: center; gap: 7px; } .dim-name::before { content: ""; width: 9px; height: 9px; border-radius: 2px; background: var(--dc); flex: none; }
.dim-track { position: relative; height: 12px; border-radius: 2px; background: var(--surface-2); border: 1px solid var(--line-2); overflow: hidden; }
.dim-fill { position: absolute; inset: 0; background: var(--dc); transform-origin: left; transform: scaleX(var(--v, 0)); transition: transform 800ms var(--ease); }
.dim-track::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), var(--surface) calc(10% - 1px) 10%); }
.dim-val { font: 600 var(--fs-sm)/1 var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
.dim.na .dim-track { background: repeating-linear-gradient(135deg, transparent 0 4px, var(--line) 4px 5px); border-style: dashed; } .dim.na .dim-val { color: var(--muted); }
.dim-w { display: block; font: 500 9.5px/1 var(--mono); color: var(--muted); letter-spacing: .08em; text-transform: uppercase; margin-top: 3px; }
/* paletteFan: paint chips fanned from one pivot */
.fan-wrap { display: grid; gap: 12px; }
.fan { position: relative; height: 224px; margin-bottom: 10px; width: calc(var(--n, 5) * 38px + 70px); max-width: 100%; margin: 0 auto 0 0; }
.fan-chip { position: absolute; left: calc(var(--i) * 38px); bottom: 0; width: 66px; height: 200px; padding: 0; border: 1px solid rgba(0,0,0,.2); border-radius: 5px 5px 4px 4px; background: #FBF8F2; color: #23201C; overflow: hidden; cursor: pointer; transform-origin: 50% 100%; transform: rotate(calc((var(--i) - (var(--n) - 1) / 2) * 7deg)); transition: transform var(--t) var(--ease), box-shadow var(--t); box-shadow: 0 1px 0 rgba(0,0,0,.08), 2px 0 6px -2px rgba(0,0,0,.25); display: grid; grid-template-rows: 112px 1fr; text-align: left; }
.fan-chip:hover, .fan-chip:focus-visible, .fan-chip[aria-pressed="true"] { transform: rotate(calc((var(--i) - (var(--n) - 1) / 2) * 7deg)) translateY(-16px); z-index: 5 !important; box-shadow: 0 8px 18px -6px rgba(0,0,0,.4); }
.fan-chip[aria-pressed="true"] { outline: 2px solid var(--brand); outline-offset: 0; }
.fan-chip .fc-col { background: var(--sw); } .fan-chip .fc-lab { display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; padding: 8px 4px 7px 8px; }
.fan-chip .fc-nm { writing-mode: vertical-rl; transform: rotate(180deg); font: 600 11px/1 var(--sans); max-height: 56px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } .fan-chip .fc-sh { font: 700 10.5px/1 var(--mono); }
.fan-cap { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); font-size: var(--fs-sm); } .fan-cap b { font-weight: 650; } .fan-cap .mono { color: var(--muted); }
/* lightMeter: a brass scale with the target band bracketed and the measured value pinned */
.lmeter { display: grid; gap: 10px; padding-top: 34px; }
.lmeter-scale { position: relative; height: 22px; border: 1px solid var(--ink); border-radius: 3px; background: linear-gradient(90deg, var(--brass-lo), var(--c-light) 55%, var(--brass-hi)); }
.lmeter-scale::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(5% - 1px), rgba(0,0,0,.28) calc(5% - 1px) 5%); mix-blend-mode: multiply; pointer-events: none; }
.lmeter-band { position: absolute; top: -6px; bottom: -6px; left: var(--lo); width: calc(var(--hi) - var(--lo)); border: 2px solid var(--ink); border-top-width: 2px; border-radius: 2px; box-shadow: 0 0 0 1.5px var(--surface); z-index: 2; background: color-mix(in srgb, var(--surface) 14%, transparent); }
.lmeter-band span { position: absolute; left: 0; bottom: -22px; font: 600 9.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink); white-space: nowrap; }
.lmeter-pin { position: absolute; top: -34px; left: var(--p); z-index: 3; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; transition: left 900ms var(--ease); }
.lmeter-pin b { padding: 3px 7px 2px; border-radius: 3px; background: var(--ink); color: var(--bg); font: 700 12px/1.1 var(--mono); } .lmeter-pin i { width: 2px; height: 34px; background: var(--ink); box-shadow: 0 0 0 1px var(--surface); } .lmeter-pin::after { content: ""; position: absolute; bottom: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--ink); }
.lmeter-axis { display: flex; justify-content: space-between; padding-top: 14px; font: 500 9.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.lmeter-note { font-size: var(--fs-sm); color: var(--ink-2); }
.lmeter[data-state="in"] .lmeter-note b { color: var(--ok-ink); } .lmeter[data-state="below"] .lmeter-note b, .lmeter[data-state="above"] .lmeter-note b { color: var(--warn-ink); }
/* checkList */
.checks { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); }
.checks li { display: grid; grid-template-columns: 20px 1fr; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); } .checks li:last-child { border-bottom: 0; }
.checks .ck { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--ok-soft); color: var(--ok-ink); } .checks .ck .i { width: 11px; height: 11px; stroke-width: 2.4; }
.checks li.bad { background: var(--bad-soft); } .checks li.bad .ck { background: var(--bad); color: var(--bg); } .checks b { font-weight: 600; } .checks span.d { display: block; color: var(--muted); }
.checks-sum { display: flex; align-items: center; gap: 8px; font: 600 var(--fs-xs)/1 var(--mono); letter-spacing: .04em; margin-bottom: 8px; } .checks-sum.bad { color: var(--bad-ink); } .checks-sum.ok { color: var(--ok-ink); }
/* stepCard: a pencilled-in suggestion with a price band */
.step { --dc: var(--line-2); position: relative; display: grid; gap: 8px; padding: 14px 16px 14px 20px; border: 1.5px dashed var(--line-2); border-radius: var(--r-lg); background: var(--surface); }
.step::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 4px; border-radius: 0 3px 3px 0; background: var(--dc); }
.step[data-dim="light"] { --dc: var(--c-light); } .step[data-dim="colour"] { --dc: var(--c-colour); } .step[data-dim="layout"] { --dc: var(--c-layout); } .step[data-dim="calm"] { --dc: var(--c-calm); } .step[data-dim="comfort"] { --dc: var(--c-comfort); }
.step.done { border-style: solid; border-color: var(--ok); } .step.later { opacity: .82; }
.step-top { display: flex; gap: 10px; align-items: flex-start; } .step-title { font: 600 1.05rem/1.25 var(--serif); } .step-price { margin-left: auto; font: 700 1rem/1 var(--mono); white-space: nowrap; font-variant-numeric: tabular-nums; }
.step-act { color: var(--ink-2); } .step-why { color: var(--muted); font-size: var(--fs-sm); } .step-meta { display: flex; gap: 6px; flex-wrap: wrap; } .step-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.delta { font: 700 var(--fs-xs)/1 var(--mono); color: var(--ok-ink); } .delta.neg { color: var(--bad-ink); }

/* ---------- charts (lib/charts.js, lib/usagechart.js) ---------- */
.chart { position: relative; width: 100%; min-height: 120px; } .chart svg { display: block; overflow: visible; max-width: 100%; } .chart text { fill: var(--muted); font: 10.5px var(--mono); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; } .chart .axis-line { stroke: var(--ink); shape-rendering: crispEdges; } .chart .bar { transition: opacity .15s; } .chart .bar.dim { opacity: .45; }
.chart-tip, .ch-tip { position: absolute; top: 0; z-index: 5; pointer-events: none; min-width: 130px; max-width: 260px; padding: 8px 10px; border-radius: var(--r-sm); font-size: var(--fs-xs); background: var(--ink); color: var(--bg); opacity: 0; transition: opacity .12s; } .chart-tip.on, .ch-tip.on { opacity: 1; }
.chart-tip b, .ch-tip-h { display: block; margin-bottom: 3px; font-weight: 650; } .chart-tip .tr, .ch-tip-row { display: flex; justify-content: space-between; gap: 14px; }
.chart-msg, .ch-msg { display: grid; place-items: center; text-align: center; color: var(--muted); min-height: 120px; padding: 20px; margin: 0; }
.ch-box { outline: none; } .ch-svg { display: block; width: 100%; height: auto; overflow: visible; } .ch-grid line { stroke: var(--line); } .ch-grid text, .ch-xaxis text { fill: var(--muted); font: 10.5px 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; stroke-dasharray: 3 3; } .ch-ring { fill: var(--bg); stroke: var(--c); stroke-width: 2.5; } .ch-hit { cursor: crosshair; }
.ch-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--c); flex: none; } .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 20px; list-style: none; margin: 0 0 12px; padding: 0; font-size: var(--fs-sm); 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(48px, 9vw, 72px); } .ch-stack > i { display: block; flex-basis: 0; min-width: 4px; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); }
.ch-stack-key { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: 8px 20px; 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: var(--fs-sm); } .ch-stack-key span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .ch-stack-key small { color: var(--muted); font-family: var(--mono); }
.ch-sw { display: block; width: 12px; height: 12px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); }
.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: 10px 0; border-bottom: 1px solid var(--line); } .ch-rank-n { font: 500 var(--fs-xs) var(--mono); color: var(--muted); } .ch-rank-name { font: 600 1.1rem/1.15 var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .ch-rank-v { font: 600 var(--fs-sm) var(--mono); }
.ch-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; } .ch-bars li { display: grid; grid-template-columns: minmax(84px, 138px) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: var(--fs-sm); } .ch-bar-track { height: 10px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 2px; overflow: hidden; } .ch-bar-fill { display: block; height: 100%; background: var(--c); } .ch-bar-val { font: 600 var(--fs-xs) var(--mono); text-align: right; }
.ch-mini { display: inline-block; vertical-align: middle; } .ch-mini-bar { fill: var(--c); } .ch-mini-na { fill: var(--line-2); }
.ch-tape { position: relative; height: 30px; margin: 6px 0 18px; border-top: 1px solid var(--ink); } .ch-tape span { position: absolute; top: 0; padding-top: 9px; transform: translateX(-50%); font: 500 10px/1 var(--mono); color: var(--muted); } .ch-tape span::before { content: ""; position: absolute; left: 50%; top: 0; width: 1px; height: 7px; background: var(--ink); }

/* ---------- in-app camera (lib/camera.js) ---------- */
body.cam-open { overflow: hidden; }
.cam { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: #000; color: #fff; }
.cam-panel { position: relative; width: 100%; height: 100%; background: #000; overflow: hidden; } .cam-stage { position: absolute; inset: 0; } .cam-video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; } .cam-video.mirror { transform: scaleX(-1); }
.cam-guide { position: absolute; inset: 12% 8% 26%; pointer-events: none; display: grid; align-items: start; justify-items: center; background:
  linear-gradient(90deg, rgba(255,255,255,.35) 1px, transparent 1px) 33.3% 0 / 1px 100% no-repeat, linear-gradient(90deg, rgba(255,255,255,.35) 1px, transparent 1px) 66.6% 0 / 1px 100% no-repeat,
  linear-gradient(rgba(255,255,255,.35) 1px, transparent 1px) 0 33.3% / 100% 1px no-repeat, linear-gradient(rgba(255,255,255,.35) 1px, transparent 1px) 0 66.6% / 100% 1px no-repeat; border: 1px solid rgba(255,255,255,.6); border-radius: 2px; }
.cam-guide span { margin-top: 8px; padding: 6px 10px; background: rgba(0,0,0,.6); font: 600 12px/1.3 var(--mono); letter-spacing: .06em; text-transform: uppercase; border-radius: 2px; text-align: center; }
.cam-count { position: absolute; inset: 0; display: none; place-items: center; font: 700 min(40vw, 240px)/1 var(--serif); text-shadow: 0 2px 24px rgba(0,0,0,.6); pointer-events: none; } .cam-count.on { display: grid; }
.cam-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: max(14px, env(safe-area-inset-top)) 14px 24px; background: linear-gradient(rgba(0,0,0,.55), transparent); }
.cam-hint { padding: 8px 12px; background: rgba(0,0,0,.6); border-radius: 2px; font: 600 14px/1.3 var(--sans); } .cam-hint:empty { display: none; }
.cam-hint[data-state="good"]::before, .cam-hint[data-state="dark"]::before, .cam-hint[data-state="bright"]::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; background: #4FD9A0; } .cam-hint[data-state="dark"]::before, .cam-hint[data-state="bright"]::before { background: #FFC24D; }
.cam-tools, .cam-timer { display: flex; gap: 8px; }
.cam-btn { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; border: 1px solid rgba(255,255,255,.5); background: rgba(0,0,0,.5); color: #fff; cursor: pointer; } .cam-btn .i { width: 22px; height: 22px; } .cam-btn[aria-pressed="true"] { background: #fff; color: #000; }
.cam-bottom { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 24px 14px max(22px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0,0,0,.65)); }
.cam-chip { min-height: 40px; min-width: 44px; padding: 0 12px; border-radius: 3px; border: 1px solid rgba(255,255,255,.5); background: rgba(0,0,0,.5); color: #fff; font: 600 13px/1 var(--mono); cursor: pointer; } .cam-chip[aria-pressed="true"] { background: #fff; color: #000; border-color: #fff; }
.cam-shutter { width: 76px; height: 76px; border-radius: 50%; border: 3px solid #fff; background: transparent; padding: 4px; cursor: pointer; display: grid; place-items: center; } .cam-shutter span { width: 100%; height: 100%; border-radius: 50%; background: var(--brand); transition: transform .1s; } .cam-shutter:active span { transform: scale(.88); } .cam-shutter.busy span { border-radius: 8px; transform: scale(.55); }
.cam-btn:focus-visible, .cam-chip:focus-visible, .cam-shutter:focus-visible { outline: 3px solid #fff; outline-offset: 3px; box-shadow: 0 0 0 6px #000; }
@media (min-width: 861px) { .cam { background: rgba(0,0,0,.78); } .cam-panel { width: min(960px, 92vw); height: min(720px, 90vh); border-radius: 8px; } }
@media (max-width: 640px) { .cam-timer { grid-column: 1 / -1; grid-row: 1; justify-content: center; } .cam-bottom { grid-template-columns: 1fr; justify-items: center; } .cam-spacer { display: none; } }

/* ---------- print: a sheet is a sheet ---------- */
@media print { .tb, .dock, .more-sheet, .toasts, .pwa-bar { display: none !important; } body { background: #fff; } .main::before, .main::after { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .meter-fill, .dim-fill { transition: none; }
}
