/* Health App dashboard.
   Concept: a food diary kept in a ruled exercise book — faint blue grid on the page,
   flat paper cards, ballpoint-blue accent, blue-black ink, a red margin rule in the
   meal diary. System fonts only (the server must work without foreign networks).

   Chart colours are validated with the dataviz palette checks:
   categorical slots 1–4 (kcal, protein, fat, carb) pass adjacent CVD/normal-vision
   gates in both modes; sleep stages use a validated one-hue ordinal ramp. */

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: light dark;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --paper: #f3f5f1;
  --paper-grid: rgba(37, 106, 191, .07);
  --surface: #fcfcfb;
  --surface-2: #eef1ec;
  --ink: #1a2230;
  --ink-2: #4b5361;
  --ink-3: #666d79;
  --rule: #e1e3dd;
  --rule-strong: #c5c9c1;
  --control: #8b919b;
  --accent: #256abf;
  --accent-ink: #ffffff;
  --accent-hover: #1c5cab;
  --link: #1c5cab;
  --accent-wash: rgba(42, 120, 214, .10);
  --margin-rule: rgba(227, 73, 72, .45);
  --rec: #d03b3b;
  --danger: #b42828;
  --danger-wash: rgba(208, 59, 59, .08);
  --good: #006300;
  --good-wash: rgba(12, 163, 12, .10);
  --warn: #fab219;
  --warn-wash: #fdecc4;
  --warn-ink: #5a3d00;
  --toast-bg: #1a2230;
  --toast-ink: #f3f5f1;

  /* chart chrome */
  --chart-grid: #e1e3dd;
  --chart-axis: #c5c9c1;
  /* categorical slots, fixed order (dataviz reference palette) */
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  /* entities keep their colour everywhere in the app */
  --s-kcal: var(--s1);
  --s-protein: var(--s2);
  --s-fat: var(--s3);
  --s-carb: var(--s4);
  /* one entity, two treatments: raw values recede, the smoothed trend leads */
  --seq-soft: #86b6ef;
  --seq-strong: #1c5cab;
  /* sleep stages: ordinal one-hue ramp, deep = most ink */
  --sleep-deep: #104281;
  --sleep-light: #256abf;
  --sleep-rem: #5598e7;
  --sleep-awake: #86b6ef;

  --r-card: 10px;
  --r-ctl: 8px;
  --r-pill: 999px;
  --gutter: 16px;
  --page-max: 1120px;
  --margin-w: 56px;
  --ctl-h: 40px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e131a;
    --paper-grid: rgba(109, 167, 236, .05);
    --surface: #171d26;
    --surface-2: #1f2632;
    --ink: #e9edf3;
    --ink-2: #b3bccb;
    --ink-3: #8a94a5;
    --rule: #29313d;
    --rule-strong: #3a4452;
    --control: #667186;
    --accent: #3987e5;
    --accent-ink: #0b1526;
    --accent-hover: #5598e7;
    --link: #6da7ec;
    --accent-wash: rgba(57, 135, 229, .16);
    --margin-rule: rgba(230, 103, 103, .42);
    --rec: #d03b3b;
    --danger: #f07a7a;
    --danger-wash: rgba(240, 122, 122, .10);
    --good: #3ccf3c;
    --good-wash: rgba(12, 163, 12, .16);
    --warn: #fab219;
    --warn-wash: rgba(250, 178, 25, .16);
    --warn-ink: #f6c560;
    --toast-bg: #e9edf3;
    --toast-ink: #171d26;

    --chart-grid: #29313d;
    --chart-axis: #3a4452;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --seq-soft: #256abf;
    --seq-strong: #9ec5f4;
    --sleep-deep: #b7d3f6;
    --sleep-light: #6da7ec;
    --sleep-rem: #3987e5;
    --sleep-awake: #1c5cab;
  }
}

@media (min-width: 720px) {
  :root { --gutter: 24px; --margin-w: 76px; }
}

@media (pointer: coarse) {
  :root { --ctl-h: 44px; }
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font: 16px/1.5 var(--font);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--paper-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-grid) 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: -1px -1px;
  overflow-x: hidden;
}

