@import url("theme.css");
/* ManualLens shell and shared components: "the highlighted page" (docs/BRAND.md, docs/UI.md).
   Tokens come from theme.css (loaded first). This file owns: reset, type, the binder spine, the phone tab bar, the
   account menu, banners, toasts, buttons, fields, the paper/page objects, the stamp, the highlighter, ruled logs,
   status lines, the hazard box, meters, dialogs, the bottom sheet and the camera. Page sheets (ask.css, shelf.css,
   ...) add layout only and reuse these classes. No shadows on UI; the only shadow is under a manual page. */

/* ---------- reset and base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font: 400 1rem/1.55 var(--font-ui); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
@media (max-width: 860px) { body { font-size: 1.0625rem; } }
img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-ink); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; letter-spacing: -.01em; font-weight: 750; text-wrap: balance; }
h1 { font-size: clamp(1.75rem, 4vw, 2.25rem); }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }
p { margin: 0 0 var(--s3); }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s4) 0; }
::selection { background: var(--brand-soft); color: var(--ink); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 20px; height: 20px; flex: none; }
.grow { flex: 1 1 auto; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums slashed-zero; }
.serif { font-family: var(--font-quote); }
[hidden] { display: none !important; }

/* two-layer focus ring: 2 px ground, then 4 px magenta */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--bg); outline-offset: 0; box-shadow: 0 0 0 4px var(--brand); border-radius: var(--r-ctl); }
main:focus-visible, [tabindex="-1"]:focus-visible { box-shadow: none; outline: none; }
h1[tabindex="-1"]:focus-visible, h2[tabindex="-1"]:focus-visible { outline: 2px dashed var(--brand); outline-offset: 4px; }

.skip { position: absolute; left: var(--s3); top: -60px; z-index: 100; background: var(--brand); color: var(--on-brand); padding: 10px 16px; border-radius: var(--r-ctl); font-weight: 700; text-decoration: none; }
.skip:focus { top: var(--s3); }

/* ---------- the running head: the top line of a manual page ---------- */
.runhead {
  display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap;
  font: 600 var(--t-xs)/1.2 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  padding-bottom: var(--s2); border-bottom: 2px solid var(--ink); margin-bottom: var(--s5);
}
.runhead b { color: var(--ink); font-weight: 700; }
.runhead .grow { flex: 1; }
.eyebrow { font: 700 var(--t-xs)/1.2 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 var(--s2); }
.title { font-size: clamp(1.9rem, 4.6vw, 2.6rem); letter-spacing: -.02em; margin-bottom: var(--s2); }
.lead { font-size: var(--t-md); color: var(--muted); max-width: 62ch; }

/* ---------- the binder spine (desktop navigation) ---------- */
.spine {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: flex-end; gap: var(--s4);
  min-height: var(--spine-h); padding: 10px max(var(--gutter), env(safe-area-inset-left)) 0;
  background: var(--bg); border-bottom: 2px solid var(--ink);
}
.brandmark { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 800; letter-spacing: -.01em; font-size: 1.0625rem; align-self: center; padding-bottom: 8px; }
.brandmark .logo { width: 32px; height: 32px; }
.tabs { display: flex; align-items: flex-end; gap: 4px; flex-wrap: nowrap; margin-bottom: -2px; min-width: 0; flex: 0 1 auto; }
.tab-devices { display: contents; }
.tab {
  --tab-c: var(--ink);
  position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; max-width: 15rem;
  padding: 0 16px; color: var(--muted); text-decoration: none; font-weight: 650; font-size: var(--t-sm);
  background: var(--bg-2); border: 1px solid var(--line); border-bottom: 2px solid var(--ink);
  border-radius: var(--r-ctl) var(--r-ctl) 0 0; box-shadow: inset 0 3px 0 var(--tab-c);
}
.tab .ico { width: 18px; height: 18px; }
.tab .tab-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-current="page"] {
  color: var(--ink); background: var(--surface); border-color: var(--ink); border-bottom-color: var(--surface);
  box-shadow: inset 0 4px 0 var(--tab-c);
}
.tab-ask { --tab-c: var(--brand); }
.tab-ask[aria-current="page"] { color: var(--brand-ink); }
.tab-device { flex: 0 1 auto; min-width: 6.5rem; max-width: 13rem; }
.tabs > a.tab:not(.tab-device) { flex: none; }
.tab:focus-visible { border-radius: var(--r-ctl) var(--r-ctl) 0 0; }
@media (prefers-reduced-motion: no-preference) {
  .tab { transition: transform var(--dur) var(--ease), color var(--dur); }
  .tab:not([aria-current="page"]):hover { transform: translateY(-2px); }
}
.spine .iconbtn, .spine .account, .meter-chip { align-self: center; margin-bottom: 8px; }

