/* Dezzert: neutral surfaces, one raspberry accent, Geist + Geist Mono for numbers.
   Shape rule: cards 14px, controls 10px, chips and badges full pill. */
@font-face { font-family: "Geist"; src: url("/fonts/geist.woff2?v=2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/fonts/geist-mono.woff2?v=2") format("woff2"); font-weight: 400 700; font-display: swap; }

:root {
  --bg: #F6F6F4;
  --surface: #FFFFFF;
  --surface-2: #EFEFEC;
  --ink: #18181B;
  --muted: #63636B;
  --line: #E4E4E1;
  --accent: #BE185D;
  --accent-ink: #BE185D;
  --accent-soft: #FCE7F0;
  --on-accent: #FFFFFF;
  --solid: #18181B;
  --on-solid: #FAFAFA;
  --good: #356B30;
  --good-soft: #E7F2E4;
  --warn: #8A5A00;
  --warn-soft: #FBF1DC;
  --bad: #B91C1C;
  --bad-soft: #FDECEC;
  --scrim: rgba(24, 24, 27, .45);
  --radius: 14px;
  --radius-sm: 10px;
  --body: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --tabbar: 72px;
  --maxw: 600px;
  color-scheme: light;
}

/* Dark is a switch, not just the phone's setting: applyTheme() in js/ui.js puts
   data-theme on <html>, and an inline script in index.html sets it before the
   first paint so a dark phone never flashes white. */