h1, h2, h3, h4, p, ul, ol, dl, figure, blockquote { margin: 0; }
ul, ol { padding: 0; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
abbr[title] { text-decoration: none; cursor: help; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
:focus:not(:focus-visible) { outline: none; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--surface); color: var(--ink);
  padding: 8px 12px; border-radius: var(--r-ctl); border: 1px solid var(--rule-strong);
}
.skip-link:focus { top: 8px; }

.muted { color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; }
.hint { font-size: 14px; color: var(--ink-3); }
.notice { padding: 12px 16px; background: var(--warn-wash); color: var(--warn-ink); border-radius: var(--r-ctl); }

/* ------------------------------------------------------------------ top bar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}
.topbar__inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  flex: none;
  color: var(--ink);
  text-decoration: none;
  font-weight: 650;
  padding: 10px 0;
}
.brand__mark { fill: var(--accent); flex: none; }
.brand__mark .brand__spoon { fill: var(--surface); }
.brand__name { font-size: 16px; letter-spacing: -.01em; }

.tabs {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: stretch;
  gap: 2px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: flex; align-items: center;
  padding: 16px 10px 14px;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
  font-size: 15px;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); }
.tab[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--accent);
}
.tabs__logout { margin-left: auto; display: flex; padding-left: 8px; }
.tab--button {
  background: none; border: 0; border-bottom: 2px solid transparent;
  cursor: pointer; font: inherit; font-size: 15px;
}

/* a fade on the edge that still has hidden tabs (set by ui.js) */
.tabs[data-more="right"] { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
.tabs[data-more="left"] { -webkit-mask-image: linear-gradient(90deg, transparent, #000 28px); mask-image: linear-gradient(90deg, transparent, #000 28px); }
.tabs[data-more="both"] {
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 28px, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 28px, #000 calc(100% - 28px), transparent);
}

@media (max-width: 719px) {
  .brand__name { display: none; }
  .topbar__inner { gap: 8px; }
  .tab { padding: 14px 9px 12px; }
}

/* ------------------------------------------------------------------ page layout */
.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 24px var(--gutter) 72px;
  display: grid;
  gap: 24px;
  min-width: 0;
}
.page:focus { outline: none; }
.page > * { min-width: 0; }

.stack { display: grid; gap: 16px; min-width: 0; }
.stack-lg { display: grid; gap: 24px; min-width: 0; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 32px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -.02em;
}
.page-sub { margin-top: 6px; color: var(--ink-2); max-width: 62ch; font-size: 15px; }

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 4px 16px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.section-title { font-size: 21px; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
.section-head__meta { color: var(--ink-3); font-size: 14px; }

.grid-2 { display: grid; gap: 16px; min-width: 0; }
@media (min-width: 880px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
  .grid-2--main { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
}
.grid-2--top { align-items: start; }

.filters { display: flex; align-items: center; gap: 8px; min-width: 0; }
.filters select { width: auto; min-width: 0; flex: 0 1 15rem; }
.table-note { font-size: 13px; color: var(--ink-3); margin-bottom: 8px; }
.status-line { font-size: 14px; color: var(--ink-2); }
.card > .field + .status-line { margin-top: 10px; }
.empty { color: var(--ink-3); padding: 8px 0; }

@media (max-width: 719px) {
  .page { padding-top: 16px; gap: 20px; }
  .page-title { font-size: 26px; }
}

/* ------------------------------------------------------------------ cards */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-card);
  padding: 16px;
  min-width: 0;
}
@media (min-width: 720px) { .card { padding: 20px 24px; } }
.card__head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 8px 16px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.card__title { font-size: 18px; line-height: 1.3; font-weight: 650; }
.card__sub { font-size: 14px; color: var(--ink-3); margin-top: 2px; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--ctl-h);
  padding: 0 14px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--control);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px; font-weight: 550; line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn--danger { color: var(--danger); }
.btn--danger:hover { background: var(--danger-wash); color: var(--danger); }
/* repeated per-row remove buttons stay quiet until pointed at */
.btn--remove { background: transparent; border-color: transparent; color: var(--ink-3); }
.btn--remove:hover, .btn--remove:focus-visible { background: var(--danger-wash); color: var(--danger); }
.btn--small { min-height: 32px; padding: 0 10px; font-size: 14px; }
.btn--icon { width: var(--ctl-h); padding: 0; flex: none; }
.btn--icon.btn--small { width: 32px; }
.btn--block { width: 100%; }
.btn--wrap { white-space: normal; text-align: center; max-width: 100%; padding-block: 8px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: default; pointer-events: none; }
.btn.is-busy { cursor: progress; }
@media (pointer: coarse) {
  .btn--small { min-height: 36px; }
  .btn--icon.btn--small { width: 36px; }
}

/* ------------------------------------------------------------------ form controls */
input[type="text"], input[type="search"], input[type="password"], input[type="number"],
select, textarea {
  width: 100%;
  min-height: var(--ctl-h);
  padding: 8px 12px;
  font-size: 16px; /* no iOS zoom on focus */
  line-height: 1.3;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--control);
  border-radius: var(--r-ctl);
}
textarea { resize: vertical; min-height: 88px; line-height: 1.45; }
select { padding-right: 32px; cursor: pointer; }
input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: 1; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); border-radius: var(--r-ctl);
}
input[aria-invalid="true"] { border-color: var(--danger); }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }

.field { display: grid; align-content: start; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field__label { font-size: 14px; font-weight: 550; color: var(--ink-2); padding: 0; }
.field > .segmented { justify-self: start; }
fieldset.field > .field__label { margin-bottom: 6px; }
.form-error { color: var(--danger); font-size: 14px; font-weight: 550; }
.form-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.form-grid { display: grid; gap: 14px 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .field--full, .form-grid .field--wide { grid-column: 1 / -1; }
.field__hint { font-size: 13px; line-height: 1.4; color: var(--ink-3); }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 15px; color: var(--ink-2); cursor: pointer; }
.check input { flex: none; width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--accent); cursor: pointer; }
.form-note { font-size: 14px; line-height: 1.45; padding: 10px 12px; border-radius: var(--r-ctl); background: var(--surface-2); color: var(--ink-2); }
.form-note--ok { background: var(--good-wash); color: var(--ink); }
.form-note--warn { background: var(--warn-wash); color: var(--warn-ink); }
.form-note--error { background: var(--danger-wash); color: var(--danger); }
.link-btn {
  padding: 0; border: 0; background: none;
  font: inherit; color: var(--link);
  text-decoration: underline; text-underline-offset: 2px;
  cursor: pointer;
}