.iconbtn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border-radius: var(--r-ctl);
  background: transparent; border: 1px solid transparent; color: var(--ink); cursor: pointer;
}
.iconbtn:hover { background: var(--bg-2); border-color: var(--line); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--ink); background: var(--surface); color: var(--ink);
  font: 700 .95rem/1 var(--font-mono); cursor: pointer; display: grid; place-items: center;
}
.avatar[aria-expanded="true"] { background: var(--ink); color: var(--bg); }

.meter-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px; border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl); color: var(--ink); text-decoration: none; font: 600 var(--t-xs)/1 var(--font-mono); letter-spacing: .02em; background: var(--surface); white-space: nowrap; flex: none;
}
.meter-ticks { display: inline-flex; gap: 2px; }
.meter-ticks i { width: 3px; height: 14px; background: var(--line-strong); }
.meter-ticks i.used { background: var(--ink); }

/* account menu (avatar on desktop, "More" sheet on phones) */
.menu {
  position: fixed; z-index: 60; top: calc(var(--spine-h) + 6px); right: max(var(--gutter), env(safe-area-inset-right));
  width: min(19rem, calc(100vw - 24px)); background: var(--surface); border: 1.5px solid var(--ink); border-radius: var(--r-ctl); padding: 6px;
}
.menu-head { display: grid; gap: 2px; padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-head span { color: var(--muted); font-size: var(--t-xs); overflow-wrap: anywhere; }
.menu [role="menuitem"] {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 12px; text-align: left;
  color: var(--ink); text-decoration: none; background: none; border: 0; border-radius: var(--r-ctl); cursor: pointer; font-weight: 550;
}
.menu [role="menuitem"]:hover, .menu [role="menuitem"]:focus-visible { background: var(--surface-2); }
.menu [role="menuitem"][aria-current="page"] { color: var(--brand-ink); }
.menu hr { margin: 4px 0; }
.menu-theme { display: none !important; }

/* ---------- public header (landing, privacy, error) ---------- */
.pub-head {
  display: flex; align-items: center; gap: var(--s3); min-height: 64px; padding: 8px max(var(--gutter), env(safe-area-inset-left));
  border-bottom: 2px solid var(--ink); background: var(--bg);
}
.pub-signin { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border: 1.5px solid var(--ink); border-radius: var(--r-ctl); color: var(--ink); text-decoration: none; font-weight: 700; font-size: var(--t-sm); }
.pub-signin:hover { background: var(--surface); }

/* ---------- page frame ---------- */
.page { flex: 1 0 auto; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: var(--s6) max(var(--gutter), env(safe-area-inset-left)) var(--s7); }
.foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s4); padding: var(--s4) max(var(--gutter), env(safe-area-inset-left));
  border-top: 1px solid var(--line); color: var(--muted); font-size: var(--t-xs);
}
.foot a { color: var(--muted); }
.foot a:hover { color: var(--ink); }

.banners:empty { display: none; }
.banners { display: grid; gap: 1px; }
.banner {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; padding: 10px max(var(--gutter), env(safe-area-inset-left));
  background: var(--surface); border-bottom: 1px solid var(--line); font-size: var(--t-sm);
}
.banner-warn { background: var(--warn-soft); }
.banner-offline { background: var(--bg-2); }
.banner-bad { background: var(--bad-soft); }

