/* ---------- tokens ---------- */
:root {
  color-scheme: light dark;
  --bg: #E9EDF4;
  --surface: #F8FAFD;
  --ink: #1C1F3A;
  --ink-2: #5A5F82;
  --ink-3: #8C91B0;
  --line: #D2D8E6;
  --brew: #A2591C;          /* the caffeine curve */
  --brew-ink: #FFF7EE;
  --sky-day: #F4F7FC;
  --sky-dusk: #9C95CF;
  --sky-night: #262B5E;
  --ok: #2E7660;
  --ok-bg: #DDEFE7;
  --warn: #B4382A;
  --warn-bg: #F7E1DC;
  --alc: #9B2B57;
  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 22px;
  --display: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, sans-serif;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
body.alc { --brew: #9B2B57; --warn: #B4540A; --warn-bg: #FBE6D2; }
body.food { --brew: #4E7A1C; }
@media (prefers-color-scheme: dark) {
  body.alc { --brew: #F08BAE; --warn: #FFB067; --warn-bg: #40280F; }
  body.food { --brew: #A8D468; }
  :root {
    --bg: #0F1226;
    --surface: #171B38;
    --ink: #E9EBF7;
    --ink-2: #A3A8CB;
    --ink-3: #6D7299;
    --line: #2A2F57;
    --brew: #EBA552;
    --brew-ink: #22140A;
    --sky-day: #1E2348;
    --sky-dusk: #3A3775;
    --sky-night: #070919;
    --ok: #6CC6A6;
    --ok-bg: #173A33;
    --warn: #FF8A78;
    --warn-bg: #45201E;
    --alc: #F08BAE;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--text);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }
svg { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2.5px solid var(--brew); outline-offset: 2px; }
.muted { color: var(--ink-2); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  min-height: 44px; padding: 0 1.1em;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: .95rem; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary:hover { border-color: var(--ink); opacity: .92; }
.btn-warn { background: var(--warn); color: #fff; border-color: var(--warn); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-2); padding: 0 .6em; }
.btn-quiet:hover { color: var(--ink); border-color: transparent; }
.btn-danger-quiet { background: transparent; color: var(--warn); border-color: transparent; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.link { background: none; border: 0; padding: 0; color: var(--brew); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--line); }

.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--ink-2); }
input[type=text], input:not([type]), input[type=password], input[type=number], input[type=time], input[type=datetime-local] {
  width: 100%; min-height: 46px; padding: 0 .85rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s);
  font-size: 1rem;
}
input:focus { border-color: var(--brew); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brew) 25%, transparent); }
.form-error { color: var(--warn); font-size: .9rem; min-height: 0; margin: -.2rem 0 .7rem; }
.form-error:empty { display: none; }
.check { display: flex; gap: .65rem; align-items: flex-start; margin: .55rem 0; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: .15rem 0 0; accent-color: var(--brew); flex: none; }
.check small { color: var(--ink-2); font-size: .85rem; }
.hint { color: var(--ink-2); font-size: .92rem; margin-bottom: .6rem; }

.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: .5em 1em; min-height: 38px; font-weight: 600; font-size: .92rem; color: var(--ink-2); cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(20, 24, 60, .15); }
.seg-wrap { display: flex; flex-wrap: wrap; border-radius: var(--radius-m); margin-bottom: .6rem; }
.seg-wrap button { border-radius: 11px; flex: 1 1 45%; }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; position: relative; overflow: hidden; }
.auth-sky { position: absolute; inset: auto 0 0 0; height: 46vh; background: linear-gradient(90deg, var(--sky-day) 0%, var(--sky-day) 45%, var(--sky-dusk) 72%, var(--sky-night) 100%); }
.auth-curve { position: absolute; inset: 0; width: 100%; height: 100%; }
.auth-curve path { stroke: var(--brew); stroke-width: 3; fill: none; vector-effect: non-scaling-stroke; opacity: .85; }
.auth-card { position: relative; width: 100%; max-width: 380px; background: var(--surface); border-radius: var(--radius-l); padding: 32px 26px 24px; box-shadow: 0 24px 60px -30px rgba(20, 24, 70, .55); }
.auth-title { font-size: 2.6rem; font-weight: 800; letter-spacing: -0.03em; color: var(--brew); }
.auth-lede { color: var(--ink-2); margin: .4rem 0 1.4rem; }
.auth-switch { margin-top: 1rem; text-align: center; color: var(--ink-2); font-size: .95rem; }

/* ---------- app shell ---------- */
.app { max-width: 1080px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top)) 0 10px; }
.modes { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.modes button { border: 0; background: transparent; border-radius: 999px; padding: .4em .95em; font: 800 1.05rem/1.2 var(--display); letter-spacing: -0.01em; color: var(--ink-3); cursor: pointer; }
.modes button[aria-pressed=true] { background: var(--brew); color: var(--surface); }
.wordmark { font-family: var(--display); font-weight: 800; font-size: 1.35rem; color: var(--brew); letter-spacing: -0.02em; }
.tabs { display: flex; gap: 4px; }
.tabs button { display: flex; align-items: center; gap: .45em; border: 0; background: transparent; color: var(--ink-2); font-weight: 600; padding: .55em .9em; border-radius: 999px; cursor: pointer; }
.tabs button[aria-current=page] { background: var(--surface); color: var(--ink); }
@media (max-width: 719px) {
  .tabs {
    position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
    border-top: 1px solid var(--line); justify-content: space-around;
  }
  .tabs button { flex-direction: column; gap: 2px; font-size: .72rem; padding: .35em .6em; min-width: 64px; }
  .tabs button svg { width: 24px; height: 24px; }
  .tabs button[aria-current=page] { background: transparent; color: var(--brew); }
}

.banner { background: var(--warn-bg); color: var(--ink); border-radius: var(--radius-m); padding: .8rem 1rem; margin: 4px 0 12px; font-size: .95rem; }
.banner .link { margin-left: .3em; }

.view { animation: none; }
.view-title { font-size: 1.6rem; margin: 10px 0 6px; }

/* ---------- today ---------- */
.view-today { display: grid; grid-template-columns: 1fr; gap: 6px 32px; }
.now-block { padding: 10px 2px 4px; }
.now-label { color: var(--ink-2); font-weight: 600; font-size: .95rem; }
.now-figure { font-family: var(--display); font-weight: 800; font-size: clamp(4rem, 17vw, 6.2rem); line-height: .95; letter-spacing: -0.045em; display: flex; align-items: baseline; gap: .12em; }
.now-figure .unit { font-size: .3em; letter-spacing: 0; color: var(--ink-2); font-weight: 700; }
.bed-verdict { display: inline-flex; align-items: center; gap: .5em; margin-top: .8rem; padding: .45em .9em .45em .7em; border-radius: 999px; font-weight: 600; font-size: .95rem; }
.bed-verdict:not(.ok):not(.bad) { background: var(--surface); }
.bed-verdict svg { width: 1.1em; height: 1.1em; }
.bed-verdict.ok { background: var(--ok-bg); color: var(--ok); }
.bed-verdict.bad { background: var(--warn-bg); color: var(--warn); }

.chart-wrap { position: relative; margin: 8px -16px 0; }
.chart { width: 100%; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: auto; stroke: none; }
.chart text { font: 600 11px var(--text); fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.chart .night-text { fill: #C9C6F0; }
.chart .halo { paint-order: stroke; stroke: var(--sky-day); stroke-width: 4px; stroke-linejoin: round; }
.chart-tip {
  position: absolute; top: 6px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); font-size: .82rem; font-weight: 600;
  padding: .25em .6em; border-radius: 6px; pointer-events: none; white-space: nowrap;
}

.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px 16px; margin: 18px 0 8px; }
.facts div { border-left: 3px solid var(--line); padding-left: 10px; }
.facts dt { color: var(--ink-2); font-size: .82rem; font-weight: 600; }
.facts dd { margin: 2px 0 0; font-family: var(--display); font-weight: 700; font-size: 1.2rem; line-height: 1.25; }
.facts dd small { display: block; font-family: var(--text); font-weight: 500; font-size: .82rem; color: var(--ink-2); }
.facts .good { border-color: var(--ok); }
.facts .bad { border-color: var(--warn); }

.add-zone { margin-top: 18px; }
.zone-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.drink-btn {
  display: flex; align-items: center; gap: .6rem; text-align: left;
  min-height: 58px; padding: .55rem .75rem; border-radius: var(--radius-m);
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
}
.drink-btn:hover { border-color: var(--brew); }
.drink-btn:active { transform: scale(.98); }
.drink-btn svg { width: 26px; height: 26px; color: var(--brew); }
.drink-btn b { display: block; font-weight: 600; font-size: .92rem; line-height: 1.2; }
.drink-btn small { color: var(--ink-2); font-size: .8rem; }
.drink-btn[aria-pressed=true] { border-color: var(--brew); box-shadow: inset 0 0 0 1px var(--brew); }

.today-list { margin-top: 26px; }
.today-list h2 { margin-bottom: 6px; }
.entries { list-style: none; margin: 0; padding: 0; }
.entries li button {
  width: 100%; display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: .75rem;
  padding: .7rem .2rem; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; cursor: pointer;
}
.entries li:last-child button { border-bottom: 0; }
.entries svg { width: 24px; height: 24px; color: var(--brew); }
.entries .t { color: var(--ink-2); font-size: .85rem; display: block; }
.entries .mg { font-family: var(--display); font-weight: 700; text-align: right; }
.entries .mg small { display: block; font: 500 .8rem var(--text); color: var(--ink-2); }
.empty { color: var(--ink-2); padding: .8rem 0; }

@media (min-width: 900px) {
  .view-today { grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); align-items: start; }
  .col-side .add-zone { margin-top: 18px; }
  .chart-wrap { margin: 8px 0 0; }
  .quick { grid-template-columns: 1fr 1fr; }
}