.inline-form { display: flex; gap: 8px; min-width: 0; }
.inline-form > input { flex: 1; min-width: 0; }
.inline-form--compact input { min-height: 36px; font-size: 15px; }
.inline-form--compact .btn { min-height: 36px; }

/* segmented control: radio inputs styled as one track */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  margin: 0;
  border: 1px solid var(--control);
  border-radius: var(--r-ctl);
  background: var(--surface);
  min-width: 0;
}
.segmented__item { position: relative; display: flex; }
.segmented__item input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented__item span {
  display: flex; align-items: center;
  min-height: calc(var(--ctl-h) - 8px);
  padding: 0 12px;
  border-radius: 5px;
  font-size: 14px; font-weight: 550;
  color: var(--ink-2);
  white-space: nowrap;
}
.segmented__item input:checked + span { background: var(--accent); color: var(--accent-ink); }
.segmented__item input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.segmented__item:hover input:not(:checked) + span { background: var(--surface-2); color: var(--ink); }

/* ------------------------------------------------------------------ icons, badges, chips, tooltips */
.icon { flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; line-height: 1.5;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 0;
  vertical-align: 1px;
}
.badge--warn { background: var(--warn-wash); color: var(--warn-ink); }
.badge--pending { background: var(--accent-wash); color: var(--link); }
.badge--ok { background: var(--good-wash); color: var(--good); }
button.badge { cursor: help; font-family: inherit; }
a.badge { text-decoration: none; }
a.badge:hover { text-decoration: underline; text-underline-offset: 2px; }

.tip { position: relative; }
/* tooltip is out of layout until shown, so it can never widen the page */
.tip::after {
  content: attr(data-tip);
  display: none;
  position: absolute;
  left: 50%; bottom: calc(100% + 6px);
  transform: translateX(-50%);
  z-index: 20;
  width: max-content;
  max-width: min(240px, 70vw);
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--toast-bg); color: var(--toast-ink);
  font-size: 12px; font-weight: 500; line-height: 1.3;
  white-space: normal;
  text-align: left;
  pointer-events: none;
}
.tip:hover::after, .tip:focus-visible::after, .tip:focus::after { display: block; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 6px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 14px; line-height: 1.35;
  text-align: left;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--ink); background: var(--accent-wash); }

.spinner {
  display: inline-block; flex: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--rule-strong);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
  vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; min-width: 0; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
table.data th {
  text-align: left;
  font-size: 13px; font-weight: 600;
  color: var(--ink-2);
  padding: 8px 10px;
  border-bottom: 1px solid var(--rule-strong);
  white-space: nowrap;
  vertical-align: bottom;
}
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.data th:first-child, table.data td:first-child { padding-left: 0; }
table.data th:last-child, table.data td:last-child { padding-right: 0; }
table.data .r { text-align: right; white-space: nowrap; }
table.data tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
table.data tr.is-off td { color: var(--ink-3); }
table.data tr.is-today td:first-child { font-weight: 650; }
table.data tfoot td { font-weight: 650; border-top: 1px solid var(--rule-strong); border-bottom: 0; }
.data--auto { width: auto; min-width: min(100%, 22rem); }
table.data caption { text-align: left; color: var(--ink-3); font-size: 13px; padding-bottom: 6px; }

