/* Scan — Apple's shape (large cards on grey, a floating tab bar), myjp cloud's sky blue. Light is the base; dark
 * is a token swap. The base is Meals' (~/claude/mealapp/web/styles.css) with News' stage height (IOS.md §25):
 * the document never scrolls; #app is a screen tall; the screens scroll inside #page; the tab bar (.foot), the
 * sheet and the camera are its SIBLINGS, absolute in the stage. Nothing is position: fixed. §24: no
 * backdrop-filter, no transitions on the shell.
 */
:root {
  --bg:      #f2f2f7;
  --panel:   #ffffff;
  --panel-2: #f6f6f9;
  --line:    rgba(60, 60, 67, .16);
  --ink:     #000000;
  --ink-2:   #3c3c43;
  --dim:     #8a8a8e;
  --pill:    #e5e5ea;
  --accent:  #168aad;
  --on-accent: #ffffff;
  --bad:     #e5322b;
  --good:    #1f9d55;
  --gold:    #e0a100;
  --shadow:  0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.06);
  --r-card: 18px; --r-mid: 12px;
  --font: -apple-system, BlinkMacSystemFont, system-ui, "SF Pro Text", "Helvetica Neue", sans-serif;
  --font-num: ui-rounded, -apple-system, "SF Pro Rounded", system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --sb: 0px;
  --foot-h: 0px; --kb: 0px;
  --side: 16px;
  --col: 720px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --panel: #1c1c1e; --panel-2: #2c2c2e; --line: rgba(84, 84, 88, .48);
    --ink: #ffffff; --ink-2: #d7d7db; --dim: #98989f; --pill: #2c2c2e;
    --accent: #4cc3e6; --on-accent: #00222e; --bad: #ff453a; --good: #30d158; --gold: #ffd60a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
/* IOS.md §27: touch-action is not inherited, and the stage's scroller stops html's from reaching
   anything inside it — so on every element: pan and pinch, never a double-tap zoom */