/* ---------- phone tab bar ---------- */
.tabbar { display: none; }
@media (max-width: 860px) {
  .spine { position: sticky; align-items: center; padding-top: 0; min-height: 56px; }
  .spine .tabs, .spine .account, .spine .meter-chip { display: none; }
  .spine .brandmark { padding-bottom: 0; }
  .spine .iconbtn { margin-bottom: 0; }
  .page { padding-top: var(--s5); padding-bottom: calc(var(--tabbar-h) + var(--s6) + env(safe-area-inset-bottom)); }
  .foot { padding-bottom: calc(var(--tabbar-h) + var(--s4) + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; z-index: 65; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 0 6px env(safe-area-inset-bottom);
    background: var(--surface); border-top: 2px solid var(--ink);
  }
  .tabbar a, .tabbar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 48px;
    color: var(--muted); text-decoration: none; font-size: .75rem; font-weight: 650; background: none; border: 0; cursor: pointer;
  }
  .tabbar .ico { width: 22px; height: 22px; }
  .tabbar [aria-current="page"] { color: var(--ink); }
  .tabbar [aria-current="page"]:not(.tb-ask) .ico { color: var(--brand); }
  .tb-ask { position: relative; }
  .tb-stamp {
    display: grid; place-items: center; width: 58px; height: 50px; margin-top: -26px; background: var(--brand); color: var(--on-brand);
    border-radius: var(--r-ctl); outline: 2px solid var(--brand); outline-offset: 3px; transform: rotate(-4deg);
  }
  .tb-stamp .ico { width: 26px; height: 26px; transform: rotate(4deg); }
  .tb-ask[aria-current="page"] { color: var(--brand-ink); }
  .menu.menu-sheet {
    top: auto; left: 0; right: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); width: auto;
    border-radius: 0; border-width: 2px 0 0; padding: 8px 8px 12px; max-height: 70vh; overflow: auto;
  }
  .menu-theme { display: flex !important; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px;
  border: 1.5px solid var(--ink); border-radius: var(--r-ctl); background: var(--surface); color: var(--ink);
  font-weight: 700; font-size: var(--t-sm); line-height: 1.1; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--bg-2); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
:root[data-theme="dark"] .btn.danger { color: var(--bg); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.danger { color: var(--bg); } }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: var(--t-xs); }
.btn.lg { min-height: 54px; padding: 0 24px; font-size: var(--t-md); }
.btn.block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; filter: none; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand-ink); text-decoration: underline; text-underline-offset: .18em; cursor: pointer; font-weight: 600; min-height: 44px; }
.actions { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }

/* ---------- fields ---------- */
.field { display: grid; gap: 6px; margin-bottom: var(--s4); }
.field > label, .label { font-weight: 650; font-size: var(--t-sm); }
.hint { color: var(--muted); font-size: var(--t-xs); margin: 0; }
.err { color: var(--bad); font-size: var(--t-sm); font-weight: 600; margin: 0; }
input[type="text"], input[type="search"], input[type="email"], input[type="number"], input[type="url"], input:not([type]), select, textarea, .input {
  width: 100%; min-height: 46px; padding: 10px 12px; background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--line-strong); border-radius: var(--r-ctl);
}
textarea { min-height: 7rem; resize: vertical; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: var(--ink); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--bad); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); align-items: start; }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px var(--s3); }
@media (max-width: 560px) { .checks { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; accent-color: var(--brand); margin: 0; flex: none; }

/* the display-code field: a real input that looks like the thing blinking at you */
.codefield {
  font: 700 1.6rem/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; font-variant-numeric: tabular-nums;
  min-height: 58px; padding: 10px 14px; color: var(--ink); border: 1.5px solid var(--line-strong); border-radius: var(--r-ctl);
  background-color: var(--bg-2);
  background-image: linear-gradient(90deg, transparent calc(100% - 1px), color-mix(in srgb, var(--line) 70%, transparent) 0), linear-gradient(transparent calc(100% - 1px), color-mix(in srgb, var(--line) 70%, transparent) 0);
  background-size: 14px 14px;
}

/* segmented control (radio group) */
.seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: var(--r-ctl); overflow: hidden; }
.seg label { position: relative; display: inline-flex; align-items: center; min-height: 42px; padding: 0 14px; cursor: pointer; font-weight: 650; font-size: var(--t-sm); }
.seg label + label { border-left: 1px solid var(--line-strong); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--ink); color: var(--bg); }
.seg label:has(input:focus-visible) { box-shadow: inset 0 0 0 3px var(--brand); }

