/* Layout: a phone count sheet. A sticky plum header carries the running tally, search and scan;
   below it each brand line is a tally table whose unit columns (Pods, Kits, Units) line up on the
   right, under the thumb. Brass marks the two things she reaches for: Scan and delivery mode. */
:root {
  --bg: #F4F1F5;
  --surface: #FFFFFF;
  --sunk: #FAF7FB;
  --ink: #24182B;
  --muted: #6B5F72;
  --line: #E2DAE6;
  --accent: #8C2C6E;
  --accent-ink: #FFFFFF;
  --accent-soft: #F4E2EE;
  --ok: #2E7550;
  --ok-soft: #E3F1E9;
  --warn: #A9480F;
  --warn-soft: #FCEADD;
  --danger: #B42318;
  --head: #2B1932;
  --head-2: #3D2746;
  --head-ink: #F7EFF8;
  --head-muted: #C9B6CF;
  --brass: #F0B84A;
  --brass-ink: #2B1932;
  --chart-accent: #8C2C6E;
  --chart-muted: #9A8EA0;
  --grid: #ECE6EF;
  --scrim: rgba(16, 6, 20, .55);
  --cam: #000000;
  --cam-ink: #FFFFFF;
  --display: "Bagel Fat One", "Arial Rounded MT Bold", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "DM Mono", ui-monospace, "Roboto Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141016; --surface: #1E1822; --sunk: #18131B; --ink: #EEE6F1; --muted: #A898AE; --line: #342A3A;
    --accent: #E38BC9; --accent-ink: #2A0E21; --accent-soft: #3A2035;
    --ok: #7FCB9C; --ok-soft: #1C3125; --warn: #F2A26C; --warn-soft: #3A2517; --danger: #FF8C82;
    --head: #0E0A10; --head-2: #251B2A; --head-ink: #F7EFF8; --head-muted: #A898AE;
    --brass: #E9B04A; --brass-ink: #1A0F1E;
    --chart-accent: #CF62B3; --chart-muted: #6E6374; --grid: #2C2331;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box }
[hidden] { display: none !important }
html { -webkit-text-size-adjust: 100%; min-height: 100%; background: var(--bg) }
body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.4; -webkit-tap-highlight-color: transparent }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--head) }
button, input, select, textarea { font: inherit; color: inherit }
button, label.btn, label.scan { cursor: pointer }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap }
svg { flex: none }
.wrap { width: 100%; max-width: 44rem; margin-inline: auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)) }

/* ---------- header ---------- */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--head); color: var(--head-ink) }
.top .wrap { padding-block: 12px; display: grid; gap: 10px }
.brandrow { display: flex; align-items: center; gap: 8px }
.brand { flex: 1; min-width: 0 }
.word { margin: 0; font-family: var(--display); font-weight: 400; font-size: 1.55rem; line-height: 1; letter-spacing: .01em }
.sub { display: flex; flex-wrap: wrap; gap: 2px 8px; margin-top: 5px; font-size: .8125rem; color: var(--head-muted) }
.save { display: inline-flex; align-items: center; gap: 5px }
.save::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor }
.save[data-s="saving"] { color: var(--brass) }
.save[data-s="error"] { color: var(--warn) }
.save[data-s=""] { display: none }
.hbtn { min-height: 40px; min-width: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--head-2); background: var(--head-2); color: var(--head-ink); font-weight: 700; font-size: .875rem; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap }
.hbtn.icon { padding: 0; width: 40px }
.hbtn svg { width: 20px; height: 20px }
.hbtn.on { background: var(--head-ink); color: var(--head); border-color: var(--head-ink) }

.modeband { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--brass); color: var(--brass-ink); border-radius: 12px; padding: 8px 8px 8px 14px }
.modeband p { margin: 0; flex: 1 1 10rem; min-width: 0; font-weight: 700; font-size: .9375rem; line-height: 1.25 }
.modeband p span { display: block; font-weight: 400; font-size: .8125rem }
.modeband .hbtn { background: var(--brass-ink); color: var(--brass); border-color: var(--brass-ink) }
.modeband .hbtn.ghost { background: transparent; color: var(--brass-ink); border-color: var(--brass-ink) }

.progress { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px }
.ptext { font-size: .875rem; color: var(--head-muted); font-variant-numeric: tabular-nums; white-space: nowrap }
.ptext b { font-family: var(--mono); font-weight: 500; color: var(--head-ink); font-size: 1.0625rem }
.pbar { height: 6px; border-radius: 99px; background: var(--head-2); overflow: hidden }
.pbar span { display: block; height: 100%; width: 0; background: var(--brass); border-radius: inherit; transition: width .3s ease }