*, *::before, *::after { touch-action: manipulation; }
[hidden] { display: none !important; }
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; overflow: hidden; overscroll-behavior: none; }
html, body { background: var(--bg); color: var(--ink); margin: 0; }
body { position: relative; height: 100vh; height: 100dvh; overflow: hidden;
       font: 15px/1.4 var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
@media (display-mode: standalone) {
  :root { --sb: calc(100lvh - 100dvh); }
  body { height: 100vh; height: 100lvh; height: var(--stage-h, 100lvh); }   /* --stage-h: app.js seat() (News v19) */
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
img { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── the door ─────────────────────────────────────────────────────────── */
.door { position: absolute; inset: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center;
        justify-content: center; text-align: center; padding: calc(var(--sb) + 24px) 28px calc(var(--safe-b) + 24px); }
.doormark { width: 84px; height: 84px; border-radius: 19px; box-shadow: var(--shadow); }
.lockup { margin: 18px 0 26px; font-weight: 800; letter-spacing: -.03em; display: flex; flex-direction: column; align-items: center; line-height: 1; }
.lockup .lm { font-size: 17px; color: var(--dim); font-weight: 700; letter-spacing: -.01em; }
.lockup .lc { color: var(--accent); }
.lockup .ls { font-size: 44px; }
.note { color: var(--dim); max-width: 340px; font-size: 14px; margin: 16px auto 0; }

/* ── the stage ────────────────────────────────────────────────────────── */
#app { position: absolute; inset: 0; }
#page { position: absolute; inset: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
        display: flex; flex-direction: column; }
#page.locked { overflow: hidden; }
.top { position: sticky; top: 0; z-index: 20; background: var(--bg);
       padding: calc(var(--safe-t) + var(--sb)) calc(var(--side) + var(--safe-r)) 0 calc(var(--side) + var(--safe-l)); }
.top.scrolled { box-shadow: 0 1px 0 var(--line); }
.bar { max-width: calc(var(--col) - 2 * var(--side)); margin: 0 auto; min-height: 52px; display: flex; align-items: center; gap: 4px; }
.bar h1 { flex: 1; margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.bar.sub h1 { font-size: 17px; font-weight: 650; letter-spacing: -.01em; text-align: center; }
.ibtn { width: 40px; height: 40px; border: 0; border-radius: 20px; background: transparent; color: var(--accent);
        display: inline-flex; align-items: center; justify-content: center; flex: none; padding: 0; }
.ibtn svg { width: 24px; height: 24px; }
.ibtn:active { background: var(--pill); }
.ibtn.spacer { visibility: hidden; }

main { flex: 1 0 auto; width: 100%; max-width: var(--col); margin: 0 auto;
       padding: 4px calc(var(--side) + var(--safe-r)) calc(var(--foot-h) + var(--kb) + 24px) calc(var(--side) + var(--safe-l)); }

/* ── the foot: the tab bar ────────────────────────────────────────────── */
.foot { position: absolute; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; flex-direction: column; align-items: center; gap: 8px;
        pointer-events: none; padding: 8px calc(14px + var(--safe-r)) calc(6px + max(0px, var(--safe-b) - 12px)) calc(14px + var(--safe-l)); }
.foot > * { pointer-events: auto; }
.tabbar { display: flex; width: 100%; max-width: 520px; height: 60px; padding: 4px; border-radius: 999px; background: var(--panel);
          border: 1px solid color-mix(in srgb, var(--ink) 9%, transparent); box-shadow: 0 6px 24px rgba(0,0,0,.14); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 999px;
            color: var(--ink); font-size: 10.5px; font-weight: 600; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.on { color: var(--accent); background: color-mix(in srgb, var(--ink) 7%, transparent); }
.toast { max-width: 100%; padding: 10px 16px; border-radius: 14px; background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 550;
         box-shadow: 0 6px 24px rgba(0,0,0,.2); }
.toast.bad { background: var(--bad); color: #fff; }

/* ── the sheet (absolute in the stage, never fixed) ───────────────────── */
.sheet { position: absolute; inset: 0; z-index: 40; display: flex; flex-direction: column; justify-content: flex-end; }
.scrim { position: absolute; inset: 0; background: rgba(0,0,0,.38); }
.sheetbox { position: relative; background: var(--bg); border-radius: 22px 22px 0 0; max-height: calc(100% - var(--sb) - 30px); overflow-y: auto;
            overscroll-behavior: contain; width: 100%; max-width: 620px; margin: 0 auto;
            padding: 8px calc(var(--side) + var(--safe-r)) calc(var(--safe-b) + var(--kb) + 18px) calc(var(--side) + var(--safe-l)); }
.sheetbox .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--pill); margin: 0 auto 8px; }
.sheetbox h2 { font-size: 20px; margin: 4px 0 6px; letter-spacing: -.02em; }

/* ── buttons ──────────────────────────────────────────────────────────── */
.btn { border: 0; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-weight: 650; padding: 10px 18px; min-height: 44px;
       display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.big { font-size: 17px; padding: 13px 30px; min-width: 220px; }
.btn.wide { width: 100%; }
.btn.quiet { background: var(--pill); color: var(--ink); }
.btn.danger { background: transparent; color: var(--bad); }
.btn:disabled { opacity: .5; }
.btn:active { filter: brightness(.92); }
.btn svg { width: 20px; height: 20px; }
.btnrow { display: flex; gap: 10px; margin: 12px 0; }
.btnrow > .btn { flex: 1; padding-left: 10px; padding-right: 10px; }

/* ── cards, rows ──────────────────────────────────────────────────────── */
.card { background: var(--panel); border-radius: var(--r-card); padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 8px; font-size: 17px; }
h2.sec { font-size: 20px; font-weight: 750; letter-spacing: -.02em; margin: 22px 2px 8px; display: flex; align-items: baseline; gap: 8px; }
h2.sec .act { margin-left: auto; font-size: 15px; font-weight: 600; background: none; border: 0; color: var(--accent); padding: 4px 2px; }
h3.sec { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--dim); margin: 22px 16px 6px; }
.rows { background: var(--panel); border-radius: var(--r-card); overflow: hidden; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 10px 16px; border: 0; background: none; text-align: left;
       color: var(--ink); position: relative; }
.rows > .row + .row::before { content: ''; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--line); }
.rows > a.row:active, .rows > button.row:active { background: var(--panel-2); }
.row-k { flex: 1; min-width: 0; }
.row-k small { display: block; color: var(--dim); font-size: 13px; }
.row-v { color: var(--dim); text-align: right; flex: none; }
.chev { color: var(--dim); font-size: 20px; line-height: 1; }
.row.danger .row-k { color: var(--bad); }
.fineprint { color: var(--dim); font-size: 12px; text-align: center; margin: 18px 0 0; }
.addr { color: var(--dim); font-size: 13px; text-align: center; margin: 20px 0 0; }
.lockrow { font-weight: 800; letter-spacing: -.02em; }
.lockrow .lc { color: var(--accent); }
.err { color: var(--bad); margin: 10px 0 0; font-size: 14px; }
.empty { text-align: center; color: var(--dim); padding: 40px 12px; }
.empty b { display: block; color: var(--ink); font-size: 19px; margin-bottom: 6px; }

/* ── forms ────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.field > label, .lbl { color: var(--dim); font-size: 13px; font-weight: 600; }
select, input[type=text], input[type=number], input[type=search], input[type=datetime-local], textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--r-mid); border: 1px solid var(--line); background: var(--panel-2); font-size: 17px; }
textarea { min-height: 96px; resize: vertical; line-height: 1.35; }
.seg { display: flex; background: var(--pill); border-radius: 10px; padding: 2px; gap: 2px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 8px; padding: 7px 4px; font-weight: 600; font-size: 14px; min-height: 36px; color: var(--ink); }
.seg button.on { background: var(--panel); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper input { text-align: center; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stepper button { flex: none; width: 48px; height: 44px; border-radius: var(--r-mid); border: 0; background: var(--pill); font-size: 22px; font-weight: 700; }
.switchrow { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.switchrow span { flex: 1; font-weight: 600; }
.switch { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 999px; background: var(--pill); position: relative; flex: none; margin: 0; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .2s; }
.switch:checked { background: var(--good); }
.switch:checked::after { transform: translateX(20px); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chips button, .chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 12px; font-size: 14px; color: var(--ink-2); }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--pill); border: 0; font-weight: 600; font-size: 13px; padding: 4px 10px; }
.chip.low { color: var(--bad); }
.search { margin: 4px 0 10px; }
.note.big { font-size: 16px; color: var(--ink-2); margin-bottom: 20px; }
.door .btn.quiet { margin-top: 10px; }

/* ── the tab bar's Scan button ────────────────────────────────────────── */
.tabbar .scanbtn { flex: 1.15; border: 0; margin: 2px 4px; border-radius: 999px; background: var(--accent); color: var(--on-accent);
                   display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 10.5px; font-weight: 700; }
.tabbar .scanbtn svg { width: 24px; height: 24px; }
.tabbar .scanbtn:active { filter: brightness(.92); }

/* ── lists ────────────────────────────────────────────────────────────── */
.thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex: none; background: var(--pill); }
.irow { gap: 12px; }
.irow b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; }
.irow .row-k small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { flex: none; font-size: 12px; font-weight: 750; border-radius: 999px; padding: 3px 8px; }
.badge.ok { color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.badge.look { color: var(--gold); background: color-mix(in srgb, var(--gold) 18%, transparent); }
.badge.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }
.spin { width: 18px; height: 18px; border: 2.5px solid var(--pill); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.keepnote { color: var(--dim); font-size: 13px; margin: 6px 4px 0; }
.daysep { font-size: 15px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; margin: 22px 4px 8px; }
.list > .daysep:first-child { margin-top: 8px; }
/* a batch: one card; a run of scans gets a head (scan-v4) */
.batch { margin: 0 0 10px; }
.bhead { min-height: 64px; }
.bhead b { font-weight: 700; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.25; }
.bhead .chev { transition: none; }
.batch.open .bhead .chev { transform: rotate(90deg); }
.fanbox { position: relative; width: 58px; height: 52px; flex: none; }
.fan { position: absolute; top: 0; width: 40px; height: 52px; border-radius: 7px; object-fit: cover; background: var(--pill);
       border: 1.5px solid var(--panel); box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.fan.f0 { left: 0; z-index: 3; }
.fan.f1 { left: 9px; z-index: 2; transform: rotate(5deg); }
.fan.f2 { left: 18px; z-index: 1; transform: rotate(10deg); }
.batch .irow .thumb { width: 44px; height: 52px; border-radius: 8px; }
/* an item's place in its batch: ‹ Page 3 of 12 › */
.pager { display: flex; align-items: center; gap: 4px; margin: 0 0 10px; padding: 4px; background: var(--panel); border-radius: 999px; box-shadow: var(--shadow); }
.pg { width: 40px; height: 40px; border-radius: 20px; display: inline-flex; align-items: center; justify-content: center; color: var(--accent); flex: none; }
.pg:active { background: var(--pill); }
.pg svg { width: 22px; height: 22px; }
.pg.off { visibility: hidden; }
.pgk { flex: 1; min-width: 0; text-align: center; }
.pgk small { display: block; color: var(--dim); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.how { font-size: 13.5px; margin: 10px 0 4px; color: var(--ink-2); }
.howk { font-weight: 650; color: var(--ink); margin: 0 0 4px; }
.howk small { font-weight: 500; color: var(--dim); }
.how ul { margin: 0; padding-left: 18px; }
.how li { margin: 2px 0; }
.how .warnline { color: var(--gold); }
.newcard { display: flex; align-items: center; gap: 14px; width: 100%; border: 0; text-align: left; background: var(--accent); color: var(--on-accent);
           border-radius: var(--r-card); padding: 16px; margin: 6px 0 12px; font-weight: 650; font-size: 17px; }
.newcard svg { width: 34px; height: 34px; flex: none; }
.newcard small { display: block; font-weight: 500; font-size: 14px; opacity: .88; }

/* ── an item ──────────────────────────────────────────────────────────── */
.hero { display: block; width: 100%; max-height: 62vh; object-fit: contain; border-radius: var(--r-card); margin: 4px 0 10px;
        background: var(--panel); box-shadow: var(--shadow); }
.status { display: flex; align-items: center; gap: 10px; margin: 2px 4px 10px; font-size: 14px; color: var(--ink-2); }
.status b { color: var(--ink); }
.status.ok b { color: var(--good); }
.status.warn b { color: var(--gold); }
.status.bad b { color: var(--bad); }
.ititle { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0 2px; line-height: 1.2; }
.isub { color: var(--dim); font-size: 14px; margin: 0 0 8px; }
.isum { color: var(--ink-2); margin: 0 0 6px; }
.reading { font-size: 15.5px; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; }
/* one paragraph per printed line, tight, its continuation indented: reads as the page did */
.reading p { margin: 0; padding-left: 1em; text-indent: -1em; }
.reading .w.rough { text-decoration: underline dotted color-mix(in srgb, var(--gold) 80%, transparent); text-underline-offset: 3px; }
.reading .w.doubt { text-decoration: underline wavy var(--bad); text-underline-offset: 3px; }
.conf { color: var(--dim); font-size: 13px; margin: 10px 0 0; }
.conf b { color: var(--ink); }
.fields .row-k small { white-space: normal; }
.allergen { display: inline-block; margin: 2px 4px 2px 0; padding: 3px 9px; border-radius: 999px; background: color-mix(in srgb, var(--bad) 13%, transparent); color: var(--bad); font-weight: 650; font-size: 13px; }
textarea.edit { min-height: 260px; font-size: 15px; font-family: var(--font); }
.del { border: 0; background: var(--pill); color: var(--dim); border-radius: 999px; padding: 5px 10px; font-size: 13px; font-weight: 600; flex: none; }
.del.sure { background: var(--bad); color: #fff; }
details.card summary { display: flex; align-items: center; list-style: none; cursor: pointer; font-weight: 600; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary .chev { margin-left: auto; }
dl.kv { margin: 10px 0 0; font-size: 13px; }
dl.kv div { display: flex; gap: 10px; padding: 4px 0; border-top: 1px solid var(--line); }
dl.kv dt { color: var(--dim); width: 110px; flex: none; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.meter { height: 8px; border-radius: 4px; background: var(--pill); overflow: hidden; margin: 8px 0 4px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

/* ── the camera (absolute in the stage, over everything; dark whatever the theme) ── */
.cam { position: absolute; inset: 0; z-index: 60; background: #000; color: #fff; display: flex; flex-direction: column; }
.camview { position: absolute; inset: 0; }
.camview video, .camview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
#camink { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.camtop { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 10px;
          padding: calc(var(--safe-t) + var(--sb) + 8px) calc(14px + var(--safe-r)) 8px calc(14px + var(--safe-l)); }
.camhint { flex: 1; text-align: center; font-weight: 650; font-size: 15px; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
.cambot { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px;
          padding: 14px calc(18px + var(--safe-r)) calc(18px + var(--safe-b)) calc(18px + var(--safe-l)); }
.cbtn { min-width: 44px; height: 44px; border: 0; border-radius: 22px; background: rgba(40,40,44,.72); color: #fff;
        display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; font-weight: 650; font-size: 14px; }
.cbtn svg { width: 22px; height: 22px; }
.cbtn.wide { min-width: 104px; }
.cbtn[aria-pressed="true"] { background: #fff; color: #000; }
.shutter { width: 78px; height: 78px; border-radius: 50%; border: 4px solid #fff; background: transparent; padding: 5px; flex: none; }
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; }
.shutter:active span { transform: scale(.92); }
.review, .adjust { position: absolute; inset: 0; background: #000; display: flex; flex-direction: column;
                   padding: calc(var(--safe-t) + var(--sb) + 12px) calc(14px + var(--safe-r)) calc(16px + var(--safe-b)) calc(14px + var(--safe-l)); }
.reviewimg { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.reviewimg img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; background: #fff; }
.reviewnote { text-align: center; color: #c7c7cc; font-size: 14px; margin: 12px 8px; min-height: 1.4em; }
.reviewbtns { display: flex; gap: 10px; }
.reviewbtns .btn { flex: 1; }
.review .btn.quiet, .adjust .btn.quiet { background: #2c2c2e; color: #fff; }
.adjview { flex: 1; min-height: 0; position: relative; touch-action: none; margin-bottom: 14px; }
#adjcanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.bymeaning { white-space: normal !important; display: -webkit-box !important; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ── the viewer (absolute in the stage, over everything; it owns every gesture inside it) ── */
.viewer { position: absolute; inset: 0; z-index: 70; background: #000; display: flex; align-items: center; justify-content: center;
          overflow: hidden; touch-action: none; }
.viewer * { touch-action: none; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: 50% 50%; will-change: transform; user-select: none; -webkit-user-drag: none; background: #fff; }
#viewerClose { position: absolute; top: calc(var(--safe-t) + var(--sb) + 10px); right: calc(14px + var(--safe-r)); z-index: 2; }
.zoomable { cursor: zoom-in; }
.reviewimg img { cursor: zoom-in; }