/* ---------- paper: a sheet with square edges and a dog-ear ---------- */
.paper {
  position: relative; background: var(--surface); padding: var(--s5); border-top: 2px solid var(--ink);
  clip-path: polygon(0 0, calc(100% - var(--ear)) 0, 100% var(--ear), 100% 100%, 0 100%);
}
.paper::after {
  content: ""; position: absolute; top: 0; right: 0; width: var(--ear); height: var(--ear);
  background: linear-gradient(225deg, var(--bg-2) 50%, var(--line) 50%);
}
.paper.flat { clip-path: none; }
.paper.flat::after { display: none; }
/* the manual page object: the customer's page, lying on the desk (the one shadow in the UI) */
.mpage {
  position: relative; background: var(--page-paper); color: var(--page-ink); padding: var(--s6) var(--s5) var(--s5);
  clip-path: polygon(0 0, calc(100% - var(--ear)) 0, 100% var(--ear), 100% 100%, 0 100%);
  filter: drop-shadow(0 10px 18px var(--page-shadow));
  font-family: var(--font-quote); font-size: 1rem; line-height: 1.5;
}
.mpage-wrap { filter: drop-shadow(0 12px 22px var(--page-shadow)); }
.mpage-wrap .mpage { filter: none; }
.mpage::after {
  content: ""; position: absolute; top: 0; right: 0; width: var(--ear); height: var(--ear);
  background: linear-gradient(225deg, var(--bg-2) 50%, #D8D3C2 50%);
}
.mpage .mpage-head { font: 600 var(--t-xs)/1.2 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--page-muted); border-bottom: 1px solid #D3CFC0; padding-bottom: 6px; margin-bottom: var(--s4); }
.mpage-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.mpage .muted { color: var(--page-muted); }

/* ---------- the stamp: the page number as a stamped object ---------- */
.stamp {
  display: inline-flex; align-items: baseline; gap: .3em; min-height: 44px; padding: 8px 12px 6px;
  font: 800 1.15rem/1 var(--font-mono); letter-spacing: .01em; color: var(--brand-ink);
  border: 2px solid var(--brand); outline: 1px solid var(--brand); outline-offset: 2px; border-radius: 3px;
  transform: rotate(-4deg); mix-blend-mode: var(--stamp-blend); white-space: nowrap; background: transparent;
}
.stamp-k { font-size: .7em; font-weight: 700; }
.stamp-lg { font-size: 1.9rem; padding: 12px 18px 10px; }
.stamp-sm { font-size: .9rem; min-height: 32px; padding: 6px 8px 4px; outline-offset: 1px; }
.stamp-empty { color: var(--muted); border-color: var(--line-strong); outline-color: var(--line-strong); border-style: dashed; }
button.stamp, a.stamp { cursor: pointer; text-decoration: none; }
@media (prefers-reduced-motion: no-preference) {
  .stamp-press { animation: stamp-press 180ms cubic-bezier(.3,1.6,.5,1) both; }
  @keyframes stamp-press { from { transform: rotate(-4deg) scale(1.25); opacity: 0; } to { transform: rotate(-4deg) scale(1); opacity: 1; } }
}

/* ---------- the highlighter: ONLY the verbatim quote ---------- */
.hl {
  color: var(--accent-ink); padding: 0 .12em;
  background: linear-gradient(transparent 12%, var(--accent) 12% 88%, var(--hl-edge) 88% 92%, transparent 92%);
  background-repeat: no-repeat; background-size: 100% 100%;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
@media (prefers-reduced-motion: no-preference) {
  .hl.hl-wait { background-size: 0% 100%; }
  .hl.hl-wait.hl-on { background-size: 100% 100%; transition: background-size 500ms var(--ease); }
}
.quote { margin: 0; font: 400 1.25rem/1.5 var(--font-quote); color: var(--ink); max-width: 62ch; }
.quote .hl { color: var(--accent-ink); }

/* ---------- status lines: found / does not say / refused (icon + words, never colour alone) ---------- */
.status-line { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: var(--t-md); margin-bottom: var(--s3); }
.status-line .ico { width: 24px; height: 24px; }
.st-found { color: var(--ok); }
.st-nosay { color: var(--warn); }
.st-refused { color: var(--bad); }
.st-working { color: var(--muted); }

/* the hazard box: hatch + icon + words (refusal and Erase only) */
.hazard {
  position: relative; border: 2px solid var(--hazard-a); background: var(--surface); padding: var(--s5); padding-top: calc(var(--s5) + 12px);
}
.hazard::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 12px;
  background: repeating-linear-gradient(-45deg, var(--hazard-a) 0 10px, var(--hazard-b) 10px 20px);
}
.hazard h2, .hazard h3 { display: flex; align-items: center; gap: 10px; color: var(--bad); }

/* ---------- ruled log (history, past questions, parts lists) ---------- */
.ruled { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); }
.ruled > li { display: grid; grid-template-columns: 5.5rem 1fr auto; gap: var(--s3); align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); min-height: 56px; }
/* The row link spans the row on a subgrid instead of display: contents, which takes a link out of the tab order
   (browser walk 2026-12-05: no question row on Ask, History or a device page could be reached with the keyboard). */
