/* PureBite. See DESIGN.md: Uno reads the label for you. White paper, black ink, one typeface,
   thin rules, and one loud thing per screen: the shelf label with the answer. */

@font-face {
  font-family: 'Overpass';
  src: url('../fonts/overpass.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #FFFFFF;
  --ink: #000000;
  --quiet: #5B6168;
  --rail: #EEF0F2;
  --rule: #000000;
  --rule-soft: #D5D9DD;
  --overlay: rgba(0, 0, 0, 0.45);
  /* Uno's colour (app.js sets these from it; black Uno by default) */
  --brand-l: #000000; --on-brand-l: #FFFFFF; --brand-d: #FFFFFF; --on-brand-d: #000000;
  --ink-l: #000000; --ink-d: #FFFFFF; --uno: #000000;
  --brand: var(--brand-l); --on-brand: var(--on-brand-l); --accent: var(--ink-l);
  /* Labels: the colours of real shelf tags; they stay the same in dark mode */
  --yes: #00A651; --on-yes: #000000;
  --max: #FFD60A; --on-max: #000000;
  --no: #E3000F; --on-no: #FFFFFF;
  /* the same verdicts as text on paper */
  --yes-ink: #007A3C; --max-ink: #000000; --no-ink: #C4000D;

  --font: 'Overpass', 'Helvetica Neue', Arial, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #000000; --ink: #FFFFFF; --quiet: #A3A9B0; --rail: #1A1B1D; --rule: #FFFFFF; --rule-soft: #34373B;
    --overlay: rgba(0, 0, 0, 0.7);
    --brand: var(--brand-d); --on-brand: var(--on-brand-d); --accent: var(--ink-d);
    --yes-ink: #3DDC84; --max-ink: #FFD60A; --no-ink: #FF6B6B;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #000000; --ink: #FFFFFF; --quiet: #A3A9B0; --rail: #1A1B1D; --rule: #FFFFFF; --rule-soft: #34373B;
  --overlay: rgba(0, 0, 0, 0.7);
  --brand: var(--brand-d); --on-brand: var(--on-brand-d); --accent: var(--ink-d);
  --yes-ink: #3DDC84; --max-ink: #FFD60A; --no-ink: #FF6B6B;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { background: var(--paper); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.locked { overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select { font: inherit; color: var(--ink); }
a { color: var(--ink); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 34px; line-height: 1.05; font-weight: 800; letter-spacing: -0.015em; text-wrap: balance; }
h2 { font-size: 22px; line-height: 1.15; font-weight: 800; letter-spacing: -0.01em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.noscript { padding: 24px; }
.quiet { color: var(--quiet); }
.fine { font-size: 14px; color: var(--quiet); line-height: 1.5; }
.hint { margin-top: 10px; font-size: 15px; color: var(--quiet); }
.small-head { font-size: 17px; font-weight: 800; margin: 26px 0 10px; }

/* ---------------- actions: capsules, like Uno's eyes ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 54px; padding: 12px 26px;
  border-radius: 999px;
  font-weight: 800; font-size: 18px; letter-spacing: -0.005em;
  text-decoration: none;
  transition: transform 0.1s ease, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn-main { width: 100%; background: var(--brand); color: var(--on-brand); }
.btn-line { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.btn-small { min-height: 42px; padding: 8px 18px; font-size: 16px; }
.btn-apple { background: #000; color: #fff; }
:root[data-theme="dark"] .btn-apple { background: #fff; color: #000; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-apple { background: #fff; color: #000; } }
.btn-light { background: #fff; color: #000; }
.btn.danger { background: var(--no); color: var(--on-no); }
.link { color: var(--ink); font-weight: 700; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.link.light { color: #fff; }
.link.danger { color: var(--no-ink); }
.icon-btn {
  width: 44px; height: 44px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--rail); color: var(--ink);
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn.dark { background: rgba(0, 0, 0, 0.5); color: #fff; }
.icon-btn.dark[aria-pressed="true"] { background: var(--max); color: #000; }

/* ---------------- fields ---------------- */
.field { display: grid; gap: 6px; }
.field > span:first-child { font-size: 15px; font-weight: 700; }
.input {
  width: 100%; min-height: 52px; padding: 12px 14px;
  border: 0; border-radius: 10px;
  background: var(--rail);
  font-size: 18px;
}
.input:focus { outline: 3px solid var(--accent); outline-offset: 0; }
.input.invalid, .field.invalid .input { outline: 3px solid var(--no); animation: nudge 0.3s; }
@keyframes nudge { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.input-big { font-size: 24px; font-weight: 700; min-height: 60px; }
.unit-input { position: relative; display: block; }
.unit-input em { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 15px; color: var(--quiet); pointer-events: none; }
.unit-input .input { padding-right: 38px; }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%); background-position: calc(100% - 22px) 52%, calc(100% - 16px) 52%; background-size: 6px 6px; background-repeat: no-repeat; }
.form-error { color: var(--no-ink); font-size: 15px; font-weight: 700; }
.pw { position: relative; display: block; }
.pw .input { padding-right: 76px; }
.pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); padding: 8px 10px; font-size: 15px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.add-row { display: flex; gap: 8px; align-items: center; }
.add-row .input { flex: 1; min-width: 0; min-height: 48px; font-size: 17px; }

/* ---------------- tags: the things you pick, printed like small labels ---------------- */
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-btn {
  min-height: 44px; padding: 9px 14px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 2px var(--rule-soft);
  font-weight: 700; font-size: 16px;
  transition: background 0.12s, box-shadow 0.12s, color 0.12s;
}
.tag-btn.on, .tag-btn[aria-checked="true"], .tag-btn[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); box-shadow: inset 0 0 0 2px var(--brand); }
.tag-btn.x::after { content: "\00d7"; margin-left: 8px; font-size: 18px; line-height: 1; }