.tools { display: flex; gap: 8px }
.search { flex: 1; min-width: 0; position: relative }
.search input { width: 100%; height: 46px; border-radius: 12px; border: 1px solid var(--head-2); background: var(--head-2); color: var(--head-ink); padding: 0 12px 0 40px; font-size: 1rem }
.search input::placeholder { color: var(--head-muted) }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--head-muted); pointer-events: none }
.scan { height: 46px; padding: 0 16px; border-radius: 12px; background: var(--brass); color: var(--brass-ink); font-weight: 700; display: inline-flex; align-items: center; gap: 8px; border: 0; white-space: nowrap }
.scan svg { width: 22px; height: 18px }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-inline: -2px; padding-inline: 2px }
.chips::-webkit-scrollbar { display: none }
.chip { flex: none; height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--head-2); background: transparent; color: var(--head-muted); font-size: .875rem; font-weight: 700; display: inline-flex; align-items: center; gap: 6px }
.chip .n { font-family: var(--mono); font-weight: 500; font-size: .8125rem }
.chip[aria-pressed="true"] { background: var(--head-ink); color: var(--head); border-color: var(--head-ink) }
.editbar { margin: 0; font-size: .875rem; color: var(--head-muted) }

/* ---------- list ---------- */
main.wrap { padding-block: 14px calc(120px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 14px }
#banner { display: grid; gap: 10px }
#banner:empty { display: none }
.note { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; gap: 10px 12px; align-items: center; flex-wrap: wrap; font-size: .9375rem }
.note p { margin: 0; flex: 1 1 14rem; min-width: 0 }
.note .btns { display: flex; gap: 8px; flex-wrap: wrap }
.note.ex { background: var(--accent-soft); border-color: transparent }
.note.bad { background: var(--warn-soft); border-color: transparent }
#list { display: grid; gap: 14px }

.sec { --n: 1; --cw: 4.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden }
.sechead { display: flex; align-items: center; gap: 6px; padding: 2px 10px 2px 2px }
.secname { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 10px; text-align: left; min-height: 50px; border-radius: 12px }
.secname svg { width: 16px; height: 16px; color: var(--muted); transition: transform .2s ease }
.sec.collapsed .secname svg { transform: rotate(-90deg) }
.secname .t { font-weight: 700; font-size: 1.0625rem; line-height: 1.25; text-wrap: balance; min-width: 0 }
.tag { flex: none; font-size: .6875rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent) }
.secprog { font-family: var(--mono); font-size: .8125rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap }
.secprog.done { color: var(--ok) }
.mini { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: .8125rem; color: var(--accent); white-space: nowrap }
.sec.collapsed .secbody { display: none }
.cols, .rgrid { display: grid; grid-template-columns: minmax(0, 1fr) repeat(var(--n), var(--cw)); gap: 8px; align-items: start }
.cols { padding: 0 12px 6px; font-size: .6875rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted) }
.cols span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.cols span:not(:first-child) { text-align: center }
.rows { list-style: none; margin: 0; padding: 0 }
.row { border-top: 1px solid var(--line) }
.row.count { padding: 8px 12px; display: grid; gap: 6px }
.row.count.strengths .rgrid:first-child .iname { grid-column: 1 / -1; min-height: 0 }
.iname { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-height: 46px }
.nbtn { display: inline-flex; align-items: center; gap: 9px; min-width: 0; background: none; border: 0; padding: 4px 0; text-align: left; line-height: 1.25; border-radius: 6px }
.n { min-width: 0; overflow-wrap: anywhere }
.dot { flex: none; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--muted) }
.row.counted .dot { background: var(--ok); border-color: var(--ok) }
.bcmark { color: var(--muted); display: inline-flex }
.bcmark svg { width: 15px; height: 12px }
.flags { display: inline-flex; gap: 6px; flex-wrap: wrap }
.flags:empty { display: none }
.pill { font-size: .6875rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; white-space: nowrap }
.pill.low { background: var(--warn-soft); color: var(--warn) }
.pill.order { background: var(--accent-soft); color: var(--accent) }
.pill.cur { background: var(--accent-soft); color: var(--accent) }
.pill.open { background: var(--brass); color: var(--brass-ink) }
.slab { align-self: center; padding-left: 18px; font-family: var(--mono); font-size: .875rem; color: var(--muted); min-width: 0; overflow-wrap: anywhere }
.cell { display: grid; gap: 3px; min-width: 0 }
.cnt { width: 100%; height: 46px; border-radius: 10px; border: 1px solid var(--line); background: var(--sunk); text-align: center; font-family: var(--mono); font-size: 1.1875rem; font-variant-numeric: tabular-nums; padding: 0 4px }
.cnt::placeholder { color: var(--muted); opacity: .6 }
.cnt:not(:placeholder-shown) { background: var(--ok-soft); border-color: transparent }
.delivery .cnt:not(:placeholder-shown) { background: var(--accent-soft) }
.cnt.lowv:not(:placeholder-shown) { background: var(--warn-soft); color: var(--warn) }
.cnt:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; background: var(--surface); color: var(--ink) }
.hint2 { font-size: .6875rem; color: var(--muted); text-align: center; font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.hint2:empty { display: none }
.hint2.over { color: var(--warn); font-weight: 500 }
.none { padding: 14px 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: .9375rem }

.row.edit { display: flex; align-items: stretch }
.handle { flex: none; width: 44px; display: flex; align-items: center; justify-content: center; color: var(--muted); touch-action: none; cursor: grab }
.handle svg { width: 18px; height: 18px }
.row.dragging { position: relative; z-index: 2; background: var(--accent-soft); box-shadow: 0 6px 18px rgba(20, 6, 24, .18) }
.rowedit { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 0; background: none; border: 0; text-align: left; min-height: 54px }
.rowedit .n { flex: 1 }
.rowedit .meta { font-size: .75rem; color: var(--muted); white-space: nowrap }
.rowedit .go { font-size: .8125rem; color: var(--accent); font-weight: 700 }
.addrow { display: flex; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--line) }
.addrow input { flex: 1; min-width: 0; height: 46px; border: 1px dashed var(--muted); border-radius: 10px; background: var(--sunk); padding: 0 12px }