/* ---------- history ---------- */
#view-history, #view-alc-history, #view-food-history { max-width: 760px; }
.hist-chart { margin: 14px 0 4px; }
.hist-chart svg { display: block; width: 100%; height: auto; stroke: none; }
.hist-chart text { font: 600 11px var(--text); fill: var(--ink-2); }
.hist-chart .bar { cursor: pointer; }
.day-group { margin-top: 22px; }
.day-group h3 { display: flex; justify-content: space-between; font-size: 1rem; padding-bottom: 4px; border-bottom: 2px solid var(--ink); }
.day-group h3 span { color: var(--ink-2); font-weight: 600; }

/* ---------- profile ---------- */
.profile-form, .group-plain { max-width: 560px; }
.group { border: 0; padding: 0; margin: 18px 0 8px; }
.group legend, .group-plain h3 { font-family: var(--display); font-weight: 700; font-size: 1.1rem; margin-bottom: .7rem; padding: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.field.indent { margin-left: 30px; max-width: 360px; }
.field.indent input { max-width: 160px; }
.field.indent .hint { margin: .3rem 0 0; font-size: .85rem; }
.estimate dl + dl { margin-top: .7rem; padding-top: .7rem; border-top: 1px solid var(--line); }
.estimate dd small { font-weight: 500; color: var(--ink-2); }
.hist-switch { margin-top: 14px; }
.estimate { background: var(--surface); border-radius: var(--radius-m); padding: 1rem 1.1rem; margin: 14px 0 16px; border: 1px solid var(--line); }
.estimate dl { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; margin: 0; }
.estimate dt { color: var(--ink-2); }
.estimate dd { margin: 0; font-weight: 700; text-align: right; }
.group-plain { margin-top: 34px; padding-top: 22px; border-top: 1px solid var(--line); }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; gap: .7rem; padding: .45rem 0; }
.mini-list li svg { color: var(--brew); }
.mini-list li span { flex: 1; }
.pw-form { max-width: 360px; }
.fine { color: var(--ink-3); font-size: .82rem; margin-top: 1.2rem; }

