/* Layout: one phone-width column: lookup on top, a meter-style carb readout, then today's log and saved foods. */
/* Monochrome greys and black; one deep purple accent. --accent fills buttons, --accent-text is for
   purple text and strokes (lighter in dark mode so it stays readable on black). */
:root {
  --bg: #E6E6E6;
  --surface: #F7F7F7;
  --ink: #0B0B0B;
  --muted: #5A5A5A;
  --line: #C9C9C9;
  --accent: #3B1A5E;
  --accent-text: #3B1A5E;
  --accent-ink: #FFFFFF;
  --accent-soft: #E3DDEA;
  --chip: #D6D6D6;         /* mid-grey fill for neutral tags */
  --strong: #0B0B0B;       /* black fill for the loudest tags */
  --strong-ink: #F7F7F7;
  --f-display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --f-body: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-data: "Atkinson Hyperlegible Mono", ui-monospace, "SF Mono", Consolas, monospace;
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0A0A0A; --surface: #161616; --ink: #EDEDED; --muted: #9B9B9B; --line: #2C2C2C;
    --accent: #3B1A5E; --accent-text: #BFA6DE; --accent-ink: #FFFFFF; --accent-soft: #241636;
    --chip: #2A2A2A; --strong: #EDEDED; --strong-ink: #0A0A0A;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg); color: var(--ink);
  font-family: var(--f-body); font-size: 16px; line-height: 1.45;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: calc(18px + env(safe-area-inset-top, 0px)) calc(40px + env(safe-area-inset-bottom, 0px));
}
[hidden] { display: none !important; }
img { max-width: 100%; }
a { color: var(--accent-text); }
.wrap { max-width: 560px; margin: 0 auto; display: grid; gap: 18px; }
button, input, select { font: inherit; color: inherit; }
button, label.btn { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 2px; border-radius: 6px; }
.num, .mono { font-family: var(--f-data); font-variant-numeric: tabular-nums; }
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; margin: 0; }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }

/* header */
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; }
.ring { width: 26px; height: 26px; border-radius: 50%; border: 6px solid var(--accent-text); flex: none; }
h1 { font-size: 26px; font-weight: 800; font-stretch: 80%; letter-spacing: -.01em; }
.today-chip { display: flex; align-items: baseline; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.today-chip .num { font-size: 18px; font-weight: 600; }

/* top sections: Food / Tracker */
.topnav { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-bottom: 2px solid var(--line); margin-bottom: -4px; }
.topnav button { position: relative; border: 0; background: transparent; padding: 10px 8px 12px; font-family: var(--f-display); font-stretch: 85%; font-weight: 700; font-size: 18px; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.topnav button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent-text); }
.due-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--accent-text); vertical-align: super; margin-left: 2px; }
.view { display: grid; gap: 18px; }
/* Single-column grids: let the column shrink to the screen instead of growing to fit wide content. */
.wrap, .view, .card, .lf, .panel, .log-form, .rem-group { grid-template-columns: minmax(0, 1fr); }

/* tabs */
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.tabs button { border: 0; background: transparent; padding: 10px 4px; border-radius: 9px; font-weight: 600; font-size: 15px; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }

.panel { display: grid; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; min-width: 0; }
input[type="text"], input[type="number"], input[type="search"], select {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 14px; font-size: 16px;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
/* The search box grows with what you type (up to about 8 lines, then scrolls). */
.search-row { align-items: flex-end; }
#q {
  flex: 1; min-width: 0; resize: none; overflow-y: hidden; max-height: 12em;
  font: inherit; font-size: 16px; line-height: 1.4; color: var(--ink);
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 14px;
}
#q.scroll { overflow-y: auto; }

/* how a typed meal was read */
.parsed .hit { cursor: default; }
.parsed .hit .typed { display: block; font-size: 13px; color: var(--muted); }
.parsed .hit .act { flex: none; }
.context-note { margin: 0; padding: 12px 14px; font-size: 14px; border-bottom: 1px solid var(--line); }
.context-note:last-child { border-bottom: 0; }
.web-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: none; }
.web-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 12px 14px; font-size: 14px; color: var(--muted); }
.replace-banner { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); font-weight: 600; font-size: 14px; }
.btn { display: inline-block; border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700; background: var(--accent); color: var(--accent-ink); white-space: nowrap; text-align: center; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); font-weight: 600; }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn.danger { color: var(--ink); border-color: var(--ink); }
.tries { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 14px; color: var(--muted); }
.tries button { border: 1px dashed var(--line); background: transparent; border-radius: 999px; padding: 5px 11px; font-size: 14px; color: var(--ink); }