/* ------------------------------------------------------------------ toasts */
.toasts {
  position: fixed; z-index: 60;
  left: var(--gutter); right: var(--gutter);
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: grid; gap: 8px; justify-items: center;
  pointer-events: none;
}
@media (min-width: 720px) {
  .toasts { left: auto; right: 24px; bottom: 24px; width: 400px; justify-items: end; }
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  max-width: 100%;
  padding: 10px 8px 10px 14px;
  border-radius: 10px;
  background: var(--toast-bg); color: var(--toast-ink);
  font-size: 14px; line-height: 1.4;
  box-shadow: 0 8px 28px rgba(9, 14, 22, .22);
  animation: toast-in .18s ease-out;
}
.toast__icon { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.toast--error .toast__icon { color: #f07a7a; }
.toast--ok .toast__icon { color: #3ccf3c; }
@media (prefers-color-scheme: dark) {
  .toast--error .toast__icon { color: #b42828; }
  .toast--ok .toast__icon { color: #006300; }
}
.toast__msg { flex: 1; min-width: 0; overflow-wrap: anywhere; padding-top: 1px; }
.toast__close {
  flex: none; width: 28px; height: 28px; margin: -4px 0 -4px 4px;
  display: grid; place-items: center;
  border: 0; border-radius: 6px; background: transparent; color: inherit; opacity: .7; cursor: pointer;
}
.toast__close:hover { opacity: 1; }
.toast svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ login */
.auth { min-height: 100vh; display: grid; place-items: center; align-content: center; padding: 32px var(--gutter); }
.auth__card { width: min(100%, 380px); padding: 24px; }
.auth__brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth__title { font-size: 21px; font-weight: 650; line-height: 1.2; }
.auth__sub { color: var(--ink-3); font-size: 14px; }

/* ------------------------------------------------------------------ today: header */
.today { display: grid; gap: 20px; min-width: 0; }
.daynav { align-items: center; }
.daynav__label { display: flex; align-items: baseline; gap: 6px 14px; flex-wrap: wrap; min-width: 0; }
.daynav__date { color: var(--ink-2); font-size: 18px; }
.daynav__controls { display: flex; align-items: center; gap: 6px; }

.today__top { display: grid; gap: 16px; min-width: 0; }
@media (min-width: 960px) {
  .today__top { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); align-items: stretch; gap: 20px; }
  .today__top .recorder { align-content: center; }
  .today__top .tiles { align-content: start; }
}

/* ------------------------------------------------------------------ today: recorder (the hero control) */
.recorder { display: grid; gap: 18px; }
.recorder__main { display: flex; align-items: center; gap: 20px; min-width: 0; }
.mic {
  position: relative;
  flex: none;
  width: 88px; height: 88px;
  border-radius: 50%;
  border: 0;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  transition: background-color .15s, transform .1s;
}
.mic:hover { background: var(--accent-hover); }
.mic:active { transform: scale(.97); }
.mic:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 50%; }
.mic__glyph { width: 38px; height: 38px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.mic__glyph .fill { fill: currentColor; stroke: none; }
.mic__glyph--stop { display: none; }
.mic[aria-pressed="true"] { background: var(--rec); color: #fff; }
.mic[aria-pressed="true"] .mic__glyph--mic { display: none; }
.mic[aria-pressed="true"] .mic__glyph--stop { display: block; }
.mic[aria-pressed="true"]::after {
  content: "";
  position: absolute; inset: -7px;
  border-radius: 50%;
  border: 3px solid var(--rec);
  animation: rec-pulse 1.5s ease-out infinite;
  pointer-events: none;
}
.mic:disabled { opacity: .5; cursor: default; }
.mic.is-busy::after {
  content: "";
  position: absolute; inset: -6px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
@keyframes rec-pulse {
  0% { transform: scale(.94); opacity: .85; }
  100% { transform: scale(1.22); opacity: 0; }
}
.recorder__copy { min-width: 0; display: grid; gap: 4px; }
.recorder__title { font-size: 21px; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
.recorder__hint { color: var(--ink-2); font-size: 15px; }
.recorder__timer {
  font-size: 28px; font-weight: 600; line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--rec);
}
@media (max-width: 719px) {
  .mic { width: 76px; height: 76px; }
  .mic__glyph { width: 34px; height: 34px; }
  .recorder__main { gap: 16px; }
  .recorder__title { font-size: 19px; }
}

/* job progress + result inside the recorder card */
.job { border-top: 1px solid var(--rule); padding-top: 16px; display: grid; gap: 12px; min-width: 0; }
.job__status { display: flex; align-items: center; gap: 10px; font-weight: 550; }
.job__status--error { color: var(--danger); }
.job__status--done { color: var(--good); }
.job__transcript {
  padding: 2px 0 2px 12px;
  border-left: 2px solid var(--rule-strong);
  color: var(--ink-2);
  font-size: 15px;
}
.job__message { font-weight: 550; }
.job__meals { list-style: none; display: grid; gap: 10px; }
.job-meal { border: 1px solid var(--rule); border-radius: var(--r-ctl); padding: 12px; display: grid; gap: 8px; min-width: 0; }
.job-meal__head { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 12px; flex-wrap: wrap; }
.job-meal__title { font-weight: 650; }
.job-meal__totals { font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.job-meal__entries { list-style: none; display: grid; gap: 4px; font-size: 14px; }
.job-meal__entries li { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.job-meal__entries .nm { min-width: 0; overflow-wrap: anywhere; }
.job-meal__entries .q { flex: none; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.job__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ today: stat tiles */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; min-width: 0; }
@media (min-width: 720px) and (max-width: 959px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tiles__hint { grid-column: 1 / -1; font-size: 14px; color: var(--ink-3); }
.tile {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-card);
  padding: 14px 16px 12px;
  display: grid; gap: 4px; align-content: start;
  min-width: 0;
}
.tile--kcal { --key: var(--s-kcal); }
.tile--protein { --key: var(--s-protein); }
.tile--fat { --key: var(--s-fat); }
.tile--carb { --key: var(--s-carb); }
.tile__label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); font-weight: 550; }
.tile__value { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 6px; min-width: 0; }
.tile__num { font-size: 30px; font-weight: 650; line-height: 1.15; letter-spacing: -.02em; }
.tile__of { font-size: 14px; color: var(--ink-3); }
.tile__note { font-size: 13px; color: var(--ink-3); min-height: 1.4em; }
.meter {
  height: 4px; margin-top: 8px;
  border-radius: 2px;
  background: var(--rule);
  background: color-mix(in srgb, var(--key) 20%, transparent);
  overflow: hidden;
}
.meter__fill { height: 100%; width: 0; border-radius: 2px; background: var(--key); transition: width .35s ease-out; }
@media (max-width: 719px) {
  .tile { padding: 12px 14px 10px; }
  .tile__num { font-size: 26px; }
}

/* legend keys mirror the mark: dot, bar (rect), line, dashed reference */
.key { display: inline-block; flex: none; background: var(--key, var(--ink-3)); }
.key--dot { width: 9px; height: 9px; border-radius: 50%; }
.key--bar { width: 12px; height: 12px; border-radius: 3px; }
.key--line { width: 18px; height: 2px; border-radius: 1px; }
.key--dash { width: 18px; height: 2px; background: repeating-linear-gradient(90deg, var(--key) 0 5px, transparent 5px 8px); }
.key--point { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface); }

/* ------------------------------------------------------------------ today: pending */
.pending { border-color: color-mix(in srgb, var(--accent) 35%, var(--rule)); }
.pending .card__head { margin-bottom: 6px; }
.pending__list { list-style: none; display: grid; }
.pending__item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px 16px; flex-wrap: wrap;
  padding: 12px 0;
  border-top: 1px solid var(--rule);
}
.pending__item:first-child { border-top: 0; }
.pending__main { min-width: 0; flex: 1 1 320px; display: grid; gap: 2px; }
.pending__title { font-weight: 650; }
.pending__title .muted { font-weight: 400; }
.pending__entries { color: var(--ink-2); font-size: 15px; overflow-wrap: anywhere; }
.pending__meta { color: var(--ink-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.pending__actions { display: flex; gap: 8px; flex: none; }

/* ------------------------------------------------------------------ today: the diary page */
.diary__page { padding: 0; overflow: hidden; }
.diary__page > .empty { padding: 20px; }
.meal {
  display: grid;
  grid-template-columns: var(--margin-w) minmax(0, 1fr);
  border-top: 1px solid var(--rule);
}
.meal:first-child { border-top: 0; }
.meal__margin {
  padding: 16px 10px 16px 8px;
  border-right: 2px solid var(--margin-rule);
  text-align: right;
}
.meal__time {
  display: block;
  font-size: 18px; font-weight: 650; line-height: 1.3;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.meal__body { padding: 14px 16px 16px; min-width: 0; display: grid; gap: 10px; }
@media (min-width: 720px) { .meal__body { padding: 16px 20px 18px; } }
.meal--pending .meal__margin { background: var(--accent-wash); }

/* rows share one column template so numbers align down the page */
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 36px;
  column-gap: 12px;
  align-items: baseline;
}
.row__end { display: flex; justify-content: flex-end; align-self: center; }
.nums {
  display: grid;
  grid-template-columns: 4.75rem 5.5rem repeat(3, 3.6rem);
  column-gap: 6px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  white-space: nowrap;
}
.n abbr { color: var(--ink-3); margin-right: 3px; font-size: 13px; }
.n--kcal { font-weight: 600; }
.n--kcal small { font-size: 13px; font-weight: 400; color: var(--ink-3); }

.meal__head .meal__name { display: flex; align-items: baseline; gap: 6px 10px; flex-wrap: wrap; min-width: 0; }
.meal__type { font-size: 17px; font-weight: 650; line-height: 1.3; }
.meal__head .nums { color: var(--ink); }
.meal__head .n--kcal { font-size: 16px; }

.entries { list-style: none; display: grid; border-top: 1px dashed var(--rule); }
.entry { padding: 8px 0; border-bottom: 1px dashed var(--rule); }
.entry__name { min-width: 0; display: grid; gap: 1px; }
.entry__title { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; min-width: 0; }
.entry__basis { font-size: 13px; color: var(--ink-3); overflow-wrap: anywhere; }
.entry .nums { color: var(--ink-2); }
.entry .n--kcal { color: var(--ink); }

/* click-to-edit values */
.editable {
  display: inline;
  padding: 1px 3px; margin: -1px -3px;
  border: 0; border-radius: 4px;
  background: transparent;
  color: inherit; font: inherit; text-align: inherit;
  cursor: text;
  overflow-wrap: anywhere;
  text-decoration: underline dotted var(--control);
  text-underline-offset: 4px;
}
.editable:hover { background: var(--accent-wash); text-decoration-color: var(--accent); }
.edit-input { min-height: 32px !important; padding: 4px 8px !important; font-size: 15px !important; }
.n--g .edit-input { width: 5.5rem; text-align: right; }
.entry__title .edit-input { max-width: 28rem; }

.meal__foot { display: grid; gap: 10px; }
.transcript summary {
  cursor: pointer; color: var(--ink-2); font-size: 14px; width: fit-content;
  list-style-position: inside;
}
.transcript summary:hover { color: var(--ink); }
.transcript p { margin-top: 6px; padding-left: 12px; border-left: 2px solid var(--rule-strong); color: var(--ink-2); font-size: 15px; }
.meal__note { font-size: 14px; color: var(--ink-2); }
.meal__tools { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.meal__tools .correct { flex: 1 1 280px; }
.meal__job { font-size: 14px; color: var(--ink-2); display: flex; gap: 8px; align-items: center; }
.meal__job--error { color: var(--danger); }

@media (max-width: 719px) {
  .row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "name end" "nums nums";
    row-gap: 2px;
  }
  .row > :first-child { grid-area: name; }
  .row > .nums { grid-area: nums; }
  .row > .row__end { grid-area: end; align-self: start; }
  .nums {
    display: flex; flex-wrap: wrap;
    gap: 2px 12px;
    text-align: left;
    font-size: 14px;
  }
  .nums .n:empty { display: none; }
  .meal__margin { padding: 14px 8px 14px 4px; }
  .meal__time { font-size: 16px; }
  .meal__head .n--kcal { font-size: 15px; }
}

/* ------------------------------------------------------------------ charts */
.chart-card { display: grid; gap: 10px; min-width: 0; }
.chart-card__head { display: grid; gap: 2px; }
.chart-card.is-loading .chart { opacity: .45; transition: opacity .2s; }
.chart { position: relative; width: 100%; height: 260px; min-width: 0; }
.chart--tall { height: 320px; }
.chart--short { height: 220px; }
@media (max-width: 719px) {
  .chart { height: 230px; }
  .chart--tall { height: 270px; }
  .chart--short { height: 200px; }
}
.chart-empty {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 16px;
  text-align: center;
  color: var(--ink-3);
  font-size: 14px;
  border: 1px dashed var(--rule-strong);
  border-radius: var(--r-ctl);
}
.legend {
  list-style: none;
  display: flex; flex-wrap: wrap; gap: 4px 16px;
  font-size: 13px; color: var(--ink-2);
}
.legend:empty { display: none; }
.legend li { display: inline-flex; align-items: center; gap: 7px; }
.twin summary { cursor: pointer; font-size: 14px; color: var(--ink-3); width: fit-content; }
.twin summary:hover { color: var(--ink); }
.twin[open] summary { margin-bottom: 8px; }
.twin .table-wrap { max-height: 360px; overflow-y: auto; }

/* Plotly: keep hover label text in system font, no modebar */
.js-plotly-plot .plotly .modebar { display: none !important; }

/* ------------------------------------------------------------------ markdown prose */
.prose { font-size: 16px; line-height: 1.6; max-width: 72ch; overflow-wrap: break-word; }
.prose > * + * { margin-top: .75em; }
.prose h2, .prose h3, .prose h4, .prose h5 { line-height: 1.3; font-weight: 650; margin-top: 1.4em; }
.prose h2 { font-size: 21px; }
.prose h3 { font-size: 18px; }
.prose h4, .prose h5 { font-size: 16px; }
.prose > :first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: .3em; }
.prose li > ul, .prose li > ol { margin-top: .3em; }
.prose blockquote { padding-left: 12px; border-left: 2px solid var(--rule-strong); color: var(--ink-2); }
.prose code { font-family: var(--font-mono); font-size: .88em; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
.prose pre { background: var(--surface-2); padding: 12px 14px; border-radius: var(--r-ctl); overflow-x: auto; }
.prose pre code { background: none; padding: 0; font-size: 13px; }
.prose hr { border: 0; border-top: 1px solid var(--rule); }
.prose table { border-collapse: collapse; font-size: 14px; display: block; overflow-x: auto; max-width: 100%; }
.prose th, .prose td { padding: 6px 10px; border-bottom: 1px solid var(--rule); text-align: left; }
.prose th { border-bottom-color: var(--rule-strong); }
.prose th.r, .prose td.r { text-align: right; font-variant-numeric: tabular-nums; }
.prose th.c, .prose td.c { text-align: center; }
.prose strong { font-weight: 650; }

/* ------------------------------------------------------------------ reviews */
.review { display: grid; gap: 14px; }
.review__head { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 16px; flex-wrap: wrap; }
.review__title { font-size: 19px; font-weight: 650; line-height: 1.3; }
.review__meta { font-size: 13px; color: var(--ink-3); }
details.review > summary { cursor: pointer; list-style: none; }
details.review > summary::-webkit-details-marker { display: none; }
details.review > summary .review__title::before {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 10px;
  border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3);
  transform: rotate(-45deg); vertical-align: 2px; transition: transform .15s;
}
details.review[open] > summary .review__title::before { transform: rotate(45deg); vertical-align: 4px; }

/* ------------------------------------------------------------------ ask */
.answer { display: grid; gap: 16px; }
.answer__sql summary, .answer__rows summary { cursor: pointer; color: var(--ink-2); font-size: 14px; width: fit-content; }
.answer pre.sql {
  margin-top: 8px;
  font-family: var(--font-mono); font-size: 13px; line-height: 1.5;
  background: var(--surface-2);
  padding: 12px 14px;
  border-radius: var(--r-ctl);
  overflow-x: auto;
  white-space: pre;
}
.answer__thinking { display: flex; align-items: center; gap: 10px; color: var(--ink-2); }
.answer__rows { display: grid; gap: 8px; }

/* ------------------------------------------------------------------ «База продуктов» */
.add-mode { margin-bottom: 18px; }
@media (min-width: 720px) {
  .product-form.form-grid, .recipe-form .form-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .product-form .field--wide, .recipe-form .field--wide { grid-column: span 2; }
}
@media (max-width: 719px) {
  .form-grid .field--narrow-full { grid-column: 1 / -1; }
}
.add-panel .card__head { flex-wrap: nowrap; }
.barcode-row { max-width: 440px; }
.barcode-row input { font-variant-numeric: tabular-nums; }
.kcal-check { font-size: 14px; color: var(--ink-3); }
.kcal-check.is-warn { padding: 8px 12px; border-radius: var(--r-ctl); background: var(--warn-wash); color: var(--warn-ink); }

/* where the numbers come from: one tile per source, also a filter */
.sources { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .sources { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .sources { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); } }
.source-tile {
  display: grid; align-content: start; gap: 2px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: var(--r-ctl);
  background: var(--surface);
  color: var(--ink);
  font: inherit; text-align: left;
  cursor: pointer;
  transition: background-color .12s, border-color .12s;
}
.source-tile:hover { border-color: var(--accent); background: var(--accent-wash); }
.source-tile[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-wash); box-shadow: inset 0 0 0 1px var(--accent); }
.source-tile--warn { border-color: transparent; background: var(--warn-wash); }
.source-tile--warn .source-tile__name, .source-tile--warn .source-tile__text { color: var(--warn-ink); }
.source-tile__count { font-size: 24px; line-height: 1.2; font-weight: 650; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.source-tile__name { font-size: 14px; font-weight: 600; }
.source-tile__text { font-size: 13px; line-height: 1.35; color: var(--ink-3); }
.sources__total { margin-top: 12px; }
@media (max-width: 519px) {
  .source-tile { padding: 10px 12px; }
  .source-tile__count { font-size: 20px; }
  .source-tile__text { display: none; }
}

.food-toolbar { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 12px; }
.food-toolbar__q { grid-column: 1 / -1; }
@media (min-width: 880px) {
  .food-toolbar { grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)); }
  .food-toolbar__q { grid-column: auto; }
}
.food-toolbar select:disabled { opacity: .55; cursor: default; }
@media (max-width: 519px) {
  .food-toolbar select { padding-left: 10px; padding-right: 26px; font-size: 15px; }
}
.food-status { margin-bottom: 4px; }
.list-more { display: flex; justify-content: center; }
.list-more .btn { margin-top: 14px; }
.empty-state { display: grid; gap: 12px; justify-items: start; padding: 8px 0; color: var(--ink-2); }

.foods-table .food-row { cursor: pointer; }
.foods-table .food-name { min-width: 14rem; overflow-wrap: anywhere; }
.food-toggle {
  margin: 0; padding: 0; border: 0; background: none;
  font: inherit; font-weight: 600; color: var(--ink);
  text-align: left; cursor: pointer;
}
.food-toggle::before {
  content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 9px;
  border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3);
  transform: rotate(-45deg); vertical-align: 2px; transition: transform .15s;
}
.food-toggle[aria-expanded="true"]::before { transform: rotate(45deg); vertical-align: 4px; }
.food-row:hover .food-toggle { color: var(--link); }
.foods-table .food-sub { display: block; padding-left: 18px; font-size: 13px; font-weight: 400; color: var(--ink-3); }
.food-sub--warn { color: var(--warn-ink); }
.food-matched { color: var(--ink-2); }
.food-macros { padding-left: 18px; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.foods-table .food-row.is-open td { background: var(--accent-wash); border-bottom-color: transparent; }
.foods-table tbody tr.food-details-row:hover td { background: transparent; }
.food-details-row > td { padding: 0 0 18px; cursor: auto; }
.only-narrow { display: none; }
@media (max-width: 719px) {
  .foods-table thead, .foods-table .col-num, .foods-table .col-src { display: none; }
  .foods-table .food-name { min-width: 0; padding-right: 0; }
  .only-narrow { display: inline; }
  .food-macros.only-narrow { display: block; }
}

/* an opened food */
.food-panel {
  display: grid; gap: 18px;
  padding: 16px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-card);
  background: var(--surface);
}
@media (min-width: 720px) { .food-panel { padding: 18px 20px; } }
.food-panel__cols { display: grid; gap: 18px; }
@media (min-width: 720px) { .food-panel__cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; } }
.food-panel__sec { display: grid; gap: 8px; align-content: start; min-width: 0; }
.food-panel__h { font-size: 13px; font-weight: 650; letter-spacing: .03em; text-transform: uppercase; color: var(--ink-2); }
.food-panel--edit .food-panel__h { text-transform: none; letter-spacing: 0; font-size: 16px; color: var(--ink); }
.food-panel__actions { padding-top: 14px; border-top: 1px solid var(--rule); }
.nutri-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin: 0; }
.nutri-list > div { padding: 6px 10px; border-radius: var(--r-ctl); background: var(--surface-2); }
.nutri-list dt { font-size: 12px; color: var(--ink-3); }
.nutri-list dd { margin: 0; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }

.alias-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.alias-chip {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px 3px 2px 10px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  font-size: 14px; line-height: 1.4;
}
.alias-chip--user { background: var(--accent-wash); }
.alias-chip__remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--ink-3);
  cursor: pointer;
}
.alias-chip__remove:hover, .alias-chip__remove:focus-visible { background: var(--danger-wash); color: var(--danger); }
@media (pointer: coarse) { .alias-chip__remove { width: 32px; height: 32px; } }
.alias-form { max-width: 460px; }

/* «Блюдо по рецепту» */
.recipe-form { display: grid; gap: 18px; }
.recipe-ingredients { display: grid; gap: 10px; min-width: 0; margin: 0; padding: 0; border: 0; }
.recipe-ingredients > legend { margin-bottom: 8px; }
.combo { display: grid; gap: 6px; }
.combo__row { display: grid; grid-template-columns: minmax(0, 1fr) 6.5rem auto; gap: 8px; }
@media (max-width: 519px) {
  .combo__row { grid-template-columns: minmax(0, 1fr) auto; }
  .combo__input { grid-column: 1 / -1; }
}
.combo__input { position: relative; min-width: 0; }
.combo__list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  max-height: 320px; overflow-y: auto;
  margin: 0; padding: 4px; list-style: none;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-ctl);
  box-shadow: 0 10px 28px rgba(16, 24, 40, .14);
}
.combo__option {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 8px 10px; border-radius: 6px;
  font-size: 15px; cursor: pointer;
}
.combo__option[aria-selected="true"], .combo__option:hover { background: var(--accent-wash); }
.combo__name { min-width: 0; overflow-wrap: anywhere; }
.combo__meta { flex: none; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.combo__empty { padding: 8px 10px; font-size: 14px; color: var(--ink-3); }
.recipe-table td { vertical-align: middle; }
.food-panel table.recipe-table { width: auto; min-width: min(100%, 26rem); }
.recipe-items__name { overflow-wrap: anywhere; }
.recipe-items__name .food-sub { display: block; font-size: 13px; color: var(--ink-3); }
.recipe-items__name .food-sub--warn { color: var(--warn-ink); }
.recipe-items__grams input { width: 6rem; min-height: 34px; padding: 4px 8px; font-size: 14px; text-align: right; }
.recipe-preview { display: grid; gap: 10px; padding: 14px 16px; border-radius: var(--r-ctl); background: var(--surface-2); }
.recipe-preview__title { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.nutri-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.nutri-tile { display: grid; padding: 8px 10px; border-radius: var(--r-ctl); background: var(--surface); min-width: 0; }
.nutri-tile__label { font-size: 12px; color: var(--ink-3); }
.nutri-tile__value { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
@media (max-width: 419px) { .nutri-tile__value { font-size: 17px; } }

/* ------------------------------------------------------------------ settings */
.kv { display: grid; gap: 0; font-size: 15px; }
.kv > div {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--rule);
}
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 719px) {
  .kv > div { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .kv dt { font-size: 13px; color: var(--ink-3); }
}
.targets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.target {
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: var(--r-ctl);
  display: grid; gap: 2px;
}
.target__label { font-size: 13px; color: var(--ink-2); }
.target__value { font-size: 24px; font-weight: 650; line-height: 1.2; letter-spacing: -.01em; }
.target__value small { font-size: 14px; font-weight: 400; color: var(--ink-3); }
.target__note { font-size: 12px; color: var(--ink-3); }
.pairing__body { display: grid; gap: 14px; justify-items: start; }
.qr {
  width: min(100%, 248px);
  aspect-ratio: 1;
  padding: 12px;
  background: #ffffff;
  border-radius: var(--r-ctl);
  border: 1px solid var(--rule);
}
.qr svg { width: 100%; height: 100%; }
.deeplink { width: 100%; }
.deeplink summary { cursor: pointer; font-size: 14px; color: var(--ink-2); width: fit-content; }
.deeplink code {
  display: block; margin-top: 8px;
  font-family: var(--font-mono); font-size: 13px;
  padding: 10px 12px; background: var(--surface-2); border-radius: var(--r-ctl);
  overflow-wrap: anywhere; user-select: all;
}

/* ------------------------------------------------------------------ «Обзоры»: prompt for a chat app */
.segmented--wrap { flex-wrap: wrap; }
.chat-dates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 420px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chat-text {
  font-family: var(--font-mono); font-size: 13px; line-height: 1.5;
  min-height: 280px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.disclosure > summary { cursor: pointer; font-size: 15px; font-weight: 550; color: var(--ink-2); width: fit-content; }
.disclosure > summary:hover { color: var(--ink); }
.disclosure[open] > summary { margin-bottom: 12px; }
.review__actions { margin-top: 8px; }

/* ------------------------------------------------------------------ motion, contrast modes */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; animation-iteration-count: 1 !important; }
  .mic[aria-pressed="true"]::after { animation: none; opacity: .5; transform: scale(1.08); }
  .spinner, .mic.is-busy::after { animation: spin 1.6s linear infinite !important; animation-duration: 1.6s !important; animation-iteration-count: infinite !important; }
}
@media (forced-colors: active) {
  .meter { border: 1px solid CanvasText; }
  .meter__fill { background: Highlight; }
  .mic { border: 2px solid ButtonText; }
  .key { forced-color-adjust: none; }
}
@media print {
  body { background: #fff; }
  .topbar, .recorder, .toasts, .meal__tools, .row__end { display: none !important; }
  .card { border-color: #ccc; }
}