/* ---------- admin ---------- */
.switch-row { margin: 12px 0 18px; font-weight: 600; }
.table-wrap { overflow-x: auto; }
.users { width: 100%; border-collapse: collapse; font-size: .92rem; }
.users th { text-align: left; color: var(--ink-2); font-weight: 600; padding: .5rem; border-bottom: 2px solid var(--ink); }
.users td { padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.users td:last-child { text-align: right; white-space: nowrap; }
.users .tag { font-size: .75rem; background: var(--line); border-radius: 4px; padding: .05em .4em; margin-left: .3em; }
.users .btn { min-height: 34px; padding: 0 .7em; font-size: .82rem; }

/* ---------- dialogs ---------- */
dialog { border: 0; padding: 0; color: var(--ink); background: var(--surface); }
dialog::backdrop { background: rgba(10, 12, 35, .5); }
.sheet { width: min(560px, 100%); max-height: 92dvh; border-radius: var(--radius-l); margin: auto; }
.sheet form { padding: 18px 18px 20px; }
@media (max-width: 719px) {
  .sheet { margin: auto 0 0; max-width: 100%; width: 100%; border-radius: var(--radius-l) var(--radius-l) 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .sheet[open] { animation: rise .22s ease-out; }
}
@keyframes rise { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; max-height: 34dvh; overflow-y: auto; margin-bottom: 14px; padding: 2px; }
.presets h4 { grid-column: 1 / -1; margin: 6px 0 0; font-size: .82rem; color: var(--ink-2); font-weight: 600; }
.presets .drink-btn { min-height: 50px; padding: .5rem .6rem; gap: .45rem; }
.presets .drink-btn svg { width: 22px; height: 22px; }
.presets .drink-btn small { white-space: nowrap; }
.sheet-fields { display: flex; gap: 10px; align-items: flex-end; }
.sheet-fields .grow { flex: 1; min-width: 0; }
.sheet-fields .mg { width: 120px; }
.when-now { margin-bottom: .9rem; }
.kinds { display: flex; flex-wrap: wrap; gap: 4px; }
.kinds button { width: 44px; height: 40px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.kinds button[aria-pressed=true] { border-color: var(--brew); color: var(--brew); box-shadow: inset 0 0 0 1px var(--brew); }
.kinds svg { width: 22px; height: 22px; }
.preview { font-size: .92rem; padding: .6rem .8rem; border-radius: var(--radius-s); margin: .4rem 0 .8rem; }
.preview:empty { display: none; }
.preview.ok { background: var(--ok-bg); color: var(--ok); }
.preview.bad { background: var(--warn-bg); color: var(--warn); }
.sheet-actions { display: flex; justify-content: space-between; gap: 10px; position: sticky; bottom: -20px; background: var(--surface); padding: 10px 0 2px; margin-bottom: -2px; }
.sheet-actions .btn-primary { margin-left: auto; min-width: 140px; }

.warn { width: min(420px, calc(100% - 32px)); border-radius: var(--radius-l); padding: 24px 22px 20px; margin: auto; }
.warn[open] { animation: pop .18s ease-out; }
@keyframes pop { from { transform: scale(.96); opacity: .5; } to { transform: none; opacity: 1; } }
.warn-icon { width: 52px; height: 52px; border-radius: 50%; background: var(--sky-night); color: #F3D9A6; display: grid; place-items: center; margin-bottom: 12px; }
.warn-icon svg { width: 26px; height: 26px; fill: currentColor; }
.warn h2 { font-size: 1.3rem; margin-bottom: .6rem; }
.warn p { margin: .5rem 0; color: var(--ink-2); }
.warn p strong { color: var(--ink); }
.warn .big { font-family: var(--display); font-size: 1.05rem; color: var(--ink); }
.warn-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.warn-actions .btn { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: .65rem .6rem .65rem 1rem; border-radius: 999px;
  display: flex; align-items: center; gap: .8rem; font-weight: 600; font-size: .92rem; z-index: 50;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .5); width: max-content; max-width: calc(100% - 32px);
}
.toast button { background: none; border: 0; color: var(--brew); font-weight: 700; cursor: pointer; padding: .2rem .6rem; }
@media (prefers-color-scheme: dark) { .toast button { color: #B4602A; } }
@media (min-width: 720px) { .toast { bottom: 28px; } }

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

/* ---------- food ---------- */
.meters { display: grid; gap: 14px; margin: 18px 0 6px; }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; font-size: .92rem; color: var(--ink-2); }
.meter-head b { color: var(--ink); font-family: var(--display); font-size: 1.02rem; }
.meter-head strong { color: var(--ink); }
.meter .bar { position: relative; height: 14px; border-radius: 999px; background: color-mix(in srgb, var(--line) 70%, transparent); display: flex; overflow: visible; }
.meter .bar i { display: block; height: 100%; }
.meter .bar i:first-child { border-radius: 999px 0 0 999px; }
.meter .bar i:last-of-type { border-radius: 0 999px 999px 0; }
.meter .bar i:only-of-type { border-radius: 999px; }
.m-food, .m-prot { background: var(--brew); }
.m-alc { background: var(--alc); }
.meter.over .bar i.m-food { background: var(--warn); }
.meter .goal { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: var(--ink); }
.legend { display: flex; gap: 14px; align-items: center; font-size: .82rem; color: var(--ink-2); margin: -4px 0 0; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.meal-group { margin-top: 12px; }
.meal-group h3 { display: flex; justify-content: space-between; font-size: .95rem; color: var(--ink-2); padding-bottom: 2px; }
.meal-group h3 span { font-weight: 600; }
.day-group .meal-group h3 { border: 0; }

.food-search { display: flex; gap: 8px; margin-bottom: 10px; }
.search-box { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 .8rem; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--ink-2); }
.search-box:focus-within { border-color: var(--brew); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brew) 25%, transparent); }
.search-box input { flex: 1; min-width: 0; border: 0; background: transparent; min-height: 44px; font-size: 1rem; outline: none; padding: 0; }
.results { max-height: 32dvh; overflow-y: auto; margin: 0 -4px 14px; padding: 0 4px; border-bottom: 1px solid var(--line); }
.results h4 { margin: 10px 0 2px; font-size: .82rem; color: var(--ink-2); font-weight: 600; }
.result { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; text-align: left; padding: .55rem .2rem; border: 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); background: none; cursor: pointer; }
.result:hover { background: color-mix(in srgb, var(--brew) 7%, transparent); }
.result b { display: block; font-weight: 600; font-size: .95rem; }
.result em { display: block; font-style: normal; font-size: .8rem; color: var(--ink-2); }
.result small { color: var(--ink-2); font-size: .8rem; text-align: right; flex: none; max-width: 48%; }
.off-btn { display: flex; align-items: center; gap: .5em; width: 100%; margin: 4px 0 6px; padding: .6rem .8rem; border-radius: var(--radius-s); border: 1px dashed var(--brew); background: color-mix(in srgb, var(--brew) 8%, transparent); color: var(--ink); font-weight: 600; cursor: pointer; text-align: left; }
.portions { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 10px; }
.portions button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: .35em .8em; font-size: .85rem; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.portions button[aria-pressed=true] { border-color: var(--brew); color: var(--ink); box-shadow: inset 0 0 0 1px var(--brew); }
.mode-link { margin: -2px 0 12px; font-size: .9rem; }
#food-meal { display: flex; }
#food-meal button { flex: 1; padding: .5em .3em; font-size: .88rem; }
.food-search .btn { flex: none; }
.row3 { align-items: end; }
.row3 .field > span { font-size: .8rem; white-space: nowrap; }
.modes button { padding: .4em .8em; }
@media (max-width: 380px) { .modes button { padding: .4em .6em; font-size: .98rem; } }

.scanner .scan-view { position: relative; aspect-ratio: 4 / 3; background: #000; border-radius: var(--radius-m); overflow: hidden; margin: 0 18px; }
.scanner .sheet-head { padding: 18px 18px 0; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; left: 12%; right: 12%; top: 32%; bottom: 32%; border: 2px solid rgba(255, 255, 255, .85); border-radius: 10px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .28); }
.scanner > .hint { margin: 10px 18px; }
.scanner form { padding: 0 18px 18px; }

/* ---------- offline / sync ---------- */
.netbar { display: flex; align-items: center; flex-wrap: wrap; gap: .3em .5em; margin: 2px 0 10px; padding: .55rem .9rem; border-radius: var(--radius-m); background: var(--surface); border: 1px solid var(--line); font-size: .92rem; color: var(--ink-2); }
.netbar b { color: var(--ink); }
.netbar.off { background: var(--sky-night); border-color: var(--sky-night); color: #D9D6F5; }
.netbar.off b { color: #F3D9A6; }
.pend { display: inline-block; font-size: .72rem; font-weight: 700; color: var(--brew); border: 1px solid currentColor; border-radius: 4px; padding: 0 .35em; margin-right: .45em; line-height: 1.45; }

/* ---------- reminders, shortcuts ---------- */
select { width: 100%; min-height: 46px; padding: 0 .7rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); font-size: 1rem; }
.indent-block { margin-left: 30px; }
.note { font-size: .92rem; color: var(--ink-2); margin: .2rem 0 .7rem; }
.note.ok { color: var(--ok); font-weight: 600; }
.sc-list { list-style: none; padding: 0; margin: 12px 0; }
.sc-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.sc-list b { display: block; font-weight: 600; }
.sc-list small { display: block; color: var(--ink-2); font-size: .82rem; }
.sc-list .btn { flex: none; min-height: 36px; font-size: .85rem; }
.howto { margin: 10px 0 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: .7rem 1rem; }
.howto summary { font-weight: 700; cursor: pointer; }
.howto ol { padding-left: 1.2rem; margin: .7rem 0; }
.howto li { margin-bottom: .55rem; }
.howto code, .copy-row code { font-size: .85em; background: color-mix(in srgb, var(--line) 60%, transparent); padding: .05em .35em; border-radius: 4px; }
.cron-box { margin: 0 0 22px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); max-width: 760px; }
.cron-box h3 { margin-bottom: .4rem; }
.copy-row { display: flex; gap: 10px; align-items: center; margin: .5rem 0; }
.copy-row code { flex: 1; min-width: 0; overflow-wrap: anywhere; padding: .5em .6em; }