/* search results and photo guesses */
.results { display: grid; gap: 14px; }
.results:empty { display: none; }
.group h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.group h4 span { text-transform: none; letter-spacing: 0; font-weight: 400; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.hit { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--line); padding: 11px 14px; }
.hit:last-child { border-bottom: 0; }
.hit:hover { background: var(--bg); }
.hit img { width: 40px; height: 40px; object-fit: contain; border-radius: 6px; background: var(--bg); flex: none; }
.hit .nm { flex: 1; min-width: 0; }
.hit .nm b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.hit .nm span { display: block; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.hit .c { font-family: var(--f-data); font-weight: 600; white-space: nowrap; text-align: right; }
.hit .c small { display: block; font-family: var(--f-body); font-weight: 400; font-size: 12px; color: var(--muted); }
.hit input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.hit .pct { font-family: var(--f-data); font-size: 13px; color: var(--muted); width: 3.5em; text-align: right; flex: none; }
.muted-line { margin: 0; padding: 12px 14px; color: var(--muted); font-size: 14px; }
.guess-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.guess-actions .btn { flex: 1; }

/* barcode */
.viewfinder { position: relative; aspect-ratio: 4 / 3; max-width: 100%; border-radius: var(--r); overflow: hidden; background: #000000; border: 1px solid var(--line); }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; }
.vf-idle { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 16px; text-align: center; color: #E6E6E6; }
.vf-idle p { margin: 0; max-width: 30ch; }
.vf-frame { position: absolute; left: 12%; right: 12%; top: 32%; bottom: 32%; border: 3px solid rgba(255,255,255,.85); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0,0,0,.25); display: none; }
.viewfinder.live .vf-frame { display: block; }
.viewfinder.live .vf-idle { display: none; }
.vf-stop { position: absolute; right: 10px; bottom: 10px; }

/* photos */
.drop { display: grid; gap: 10px; justify-items: center; text-align: center; border: 2px dashed var(--line); border-radius: var(--r); padding: 22px 16px; background: var(--surface); }
.drop p { margin: 0; color: var(--muted); font-size: 14px; max-width: 36ch; }
.drop .row { flex-wrap: wrap; justify-content: center; }
.preview { position: relative; display: none; }
.preview.on { display: block; }
.preview img { display: block; width: 100%; max-height: 300px; object-fit: cover; border-radius: var(--r); border: 1px solid var(--line); }
.preview button { position: absolute; top: 8px; right: 8px; border: 0; border-radius: 999px; padding: 6px 12px; background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 600; }
.file-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* label form */
.label-form { gap: 14px; }
.label-intro { margin: 0; font-weight: 600; }
.lf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lf-grid label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; min-width: 0; }
.lf-grid label.wide { grid-column: 1 / -1; }
.lf-grid input { width: 100%; min-width: 0; color: var(--ink); font-weight: 400; padding: 10px 12px; }
.lf-grid label.key input { border-color: var(--accent-text); border-width: 2px; font-weight: 700; }
.lf-grid label.missing input { border: 2px dashed var(--ink); background: var(--chip); }

.status { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); font-weight: 600; }
.status.err { background: var(--strong); color: var(--strong-ink); }
.status .grow { flex: 1; min-width: 0; }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--accent-text); flex: none; animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

/* result card */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: grid; gap: 16px; }
.r-head { display: flex; gap: 12px; align-items: flex-start; }
.r-head > div { flex: 1; min-width: 0; }
.r-head h2 { font-size: 22px; font-weight: 700; font-stretch: 90%; line-height: 1.15; overflow-wrap: anywhere; }
.serving { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 2px 8px; border-radius: 6px; background: var(--strong); color: var(--strong-ink); margin-bottom: 6px; }
.star { border: 1px solid var(--line); background: transparent; border-radius: 10px; padding: 7px 10px; font-size: 14px; font-weight: 600; flex: none; }
.star[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-text); color: var(--accent-text); }

.readout { display: grid; gap: 10px; }
.big { display: flex; align-items: baseline; gap: 8px; }
.big .num { font-family: var(--f-display); font-weight: 800; font-stretch: 70%; font-size: 76px; line-height: .9; letter-spacing: -.02em; color: var(--accent-text); }
.big .unit { font-size: 18px; font-weight: 700; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }
.pill.good { background: transparent; color: var(--ink); border-color: var(--muted); }
.pill.warn { background: var(--chip); color: var(--ink); border-color: transparent; }
.pill.bad { background: var(--strong); color: var(--strong-ink); border-color: transparent; }