:root[data-theme="dark"] {
  --bg: #111113;
  --surface: #1A1A1D;
  --surface-2: #242428;
  --ink: #F4F4F5;
  --muted: #A1A1AA;
  --line: #2C2C31;
  --accent: #F472B6;
  --accent-ink: #F472B6;
  --accent-soft: #3A1A2A;
  --on-accent: #111113;
  --solid: #2E2E33;
  --on-solid: #F4F4F5;
  --good: #8FCB7E;
  --good-soft: #1D2B1B;
  --warn: #E3B04B;
  --warn-soft: #2F2615;
  --bad: #F87171;
  --bad-soft: #3A1A1A;
  --scrim: rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-feature-settings: "tnum";
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
img { display: block; max-width: 100%; }
h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.015em; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.boot { min-height: 100dvh; display: grid; place-items: center; font: 600 28px var(--body); letter-spacing: -.02em; color: var(--accent); }

/* ---------- layout ---------- */
.view {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar) + 28px + env(safe-area-inset-bottom));
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.xs { gap: 4px; }
.stack.sm { gap: 8px; }
.stack.lg { gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.gap { gap: 10px; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 360px) { .grid2 { grid-template-columns: 1fr; } }
.center { text-align: center; }
.right { text-align: right; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.xsmall { font-size: 12px; }
.bad { color: var(--bad) !important; }
.good { color: var(--good) !important; }
.strong { font-weight: 700; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) max(16px, calc((100% - var(--maxw)) / 2 + 16px)) 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.event-switch {
  flex: 1; min-width: 0;
  display: grid; grid-template-columns: 1fr auto; column-gap: 6px;
  text-align: left; background: none; border: 0; padding: 4px 0;
}
.event-name { font: 600 17px/1.25 var(--body); letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-meta { grid-row: 2; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-switch .chev { grid-row: 1 / 3; grid-column: 2; align-self: center; width: 18px; height: 18px; color: var(--muted); }
.sync { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 99px; white-space: nowrap; }
.sync .i { width: 14px; height: 14px; }
.sync.off { background: var(--warn-soft); color: var(--warn); }
.sync.busy { background: var(--surface-2); color: var(--muted); }
/* Cycles Auto, Light, Dark; the icon shows the theme in effect. */
.theme-toggle { width: 36px; height: 36px; color: var(--muted); }
.theme-toggle .i { width: 18px; height: 18px; }

/* ---------- tab bar ---------- */
/* Home, then two labelled groups: "Before the event" and "On the day".
   The column widths are set inline from the visible tab counts, so hiding a
   tab needs no change here. */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid;
  height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tab-group { position: relative; display: flex; border-left: 1px solid var(--line); }
.tab-group-label { position: absolute; top: 6px; left: 0; right: 0; font-size: 11px; font-weight: 600; color: var(--muted); text-align: center; white-space: nowrap; }
.tabbar a {
  position: relative; flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; padding-bottom: 9px;
  text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 500; white-space: nowrap;
}
.tabbar a .i { width: 22px; height: 22px; stroke-width: 1.75; }
.tabbar a.on { color: var(--ink); font-weight: 600; }
.tabbar a.on .i { color: var(--accent); stroke-width: 2.25; }
.tabbar .dot {
  position: absolute; top: 2px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  background: var(--accent); color: var(--on-accent); font: 600 11px/18px var(--body); text-align: center;
}
.tab-group .dot { top: auto; bottom: 36px; }
@media (max-width: 374px) { .tabbar a { font-size: 10px; letter-spacing: -.01em; } }

/* Says which page you are on and what it is for. */
.page-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -.025em; line-height: 1.2; }

/* ---------- icons ---------- */
.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
section.card[role=link] { cursor: pointer; }
.section-title { margin: 0; font-size: 14px; font-weight: 600; color: var(--muted); }
.stock-list + .section-title { margin-top: 12px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--surface-2); color: var(--ink);
  font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: transform .08s ease, background-color .15s ease;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.pist { background: var(--solid); color: var(--on-solid); }
.btn.ghost { background: var(--surface); border-color: var(--line); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn.small .i { width: 16px; height: 16px; }
.btn.block { width: 100%; }
.btn.big { min-height: 68px; padding: 0; font: 600 22px var(--mono); letter-spacing: -.02em; }
.danger-text { color: var(--bad); }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.faint { color: var(--muted); }
.icon-btn.tiny { width: 28px; height: 28px; }
.icon-btn.tiny .i { width: 15px; height: 15px; }
.link { background: none; border: 0; padding: 0; color: var(--accent-ink); font-weight: 600; font-size: 14px; }

/* ---------- segmented ---------- */
.seg { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: var(--radius-sm); }
.seg button { flex: 1; min-height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 500; font-size: 14px; padding: 0 6px; }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(24, 24, 27, .08); }
.seg.sticky { position: sticky; top: calc(60px + env(safe-area-inset-top)); z-index: 10; box-shadow: 0 0 0 8px var(--bg); }
.seg.kinds button.on { color: var(--accent-ink); }

/* ---------- hero stats & counters ---------- */
.hero-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 14px 16px 16px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); text-align: left;
}
.stat-label { font-size: 14px; font-weight: 500; color: var(--muted); }
.stat-num { font: 600 40px/1 var(--mono); letter-spacing: -.04em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-of { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); margin-bottom: 12px; }
.stat .bar { width: 100%; }

.counter {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 18px 18px 20px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
}
.counter-label { font-size: 14px; font-weight: 500; color: var(--muted); }
.counter-num { font: 600 76px/1 var(--mono); letter-spacing: -.05em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.counter-of { font-size: 14px; font-variant-numeric: tabular-nums; color: var(--muted); margin-bottom: 14px; }
.counter .bar { width: 100%; }

.quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.quick .btn.big.ghost { font: 600 16px var(--body); letter-spacing: 0; }

/* ---------- progress ---------- */
.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: inherit; background: var(--ink); transition: width .4s ease; }
.bar.berry span, .bar.pist span { background: var(--accent); }
.bar.bad span { background: var(--bad); }
/* Covered reads as done, matching the green "covered" / "enough" tags. */
.bar.good span { background: var(--good); }

/* ---------- key/value ---------- */
.kv { display: flex; flex-direction: column; }
.kv-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.kv-row:first-child { padding-top: 0; }
.kv-row:last-child { border-bottom: 0; padding-bottom: 0; }
.kv-row strong { font-family: var(--mono); font-weight: 600; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- alerts ---------- */
.alert {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line); border-left: 3px solid var(--muted);
  background: var(--surface); font-size: 14.5px;
}
.alert.warn { border-left-color: var(--warn); }
.alert.bad { border-left-color: var(--bad); }
.alert.film { background: var(--solid); color: var(--on-solid); border: 0; }
.alert.film .btn { background: var(--accent); color: var(--on-accent); }
.alert.film .btn.ghost { background: transparent; color: var(--on-solid); border-color: color-mix(in srgb, var(--on-solid) 35%, transparent); }
.film-text { color: var(--accent-ink); display: flex; align-items: center; gap: 6px; }
.film-text .i { width: 16px; height: 16px; }

/* ---------- lists ---------- */
.rows, .mini-list, .checks, .event-list { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); }
.rows li:last-child { border-bottom: 0; }
.row-btn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 11px 0; background: none; border: 0; text-align: left; }
.row-title { display: block; font-weight: 500; }
.row-btn .muted.small { display: block; }
/* Every quantity and money value is Geist Mono, so figures line up column-wise. */
.row-num, .num { font: 600 15px var(--mono); white-space: nowrap; font-variant-numeric: tabular-nums; }
.num { font-weight: 500; }
.mini-list li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.mini-list li:first-child { padding-top: 0; }
.mini-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.mini-list .small { font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini-list .time { width: 44px; flex: none; }
.log { padding: 9px 0; gap: 12px !important; }
.thumb { width: 40px; height: 40px; flex: none; border-radius: var(--radius-sm); overflow: hidden; border: 0; padding: 0; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.thumb .i { width: 18px; height: 18px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.ph.sample, .thumb.ph.staff { color: var(--warn); }
.thumb.ph.damaged { color: var(--bad); }
.pending { color: var(--warn); font-weight: 500; font-size: 13px; }
.empty { color: var(--muted); font-size: 14.5px; padding: 4px 0; }
.hint { font-size: 13px; color: var(--muted); }

.chip { border: 1px solid transparent; border-radius: 99px; padding: 5px 11px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.chip.planned { background: transparent; border-color: var(--line); color: var(--muted); }
.chip.ordered { background: var(--warn-soft); color: var(--warn); }
.chip.paid { background: var(--accent-soft); color: var(--accent-ink); }
.chip.arrived { background: var(--good-soft); color: var(--good); }
.tag { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.ok { background: var(--good-soft); color: var(--good); }
.tag.none { background: var(--surface-2); color: var(--muted); }
.stock-row { padding: 12px 0; }
.stock-row:first-child { padding-top: 4px; }
.stock-row .bar { height: 4px; }
.stock-row .row.between { align-items: baseline; }

/* checklist */
.checks li { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); }
.checks li:last-child { border-bottom: 0; }
.check { flex: 1; display: flex; align-items: center; gap: 12px; padding: 11px 0; cursor: pointer; min-width: 0; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box { width: 24px; height: 24px; flex: none; border-radius: 7px; border: 1.5px solid color-mix(in srgb, var(--muted) 60%, transparent); display: grid; place-items: center; color: transparent; transition: background-color .15s ease, border-color .15s ease; background: var(--surface); }
.check .box .i { width: 15px; height: 15px; stroke-width: 3; }
.check input:checked + .box { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.check input:focus-visible + .box { outline: 2px solid var(--accent); outline-offset: 2px; }
.checks li.done .check-label { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 70%, transparent); color: var(--muted); }

/* tiles */
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px; text-align: left; }
.tile-num { font: 600 22px var(--mono); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }

/* stock table */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.stock { width: 100%; border-collapse: collapse; font-size: 14px; }
table.stock th { text-align: right; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.stock td { text-align: right; padding: 9px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
table.stock th:first-child, table.stock td:first-child { text-align: left; white-space: normal; font: 600 14px var(--body); }
table.stock tr:last-child td { border-bottom: 0; }
table.stock tr.short td:first-child { color: var(--bad); }

/* money */
.money-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.money-big { font: 600 26px/1.15 var(--mono); letter-spacing: -.03em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.money-mid { font: 600 17px var(--mono); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* pace chart */
.spark { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 8px; }
.spark-col { flex: 1; max-width: 40px; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; }
.spark-bar { width: 100%; border-radius: 6px 6px 2px 2px; background: var(--accent); min-height: 4px; }
.spark-val, .spark-lbl { font-size: 11px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.spark-val { color: var(--ink); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 14px; font-weight: 500; color: var(--ink); }
.input {
  width: 100%; min-height: 46px; padding: 10px 12px;
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--muted) 40%, var(--line)); border-radius: var(--radius-sm);
  font-size: 16px; /* stops iOS zoom */
}
.input::placeholder { color: var(--muted); opacity: .8; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 20px, calc(100% - 15px) 20px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.error { color: var(--bad); font-size: 14px; min-height: 0; }
.error:empty { display: none; }
.photo-field { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.photo-field label.btn { cursor: pointer; }
.photo-preview { position: relative; }
.photo-preview img { max-height: 220px; border-radius: var(--radius-sm); }
.photo-preview .on-photo { position: absolute; top: 6px; right: 6px; background: rgba(0, 0, 0, .55); color: #fff; }

/* ---------- sheet ---------- */
.sheet-wrap {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  background: transparent; transition: background-color .2s ease;
}
.sheet-wrap.open { background: var(--scrim); }
.sheet {
  width: 100%; max-width: 600px; max-height: 92dvh; overflow: auto;
  background: var(--bg); border-radius: 20px 20px 0 0;
  padding: 0 16px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .22s cubic-bezier(.2, .8, .2, 1);
  overscroll-behavior: contain;
}
.sheet-wrap.open .sheet { transform: none; }
.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 18px 0 12px; background: var(--bg); }
/* Long sheets (item, purchase) keep their actions reachable without scrolling. */
.sheet-actions { position: sticky; bottom: 0; z-index: 1; margin-top: 4px; padding: 12px 0 6px; background: var(--bg); border-top: 1px solid var(--line); }
.sheet-head::before { content: ""; position: absolute; top: 7px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 99px; background: var(--line); }
@media (min-width: 640px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 20px; max-height: 86dvh; }
  .sheet-head::before { display: none; }
}
.viewer-img { width: 100%; border-radius: var(--radius-sm); }

/* events list */
.event-row { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-align: left; margin-bottom: 8px; }
.event-row.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.event-row.archived { opacity: .65; }
.event-row-name { font: 600 16px var(--body); }
/* Each row carries its own edit button, so the list item is the flex row. */
.event-list li { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.event-list li .event-row { flex: 1; min-width: 0; margin-bottom: 0; }

/* ---------- content ---------- */
.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 520px) { .gallery { grid-template-columns: repeat(3, 1fr); } }
.gallery figure { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.gallery-img { aspect-ratio: 4 / 5; border: 0; padding: 0; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.gallery-img img { width: 100%; height: 100%; object-fit: cover; }
.gallery figcaption { display: grid; grid-template-columns: 1fr auto; column-gap: 4px; }
.gallery figcaption .xsmall { grid-row: 2; }
.gallery figcaption .icon-btn { grid-row: 1 / 3; grid-column: 2; align-self: center; }

.canvas-frame { display: flex; justify-content: center; }
.card-canvas { width: min(100%, 340px); aspect-ratio: 9 / 16; height: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2); }
.bg-picker { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.bg-opt { width: 56px; height: 72px; flex: none; padding: 0; border-radius: var(--radius-sm); overflow: hidden; border: 2px solid transparent; background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--muted); }
.bg-opt img { width: 100%; height: 100%; object-fit: cover; }
.bg-opt.on { border-color: var(--accent); }
.caption-box { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.caption-box .seg { align-self: stretch; }
.caption-text { white-space: pre-wrap; font-size: 15px; background: var(--surface-2); padding: 12px 14px; border-radius: var(--radius-sm); width: 100%; user-select: text; }

/* ---------- login ---------- */
.login { max-width: 400px; margin: 0 auto; padding: calc(64px + env(safe-area-inset-top)) 16px 40px; display: flex; flex-direction: column; gap: 14px; }
.brand-mark { font: 600 32px var(--body); color: var(--accent); letter-spacing: -.03em; }
.login > .muted.center { text-align: left; margin-top: -8px; margin-bottom: 8px; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--radius-sm); font-size: 14.5px; font-weight: 500;
  transition: opacity .2s ease, transform .2s ease; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- recipe tab: cups band and typed recipe cards ---------- */
.cups-band { display: flex; flex-direction: column; gap: 8px; }
.cups-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.cups-stat { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; min-width: 0; }
.cups-stat + .cups-stat { border-left: 1px solid var(--line); }
.cups-stat-label { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cups-stat-num { font: 600 26px/1 var(--mono); letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.cups-stat.total .cups-stat-num { color: var(--accent-ink); }

.rc-head { display: flex; align-items: flex-start; gap: 12px; }
.rc-icon { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); }
.rc-icon .i { width: 20px; height: 20px; }
.rc-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 22px; }
.rc-title-row h3 { font-size: 17px; }
.rc-tag { font-size: 12px; font-weight: 600; color: var(--muted); }
.rc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rc-chip { padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.rc-chip.bad { background: var(--bad-soft); color: var(--bad); }
.rc-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.cost-kv { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.cost-kv .kv-row { border-bottom-color: color-mix(in srgb, var(--line) 70%, var(--surface-2)); font-size: 14.5px; }

/* Ingredient rows: names a row's two amount columns once, so the right-hand
   figure is never an unlabelled number. Shared by every recipe card. */
.ing-cols { display: flex; justify-content: space-between; gap: 12px; margin-top: 2px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.ing-cols span:last-child { text-align: right; }

/* Coverage ledger (Plan > Budget): one row per item instead of a card each. */
.rows li.cover-row { display: block; padding: 12px 0; }
.cover-row > .row + .row { margin-top: 6px; }
.cover-row .bar { margin-top: 8px; }
.cover-row .row-title { font-size: 15px; }

/* Native disclosure for folded-away lists: already-covered lines, purchases. */
.more > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 8px 0 0; color: var(--muted); font-size: 13px; font-weight: 600; }
.more > summary::-webkit-details-marker { display: none; }
.more > summary .more-chev { width: 15px; height: 15px; transition: transform .15s ease; }
.more[open] > summary .more-chev { transform: rotate(180deg); }
.more[open] > summary { padding-bottom: 4px; }
@media (hover: hover) { .more > summary:hover { color: var(--ink); } }

/* Folded rows are reference, not work in progress. */
.rows.quiet .row-title { font-weight: 400; color: var(--muted); }
.rows.quiet .row-btn { padding: 9px 0; }

/* ---------- dashboard ---------- */
/* Dashboard columns: one column on a phone, two on a tablet or desktop. */
.home-col, .home-cols { display: contents; }
.progress-grid { display: contents; }
@media (min-width: 768px) {
  .home-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
  .home-col { display: flex; flex-direction: column; gap: 16px; }
  /* Meters on the left, the readouts that follow from them on the right. */
  .progress-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 28px; align-items: start; }
}

/* A labelled meter: the number carries the reading, the bar carries the pace. */
.meter { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 0; }
.meter-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.meter-label { font-size: 14px; font-weight: 500; color: var(--muted); }
.meter-value { font: 600 22px var(--mono); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.meter-of { font: 400 13px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.meter .bar { margin-top: 6px; }

/* Countdown next to the Progress heading. */
.pill { display: inline-block; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill.now { background: var(--accent-soft); color: var(--accent-ink); }
.pill.past { background: transparent; border: 1px solid var(--line); }

/* Alerts as compact rows inside one card, instead of a banner each. */
.note { display: flex; align-items: center; gap: 10px; padding: 9px 11px; margin-bottom: 6px; border-radius: var(--radius-sm); background: var(--surface-2); border-left: 3px solid var(--muted); font-size: 14px; }
.note:last-child { margin-bottom: 0; }
.note.warn { border-left-color: var(--warn); }
.note.bad { border-left-color: var(--bad); }
.note.film { background: var(--solid); color: var(--on-solid); border-left: 0; }
.note.film .btn.ghost { background: transparent; color: var(--on-solid); border-color: color-mix(in srgb, var(--on-solid) 35%, transparent); }
.note .btn { flex: none; }
.note[onclick] { cursor: pointer; }
.note .chev-right { width: 16px; height: 16px; color: var(--muted); flex: none; }
.note.film .i { width: 16px; height: 16px; flex: none; }

/* Readiness rows reuse .rows; the bar sits under the label and count. */
.ready-list .row-btn { padding: 12px 0; }
.ready-list .row-btn > .grow { display: flex; flex-direction: column; gap: 6px; }

/* ---------- bulk selection ---------- */
/* A toolbar row that carries the list count and the way into select mode. */
.list-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 34px; }

.pick-row { cursor: pointer; }
.pick-box {
  width: 24px; height: 24px; flex: none; display: grid; place-items: center;
  border-radius: 7px; border: 1.5px solid color-mix(in srgb, var(--muted) 60%, transparent);
  background: var(--surface); color: transparent;
  transition: background-color .15s ease, border-color .15s ease;
}
.pick-box .i { width: 15px; height: 15px; stroke-width: 3; }
.pick-row input:checked + .pick-box { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.pick-row input:focus-visible + .pick-box { outline: 2px solid var(--accent); outline-offset: 2px; }
.rows li.on, .checks li.on { background: var(--accent-soft); }
.rows li.on .row-title, .checks li.on .check-label { color: var(--accent-ink); }

/* Sticky action bar, above the tabs and below any sheet. */
.bulk-bar {
  position: fixed; left: 0; right: 0; z-index: 25;
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 10px);
  width: min(100% - 24px, var(--maxw) - 24px); margin: 0 auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--ink) 18%, transparent);
}
.bulk-count { font-size: 14px; font-weight: 600; }
/* Keep the last rows reachable under the bar. */
#app:has(.bulk-bar) .view { padding-bottom: calc(var(--tabbar) + 132px + env(safe-area-inset-bottom)); }
/* --ink is near-white in dark mode, so the shadow needs its own dark value. */
:root[data-theme="dark"] .bulk-bar { box-shadow: 0 10px 30px rgba(0, 0, 0, .55); }

/* Main recipe: the strongest card, accent edge and tile. */
.recipe-card.main { border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); box-shadow: inset 0 3px 0 var(--accent); }
.recipe-card.main .rc-icon { background: var(--accent-soft); color: var(--accent-ink); }
.recipe-card.main .rc-tag { color: var(--accent-ink); }
.recipe-card.main .rc-title-row h3 { font-size: 20px; letter-spacing: -.02em; }
/* Prep recipe: standard card, ink tile. */
.recipe-card.prep .rc-icon { background: var(--solid); color: var(--on-solid); }
/* Packaging: quiet, no fill. */
.recipe-card.pack { background: transparent; }
.recipe-card.pack .rc-icon { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.recipe-card.pack .rc-foot { border-top-style: dashed; }
/* Add prep: an action, not content. */
.add-tile { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1.5px dashed color-mix(in srgb, var(--muted) 45%, var(--line)); border-radius: var(--radius); background: transparent; color: var(--ink); text-align: left; }
.add-tile .rc-icon { background: transparent; border: 1px dashed color-mix(in srgb, var(--muted) 45%, var(--line)); color: var(--muted); }
.add-tile .row-title, .add-tile .muted { display: block; }
@media (hover: hover) { .add-tile:hover { border-color: var(--accent); } .add-tile:hover .rc-icon { color: var(--accent-ink); border-color: var(--accent); } }

/* ---------- recipe focus ---------- */
.focus-head { display: flex; flex-direction: column; gap: 10px; }
.back { align-self: flex-start; display: inline-flex; align-items: center; gap: 2px; margin-left: -4px; padding: 4px 6px 4px 0; border: 0; background: none; color: var(--muted); font-size: 14px; font-weight: 500; }
.back .i { width: 18px; height: 18px; }
.focus-title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.focus-title-row > .grow { min-width: min(100%, 300px); }
.focus-title { font-size: 28px; letter-spacing: -.03em; line-height: 1.15; }
.link { display: inline-flex; align-items: center; gap: 2px; }
.link-icon { width: 15px; height: 15px; }
.row-btn .chev-right { width: 16px; height: 16px; color: var(--muted); }

.stepper { display: flex; align-items: center; gap: 6px; }
.stepper .input.stepper-input { width: 64px; min-height: 38px; padding: 6px; text-align: center; font-weight: 600; -moz-appearance: textfield; }
.stepper-input::-webkit-inner-spin-button, .stepper-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-unit { min-width: 52px; color: var(--muted); }
.icon-btn.ghostly { width: 38px; height: 38px; border: 1px solid var(--line); background: var(--surface); }
.icon-btn.ghostly .i { width: 16px; height: 16px; }

table.compare { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.compare caption { text-align: left; padding: 4px 0 6px; }
table.compare th { padding: 6px 8px; font-size: 12.5px; font-weight: 500; color: var(--muted); text-align: right; border-bottom: 1px solid var(--line); }
table.compare td { padding: 4px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.compare th:first-child, table.compare td:first-child { text-align: left; padding-left: 0; }
table.compare tr:last-child td { border-bottom: 0; }
table.compare .col-pick { min-width: 44px; min-height: 32px; border: 1px solid var(--line); background: var(--surface); padding: 0 10px; border-radius: 8px; font: 600 14px var(--body); color: var(--ink); }
table.compare tr.on td { color: var(--accent-ink); font-weight: 600; }
table.compare tr.on .col-pick { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.film-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.film-dot { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.film-dot .i { width: 16px; height: 16px; }
.film-dot.due { background: var(--accent-soft); color: var(--accent-ink); }
.film-dot.done { background: var(--good-soft); color: var(--good); }

/* ---------- two panes (Kitchen, Hand out, Story cards) ---------- */
.split { display: flex; flex-direction: column; gap: 16px; }

/* ---------- hover (mouse and trackpad only) ---------- */
@media (hover: hover) {
  .btn:hover:not(:disabled) { filter: brightness(.96); }
  .btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
  .row-btn:hover .row-title { color: var(--accent-ink); }
  section.card[role=link]:hover, button.card:hover { border-color: color-mix(in srgb, var(--muted) 45%, var(--line)); }
  .tabbar a:hover { color: var(--ink); }
  .chip:hover:not(:disabled) { filter: brightness(.95); }
}

/* ---------- tablet: wider page, two-column boards, side-by-side panes ---------- */
@media (min-width: 768px) {
  :root { --maxw: 980px; }
  .view { padding-top: 20px; }
  .board { display: block; columns: 2; column-gap: 16px; }
  .board > * { break-inside: avoid; margin-bottom: 16px; }
  .board > .full { column-span: all; }
  .split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 20px; align-items: start; }
  .quick .btn.big { min-height: 88px; font-size: 26px; }
  .counter-num { font-size: 96px; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .sheet { max-width: 640px; padding-left: 24px; padding-right: 24px; }
}

/* ---------- desktop and iPad landscape: sidebar instead of bottom tabs ---------- */
@media (min-width: 1024px) {
  :root { --rail: 220px; --maxw: 1120px; }
  #app:has(> .tabbar) { padding-left: var(--rail); }
  .tabbar {
    top: 0; right: auto; width: var(--rail); height: auto;
    display: flex; flex-direction: column; gap: 2px;
    padding: 16px 12px; border-top: 0; border-right: 1px solid var(--line);
  }
  .tabbar::before { content: "Dezzert"; padding: 8px 12px 20px; font: 600 20px var(--body); letter-spacing: -.03em; color: var(--accent); }
  .tab-group { display: flex; flex-direction: column; gap: 2px; border: 0; }
  .tab-group-label { position: static; padding: 20px 12px 6px; text-align: left; font-size: 12.5px; }
  .tabbar a { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; height: 42px; padding: 0 12px; border-radius: var(--radius-sm); font-size: 14.5px; }
  .tabbar a.on { background: var(--surface-2); }
  .tabbar .dot { position: static; margin-left: auto; }
  .view { padding-bottom: 48px; }
  #toast { bottom: 24px; left: calc(50% + var(--rail) / 2); }
  /* Fixed elements size against the viewport, so the rail comes off the width here. */
  .bulk-bar { bottom: 24px; left: var(--rail); width: min(calc(100% - var(--rail) - 24px), calc(var(--maxw) - 24px)); }
  #app:has(.bulk-bar) .view { padding-bottom: 168px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