.switch-row { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 60px; padding: 10px 0; text-align: left; font-weight: 700; border-bottom: 1px solid var(--rule-soft); }
.switch-row small { display: block; font-size: 14px; font-weight: 500; color: var(--quiet); }
.switch { position: relative; flex-shrink: 0; width: 52px; height: 32px; border-radius: 999px; background: var(--rail); box-shadow: inset 0 0 0 2px var(--rule-soft); transition: background 0.15s; }
.switch::after { content: ""; position: absolute; top: 5px; left: 5px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); transition: transform 0.15s; }
.switch.on { background: var(--brand); box-shadow: none; }
.switch.on::after { transform: translateX(20px); background: var(--on-brand); }

.choice-list { display: grid; }
.choice-list button { display: grid; gap: 1px; padding: 12px 0 12px 34px; text-align: left; position: relative; border-bottom: 1px solid var(--rule-soft); }
.choice-list button::before { content: ""; position: absolute; left: 2px; top: 15px; width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--ink); }
.choice-list button.on::before { box-shadow: inset 0 0 0 6px var(--brand); }
.choice-list b { font-weight: 700; }
.choice-list span { font-size: 15px; color: var(--quiet); }

/* ---------------- Uno talking: plain words next to him, no bubble ---------------- */
.uno-line { font-size: 21px; line-height: 1.3; font-weight: 600; letter-spacing: -0.005em; }
.uno-line.small { font-size: 17px; }
.talk { flex: 1; min-width: 0; display: grid; gap: 8px; justify-items: start; }
.say-chips { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.say-chip { min-height: 40px; padding: 6px 0; font-weight: 800; font-size: 17px; color: var(--ink); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 5px; }
.say-chip.main { text-decoration-color: var(--uno); }

.offline-banner { position: sticky; top: 0; z-index: 60; padding: calc(6px + var(--safe-t)) 16px 6px; background: var(--max); color: var(--on-max); font-weight: 700; font-size: 15px; }

/* ---------------- first start ---------------- */
.setup { min-height: 100vh; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; padding: calc(10px + var(--safe-t)) 20px 0; }
.setup-top { display: flex; align-items: center; justify-content: space-between; min-height: 48px; }
.setup-count { font-weight: 700; color: var(--quiet); font-size: 15px; }
.setup-hero { display: flex; align-items: center; gap: 14px; margin: 18px 0 26px; min-height: 92px; }
.setup-uno { width: 88px; height: 88px; flex-shrink: 0; }
.setup-steps { flex: 1; }
.setup-step { display: none; }
.setup-step.active { display: grid; gap: 14px; align-content: start; }
.setup-step h1 { margin-bottom: -4px; }
.num-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.setup-foot { position: sticky; bottom: 0; padding: 16px 0 calc(16px + var(--safe-b)); background: var(--paper); }

/* ---------------- the app ---------------- */
.app { max-width: 520px; margin: 0 auto; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; padding: calc(8px + var(--safe-t)) 20px 8px; background: var(--paper); }
.wordmark { font-weight: 900; font-size: 25px; letter-spacing: -0.03em; min-height: 44px; }
.topbar-link { position: relative; min-height: 44px; padding: 0 2px; font-weight: 700; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.sync-dot { position: absolute; right: -10px; top: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--yes); }
.sync-dot.syncing { background: var(--max); }
.sync-dot.offline, .sync-dot.error { background: var(--quiet); }
.screen { display: none; padding: 6px 20px calc(36px + var(--safe-b)); }
.screen.active { display: block; }

/* home */
.hero { display: flex; align-items: center; gap: 16px; margin: 10px 0 30px; min-height: 140px; }
.hello-uno { width: 128px; height: 128px; flex-shrink: 0; }
.btn-scan { min-height: 66px; font-size: 20px; }
.search-bar { width: 100%; margin-top: 10px; display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 0 18px; border-radius: 10px; background: var(--rail); color: var(--quiet); font-size: 17px; text-align: left; }
.recent { margin-top: 44px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.section-head .link { padding: 8px 0; font-size: 15px; }

/* receipts: name, dotted leader, the answer */
.receipt { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--rule); }
.receipt .day { padding: 14px 0 4px; font-size: 14px; font-weight: 800; color: var(--quiet); }
.row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 0; min-height: 62px; text-align: left; border-bottom: 1px solid var(--rule-soft); }
.row:active { background: var(--rail); }
.row-name { min-width: 0; flex: 0 1 auto; }
.row-name b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-name small { display: block; color: var(--quiet); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leader { flex: 1 1 24px; min-width: 24px; align-self: center; border-bottom: 2px dotted var(--rule-soft); transform: translateY(4px); }
.row.fresh { animation: fresh 1.2s ease; }
@keyframes fresh { from { background: var(--rail); } to { background: transparent; } }
.empty { padding: 22px 0; color: var(--quiet); }
.thumb { width: 44px; height: 44px; flex-shrink: 0; border-radius: 8px; overflow: hidden; background: var(--rail); display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.thumb-letter { display: grid; place-items: center; width: 100%; height: 100%; color: var(--quiet); font-weight: 900; font-size: 19px; }
.thumb-letter.big { font-size: 44px; }

/* small labels with the answer (in lists) */
.mini { flex-shrink: 0; padding: 3px 8px 2px; border-radius: 3px; font-size: 14px; font-weight: 800; white-space: nowrap; }
.mini.good { background: var(--yes); color: var(--on-yes); }
.mini.okay { background: var(--max); color: var(--on-max); }
.mini.skip { background: var(--no); color: var(--on-no); }
.mini.wait { background: var(--rail); color: var(--quiet); }

/* ---------------- settings ---------------- */
.page-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 18px; }
.uno-card { display: flex; align-items: center; gap: 14px; margin-bottom: 34px; }
.profile-uno { width: 76px; height: 76px; flex-shrink: 0; }
.group { margin-bottom: 40px; }
.group > h2 { margin-bottom: 12px; }
.group > .quiet { margin-bottom: 14px; }
.auth-buttons { display: grid; gap: 10px; }
.auth-buttons .btn { width: 100%; }
.google-slot { display: flex; justify-content: center; min-height: 44px; }
#signed-out .fine { margin-top: 12px; }
.account { display: grid; gap: 12px; }
.account-sync { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--quiet); }
.account-sync i { width: 9px; height: 9px; border-radius: 50%; background: var(--yes); }
.account-sync.syncing i { background: var(--max); }
.account-sync.offline i, .account-sync.error i { background: var(--quiet); }
.account-sync .link { margin-left: auto; padding: 8px 0; }
.account-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.me { display: flex; align-items: center; gap: 14px; }
.me-text { flex: 1; min-width: 0; display: grid; }
.me-text b { font-size: 21px; font-weight: 800; }
.me-text span { color: var(--quiet); font-size: 15px; }
.setting-row { width: 100%; display: flex; align-items: center; gap: 14px; min-height: 68px; padding: 8px 0; text-align: left; border-bottom: 1px solid var(--rule-soft); border-top: 2px solid var(--rule); }
.uno-thumb { width: 48px; height: 48px; flex-shrink: 0; }
.uno-thumb svg { display: block; width: 100%; height: 100%; }
.setting-text { flex: 1; display: grid; }
.setting-text small { color: var(--quiet); font-size: 15px; }
.setting-go { font-weight: 700; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
#appearance-seg { margin-bottom: 8px; }
.country { margin-top: 18px; }
.strict-list { display: grid; border-top: 2px solid var(--rule); }
.strict-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--rule-soft); }
.strict-row b { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strict-row .tags { flex-shrink: 0; gap: 6px; }
.strict-row .tag-btn { min-height: 36px; padding: 6px 9px; font-size: 14px; }
.strict-row .icon-btn { width: 36px; height: 36px; font-size: 20px; }
.fine-links { display: flex; flex-wrap: wrap; gap: 0 20px; margin: 10px 0 8px; font-size: 15px; }
.fine-links > * { padding-block: 10px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.fine-links a { color: var(--ink); }

/* ---------------- the result: the shelf, the label, then the details ---------------- */
.result { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; background: var(--paper); }
.result-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.shelf { background: var(--rail); padding: calc(8px + var(--safe-t)) 20px 26px; }
.shelf > *, .r-body { max-width: 520px; margin-left: auto; margin-right: auto; }
.result-top { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.result-top .icon-btn { background: var(--paper); }
.r-code { font-size: 14px; color: var(--quiet); letter-spacing: 0.04em; }
.r-product { display: flex; align-items: center; gap: 16px; margin: 14px 0 22px; }
.r-img-wrap { perspective: 700px; flex-shrink: 0; }
.r-img { width: 104px; height: 104px; border-radius: 8px; overflow: hidden; background: #fff; display: grid; place-items: center; transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform 0.1s linear; }
.r-img img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.r-about { min-width: 0; }
.r-kind { font-weight: 800; }
.r-what { font-size: 15px; color: var(--quiet); line-height: 1.4; }

.label {
  position: relative;
  padding: 18px 20px 20px;
  border-radius: 4px;
  background: var(--max); color: var(--on-max);
}
.label.good { background: var(--yes); color: var(--on-yes); }
.label.skip { background: var(--no); color: var(--on-no); }
.label-uno { position: absolute; top: -30px; right: 16px; width: 80px; height: 80px; }
.label-name { font-size: 21px; line-height: 1.15; font-weight: 800; letter-spacing: -0.01em; padding-right: 92px; overflow-wrap: anywhere; }
.label-brand { font-size: 15px; font-weight: 500; margin-top: 2px; padding-right: 92px; }
.label-fig { display: flex; align-items: flex-end; flex-wrap: wrap; column-gap: 12px; margin-top: 18px; }
.fig-pre { width: 100%; font-size: 21px; font-weight: 800; line-height: 1; margin-bottom: 2px; }
.fig-num { font-size: 116px; line-height: 0.78; font-weight: 900; letter-spacing: -0.04em; }
.fig-unit { font-size: 23px; line-height: 1.05; font-weight: 800; max-width: 8em; padding-bottom: 4px; }
.fig-word { font-size: 92px; line-height: 0.8; font-weight: 900; letter-spacing: -0.035em; }
.label-why { margin-top: 16px; padding-top: 12px; border-top: 2px solid currentColor; font-size: 17px; line-height: 1.4; font-weight: 600; min-height: 2.6em; }
.result.reveal .label { animation: labelIn 0.42s cubic-bezier(0.2, 0.9, 0.3, 1) 0.05s backwards; }
.result.reveal .label-uno { animation: stickOn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1) 0.3s backwards; }
@keyframes labelIn { from { transform: translateY(16px) rotate(-1.2deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes stickOn { from { transform: scale(1.35) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }

.r-body { padding: 20px 20px 28px; }
.r-flags { font-size: 17px; font-weight: 600; }
.r-body .say-chips { margin-top: 6px; }
.block { margin-top: 34px; }
.block h2 { margin-bottom: 12px; }
.bars { display: grid; border-top: 2px solid var(--rule); }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 0 12px; border-bottom: 1px solid var(--rule-soft); }
.bar-row b { font-weight: 700; }
.bar-row small { color: var(--quiet); font-size: 14px; font-weight: 600; }
.bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--rail); overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--ink); width: 0; transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.bar i.mid { background: var(--max); }
.bar i.high { background: var(--no); }
.bar i.plus { background: var(--yes); }
.allergen-line { margin-bottom: 6px; }
.allergen-line > span:first-child { font-weight: 800; }
.you { color: var(--no-ink); font-weight: 800; }
.additive-list { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--rule); }
.additive { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; gap: 0 10px; padding: 10px 0; border-bottom: 1px solid var(--rule-soft); }
.additive .code { grid-row: span 2; font-weight: 900; }
.additive b { font-weight: 700; }
.additive p { grid-column: 2 / -1; font-size: 15px; color: var(--quiet); }
.risk { font-size: 14px; font-weight: 800; white-space: nowrap; }
.risk.none { color: var(--yes-ink); }
.risk.low { color: var(--quiet); }
.risk.moderate { color: var(--ink); }
.risk.high { color: var(--no-ink); }
.swap { width: 100%; margin-top: 34px; display: flex; align-items: center; gap: 12px; padding: 14px 0; text-align: left; border-top: 2px solid var(--rule); border-bottom: 1px solid var(--rule-soft); }
.swap-text { min-width: 0; flex: 1; display: grid; }
.swap-text small { font-size: 14px; font-weight: 800; }
.swap-text b { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swap.flash { animation: fresh 1.4s ease; }
.details { margin-top: 26px; border-top: 2px solid var(--rule); }
.details summary { list-style: none; display: flex; align-items: center; justify-content: space-between; min-height: 56px; font-weight: 800; cursor: pointer; }
.details summary::-webkit-details-marker { display: none; }
.details summary::after { content: "+"; font-size: 26px; font-weight: 500; }
.details[open] summary::after { content: "\2212"; }
.details-body { display: grid; gap: 14px; padding-bottom: 12px; font-size: 16px; }
.details-body h4 { margin: 0 0 4px; font-size: 15px; }
.nutri { width: 100%; border-collapse: collapse; }
.nutri td, .nutri th { padding: 7px 0; border-bottom: 1px solid var(--rule-soft); text-align: left; font-weight: 400; }
.nutri th { font-size: 14px; font-weight: 800; }
.nutri td:last-child, .nutri th:last-child { text-align: right; }
.ingredients { color: var(--quiet); line-height: 1.55; }
.hl { color: var(--no-ink); font-weight: 800; }
.result-foot { padding: 12px 20px calc(14px + var(--safe-b)); max-width: 560px; width: 100%; margin: 0 auto; background: var(--paper); }

/* ---------------- search ---------------- */
.overlay { position: fixed; inset: 0; z-index: 110; display: flex; flex-direction: column; background: var(--paper); }
.search-head { display: flex; align-items: center; gap: 14px; padding: calc(10px + var(--safe-t)) 20px 10px; max-width: 560px; width: 100%; margin: 0 auto; }
.search-field { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 14px; border-radius: 10px; background: var(--rail); color: var(--quiet); }
.search-field:focus-within { outline: 3px solid var(--accent); }
.search-field input { flex: 1; min-width: 0; border: 0; background: none; font-size: 18px; outline: none; }
.search-head .link { padding: 12px 0; }
.search-body { flex: 1; overflow-y: auto; padding: 6px 20px calc(28px + var(--safe-b)); max-width: 560px; width: 100%; margin: 0 auto; }
.search-uno-row { display: flex; align-items: center; gap: 12px; margin: 6px 0 18px; }
.search-uno { width: 56px; height: 56px; flex-shrink: 0; }
.shelf-words { margin-bottom: 18px; font-size: 17px; line-height: 2; }
.shelf-words b { font-weight: 800; margin-right: 6px; }
.shelf-words button { font-weight: 600; text-decoration: underline; text-decoration-color: var(--rule-soft); text-decoration-thickness: 2px; text-underline-offset: 4px; margin-right: 12px; }
.search-info { margin: 0 0 10px; font-size: 15px; color: var(--quiet); }
.search-info b { color: var(--ink); }
.search-msg { padding: 18px 0; color: var(--quiet); }
.search-msg.err { color: var(--no-ink); }
.row.best .row-name b::after { content: " (my pick)"; color: var(--yes-ink); }
.receipt.only-good li[data-level="skip"] { display: none; }
.skeleton { height: 62px; border-bottom: 1px solid var(--rule-soft); background: linear-gradient(90deg, transparent, var(--rail), transparent); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
#search-more { width: 100%; margin-top: 16px; }

/* ---------------- scanner ---------------- */
.scanner { position: fixed; inset: 0; z-index: 120; background: #000; color: #fff; overflow: hidden; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-top { position: absolute; top: calc(12px + var(--safe-t)); left: 16px; right: 16px; display: flex; justify-content: space-between; z-index: 2; }
.scan-frame { position: absolute; left: 50%; top: 40%; width: min(80vw, 340px); height: min(46vw, 200px); transform: translate(-50%, -50%); border-radius: 10px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.5); outline: 3px solid #fff; }
.scan-frame i { position: absolute; left: 12px; right: 12px; top: 50%; height: 3px; border-radius: 2px; background: var(--scanline, #fff); animation: scanline 2s ease-in-out infinite; }
@keyframes scanline { 0%, 100% { transform: translateY(-64px); } 50% { transform: translateY(64px); } }
.scan-status { position: absolute; left: 0; right: 0; top: calc(40% + min(23vw, 100px) + 20px); text-align: center; font-weight: 700; padding: 0 24px; }
.camera-msg { position: absolute; left: 20px; right: 20px; top: calc(72px + var(--safe-t)); z-index: 2; padding: 14px 16px; border-radius: 4px; background: #fff; color: #000; font-size: 16px; font-weight: 600; }
.scan-uno-row { position: absolute; left: 20px; right: 20px; bottom: calc(126px + var(--safe-b)); z-index: 2; display: flex; align-items: center; gap: 12px; pointer-events: none; }
.scan-uno { width: 64px; height: 64px; flex-shrink: 0; pointer-events: auto; }
.scan-uno-row .uno-line { color: #fff; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8); }
.scan-uno-row .say-chips { pointer-events: auto; }
.scan-uno-row .say-chip { color: #fff; text-decoration-color: #fff; }
.scan-bottom { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: 16px 20px calc(24px + var(--safe-b)); display: grid; gap: 12px; justify-items: center; }
.scan-bottom .link { padding: 12px; }
.manual { width: 100%; max-width: 420px; display: flex; gap: 8px; }
.manual .input { flex: 1; min-width: 0; background: #fff; color: #000; }
.scanner.grow { animation: growIn 0.45s cubic-bezier(0.3, 0.8, 0.3, 1); }
@keyframes growIn { from { clip-path: circle(30px at var(--ox, 50%) var(--oy, 80%)); } to { clip-path: circle(150vmax at var(--ox, 50%) var(--oy, 80%)); } }

/* ---------------- sheets, dialogs, loader, toast ---------------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-end; justify-content: center; background: var(--overlay); }
.sheet { width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; display: grid; gap: 14px; padding: 18px 20px calc(22px + var(--safe-b)); border-radius: 16px 16px 0 0; background: var(--paper); animation: sheetIn 0.28s cubic-bezier(0.2, 0.9, 0.3, 1); }
@keyframes sheetIn { from { transform: translateY(32px); opacity: 0.4; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; }
.sheet-uno { width: 72px; height: 72px; }
#auth-form { display: grid; gap: 12px; }
.dialog-backdrop { align-items: center; padding: 20px; }
.dialog { width: 100%; max-width: 400px; display: grid; gap: 8px; padding: 22px 20px 18px; border-radius: 12px; background: var(--paper); }
.dialog-uno { width: 64px; height: 64px; margin-bottom: 4px; }
.dialog h3 { font-size: 23px; line-height: 1.15; font-weight: 800; text-wrap: balance; }
.dialog p { color: var(--quiet); }
.dialog-fields { display: grid; gap: 10px; margin-top: 4px; }
.dialog-fields .field input { width: 100%; min-height: 50px; padding: 10px 12px; border: 0; border-radius: 10px; background: var(--rail); font-size: 17px; }
.check-row { display: flex; gap: 10px; align-items: center; font-size: 16px; font-weight: 600; color: var(--ink); margin-top: 6px; }
.check-row input { width: 22px; height: 22px; margin: 0; accent-color: var(--brand); }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.dialog-actions:has(#dialog-cancel[hidden]) { grid-template-columns: 1fr; }
.dialog-actions .btn { padding: 10px; white-space: nowrap; width: 100%; }
#dialog-extra { justify-self: start; margin-top: 8px; padding: 8px 0; }
.loader { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; background: var(--overlay); }
.loader-card { display: grid; justify-items: center; gap: 10px; padding: 22px 28px; border-radius: 12px; background: var(--paper); font-weight: 700; }
.loader-uno { width: 72px; height: 72px; }
.toast { position: fixed; left: 50%; bottom: calc(22px + var(--safe-b)); z-index: 300; display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px); padding: 12px 16px; border-radius: 4px; background: var(--ink); color: var(--paper); font-weight: 700; font-size: 16px; transform: translateX(-50%); }
.toast.show { animation: toastIn 0.2s ease; }
.result:not([hidden]) ~ .toast { bottom: calc(96px + var(--safe-b)); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast-action { font-weight: 800; text-decoration: underline; text-underline-offset: 3px; color: var(--paper); }

/* ---------------- Uno in the corner ---------------- */
.dock { position: fixed; z-index: 105; right: max(14px, calc(50vw - 260px + 14px)); bottom: calc(14px + var(--safe-b)); display: flex; align-items: flex-end; gap: 8px; pointer-events: none; opacity: 0; transform: translateY(20px); transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.2s; }
.dock.on { opacity: 1; transform: none; }
.dock[data-where="result"] { bottom: calc(92px + var(--safe-b)); }
.dock-uno { width: 62px; height: 62px; flex-shrink: 0; pointer-events: auto; }
.dock-bubble { position: relative; margin-bottom: 30px; max-width: min(260px, calc(100vw - 110px)); display: grid; gap: 4px; padding: 10px 12px; border-radius: 4px; background: var(--paper); box-shadow: inset 0 0 0 2px var(--ink); font-size: 15px; line-height: 1.35; font-weight: 600; pointer-events: none; opacity: 0; transition: opacity 0.2s; }
.dock-bubble.on { opacity: 1; }
.dock-bubble .say-chips, .dock-close { pointer-events: auto; }
.dock-bubble .say-chip { min-height: 32px; font-size: 15px; }
.dock-close { position: absolute; top: -14px; left: -14px; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: var(--paper); font-size: 18px; line-height: 1; }
body.has-dock .toast { bottom: calc(100px + var(--safe-b)); }
body.has-dock .screen { padding-bottom: calc(110px + var(--safe-b)); }
body.has-dock .r-body { padding-bottom: 110px; }

/* ---------------- Uno's colour ---------------- */
.customize { z-index: 115; }
.cz-head { display: flex; align-items: center; gap: 14px; padding: calc(10px + var(--safe-t)) 20px 6px; max-width: 560px; width: 100%; margin: 0 auto; }
.cz-head h1 { flex: 1; font-size: 26px; }
.cz-body { flex: 1; overflow-y: auto; max-width: 560px; width: 100%; margin: 0 auto; padding: 8px 20px calc(28px + var(--safe-b)); }
.cz-stage { display: grid; place-items: center; aspect-ratio: 4 / 3; max-height: 320px; width: 100%; border-radius: 8px; background: var(--rail); }
.cz-uno { width: min(52%, 220px); aspect-ratio: 1; }
.cz-say { margin: 14px 0 0; min-height: 1.4em; }
.pick-colors { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 26px; }
.pick-color { position: relative; aspect-ratio: 1; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1.5px var(--rule-soft); }
.pick-color.on { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5.5px var(--ink); }
.pick-color.on::after { content: ""; position: absolute; left: 50%; top: 50%; width: 22%; height: 40%; border-radius: 99px; background: var(--check, #fff); transform: translate(-50%, -50%) rotate(12deg); }
#cz-export { width: 100%; }
.setup .pick-colors { margin-top: 4px; }

@media (max-width: 360px) {
  .hello-uno { width: 96px; height: 96px; }
  .fig-num { font-size: 96px; }
  .fig-word { font-size: 76px; }
  .label-uno { width: 68px; height: 68px; }
  .num-row { grid-template-columns: 1fr 1fr; }
}

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

/* ---------------- simple pages: privacy, terms, 404 ---------------- */
.doc { max-width: 640px; margin: 0 auto; padding: calc(22px + var(--safe-t)) 20px 64px; }
.doc-back { display: inline-block; margin-bottom: 16px; padding: 10px 0; font-weight: 700; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.doc-card { border-top: 2px solid var(--rule); padding-top: 18px; }
.doc-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.doc-uno { width: 72px; height: 72px; flex-shrink: 0; }
.doc h1 { font-size: 34px; }
.doc h2 { font-size: 20px; margin: 24px 0 6px; }
.doc p, .doc li { color: var(--quiet); font-size: 16px; line-height: 1.55; margin: 0 0 8px; }
.doc ul { padding-left: 20px; margin: 0 0 10px; }
.doc strong { color: var(--ink); }
.doc-404 { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.doc-404 .doc-card { max-width: 400px; width: 100%; display: grid; gap: 10px; justify-items: start; border-top: 0; }
.doc-404 .doc-uno { width: 120px; height: 120px; }