.ruled > li > a.rowlink { color: inherit; text-decoration: none; display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; gap: inherit; align-items: center; min-width: 0; }
.ruled > li > a.rowlink:focus-visible { outline-offset: 4px; }
.ruled .r-main { min-width: 0; }
.ruled .r-title { font-weight: 650; overflow-wrap: anywhere; }
.ruled .r-meta { color: var(--muted); font-size: var(--t-xs); }
.ruled-day { font: 700 var(--t-xs)/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: var(--s4) 0 var(--s2); }
@media (max-width: 560px) { .ruled > li { grid-template-columns: 4.2rem 1fr; } .ruled > li > :nth-child(3) { grid-column: 2; } }

/* numbered list like a parts list / steps in a manual */
.numbered { list-style: none; counter-reset: n; margin: 0; padding: 0; }
.numbered > li { counter-increment: n; display: grid; grid-template-columns: 2.4rem 1fr; gap: var(--s3); padding: 10px 0; border-bottom: 1px solid var(--line); }
.numbered > li::before { content: counter(n, decimal-leading-zero); font: 700 var(--t-sm)/1.6 var(--font-mono); color: var(--muted); }

/* step checklist with a drawn tick */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.steps > li { counter-increment: s; border-bottom: 1px solid var(--line); }
.steps label { display: grid; grid-template-columns: 2rem 28px 1fr; gap: 10px; align-items: start; min-height: 48px; padding: 12px 0; cursor: pointer; }
.steps label::before { content: counter(s) "."; font: 700 var(--t-sm)/1.7 var(--font-mono); color: var(--muted); }
.steps input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.steps .tick { width: 26px; height: 26px; border: 1.5px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--surface); display: grid; place-items: center; color: var(--ok); }
.steps .tick svg { width: 20px; height: 20px; stroke-dasharray: 24; stroke-dashoffset: 24; }
.steps input:checked + .tick { border-color: var(--ok); }
.steps input:checked + .tick svg { stroke-dashoffset: 0; }
.steps input:checked ~ .s-text { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.steps input:focus-visible + .tick { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--brand); }
@media (prefers-reduced-motion: no-preference) { .steps .tick svg { transition: stroke-dashoffset 150ms var(--ease); } }

/* key/value lines (model line, device facts) */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--s4); margin: 0; }
.kv dt { color: var(--muted); font-size: var(--t-xs); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .06em; padding-top: 3px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.chip, .tag {
  display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  font: 600 var(--t-xs)/1 var(--font-mono); letter-spacing: .02em; background: var(--surface); color: var(--ink); white-space: nowrap;
}
.tag-ok { color: var(--ok); border-color: currentColor; }
.tag-warn { color: var(--warn); border-color: currentColor; }
.tag-bad { color: var(--bad); border-color: currentColor; }

/* meter strip: printed ticks */
.meter { display: grid; gap: 8px; }
.meter-strip { display: flex; gap: 3px; height: 22px; align-items: stretch; }
.meter-strip i { flex: 1; max-width: 10px; background: var(--line); }
.meter-strip i.used { background: var(--ink); }
.meter-strip i.free { background: var(--brand); }
.meter-cap { font: 600 var(--t-xs)/1.3 var(--font-mono); color: var(--muted); }

/* empty, loading, error states */
.empty { padding: var(--s6) 0; color: var(--muted); max-width: 46ch; }
.empty h2 { color: var(--ink); margin-bottom: var(--s2); }
.loading { color: var(--muted); padding: var(--s5) 0; }
.skeleton { background: linear-gradient(90deg, var(--bg-2), var(--surface-2), var(--bg-2)); background-size: 200% 100%; min-height: 1em; }
@media (prefers-reduced-motion: no-preference) { .skeleton { animation: sk 1.4s linear infinite; } @keyframes sk { to { background-position: -200% 0; } } }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: var(--s3) var(--s4); border-left: 4px solid var(--bad); background: var(--bad-soft); }
.alert.warn { border-color: var(--warn); background: var(--warn-soft); }
.alert.ok { border-color: var(--ok); background: var(--ok-soft); }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 80; left: 50%; transform: translateX(-50%); bottom: var(--s5); display: grid; gap: 8px; width: min(28rem, calc(100vw - 24px)); pointer-events: none; }
@media (max-width: 860px) { .toasts { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px); } }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px; background: var(--ink); color: var(--bg); border-radius: var(--r-ctl); font-weight: 600; font-size: var(--t-sm); }
.toast .ico { color: var(--bg); }
.toast-bad { background: var(--bad); color: #fff; }
.toast-x { width: 36px; height: 36px; display: grid; place-items: center; background: none; border: 0; color: inherit; cursor: pointer; border-radius: var(--r-ctl); }

/* ---------- dialogs and the bottom sheet ---------- */
dialog { color: var(--ink); }
dialog::backdrop { background: var(--scrim); }
.dlg { width: min(30rem, calc(100vw - 24px)); padding: var(--s5); border: 2px solid var(--ink); border-radius: 0; background: var(--surface); }
.dlg-title { display: flex; align-items: center; gap: 10px; font-size: 1.3rem; margin-bottom: var(--s3); }
.dlg-warn .dlg-title { color: var(--warn); }
.dlg-bad .dlg-title { color: var(--bad); }
.dlg-body { color: var(--muted); }
.dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s2); margin-top: var(--s4); }
.sheet { width: min(44rem, 100vw); max-width: 100vw; max-height: 92vh; margin: auto 0 0 auto; height: 100vh; padding: 0; border: 0; border-left: 2px solid var(--ink); background: var(--bg-2); }
.sheet-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); background: var(--bg); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; } /* above the page stamp and positioned page text, which otherwise paint over the sticky head */
.sheet-head h2 { font-size: 1.1rem; flex: 1; }
.sheet-grip { display: none; }
.sheet-body { padding: var(--s4); overflow: auto; }
@media (max-width: 860px) {
  .sheet { width: 100vw; height: auto; max-height: 88vh; margin: auto 0 0; border-left: 0; border-top: 2px solid var(--ink); }
  .sheet-grip { display: block; position: absolute; left: 50%; top: 6px; width: 44px; height: 4px; margin-left: -22px; background: var(--line-strong); border-radius: 2px; }
}
@media (prefers-reduced-motion: no-preference) {
  .sheet[open] { animation: sheet-in 200ms var(--ease); }
  @keyframes sheet-in { from { transform: translateX(40px); opacity: 0; } }
  @media (max-width: 860px) { @keyframes sheet-in { from { transform: translateY(60px); opacity: 0; } } }
}