.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin: 0; }
.macros div { background: var(--surface); padding: 10px 12px; display: grid; gap: 2px; }
.macros dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.macros dd { margin: 0; font-family: var(--f-data); font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.macros dd small { font-size: 12px; color: var(--muted); font-weight: 400; }

.items { display: grid; border-top: 1px solid var(--line); }
.item { display: grid; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.item-top { display: flex; gap: 10px; align-items: flex-start; }
.item-top .nm { flex: 1; min-width: 0; }
.item-top .nm b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.item-top .nm span { font-size: 13px; color: var(--muted); }
.item-top .c { font-family: var(--f-data); font-weight: 600; white-space: nowrap; }
.item-top .x { border: 0; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; padding: 0 4px; }
.portion { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.portion select { flex: 1 1 180px; min-width: 0; padding: 9px 10px; font-size: 15px; border-radius: 10px; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex: none; }
.stepper button { border: 0; background: var(--bg); width: 40px; height: 40px; font-size: 20px; font-weight: 700; }
.stepper input { width: 64px; border: 0; border-radius: 0; text-align: center; padding: 8px 2px; font-family: var(--f-data); font-weight: 600; font-size: 15px; background: var(--surface); -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.notes { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 15px; }
.basis { font-size: 13px; color: var(--muted); margin: 0; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 14px; }
.actions .btn { flex: 1; min-width: 150px; }

/* log + foods */
section > h3 { font-size: 18px; font-weight: 700; font-stretch: 90%; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
section > h3 .num { font-family: var(--f-data); font-size: 16px; }
.log { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.log-row { display: grid; grid-template-columns: 58px 1fr auto auto; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.log-row:last-child { border-bottom: 0; }
.log-row .t { font-family: var(--f-data); font-size: 13px; color: var(--muted); }
.log-row .nm { min-width: 0; overflow-wrap: anywhere; }
.log-row .nm span { display: block; font-size: 13px; color: var(--muted); }
.log-row .c { font-family: var(--f-data); font-weight: 600; }
.log-row button { border: 0; background: transparent; color: var(--muted); font-size: 20px; padding: 2px 6px; line-height: 1; }
.empty { padding: 16px; color: var(--muted); font-size: 15px; margin: 0; }
.manual { display: grid; grid-template-columns: 1fr 96px auto; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--bg); }
.manual input { min-width: 0; padding: 10px 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; gap: 8px; align-items: baseline; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 12px; font-size: 14px; text-align: left; max-width: 100%; }
.chip span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chip .num { color: var(--accent-text); font-weight: 600; flex: none; }
.sub { font-size: 13px; color: var(--muted); margin: 14px 0 8px; }
.sub:first-child { margin-top: 0; }

/* settings */
.settings { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.settings summary { padding: 14px 16px; font-weight: 700; cursor: pointer; }
.settings-body { display: grid; gap: 18px; padding: 0 16px 16px; }
.set-row { display: grid; gap: 6px; }
.set-row > label, .set-label { font-weight: 600; }
.hint { margin: 0; font-size: 14px; color: var(--muted); }
.set-row .row { flex-wrap: wrap; }

/* tracker */
.due-alerts { display: grid; gap: 8px; }
.due-alerts:empty { display: none; }
.due { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-radius: 12px; background: var(--strong); color: var(--strong-ink); }
.due .grow { flex: 1 1 160px; min-width: 0; }
.due .grow span { display: block; font-size: 13px; opacity: .75; }
.due .btn.ghost { background: transparent; color: var(--strong-ink); border-color: currentColor; }
.log-form { gap: 14px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; padding: 9px; border-radius: 8px; font-weight: 600; color: var(--muted); }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.lf { display: grid; gap: 12px; }
.big-input { display: flex; align-items: baseline; gap: 10px; border-bottom: 2px solid var(--line); padding-bottom: 4px; }
.big-input:focus-within { border-bottom-color: var(--accent-text); }
.big-input input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 0; font-family: var(--f-display); font-weight: 800; font-stretch: 70%; font-size: 64px; line-height: 1; color: var(--accent-text); -moz-appearance: textfield; }
.big-input input::-webkit-inner-spin-button, .big-input input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.big-input input:focus { outline: none; }
.big-input span { font-weight: 700; color: var(--muted); }
.chip.pick { padding: 7px 12px; cursor: pointer; }
.chip.pick small { color: var(--muted); font-size: 12px; }
.chip.pick[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip.pick[aria-pressed="true"] small { color: inherit; opacity: .8; }
/* Time and Note side by side: equal halves on wide screens; on phones Time takes just what its text needs and Note
   gets the rest. Only the narrowest phones stack them. */
.lf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 599px) {
  .lf-row { grid-template-columns: auto minmax(0, 1fr); }
  .lf-row .when { font-size: 14px; padding-inline: 10px; }
}
@media (max-width: 389px) { .lf-row .when { font-size: 13px; } }
@media (max-width: 359px) { .lf-row { grid-template-columns: minmax(0, 1fr); } }
.lf-row label, .lf-row .fld { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; min-width: 0; }
/* Date and time: our own text on top of invisible native pickers, so tapping either part opens the phone's picker. */
.when { display: flex; align-items: center; gap: 3ch; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; font-family: var(--f-data); font-size: 16px; font-weight: 400; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
.when:focus-within { border-color: var(--accent-text); }
.when-part { position: relative; display: block; flex: none; cursor: pointer; }
.when-part .v { display: block; line-height: 1.45; }
.when-part:focus-within .v { text-decoration: underline 2px var(--accent-text); text-underline-offset: 4px; }
.lf-row .when-part input { position: absolute; inset: 0; width: 100%; height: 100%; min-width: 0; margin: 0; padding: 0; border: 0; opacity: 0; font-size: 16px; cursor: pointer; -webkit-appearance: none; appearance: none; }
.when-part input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; cursor: pointer; }
.lf-row input { width: 100%; min-width: 0; padding: 10px 12px; color: var(--ink); font-weight: 400; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; font-size: 16px; }
.since { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.since div { background: var(--surface); padding: 10px 12px; display: grid; gap: 2px; min-width: 0; }
.since b { font-family: var(--f-data); font-size: 15px; overflow-wrap: anywhere; }
.since div > span:last-child { font-size: 12px; color: var(--muted); }
.day-nav { justify-content: space-between; align-items: center !important; }
.day-nav span { flex: 1; text-align: center; }
.day-nav .btn { font-size: 18px; padding: 4px 14px; }
.day-sum { margin-bottom: 10px; }
.log-row .c small { font-family: var(--f-body); font-weight: 400; font-size: 12px; color: var(--muted); }
.log-row .c .pill { margin-left: 4px; padding: 2px 8px; font-size: 12px; }
.log-row .x, .rem-row .x { border: 0; background: transparent; color: var(--muted); font-size: 20px; padding: 2px 6px; line-height: 1; }
.tl-dose .t, .tl-bg .t { color: var(--ink); }
.tl-food .nm { color: var(--muted); }
.notif-row { display: grid; gap: 8px; margin-bottom: 12px; justify-items: start; }
#reminderGroups { display: grid; gap: 12px; }
.rem-group { gap: 10px; padding: 14px; }
.rem-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.rem-row { display: grid; grid-template-columns: 112px 1fr auto auto; gap: 8px; align-items: center; }
.rem-row input[type="time"], .rem-row input[type="text"] { min-width: 0; width: 100%; padding: 9px 10px; font-size: 15px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; color: var(--ink); }
.rem-row.off input[type="time"], .rem-row.off input[type="text"] { opacity: .45; }
.rem-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.switch { position: relative; display: inline-block; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--chip); border: 1px solid var(--line); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 3px solid var(--accent-text); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .switch span, .switch span::after { transition: none; } }
.ins-row { grid-template-columns: 58px 1fr auto auto; }
.ins-add { grid-template-columns: 1fr auto auto; }
.ins-add select { padding: 10px 8px; font-size: 14px; border-radius: 10px; min-width: 0; }
.export-row { justify-content: center; }
.set-inline { flex-wrap: wrap; gap: 12px; }
.set-inline label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.set-inline input, .set-inline select { width: 110px; padding: 9px 10px; font-size: 15px; border-radius: 10px; }

footer { font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; }
footer p { margin: 0 0 6px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px); }
.toast.on { opacity: 1; }

@media (max-width: 400px) {
  .big .num { font-size: 64px; }
  .macros { grid-template-columns: repeat(2, 1fr); }
  .manual { grid-template-columns: 1fr 80px; }
  .manual .btn { grid-column: 1 / -1; }
  .tabs button { font-size: 14px; }
  .since { grid-template-columns: 1fr; }
  .rem-row { grid-template-columns: 100px 1fr auto auto; gap: 6px; }
  .ins-add { grid-template-columns: 1fr 1fr; }
  .ins-add .btn { grid-column: 1 / -1; }
}