.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: 14px; padding: 24px 18px; display: grid; gap: 12px; justify-items: start }
.empty h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 1.35rem; line-height: 1.15; text-wrap: balance }
.empty p { margin: 0; color: var(--muted); max-width: 34rem }
.empty .actions { width: 100% }
.linkbtn { background: none; border: 0; padding: 4px 0; color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px }

/* ---------- buttons ---------- */
.btn { min-height: 46px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 700; font-size: .9375rem; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center; line-height: 1.2 }
.btn svg { width: 18px; height: 15px }
.btn.small { min-height: 38px; padding: 0 12px; font-size: .875rem }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent) }
.btn.danger { color: var(--danger) }
.btn.danger.solid { background: var(--danger); color: var(--surface); border-color: var(--danger) }
.btn.wide { width: 100% }
.btn:disabled { opacity: .55; cursor: default }

/* ---------- sheets ---------- */
dialog.sheet { position: fixed; inset: auto 0 0 0; margin: 0 auto; width: 100%; max-width: 40rem; max-height: 92dvh; border: 0; padding: 0; border-radius: 20px 20px 0 0; background: var(--surface); color: var(--ink); box-shadow: 0 -10px 40px rgba(10, 4, 14, .28); flex-direction: column; overflow: hidden }
dialog.sheet[open] { display: flex }
dialog.sheet::backdrop { background: rgba(16, 6, 20, .55) }
.sheethead { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)) }
.sheethead h2 { margin: 0; font-size: 1.1875rem; line-height: 1.2; min-width: 0; overflow-wrap: anywhere }
.xbtn { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: inline-flex; align-items: center; justify-content: center }
.xbtn svg { width: 16px; height: 16px }
.sheetbody { overflow: auto; overscroll-behavior: contain; padding: 4px max(16px, env(safe-area-inset-right, 0px)) calc(22px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)) }
.sheetbody form, .stack { display: grid; gap: 16px; min-width: 0 }
.field { display: grid; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0 }
.field > label, .lab { font-weight: 700; font-size: .875rem }
.field input:not([type="checkbox"]), .field select, .field textarea { width: 100%; min-height: 46px; border-radius: 10px; border: 1px solid var(--line); background: var(--sunk); padding: 10px 12px; font-size: 1rem }
.field textarea { resize: vertical; min-height: 130px; line-height: 1.4 }
.field input.short { max-width: 9rem }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .9375rem }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); flex: none }
.hint { margin: 0; font-size: .8125rem; color: var(--muted) }
.lead { margin: 0 }
.err { margin: 0; color: var(--danger); font-size: .875rem; font-weight: 700 }
.unitchips { display: flex; flex-wrap: wrap; gap: 8px }
.uchip { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: .9375rem; display: inline-flex; align-items: center; gap: 6px }
.uchip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink) }
.uchip .o { font-family: var(--mono); font-weight: 500; font-size: .75rem; opacity: .85 }
.uchip .x { font-size: 1.1rem; line-height: 1 }
.inline { display: flex; gap: 8px; min-width: 0 }
.inline input { flex: 1; min-width: 0 }
.pargrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: 10px }
.pargrid label { display: grid; gap: 4px; font-size: .8125rem; color: var(--muted); font-weight: 700 }
.actions { display: flex; gap: 8px; flex-wrap: wrap }
.actions .btn { flex: 1 1 9rem }
.confirm { background: var(--warn-soft); border-radius: 12px; padding: 12px; display: grid; gap: 10px }
.confirm p { margin: 0 }
.code { font-family: var(--mono); font-size: .9375rem; background: var(--sunk); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; overflow-wrap: anywhere }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100% }

