/* VietCal prototype — one signal colour (tappables only), neutral everything else,
   type scale skips the middle: one huge number per screen, the rest small. */
:root {
  --bg: #f5f2ec; --card: #ffffff; --ink: #191613; --muted: #6e675f; --line: #e3ddd3; --ghost: rgba(25,22,19,.055);
  --sig: #c43a1d; --sig-ink: #ffffff; --sig-soft: rgba(196,58,29,.10);
  --ok: #2f6b4f; --warn: #8a5a12;
  --r: 18px; --shadow: 0 10px 30px rgba(25,22,19,.10), 0 2px 6px rgba(25,22,19,.06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #11100f; --card: #1c1a18; --ink: #f2ede6; --muted: #a39b91; --line: #2d2a27; --ghost: rgba(242,237,230,.05);
  --sig: #ff6b4a; --sig-ink: #1a0a05; --sig-soft: rgba(255,107,74,.14);
  --ok: #7fc4a0; --warn: #e2b062;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }
.small { font-size: 13px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- app shell ---------- */
#app { max-width: 480px; margin: 0 auto; min-height: 100%; position: relative; overflow-x: clip; padding-bottom: calc(110px + var(--safe-b)); }
.screen { position: relative; padding: 18px 18px 0; isolation: isolate; overflow-x: clip; }
/* plane 1: oversized background type */
.bgword {
  position: absolute; z-index: -1; left: -8px; top: 34px; pointer-events: none; user-select: none;
  font-size: 128px; line-height: .86; font-weight: 900; letter-spacing: -.05em; color: var(--ghost);
  white-space: nowrap; text-transform: uppercase;
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -.01em; }
.brand img { width: 28px; height: 28px; border-radius: 8px; }
.daynav { display: flex; align-items: center; gap: 4px; }
.iconbtn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  display: grid; place-items: center; color: var(--sig);
}
.iconbtn:disabled { color: var(--line); cursor: default; }
.iconbtn svg { width: 20px; height: 20px; }
.daylabel { font-weight: 700; min-width: 92px; text-align: center; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }

/* ---------- hero number (the one huge element) ---------- */
.hero { padding: 42px 0 8px; }
.hero .label { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.hero .big { font-size: 104px; line-height: .9; font-weight: 900; letter-spacing: -.055em; margin: 6px 0 4px; }
.hero .big.over { color: var(--warn); }
.hero .sub { font-size: 13px; color: var(--muted); }
.meter { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; margin: 18px 0 6px; }
.meter > i { display: block; height: 100%; width: 0; background: var(--ink); border-radius: inherit; transition: width .45s cubic-bezier(.2,.8,.2,1); }
.meter.over > i { background: var(--warn); }
.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.macro { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.macro b { display: block; font-size: 15px; }
.macro span { font-size: 12px; color: var(--muted); }
.macro .bar { height: 4px; background: var(--line); border-radius: 9px; margin-top: 8px; overflow: hidden; }
.macro .bar i { display: block; height: 100%; background: var(--muted); width: 0; transition: width .45s; }

/* ---------- log list ---------- */
.sectionhead { display: flex; justify-content: space-between; align-items: baseline; margin: 28px 0 10px; }
.sectionhead h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; margin: 0; color: var(--muted); }
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 12px 12px 14px;
}
.item .n { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .m { font-size: 12px; color: var(--muted); grid-column: 1; }
.item .k { grid-row: 1 / span 2; grid-column: 2; text-align: right; font-weight: 750; display: flex; align-items: center; gap: 8px; }
.item .k small { font-weight: 500; color: var(--muted); font-size: 12px; }
.del { border: 0; background: none; color: var(--sig); width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.del svg { width: 18px; height: 18px; }
.empty { border: 1.5px dashed var(--line); border-radius: 16px; padding: 22px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.disclaimer { font-size: 12px; color: var(--muted); margin: 22px 2px 0; }

/* ---------- plane 3: floating controls ---------- */
.dock {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--safe-b)); z-index: 30;
  width: min(452px, calc(100% - 28px)); display: flex; align-items: center; gap: 10px;
  background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 22px; padding: 8px; box-shadow: var(--shadow);
}
.tab {
  flex: 1; border: 0; background: none; border-radius: 15px; height: 52px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 650; color: var(--sig); white-space: nowrap; min-width: 0; padding: 0 2px;
}
.tab svg { width: 22px; height: 22px; }
.tab[aria-current="page"] { background: var(--sig-soft); }
.scanbtn {
  flex: 0 0 auto; height: 60px; padding: 0 18px; white-space: nowrap; border-radius: 18px; border: 0; background: var(--sig); color: var(--sig-ink);
  display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; box-shadow: 0 8px 20px var(--sig-soft);
}
.scanbtn svg { width: 22px; height: 22px; }
.scanbtn:active, .btn:active, .tab:active { transform: scale(.97); }

/* ---------- buttons, controls ---------- */
.btn {
  border: 0; border-radius: 16px; height: 54px; padding: 0 20px; font-weight: 800; background: var(--sig); color: var(--sig-ink);
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; transition: transform .1s;
}
.btn.ghost { background: none; color: var(--sig); border: 1.5px solid var(--sig); }
.btn.link { background: none; color: var(--sig); height: 44px; width: auto; padding: 0 6px; font-weight: 700; }
.btn:disabled { opacity: .5; cursor: default; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { white-space: nowrap;
  flex: 1; border: 0; background: none; border-radius: 10px; min-height: 40px; font-weight: 700; color: var(--sig); padding: 6px 8px; font-size: 14px;
}
.seg button[aria-pressed="true"] { background: var(--sig); color: var(--sig-ink); }
.seg.wrap { flex-wrap: wrap; }
.seg.wrap button { flex: 1 1 40%; font-size: 13px; }
.field { margin: 0 0 16px; }
.field > label, .field > .lab { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 0 0 6px; }
.input {
  width: 100%; height: 50px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); padding: 0 14px; font-size: 16px; color: var(--ink);
}
.input:focus { outline: 2px solid var(--sig); outline-offset: 1px; border-color: transparent; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid2 > *, .grid3 > * { min-width: 0; }
.input { min-width: 0; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--sig); border-radius: 99px; padding: 7px 13px;
  font-size: 13px; font-weight: 650; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--sig); color: var(--sig-ink); border-color: var(--sig); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

/* ---------- search ---------- */
.searchbox { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 0 8px; }
.searchbox .input { padding-left: 42px; }
.searchbox .ico { position: absolute; left: 14px; top: 24px; width: 18px; height: 18px; color: var(--muted); }
.result {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; color: var(--ink);
}
.result .n { font-weight: 650; }
.result .e { font-size: 12px; color: var(--muted); }
.result .k { grid-row: 1 / span 2; grid-column: 2; font-weight: 750; text-align: right; }
.result .k small { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.sentinel { height: 1px; }
.count { font-size: 12px; color: var(--muted); margin: 4px 2px 10px; }

/* ---------- sheet (result card) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10,8,6,.45); z-index: 40; opacity: 0; transition: opacity .2s; }
.scrim.on { opacity: 1; }
.sheet {
  position: fixed; left: 50%; bottom: 0; z-index: 41; width: min(480px, 100%); max-height: 92vh; overflow-y: auto;
  transform: translate(-50%, 104%); transition: transform .32s cubic-bezier(.2,.8,.2,1);
  background: var(--card); border-radius: 26px 26px 0 0; padding: 10px 18px calc(18px + var(--safe-b)); box-shadow: var(--shadow);
  overscroll-behavior: contain;
}
.sheet.on { transform: translate(-50%, 0); }
.grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 10px; }
.sheet .photo { position: relative; border-radius: 18px; overflow: hidden; background: var(--bg); aspect-ratio: 4/3; margin-bottom: 12px; }
.sheet .photo img { width: 100%; height: 100%; object-fit: cover; }
.scanline {
  position: absolute; left: 0; right: 0; height: 30%; top: -30%;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,.55), transparent); animation: scan 1.3s ease-in-out infinite;
}
@keyframes scan { to { top: 100%; } }
.sk { background: linear-gradient(90deg, var(--line) 0%, var(--bg) 50%, var(--line) 100%); background-size: 200% 100%; animation: sh 1.2s infinite linear; border-radius: 10px; }
@keyframes sh { to { background-position: -200% 0; } }
.dishname { font-weight: 800; font-size: 17px; line-height: 1.25; margin: 2px 0 0; }
.dishalt { font-size: 13px; color: var(--muted); }
.kcalrow { display: flex; align-items: flex-end; gap: 8px; margin: 10px 0 2px; }
.kcalrow .big { font-size: 88px; line-height: .86; font-weight: 900; letter-spacing: -.055em; }
.kcalrow .unit { font-size: 13px; color: var(--muted); font-weight: 700; padding-bottom: 8px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.badge { font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.note { font-size: 13px; color: var(--muted); background: var(--bg); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.comps { margin: 6px 0 0; border-top: 1px solid var(--line); }
.comps summary { list-style: none; padding: 12px 0; font-weight: 700; color: var(--sig); font-size: 14px; cursor: pointer; }
.comps summary::-webkit-details-marker { display: none; }
.comps table { width: 100%; border-collapse: collapse; font-size: 12px; }
.comps td, .comps th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: right; }
.comps td:first-child, .comps th:first-child { text-align: left; }
.comps th { color: var(--muted); font-weight: 600; }
.src { font-size: 11px; color: var(--muted); margin-top: 8px; }
.actions { display: grid; gap: 8px; margin-top: 14px; }
.altchips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }

/* ---------- onboarding ---------- */
.ob { padding-top: 8px; }
.ob .hero { padding-top: 18px; }
.ob h1 { font-size: 15px; margin: 4px 0 18px; font-weight: 700; color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translate(-50%, 20px); z-index: 50; opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); border-radius: 14px; padding: 10px 10px 10px 16px; display: flex; gap: 12px; align-items: center;
  font-size: 14px; font-weight: 600; transition: all .25s; max-width: calc(100% - 28px); box-shadow: var(--shadow);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { border: 0; background: none; color: var(--sig); font-weight: 800; padding: 6px 8px; filter: brightness(1.35); }
:root[data-theme="dark"] .toast button { filter: none; color: #c43a1d; }

.settings .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.settings .row:last-child { border-bottom: 0; }
.settings .row .seg { min-width: 170px; }
.sources { font-size: 12px; color: var(--muted); }
.sources a { color: var(--sig); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (max-width: 360px) { .hero .big { font-size: 84px; } .bgword { font-size: 104px; } .scanbtn { padding: 0 16px; } }

input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.sheet .searchbox { background: var(--card); }