/* ---------- camera ---------- */
.cam { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; padding: 0; border: 0; background: #0D0D0C; color: #F0EBDD; display: none; }
.cam[open] { display: flex; flex-direction: column; }
.cam-head { display: flex; align-items: center; padding: 10px 12px 10px 18px; }
.cam-head h2 { flex: 1; font-size: 1.05rem; }
.cam .iconbtn { color: #F0EBDD; }
.cam .iconbtn:hover { background: rgba(255,255,255,.08); border-color: transparent; }
.cam-stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; }
.cam-video { width: 100%; height: 100%; object-fit: cover; }
.cam-frame { position: absolute; inset: 18% 8%; border: 2px solid #FFE45C; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); border-radius: 4px; }
.cam-display .cam-frame { inset: 30% 12%; }
.cam-page .cam-frame { inset: 6% 14%; }
.cam-status { text-align: center; padding: 10px 16px 0; margin: 0; color: #D8D2C4; }
.cam-thumbs { list-style: none; display: flex; gap: 8px; padding: 10px 16px 0; margin: 0; overflow-x: auto; }
.cam-thumbs li { position: relative; flex: none; }
.cam-thumbs img { width: 56px; height: 72px; object-fit: cover; border: 1px solid #555; }
.cam-thumbs .iconbtn { position: absolute; top: -10px; right: -10px; width: 32px; height: 32px; background: #1B1A17; }
.cam-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.cam-bar .btn.ghost { color: #F0EBDD; border-color: #7C766A; justify-self: start; white-space: normal; }
.cam-bar .btn.primary { justify-self: end; }
.cam-shutter { width: 74px; height: 74px; border-radius: 50%; border: 4px solid #F0EBDD; background: transparent; padding: 5px; cursor: pointer; }
.cam-shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #FF86BD; }
.cam-shutter:disabled { opacity: .35; cursor: not-allowed; }

/* ---------- forced colours ---------- */
@media (forced-colors: active) {
  .stamp { border-color: CanvasText; outline-color: CanvasText; color: CanvasText; }
  .hl { background: Mark; color: MarkText; text-decoration: underline 2px; forced-color-adjust: none; }
  .tab[aria-current="page"] { border-color: Highlight; }
  .hazard::before { background: CanvasText; }
}

/* ---------- print (an answer printed from the browser) ---------- */
@media print {
  .spine, .tabbar, .foot, .banners, .toasts, .skip, .pwa-bar { display: none !important; }
  body { background: #fff; color: #000; }
  .page { padding: 0; max-width: none; }
}