.menu, .list { display: grid; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; list-style: none; margin: 0; padding: 0 }
.menuhead { margin: 18px 0 8px; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted) }
.menuhead:first-child { margin-top: 4px }
.mi { display: grid; gap: 2px; text-align: left; padding: 13px 14px; background: var(--surface); border: 0; border-top: 1px solid var(--line); width: 100% }
.mi:first-child { border-top: 0 }
.mi b { font-size: 1rem }
.mi span { font-size: .8125rem; color: var(--muted) }
.mi.danger b { color: var(--danger) }
.where { margin: 14px 0 0; font-size: .8125rem; color: var(--muted) }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); flex-wrap: wrap }
.list li:first-child { border-top: 0 }
.list .grow { flex: 1 1 10rem; min-width: 0; display: grid; gap: 2px }
.list .muted { font-size: .8125rem; color: var(--muted) }
.list .btns { display: flex; gap: 6px; flex-wrap: wrap }
.pick { width: 100%; display: grid; gap: 1px; text-align: left; background: none; border: 0; padding: 4px 0; min-height: 44px }
.pick .muted { font-size: .8125rem; color: var(--muted) }
.copybox { width: 100%; min-height: 16rem; font-family: var(--mono); font-size: .8125rem; border-radius: 10px; border: 1px solid var(--line); background: var(--sunk); padding: 10px; color: var(--ink) }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; background: var(--sunk) }
.seg button { border: 0; background: none; border-radius: 999px; min-height: 34px; padding: 0 12px; font-weight: 700; font-size: .875rem; color: var(--muted) }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(20, 6, 24, .14) }

/* quick count after a scan */
.quick { --n: 1; display: grid; gap: 8px }
.quick .rgrid { grid-template-columns: minmax(3rem, 1fr) repeat(var(--n), minmax(4.5rem, 6rem)); align-items: center }
.quick .qhead span { font-size: .6875rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: center }
.quick .slab { padding-left: 0 }
.quick .hit .slab { color: var(--accent); font-weight: 500 }
.quick .cnt { height: 56px; font-size: 1.5rem }

/* item details */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 10px }
.tile { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 2px; min-width: 0 }
.tile .tl { font-size: .8125rem; color: var(--muted) }
.tile .tv { font-size: 1.75rem; font-weight: 700; line-height: 1.1 }
.tile .td { font-size: .8125rem; color: var(--muted) }
.chartblock { display: grid; gap: 6px; min-width: 0 }
.chartblock h3 { margin: 0; font-size: 1rem }
.chart { position: relative; width: 100%; max-width: 100% }
.chart svg { display: block; width: 100%; height: auto; overflow: visible }
.chart .hit { fill: transparent; cursor: pointer; outline: none }
.chart .hit:focus-visible + .barmark, .chart .hit:hover + .barmark { opacity: .8 }
.tip { position: absolute; z-index: 3; pointer-events: none; background: var(--ink); color: var(--bg); border-radius: 8px; padding: 6px 9px; font-size: .8125rem; line-height: 1.3; white-space: nowrap; transform: translate(-50%, calc(-100% - 8px)) }
.tip b { font-family: var(--mono); font-weight: 500; font-size: .9375rem; display: block }
details.tbl summary { cursor: pointer; font-size: .8125rem; font-weight: 700; color: var(--accent); padding: 4px 0 }
.tablewrap { overflow-x: auto }
table.data { border-collapse: collapse; width: 100%; font-size: .8125rem; font-variant-numeric: tabular-nums }
table.data th, table.data td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap }
table.data th:first-child, table.data td:first-child { text-align: left }
table.data th { color: var(--muted); font-weight: 700 }
.rank { list-style: none; margin: 0; padding: 0; display: grid; border: 1px solid var(--line); border-radius: 14px; overflow: hidden }
.rank li { display: grid; grid-template-columns: 1.75rem minmax(0, 1fr) auto 76px; gap: 10px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--line) }
.rank li:first-child { border-top: 0 }
.rank .r { font-family: var(--mono); color: var(--muted); font-size: .8125rem }
.rank .nm { min-width: 0 }
.rank .nm b { display: block; overflow-wrap: anywhere }
.rank .nm span { font-size: .8125rem; color: var(--muted) }
.rank .v { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap }
.rank .v small { color: var(--muted); font-family: var(--body) }
.rank svg { width: 76px; height: 26px }

/* scanner */
dialog.scanner { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--cam); color: var(--cam-ink); overflow: hidden }
dialog.scanner[open] { display: block }
dialog.scanner::backdrop { background: #000 }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--cam) }
.scanner .frame { position: absolute; left: 10%; right: 10%; top: 50%; height: 26%; transform: translateY(-50%); border: 3px solid var(--brass); border-radius: 16px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45) }
.scanner .scantop { position: absolute; inset: 0 0 auto; padding: calc(16px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px)); text-align: center; font-weight: 700; font-size: 1.0625rem }
.scanner .scantop p { margin: 0 }
.scanner .scanbottom { position: absolute; inset: auto 0 0; padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); display: flex; gap: 8px; justify-content: center; flex-wrap: wrap }
.scanner .hbtn { background: rgba(0, 0, 0, .55); border-color: rgba(255, 255, 255, .35); color: var(--cam-ink); min-height: 46px }

/* guided tour: a spotlight on the real control, with a card above or below it */
dialog.tour { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; color: var(--ink); overflow: hidden }
dialog.tour[open] { display: block }
dialog.tour::backdrop { background: transparent }
.tour .spot { position: fixed; border-radius: 14px; box-shadow: 0 0 0 200vmax rgba(16, 6, 20, .66); outline: 3px solid var(--brass); pointer-events: none; transition: left .25s ease, top .25s ease, width .25s ease, height .25s ease }
.tour .spot.none { outline: 0 }
.tour .tcard { position: fixed; left: max(16px, env(safe-area-inset-left, 0px)); right: max(16px, env(safe-area-inset-right, 0px)); margin-inline: auto; max-width: 26rem; background: var(--surface); border-radius: 16px; padding: 16px; box-shadow: 0 12px 40px rgba(10, 4, 14, .4); display: grid; gap: 8px }
.tour .tcard.center { top: 50%; transform: translateY(-50%) }
.tstep { margin: 0; font-family: var(--mono); font-size: .75rem; color: var(--muted) }
.tour h3 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 1.3rem; line-height: 1.15; text-wrap: balance }
.ttext { margin: 0; font-size: .9375rem; line-height: 1.45 }
.tbtns { display: flex; gap: 8px; align-items: center; margin-top: 4px }
.tbtns .grow { flex: 1 }

/* help topics */
.help { display: grid; border: 1px solid var(--line); border-radius: 14px; overflow: hidden }
.help details { border-top: 1px solid var(--line) }
.help details:first-child { border-top: 0 }
.help summary { cursor: pointer; padding: 14px; font-weight: 700; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 50px }
.help summary::-webkit-details-marker { display: none }
.help summary::after { content: "+"; font-family: var(--mono); color: var(--muted); font-size: 1.15rem }
.help details[open] summary::after { content: "−" }
.hbody { padding: 0 14px 16px; font-size: .9375rem; display: grid; gap: 8px; line-height: 1.45 }
.hbody p, .hbody ul { margin: 0 }
.hbody ul { padding-left: 1.2rem; display: grid; gap: 6px }

/* toast */
.toast { position: fixed; inset: auto auto calc(18px + env(safe-area-inset-bottom, 0px)) 50%; transform: translateX(-50%); margin: 0; z-index: 30; width: max-content; max-width: calc(100% - 32px); background: var(--ink); color: var(--bg); border: 0; padding: 12px 16px; border-radius: 12px; font-size: .9375rem; font-weight: 700; box-shadow: 0 8px 28px rgba(10, 4, 14, .3); display: none; text-align: center }
.toast.show { display: block }
.toast:popover-open { display: block }

@keyframes flash { 0%, 30% { background: var(--accent-soft) } 100% { background: var(--surface) } }
.row.flash { animation: flash 2.4s ease-out }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important } }
@media (min-width: 560px) { .sec { --cw: 5.25rem } }
