:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f0f0f3;
  --seg: #e8e8ed;
  --text: #1d1d1f;
  --text-2: #3a3a3c;
  --muted: #6e6e73;
  --line: #e5e5ea;
  --line-strong: #d1d1d6;
  --accent: #2e7d4f;
  --accent-strong: #256b43;
  --accent-soft: #e8f3ec;
  --on-accent: #ffffff;
  --buy: #b25000;
  --buy-soft: #fff1e6;
  --over: #b23c0a;
  --over-bar: #d9541a;
  --over-soft: #fce6d8;
  --danger: #b3261e;
  --danger-soft: #fbe5e3;
  --pin: #6b3fa0;
  --pin-soft: #efe6fa;
  --ink: #1d1d1f;
  --ink-2: #2c2c2e;
  --ink-line: #3a3a3c;
  --ink-text: #ffffff;
  --ink-muted: #b9c7be;
  --ink-label: #9fb7a8;
  --protein: #1e6b45;
  --fat: #e9a23b;
  --carb: #6f9ae0;
  --fiber: #b9824c;
  --radius: 16px;
  --font-display: -apple-system, "SF Pro Display", "Inter", system-ui, sans-serif;
  --shadow: none;
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .04), 0 16px 40px rgba(0, 0, 0, .10);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --seg: #2c2c2e;
    --text: #f5f5f7;
    --text-2: #d1d1d6;
    --muted: #98989d;
    --line: #38383a;
    --line-strong: #48484a;
    --accent: #4cc38a;
    --accent-strong: #7fd9aa;
    --accent-soft: #1d3328;
    --on-accent: #0f1512;
    --buy: #f2b565;
    --buy-soft: #3a2a14;
    --over: #f29a5c;
    --over-bar: #f29a5c;
    --over-soft: #3a2418;
    --danger: #f28b82;
    --danger-soft: #3d2120;
    --pin: #c9a8f0;
    --pin-soft: #2e2340;
    --ink: #f5f5f7;
    --ink-2: #2c2c2e;
    --ink-line: #34463b;
    --protein: #5cc792;
    --fat: #e8b04a;
    --carb: #8fb3e8;
    --fiber: #dba574;
    --shadow: none;
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, .5);
    --ink-text: #000000;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, "SF Pro Text", "Inter", system-ui, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

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

/* ---------- Верхня панель ---------- */

.topbar { border-bottom: 1px solid var(--line); }
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--accent);
  display: grid;
  place-items: center;
}
.brand-mark svg { width: 20px; height: 20px; fill: none; stroke: var(--on-accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; letter-spacing: -.01em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ---------- Головний блок ---------- */

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 40px 0 28px;
}
.hero-text { flex: 1 1 420px; display: flex; flex-direction: column; gap: 10px; }
.hero-date { margin: 0; font-size: .85rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; min-height: 1.2em; }
.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.6vw, 3.25rem);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.05;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 6px 6px 6px 18px;
  transition: border-color .2s;
  text-align: left;
}
.search:focus-within { border-color: var(--accent); }
.search-icon { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex: none; }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  font-size: 1rem;
  outline: none;
}
.search input::placeholder { color: var(--muted); }
.search-add {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: transform .15s;
}
.search-add:hover { transform: scale(1.06); }

.suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 10;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
}
.suggestions li {
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.suggestions li small { color: var(--muted); }
.suggestions li[aria-selected="true"] { background: var(--surface-2); }

.receipt-btn {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  padding: 10px 14px;
  border-radius: 999px;
}
.receipt-btn:hover { background: var(--accent-soft); }
.receipt-btn svg, .dropzone svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }

/* Кнопка холодильника і вибрані продукти на головній */
.fridge-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 14px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s;
}
.fridge-btn:hover { border-color: var(--accent); }
.fridge-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.count-badge {
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: .82rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Холодильник на головній — головна дія сайту */
.hero-sub { margin: 4px 0 0; max-width: 34ch; color: var(--muted); font-size: 1.05rem; line-height: 1.45; }
.fridge-panel {
  flex: 1 1 380px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  min-width: 0;
}
.fridge-panel.empty { border: 2px dashed var(--accent); background: var(--accent-soft); }
.fridge-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.fridge-panel-label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.fridge-panel-title { display: block; font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; }
.hero-fridge-btn {
  height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.hero-fridge-btn:hover { background: var(--accent-strong); }
.fridge-panel:not(.empty) .hero-fridge-btn { background: var(--accent-soft); color: var(--accent-strong); }
.fridge-panel:not(.empty) .hero-fridge-btn:hover { background: var(--seg); }
.fridge-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  color: inherit;
}
.fridge-preview[hidden], .dashboard[hidden], .selection[hidden] { display: none; }
.preview-chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--seg);
  font-size: .9rem;
  font-weight: 600;
}
.preview-chip.selected { background: var(--accent); color: var(--on-accent); }
.preview-chip.more { background: transparent; color: var(--muted); border: 1px dashed var(--line-strong); }
.group-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  margin-left: 6px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: .9rem;
  vertical-align: 3px;
}

.selection { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; max-width: 100%; }
.selection .segmented button { height: 40px; padding: 0 16px; }
.selection .segmented button:disabled { opacity: .4; cursor: default; }
.selected-chips:empty { display: none; }
.selection .chips { justify-content: flex-start; }
.selection .hint { margin: 0; }
.selection .text-btn { margin: 0; text-decoration: underline; }
.chip.selected { background: var(--accent-soft); border-color: transparent; color: var(--accent-strong); }

/* Вікно холодильника */
.fridge-search { margin-top: 20px; }
#fridge-dialog .receipt-btn { margin-top: 8px; }
#fridge-dialog .quick { margin-top: 12px; text-align: center; }
.fridge-list { margin-top: 20px; }
.fridge-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.fridge-title { font-weight: 700; }
.fridge-title span { color: var(--muted); font-weight: 600; margin-left: 4px; }
.fridge-list .text-btn { margin: 0; }
.fridge-chips { justify-content: flex-start; }
.fridge-chips .chip { background: var(--surface-2); border-color: transparent; }
.fridge-chips .chip.unknown { background: var(--danger-soft); }
.fridge-chips .chip.selected { background: var(--accent-soft); border-color: var(--accent); }
.chip .chip-main {
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  background: none;
  padding: 0 4px 0 0;
  font: inherit;
  font-size: inherit;
  color: inherit;
  white-space: nowrap;
  cursor: pointer;
}
.chip .chip-main:hover { background: none; }
.chip:has(.chip-main) { padding-left: 14px; }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 34px;
  padding: 4px 6px 4px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  font-weight: 600;
  font-size: .9rem;
  animation: pop .18s ease-out;
}
.chip.unknown { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.chip button {
  border: 0;
  background: transparent;
  cursor: pointer;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
}
.chip button:hover { background: var(--surface-2); color: var(--text); }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }

.text-btn {
  margin-top: 12px;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  padding: 6px 8px;
}
.text-btn:hover { color: var(--text); }

.quick { margin-top: 20px; }
.quick-label { display: block; color: var(--muted); font-size: .85rem; margin-bottom: 10px; }
.quick-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.quick-chips button {
  border: 1px dashed var(--line-strong);
  background: transparent;
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: .9rem;
  color: var(--muted);
}
.quick-chips button:hover { border-style: solid; color: var(--text); background: var(--surface); }

.editor-ing-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 22px 0 8px; }
.editor-ing-head h3 { margin: 0; }
.editor-ing-head .reset-draft { margin: 0; padding: 6px 0; color: var(--accent); font-weight: 700; }
.editor-ing-head .reset-draft[hidden] { display: none; }

/* Інгредієнти з холодильника у формі рецепта та у вікні зарахування */
.fridge-pick { margin: 4px 0 12px; }
.fridge-pick-label { display: block; color: var(--muted); font-size: .82rem; font-weight: 600; margin-bottom: 8px; }
.fridge-pick-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fridge-pick-chips button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
}
.fridge-pick-chips button:hover { border-color: var(--accent); color: var(--accent-strong); background: var(--accent-soft); }
.fridge-pick-empty { margin: 4px 0 12px; font-size: .85rem; }

/* ---------- Результати ---------- */

.results { padding-bottom: 40px; }

.dashboard { display: flex; flex-wrap: wrap; gap: 20px; align-items: stretch; }
#plan-summary { flex: 999 1 560px; min-width: 0; }
#eaten-today { flex: 1 1 320px; min-width: 0; }
#plan-summary .plan { max-width: none; height: 100%; }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 16px;
}
.dashboard { margin-bottom: 20px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.segmented {
  display: inline-flex;
  padding: 4px;
  background: var(--seg);
  border-radius: 999px;
  overflow-x: auto;
  max-width: 100%;
}
.segmented button {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
  color: var(--text-2);
  white-space: nowrap;
}
.segmented button[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(21, 32, 26, .12);
}
.segmented.big button { height: 44px; padding: 0 20px; font-size: .95rem; }
.segmented.big button[aria-selected="true"] { background: var(--ink); color: var(--ink-text); box-shadow: none; }

.sort select {
  appearance: none;
  border: 0;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235b675f' stroke-width='3'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 4px center;
  padding: 10px 24px 10px 8px;
  font-weight: 600;
  font-size: .9rem;
  color: var(--muted);
  cursor: pointer;
}
.sort select option { background: var(--surface); color: var(--text); }
.toolbar .collection { margin-left: auto; }
.toolbar .collection + .sort { margin-left: -8px; }

.group-title { margin: 36px 0 4px; font-size: 1.3rem; font-weight: 700; letter-spacing: -.01em; }
.group-note { margin: 0 0 16px; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }

.card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 200px;
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card-main {
  flex: 1;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 20px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card-main:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* кругла кнопка-галочка «з'їдено» в правому верхньому куті картки та в пошуку */
.card-log, .eaten-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  transition: transform .15s;
}
.card-log { position: absolute; top: 14px; right: 14px; }
/* на картці галочка й сердечко однакові за розміром і формою, галочка — м'якого кольору, щоб не переважувала */
.card .card-log { width: 38px; height: 38px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-strong); font-size: 1.05rem; }
.card .card-log:hover { background: var(--accent); color: var(--on-accent); transform: none; }
.card-log:hover, .eaten-btn:hover { transform: scale(1.08); }
.card .tag { max-width: calc(100% - 48px); }

.tag {
  align-self: flex-start;
  font-size: .8rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}
.tag.ok { background: var(--accent-soft); color: var(--accent-strong); }
.tag.buy { background: var(--buy-soft); color: var(--buy); }

.card h3 { margin: 0; font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; }
.card .meta { margin-top: 6px; }
.meta { color: var(--muted); font-size: .85rem; }

.card-stats { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.stat-big { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; line-height: 1; color: var(--accent); }
.stat-big small, .stat small { display: block; font-size: .75rem; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-top: 4px; }
.stat { text-align: right; font-weight: 700; line-height: 1; }

.more-btn {
  display: inline-flex;
  align-items: center;
  margin: 24px auto 0;
  height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--ink-text);
  cursor: pointer;
  font-weight: 600;
}
.results > .more-btn, .plan > .more-btn { display: flex; width: fit-content; }
.more-btn:hover { box-shadow: var(--shadow-lg); }

.empty-state { margin: 36px 0 0; text-align: center; color: var(--muted); }

.footer { padding: 24px 0 40px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }

/* ---------- Картка рецепта ---------- */

.sheet {
  width: min(560px, calc(100% - 32px));
  max-height: calc(100% - 48px);
  padding: 0;
  border: 0;
  border-radius: 28px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.sheet::backdrop { background: rgba(15, 21, 18, .45); backdrop-filter: blur(4px); }
/* прокрутка вікна не передається сторінці під ним */
.sheet { overscroll-behavior: contain; }
/* поки відкрите вікно, сторінка під ним не прокручується (app.js фіксує її на місці) */
body.scroll-locked { position: fixed; left: 0; right: 0; overflow: hidden; }
.sheet[open] { animation: rise .25s ease-out; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }

.sheet-inner { padding: 28px; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.sheet h2 { margin: 0; font-family: var(--font-display); font-size: 1.4rem; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
.close-btn {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
}
.close-btn:focus { outline: none; }
.close-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.macro-tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 24px 0 12px; }
.tile { background: var(--surface-2); border-radius: 14px; padding: 10px 4px; text-align: center; }
.tile:first-child { background: var(--ink); color: var(--ink-text); }
.tile:first-child span { color: var(--ink-muted); }
.tile b { display: block; font-size: 1.15rem; font-weight: 700; }
.tile span { font-size: .72rem; color: var(--muted); font-weight: 600; }
.tile.protein b { color: var(--accent); }

.bar { display: flex; gap: 2px; height: 10px; border-radius: 99px; overflow: hidden; background: var(--line); }
.bar span { display: block; height: 100%; }
.bar .p { background: var(--protein); }
.bar .f { background: var(--fat); }
.bar .c { background: var(--carb); }
.bar-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: .78rem; color: var(--text-2); }
.bar-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

.sheet h3 { margin: 28px 0 10px; font-size: 1rem; font-weight: 700; }
.ing-list { list-style: none; margin: 0; padding: 0; }
.ing-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ing-list li:last-child { border-bottom: 0; }
.ing-list .mark { display: inline-block; width: 22px; font-weight: 700; }
.ing-list .have .mark { color: var(--accent); }
.ing-list .missing { color: var(--buy); font-weight: 600; }
.ing-list .optional { color: var(--muted); }
.ing-list .grams { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ing-list .swappable { cursor: pointer; }
.ing-list .swappable:hover { background: var(--surface-2); }
.ing-list .swappable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ing-add {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin: 0 4px 0 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--buy-soft);
  color: var(--buy);
  font-weight: 800;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  vertical-align: 1px;
}
.ing-list .optional .ing-add { background: var(--surface-2); color: var(--muted); }
.ing-add:hover { background: var(--accent); color: var(--on-accent); }
.ing-list .mark:has(.ing-add) { width: auto; }
.swap-icon { margin-left: 10px; color: var(--muted); font-weight: 700; }
.swap-badge { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--pin-soft); color: var(--pin); font-size: .72rem; font-weight: 700; vertical-align: 2px; }
.swap-hint { margin: -4px 0 10px; }
.swap-hint .text-btn { padding: 0; margin: 0; font-size: inherit; text-decoration: underline; }
.ing-list li.swap-panel { display: flex; flex-direction: column; align-items: stretch; gap: 10px; padding: 14px; margin: 6px 0 10px; border: 1px solid var(--line-strong); border-radius: 16px; background: var(--surface-2); cursor: default; }
.swap-panel .fridge-pick { margin: 0; }
.swap-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.swap-actions .receipt-btn { margin: 0; }

.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; position: relative; padding: 0 0 14px 40px; }
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -1px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--ink-text);
  font-weight: 700;
  font-size: .82rem;
  display: grid;
  place-items: center;
}

/* ---------- Пошук страви ---------- */

.dish-search {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 320px;
  max-width: 520px;
  height: 48px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
}
.dish-search:focus-within { border-color: var(--accent); }
.dish-search input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 10px 0; outline: none; }
.dish-search input::placeholder { color: var(--muted); }

.search-results {
  max-width: 720px;
  margin: 0 0 20px auto;
  padding: 8px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.search-results > .meta { padding: 10px; margin: 0; }
.search-item { padding: 10px; border-bottom: 1px solid var(--line); }
.search-item:last-child { border-bottom: 0; }
.search-item-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  border: 0;
  background: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
}
.search-item-main:hover b { color: var(--accent); }
.search-item-main .tag { margin-top: 4px; }

.slot-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.slot-btn {
  border: 1px dashed var(--line-strong);
  background: transparent;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.slot-btn.own { border-style: solid; color: var(--text); }
.slot-btn:hover { border-color: var(--accent); color: var(--accent); }
.slot-btn.active { background: var(--accent); border-color: var(--accent); border-style: solid; color: var(--on-accent); }

.pin-badge {
  font-size: .75rem;
  font-weight: 700;
  color: var(--pin);
  background: var(--pin-soft);
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
}

/* ---------- Таблиця калорій «Твій день» ---------- */

.plan { max-width: none; }

.plan-summary {
  height: 100%;
  background: var(--surface);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 24px;
}
.panel-title { margin: 0; font-size: 1.25rem; font-weight: 700; }
.goals { font-size: .9rem; color: var(--muted); }
.goals-label { display: block; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.goal-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.goal-field { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; }
.goal-input { display: flex; align-items: center; gap: 6px; }
.goals input {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg);
  font-weight: 700;
  text-align: right;
}
.goals input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.norm { margin: 14px 0 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.norm summary { cursor: pointer; font-weight: 700; color: var(--accent); list-style: none; }
.norm summary::-webkit-details-marker { display: none; }
.norm summary::before { content: "＋ "; }
.norm[open] summary::before { content: "－ "; }
.norm-form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; font-size: .9rem; color: var(--muted); }
.norm-form .goal-fields { grid-template-columns: repeat(3, 1fr); }
.norm-form select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg);
  font-weight: 600;
}
.norm-form input[type="number"] {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg);
  font-weight: 700;
  text-align: right;
}
.norm-form input:focus, .norm-form select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.pill-group { display: flex; flex-wrap: wrap; gap: 6px; }
.pill-radio input { position: absolute; opacity: 0; pointer-events: none; }
.pill-radio span {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-weight: 600;
  font-size: .85rem;
  cursor: pointer;
}
.pill-radio input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.pill-radio input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.norm-result { background: var(--surface-2); border-radius: 14px; padding: 14px; }
.norm-values { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--text); }
.norm-values b { font-size: 1.2rem; }
.norm-result .primary-btn { margin-top: 10px; }
.norm-result .meta { margin: 0; }

.plan-modes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.plan-modes button {
  border: 1px solid var(--line-strong);
  background: transparent;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-2);
}
.plan-modes button:hover { color: var(--text); }
.plan-modes button[aria-checked="true"] { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }

.goal-rows { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 22px 20px; margin-top: 20px; }
.goal-row { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.goal-label { display: flex; align-items: center; gap: 6px; font-size: .88rem; font-weight: 600; color: var(--muted); }
.goal-value { font-size: .82rem; color: var(--muted); }
.goal-value b { font-family: var(--font-display); font-size: 1.85rem; font-weight: 600; letter-spacing: -.02em; color: var(--text); line-height: 1.1; }
.goal-bar { display: flex; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.goal-bar span { display: block; height: 100%; background: var(--accent); }
.goal-bar span.planned { opacity: .3; }
.goal-caption { font-size: .8rem; color: var(--muted); }
.over-badge { font-size: .72rem; font-weight: 700; color: var(--over); background: var(--over-soft); padding: 2px 7px; border-radius: 999px; }
.goal-row.plan-over .goal-bar span, .goal-row.over .goal-bar span { background: var(--over-bar); }
.goal-row.over .goal-value b { color: var(--over); }
.plan-note-value.over { color: var(--over); font-weight: 700; }
.legend-plan { margin-top: 16px; }
.legend-plan i { width: 14px; height: 8px; border-radius: 99px; background: var(--accent); }
.legend-plan i.light { opacity: .3; }

/* ---------- Раціон на день ---------- */

.plan-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 12px; }
.plan-head .group-title { margin: 0; }

.meals {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}
.meal {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.meal-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 20px 20px 14px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.meal-main:hover .meal-name { color: var(--accent); }
.meal-main:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius); }
.meal-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.meal-slot { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.meal-name { font-family: var(--font-display); font-size: 1.08rem; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; }
.meal-kcal { font-size: .82rem; color: var(--muted); }
.meal-kcal b { font-size: 1.6rem; font-weight: 700; color: var(--text); margin-right: 2px; }
.meal-macros { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; text-align: center; font-size: .75rem; color: var(--muted); }
.meal-macros span { background: var(--bg); border-radius: 10px; padding: 6px 0; display: flex; flex-direction: column; }
.meal-macros b { font-size: .9rem; color: var(--text); }
.meal .tag { align-self: flex-start; }
.meal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 20px; margin-top: auto; }
.swap-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .2s;
}
.swap-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.swap-btn:hover svg { transform: rotate(120deg); transition: transform .3s; }
.log-btn { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.log-btn svg { width: 20px; height: 20px; stroke-width: 2.4; }
.log-btn:hover { transform: scale(1.06); }
.log-btn:hover svg { transform: none; }

/* ---------- Щоденник «З'їдено сьогодні» — темна панель ---------- */

.eaten {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--ink);
  color: var(--ink-text);
  border-radius: 24px;
  padding: 24px;
}
#eaten-today .group-title { margin: 0; font-size: 1.25rem; }
.eaten-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.eaten .cal-btn { background: transparent; border-color: var(--ink-line); color: var(--ink-text); border-radius: 14px; }
.eaten .cal-btn:hover { background: var(--ink-2); }
.eaten-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.eaten-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 6px;
  background: var(--ink-2);
  border-radius: 16px;
}
.eaten-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  color: var(--ink-text);
  text-align: left;
  cursor: pointer;
}
.eaten .meal-slot { color: var(--ink-label); font-size: .7rem; }
.eaten .meta { color: var(--ink-muted); }
.eaten-name { font-weight: 600; }
.eaten-main:hover .eaten-name { text-decoration: underline; }
.eaten-empty {
  margin: 0;
  padding: 14px 16px;
  border: 1px dashed var(--ink-line);
  border-radius: 16px;
  color: var(--ink-muted);
  font-size: .9rem;
}

.remove-btn {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
}
.eaten .remove-btn { color: var(--ink-label); }
.remove-btn:hover { background: var(--surface-2); color: var(--danger); }
.eaten .remove-btn:hover { background: var(--ink-line); color: #f28b82; }

.editor-slots { margin-top: 20px; }
.edit-list { list-style: none; margin: 0; padding: 0; }
.edit-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.edit-name { flex: 1; min-width: 0; display: flex; flex-direction: column; font-weight: 600; }
.edit-name small { color: var(--muted); font-weight: 500; font-size: .75rem; }
.edit-row .goal-input { width: 110px; color: var(--muted); font-size: .9rem; }
.edit-row input, .add-ingredient input {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg);
  font-weight: 700;
}
.edit-row input { text-align: right; }
.edit-row input:focus, .add-ingredient input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.add-ingredient { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.add-ingredient input[type="text"] { flex: 1; }
.add-ingredient input[type="number"] { width: 80px; flex: none; text-align: right; }
.add-ingredient .search-add { width: 40px; height: 40px; font-size: 1.3rem; }
.text-btn.danger { color: var(--danger); }

.shopping {
  margin-top: 16px;
  padding: 16px 20px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}
.shopping > b::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 10px;
  border-radius: 50%;
  background: var(--buy);
  vertical-align: 1px;
}
.shopping.ok { background: var(--accent-soft); color: var(--accent-strong); box-shadow: none; }
.shopping.ok > b::before { background: var(--accent); }
.shopping-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.shopping-chips span { background: var(--buy-soft); color: var(--buy); padding: 5px 12px; border-radius: 999px; font-size: .88rem; font-weight: 600; }
.plan-note { text-align: center; color: var(--muted); font-size: .85rem; margin: 12px 0 0; }

/* ---------- Акаунт ---------- */

.account-bar { display: flex; }
.account-btn {
  position: relative;
  height: 44px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 999px;
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
}
/* на дуже вузьких телефонах лишаємо тільки логотип, щоб «ккал» і «Увійти» вмістилися */
@media (max-width: 520px) { .brand-name { display: none; } }

/* Кнопка налаштувань у верхній панелі: шестерня й поточна мова */
.settings-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  flex: none;
}
.settings-btn:hover { border-color: var(--accent); }
.settings-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Вікно налаштувань */
.settings-langs { margin-bottom: 8px; }
.region-options { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.region-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  cursor: pointer;
}
.region-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.region-option input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.region-option span { display: flex; flex-direction: column; gap: 2px; }
.region-option small { color: var(--muted); font-size: .82rem; }
.cuisine-question { display: flex; flex-direction: column; gap: 6px; margin: 14px 0 4px; padding: 14px; border-radius: 16px; background: var(--accent-soft); }
.cuisine-question .review-actions { margin-top: 4px; }

/* «Увійти» — помітна зелена кнопка з іконкою; після входу стає кругла аватарка */
.account-btn:not(.signed-in) {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px 0 12px;
  border: 0;
  background: var(--accent);
  color: var(--on-accent);
  font-size: .92rem;
  box-shadow: 0 4px 12px rgba(30, 107, 69, .28);
}
.account-btn:not(.signed-in):hover { background: var(--accent-strong); }
.account-btn:not(.signed-in) svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.account-btn.signed-in { width: 44px; padding: 0; display: grid; place-items: center; border: 0; background: var(--accent-soft); }
.account-btn img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar-letter { font-weight: 700; color: var(--accent-strong); }
.status-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  background: var(--muted);
}
.status-dot.saved { background: #2f9e5b; }
.status-dot.saving, .status-dot.syncing { background: var(--fat); }
.status-dot.error { background: var(--danger); }

.sheet-small { width: min(420px, calc(100% - 32px)); }
.google-btn {
  width: 100%;
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 700;
  cursor: pointer;
}
.google-btn:hover { background: var(--surface-2); }
.google-btn svg { width: 20px; height: 20px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--muted); font-size: .85rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.email-form { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; }
.email-form input {
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg);
}
.email-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.account-info { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; }
.sync-line { font-size: .9rem; margin-top: 8px; color: var(--muted); }
.sync-line.saved { color: var(--accent); }
.sync-line.error { color: var(--danger); }
#account-error { color: var(--danger); }

/* ---------- Чек ---------- */

.receipt-tabs { margin: 24px 0 16px; }
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 36px 20px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  transition: border-color .2s, background .2s;
}
.dropzone svg { width: 36px; height: 36px; color: var(--accent); margin-bottom: 4px; }
.dropzone b { color: var(--text); }
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.hint { font-size: .85rem; color: var(--muted); margin: 10px 0 0; }

#receipt-text {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--bg);
  resize: vertical;
  font-size: .95rem;
}
#receipt-text:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.primary-btn {
  margin-top: 12px;
  min-height: 44px;
  padding: 12px 22px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  cursor: pointer;
}
.primary-btn:disabled { opacity: .45; cursor: default; }

.receipt-progress { padding: 40px 0 20px; text-align: center; }
.progress { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }

.check-list { list-style: none; margin: 12px 0 0; padding: 0; }
.check-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.check-row input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.check-main { display: flex; flex-direction: column; min-width: 0; }
.check-main small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.check-row.is-owned { opacity: .55; cursor: default; }

.unknown-lines { margin-top: 14px; font-size: .9rem; color: var(--muted); }
.unknown-lines summary { cursor: pointer; }
.unknown-lines ul { margin: 8px 0 0; padding-left: 18px; }

.review-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 16px; }
.review-actions .text-btn { margin: 12px 0 0; }

/* ---------- Згорнута ціль на день ---------- */

.goals-details { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }
.goals-details > summary {
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  min-height: 28px;
}
.goals-details > summary::-webkit-details-marker { display: none; }
.goals-details > summary::after { content: "⌄"; margin-left: auto; color: var(--muted); transition: transform .2s; }
.goals-details[open] > summary::after { transform: rotate(180deg); }
.goals-summary-values { color: var(--muted); font-weight: 500; font-size: .85rem; }
.goals-details .goals { margin-top: 4px; }
.goals-details[open] .goals-summary-values { display: none; }

/* ---------- Календар ---------- */

.cal-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.cal-btn:hover { background: var(--accent-soft); }
.cal-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#calendar-dialog { width: min(520px, calc(100% - 32px)); }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 10px; }
.cal-nav b, .cal-nav h3, .cal-nav span { font-family: var(--font-display); font-weight: 600; }
.cal-arrow {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.cal-arrow:disabled { opacity: .35; cursor: default; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-weekday { text-align: center; font-size: .7rem; font-weight: 700; color: var(--muted); padding-bottom: 2px; text-transform: uppercase; letter-spacing: .04em; }
.cal-cell {
  position: relative;
  height: 52px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1px;
  border: 0;
  border-radius: 12px;
  background: var(--surface-2);
  padding: 6px 7px;
  cursor: pointer;
  overflow: hidden;
}
.cal-cell.empty { background: transparent; cursor: default; }
.cal-cell.future { opacity: .35; cursor: default; }
.cal-num { font-size: .82rem; font-weight: 700; line-height: 1; }
.cal-kcal { font-size: .64rem; font-weight: 600; color: var(--muted); line-height: 1; min-height: .64rem; }
.cal-cell.ok { background: var(--accent-soft); }
.cal-cell.ok .cal-num, .cal-cell.ok .cal-kcal { color: var(--accent-strong); }
.cal-cell.low { background: var(--surface-2); box-shadow: inset 0 -4px 0 var(--fat); }
.cal-cell.over { background: var(--over-soft); }
.cal-cell.over .cal-num, .cal-cell.over .cal-kcal { color: var(--over); }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--text); }
.cal-cell.low.today { box-shadow: inset 0 0 0 2px var(--text), inset 0 -4px 0 var(--fat); }
.cal-cell.selected { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Останні 7 днів на головній: ті самі клітинки, що в календарі */
.week { margin: 0 0 20px; }
.week[hidden] { display: none; }
.week-head h2 { margin: 0 0 10px; font-size: 1rem; font-weight: 700; }
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)) minmax(0, 1.3fr); gap: 6px; max-width: 640px; }
.week-cell { height: auto; min-height: 66px; padding: 8px 2px; align-items: center; justify-content: center; gap: 4px; }
.week-label { font-size: .64rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.week-cell .cal-num { font-size: 1rem; }
.week-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .55; }
.week-dot.none { visibility: hidden; }
body:not(.hide-nutrition) .week-dot { display: none; }
.week-title-narrow { display: none; }
@media (max-width: 600px) {
  .week-title-wide { display: none; }
  .week-title-narrow { display: inline; }
  .week-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .week-grid .week-cell:nth-child(n + 4):not(.week-more) { display: none; }
  .week-cell { min-height: 60px; }
}
.week-more { background: transparent; border: 1px dashed var(--line-strong); }
.week-more .week-label { text-transform: none; font-size: .72rem; letter-spacing: 0; color: var(--text-2); overflow: visible; }
.week-more:hover { border-color: var(--accent); }
.week-more-arrow { font-size: 1.4rem; line-height: 1; color: var(--muted); }

.cal-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 12px; font-size: .78rem; color: var(--text-2); }
.cal-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 5px; vertical-align: -1px; }
.cal-legend i.low { background: var(--surface-2); box-shadow: inset 0 -3px 0 var(--fat); }
.cal-legend i.ok { background: var(--accent-soft); }
.cal-legend i.over { background: var(--over-soft); }
.cal-month-summary { margin: 10px 0 0; }
.cal-month-summary b { color: var(--text); }

.cal-day { margin-top: 16px; padding: 18px; border-radius: 20px; background: var(--ink); color: var(--ink-text); }
.cal-day h3 { margin: 0 0 10px; font-size: .95rem; }
.cal-day .meta, .cal-day .meal-slot { color: var(--ink-muted); }
.cal-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.cal-stat { background: var(--ink-2); border-radius: 12px; padding: 8px 4px; text-align: center; }
.cal-stat b { display: block; font-size: .95rem; }
.cal-stat span { font-size: .64rem; color: var(--ink-muted); font-weight: 600; }
.cal-dishes { list-style: none; margin: 10px 0 0; padding: 0; font-size: .88rem; }
.cal-dishes li { padding: 7px 0; border-bottom: 1px solid var(--ink-line); }
.cal-dishes li:last-child { border-bottom: 0; }
.cal-dishes .meal-slot { margin-right: 4px; }

/* ---------- Побажання до раціону ---------- */

.pref-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pref-form input {
  flex: 1 1 220px;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg);
}
.pref-form select {
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg);
  font-weight: 600;
}
.pref-form input:focus, .pref-form select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.pref-form .primary-btn { margin: 0; padding: 10px 18px; }
.pref-quick-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pref-quick {
  border: 1px dashed var(--line-strong);
  background: transparent;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.pref-quick:hover { border-style: solid; border-color: var(--accent); color: var(--accent); }
.pref-error { color: var(--danger); }
.pref-chips { justify-content: flex-start; margin-top: 10px; }
.pref-chip { background: var(--surface); border-color: var(--line-strong); color: var(--text); font-weight: 600; }

/* кнопка побажань біля заголовка раціону */
.prefs-btn { position: relative; }
.plan-head .plan-barcode-btn { flex: none; }
.barcode-slots { margin: 4px 0 8px; flex-wrap: wrap; }
.barcode-recipe-add { margin-top: 12px; align-items: center; }
.form-barcode-btn { margin-top: 0; align-self: flex-start; }
.prefs-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: .7rem;
  font-weight: 800;
  line-height: 18px;
}
.plan > .pref-chips { margin: -4px 0 12px; }
#prefs-dialog .pref-form { margin-top: 18px; }
.prefs-note { margin: -4px 0 12px; padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-strong); font-size: .88rem; font-weight: 600; }

/* ---------- Телефон ---------- */

@media (max-width: 600px) {
  .wrap { padding: 0 16px 96px; }
  .topbar-inner { padding: 12px 16px; }
  .brand-name { font-size: .92rem; white-space: nowrap; }
  .topbar-actions { gap: 8px; }
  .account-btn:not(.signed-in) { height: 36px; padding: 0 13px 0 10px; font-size: .86rem; }
  .account-btn.signed-in { width: 38px; height: 38px; }
  .hero { padding: 24px 0 20px; }
  .hero h1 { font-size: 1.75rem; }
  .hero { gap: 16px; }
  .hero-sub { font-size: .98rem; }
  .fridge-panel { padding: 16px; }
  .fridge-panel.empty .hero-fridge-btn { width: 100%; }

  /* кнопка холодильника — внизу екрана, під великим пальцем */
  .fridge-btn {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 20;
    height: 56px;
    justify-content: center;
    border: 0;
    border-radius: 18px;
    background: var(--ink);
    color: var(--ink-text);
    font-size: 1rem;
    font-weight: 700;
    box-shadow: 0 10px 24px rgba(21, 32, 26, .25);
  }
  .fridge-btn .count-badge { background: var(--accent); color: var(--on-accent); }

  .plan-summary, .eaten { padding: 18px; border-radius: 22px; }
  .goal-rows { grid-template-columns: 1fr 1fr; gap: 16px 14px; }
  .goal-value b { font-size: 1.5rem; }
  .goal-fields { grid-template-columns: 1fr 1fr; }
  .controls { margin-top: 8px; }
  .controls .segmented.big { display: flex; width: 100%; }
  .controls .segmented.big button { flex: 1; }
  .dish-search { max-width: none; }
  .meal-main { padding: 16px 16px 12px; }
  .meal-actions { padding: 0 16px 16px; }

  .sheet {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
    border-radius: 28px 28px 0 0;
    max-height: 90%;
  }
  .sheet-inner { padding: 24px 20px; }
  .macro-tiles { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .tile { padding: 8px 2px; }
  .tile b { font-size: 1rem; }
}

/* ---------- Калорії та БЖУ — лише за бажанням ---------- */

.nutrition-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 36px;
  padding: 0 12px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
  font-size: .82rem;
  cursor: pointer;
  flex: none;
}
.nutrition-toggle:hover { color: var(--text); border-color: var(--accent); }
.nutrition-toggle[aria-pressed="true"] { color: var(--accent-strong); background: var(--accent-soft); border-color: transparent; }
.nutrition-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

/* усе, що стосується калорій, БЖУ та побажань до них, ховається, поки кнопку не натиснуто */
body.hide-nutrition #plan-summary,
body.hide-nutrition .nutri,
body.hide-nutrition .card-stats,
body.hide-nutrition .meal-macros,
body.hide-nutrition .prefs-btn,
body.hide-nutrition .plan > .pref-chips,
body.hide-nutrition .prefs-note { display: none !important; }
/* без калорій карткам не потрібна висота під цифри — більше страв видно на екрані */
body.hide-nutrition .card { min-height: 0; }

/* калорії та БЖУ під назвою кожного інгредієнта */
.ing-macros { display: block; margin-top: 2px; font-size: .74rem; font-weight: 500; color: var(--muted); }
.ing-list .ing-macros { padding-left: 22px; }

/* ---------- Улюблені й свої рецепти ---------- */

.card-fav, .sheet-fav {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: transform .15s;
}
.card-fav { position: absolute; top: 14px; right: 60px; width: 38px; height: 38px; border-radius: 12px; font-size: 1.5rem; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.card-fav:hover, .sheet-fav:hover { transform: scale(1.1); }
.card-fav.on, .sheet-fav.on { background: #fde4e4; color: #d64545; }
.card .tag { font-size: .74rem; padding: 4px 9px; max-width: calc(100% - 80px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.missing-note { margin: 0 0 10px; padding: 10px 14px; border-radius: 12px; background: var(--buy-soft); color: var(--buy); font-size: .92rem; }
.sheet-head-actions { display: flex; gap: 8px; align-items: center; flex: none; }
/* свої рецепти — світло-зелені картки в стравах і в раціоні */
.card.mine, .meal.mine { background: #eef6f0; box-shadow: inset 0 0 0 1px #d3e7da; }
.card.mine .card-fav { background: #e1eee5; }
@media (prefers-color-scheme: dark) {
  .card.mine, .meal.mine { background: #1a2b21; box-shadow: inset 0 0 0 1px #24402f; }
  .card.mine .card-fav { background: #223a2c; }
}
.region-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--pin-soft); color: var(--pin); font-size: .72rem; font-weight: 700; }
.meal-top .region-badge { margin-left: 6px; }
.mine-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .72rem; font-weight: 700; }

.add-recipe-btn {
  padding: 8px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: .88rem;
  cursor: pointer;
}
.add-recipe-btn:hover { color: var(--text); border-color: var(--accent); }

.recipe-form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.recipe-form h3 { margin: 8px 0 0; }
.form-field { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.form-field input, .form-field textarea {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-weight: 500;
}
.form-field textarea { resize: vertical; }
.form-field input:focus, .form-field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.recipe-form .pill-radio input[type="checkbox"] { position: absolute; opacity: 0; pointer-events: none; }
.recipe-form .pill-radio input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- «Скільки з'їдено» в редакторі зарахування ---------- */

.amount-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-2);
}
.amount-label { font-weight: 700; flex-basis: 100%; }
.amount-quick { display: flex; gap: 6px; }
.amount-chip {
  min-width: 40px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 700;
  cursor: pointer;
}
.amount-chip:hover { border-color: var(--accent); color: var(--accent); }
.amount-inputs { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; }
.amount-inputs label { display: flex; align-items: center; gap: 6px; }
.amount-inputs input {
  width: 84px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-align: right;
}
.amount-inputs input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* перемикач «+ Десерт» біля заголовка раціону */
.plan-head .dessert-toggle { margin-left: auto; }
.dessert-toggle {
  padding: 7px 14px;
  border: 1px dashed var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: .85rem;
  cursor: pointer;
}
.dessert-toggle:hover { border-color: var(--accent); color: var(--accent); }
.dessert-toggle.on { border-style: solid; border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* хрестик «очистити» в полях пошуку */
.clear-input-btn {
  flex: none;
  width: 26px;
  height: 26px;
  margin: 0 2px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.clear-input-btn:hover { background: var(--line); color: var(--text); }
/* у браузерах прибираємо вбудований хрестик, щоб не було двох */
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }

/* ---------- Сканер штрихкодів ---------- */

#barcode-dialog .receipt-btn, #fridge-dialog #barcode-btn { margin-top: 8px; }
.barcode-video-wrap {
  position: relative;
  margin-top: 16px;
  border-radius: 16px;
  overflow: hidden;
  background: #111;
  aspect-ratio: 4 / 3;
}
.barcode-video-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.barcode-frame {
  position: absolute;
  inset: 30% 12%;
  border: 2px solid rgba(255, 255, 255, .85);
  border-radius: 12px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, .25);
}
.barcode-status { text-align: center; margin: 10px 0 0; }
.barcode-alt { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.barcode-photo { cursor: pointer; align-self: center; }
.barcode-manual { display: flex; gap: 8px; align-items: center; }
.barcode-manual input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.barcode-manual .primary-btn { margin: 0; }
.barcode-actions { flex-wrap: wrap; }
.form-row-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 600px) { .form-row-5 { grid-template-columns: repeat(3, 1fr); } }

/* ==========================================================================
   Дизайн 2026: спокійний стиль у дусі Apple.
   Один зелений акцент — лише для дій і увімкнених станів; сірий фон, білі картки.
   Стани галочок і сердечок лише два: сірий контур (вимкнено) і зелене заповнення (увімкнено).
   ========================================================================== */

body { letter-spacing: -.005em; }
h1, h2, h3, .group-title { letter-spacing: -.02em; }

/* ---------- Шапка ---------- */
.topbar { border-bottom: 0; }
.topbar-actions { gap: 8px; }
.brand-mark { border-radius: 10px; }
.brand-name { font-weight: 700; }

.fridge-btn {
  height: 36px;
  padding: 0 12px 0 10px;
  border: 0;
  background: var(--seg);
  font-weight: 500;
}
.fridge-btn:hover { border-color: transparent; background: var(--line-strong); }
.count-badge { background: var(--surface); color: var(--text); height: 22px; min-width: 22px; font-weight: 600; }

.lang-picker { position: relative; }
.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 10px 0 9px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--text);
  font-size: .94rem;
  font-weight: 500;
  cursor: pointer;
}
.lang-btn:hover { background: var(--surface); }
.lang-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.lang-btn .lang-chevron { width: 12px; height: 12px; stroke: var(--muted); stroke-width: 3; transition: transform .2s; }
.lang-btn[aria-expanded="true"] .lang-chevron { transform: rotate(180deg); }
.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  width: 220px;
  padding: 6px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .16);
  display: flex;
  flex-direction: column;
}
.lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  font-size: 1rem;
  cursor: pointer;
}
.lang-option:hover, .lang-option:focus-visible { background: var(--surface-2); outline: none; }
.lang-option[aria-selected="true"] { background: rgba(118, 118, 128, .1); }
.lang-option-name { flex: 1; }
.lang-option-code { font-size: .8rem; color: var(--muted); }
.lang-option .check-circle { width: 20px; height: 20px; }
.lang-option .check-circle:not(.on) { border-color: transparent; }

.account-btn:not(.signed-in) { height: 36px; padding: 0 14px 0 10px; border-radius: 18px; box-shadow: none; font-weight: 600; }
.account-btn:not(.signed-in):not(:has(span)) { width: 36px; padding: 0; justify-content: center; background: var(--seg); color: var(--text); }
.account-btn.signed-in { width: 36px; height: 36px; background: var(--seg); color: var(--text); font-weight: 600; }

/* ---------- Галочка-кружечок: один компонент для всього сайту ---------- */
.check-circle {
  flex: none;
  width: 24px;
  height: 24px;
  box-sizing: border-box;
  border: 2px solid #8e8e93;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
}
.check-circle.on, .on > .check-circle { border: 0; background: var(--accent); }
.check-circle.on::after, .on > .check-circle::after {
  content: "";
  width: 58%;
  height: 58%;
  background: var(--on-accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---------- Перемикачі й вкладки ---------- */
.segmented { border-radius: 10px; padding: 2px; }
.segmented button { border-radius: 8px; font-weight: 500; color: var(--text); padding: 7px 14px; }
.segmented button[aria-selected="true"] { font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.segmented.big button { height: 36px; padding: 0 18px; }
.segmented.big button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

/* Категорії страв — стрічка «таблеток» з плавним згасанням по краях */
#category-tabs {
  display: flex;
  gap: 8px;
  padding: 2px 48px 2px 0;
  background: transparent;
  border-radius: 0;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent 100%);
  mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent 100%);
}
#category-tabs::-webkit-scrollbar { display: none; }
#category-tabs button { flex: none; height: 36px; padding: 0 16px; border-radius: 18px; background: var(--surface); font-weight: 500; box-shadow: none; }
#category-tabs button[aria-selected="true"] { background: var(--ink); color: var(--ink-text); font-weight: 500; }

/* ---------- Картки страв: кружечок ліворуч, сердечко праворуч ---------- */
.grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.group-title { font-size: 1.375rem; margin-top: 32px; }
.card {
  flex-direction: row;
  align-items: center;
  gap: 2px;
  min-height: 0;
  padding: 6px 4px;
  box-shadow: none;
  transition: background .15s, box-shadow .2s;
}
.card:hover { transform: none; box-shadow: var(--shadow-lg); }
.card .card-log, .card-log {
  position: static;
  order: -1;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: transparent;
  display: grid;
  place-items: center;
}
.card .card-log:hover { background: var(--surface-2); }
.card-log:hover { transform: none; }
.card-main { flex: 1; min-width: 0; padding: 8px 2px; gap: 6px; }
.card-main > div { order: 1; }
.card-main > .card-stats { order: 2; }
.card-main > .tag { order: 3; }
.card h3 { font-size: 1.0625rem; font-weight: 600; }
.card .meta { margin-top: 3px; }
.card .tag, .tag { font-size: .78rem; font-weight: 500; padding: 4px 10px; border-radius: 9px; max-width: 100%; }
.card-stats { margin-top: 0; justify-content: flex-start; align-items: baseline; gap: 12px; }
.card .stat-big, .card .stat { font-size: .95rem; font-weight: 600; color: var(--text); text-align: left; letter-spacing: 0; }
.card .stat-big small, .card .stat small { display: inline; margin: 0 0 0 3px; font-size: .8rem; font-weight: 500; }

.card-fav, .sheet-fav { display: inline-grid; place-items: center; padding: 0; }
.card-fav { position: static; flex: none; width: 44px; height: 44px; border-radius: 50%; background: transparent; }
.card-fav:hover, .sheet-fav:hover { transform: none; }
.card-fav:hover { background: var(--surface-2); }
.card-fav svg, .sheet-fav svg { width: 22px; height: 22px; fill: none; stroke: #8e8e93; stroke-width: 1.8; stroke-linejoin: round; }
.sheet-fav svg { width: 18px; height: 18px; }
.card-fav.on, .sheet-fav.on { background: transparent; }
.sheet-fav.on { background: var(--surface-2); }
.card-fav.on svg, .sheet-fav.on svg { fill: var(--accent); stroke: var(--accent); }
.card.mine, .meal.mine { background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); box-shadow: none; }
.card.mine .card-fav { background: transparent; }
.region-badge { padding: 0; background: none; color: var(--muted); font-size: inherit; font-weight: 500; }
.region-badge::after { content: " ·"; }
@media (prefers-color-scheme: dark) {
  .card.mine, .meal.mine { background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface)); box-shadow: none; }
  .card.mine .card-fav { background: transparent; }
}

/* ---------- Кнопки й вікна ---------- */
.primary-btn { border-radius: 14px; font-weight: 600; }
.sheet { border-radius: 22px; }

/* ---------- Профіль ---------- */
.profile-account { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 16px 0 8px; text-align: center; }
.profile-account.signed-out { align-items: stretch; text-align: left; }
.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--seg);
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  font-weight: 600;
  overflow: hidden;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-account .sync-line { margin-top: 0; }
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  margin-top: 16px;
  padding: 0 16px;
  border-radius: 14px;
  background: var(--surface-2);
  font-size: 1rem;
  cursor: pointer;
}
.switch-row input {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  position: relative;
  width: 51px;
  height: 31px;
  margin: 0;
  border-radius: 16px;
  background: #d1d1d6;
  cursor: pointer;
  transition: background .2s;
}
.switch-row input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .2s;
}
.switch-row input:checked { background: var(--accent); }
.switch-row input:checked::after { transform: translateX(20px); }
.switch-row input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sign-out-btn {
  width: 100%;
  min-height: 48px;
  margin-top: 28px;
  border: 0;
  border-radius: 14px;
  background: var(--surface-2);
  font-weight: 500;
  cursor: pointer;
}
.sign-out-btn:hover { background: var(--seg); }

/* Галочки в раціоні, пошуку й інгредієнтах — той самий кружечок */
.log-btn, .log-btn:hover { background: transparent; border-color: transparent; transform: none; }
.log-btn:hover { background: var(--surface-2); }
.eaten-btn { width: 44px; height: 44px; border-radius: 50%; background: transparent; display: inline-grid; place-items: center; }
.eaten-btn:hover { transform: none; background: var(--surface-2); }
.swap-btn { border: 0; border-radius: 50%; background: transparent; }
.swap-btn:hover { background: var(--surface-2); }
.ing-list .mark { width: 32px; vertical-align: middle; }
.ing-list .mark .check-circle { width: 22px; height: 22px; vertical-align: middle; }
.ing-add { width: 22px; height: 22px; margin-right: 10px; background: transparent; box-shadow: inset 0 0 0 2px #8e8e93; color: var(--accent); }
.ing-add:hover { background: var(--accent-soft); color: var(--accent); }
.meal { box-shadow: none; }

/* «Усе є» на картці не потрібне — це вже каже заголовок групи «Можна приготувати зараз» */
.card .tag.ok { display: none; }

/* На телефоні кнопка холодильника — плаваюча зелена капсула внизу, як в iOS 26 */
@media (max-width: 600px) {
  .fridge-btn {
    height: 52px;
    border-radius: 26px;
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(46, 125, 79, .3);
  }
  .fridge-btn:hover { background: var(--accent-strong); }
  .fridge-btn .count-badge { background: var(--on-accent); color: var(--accent); }
}

/* ==========================================================================
   Етап 2: навігація на 4 розділи, кільця днів, світлі блоки раціону
   ========================================================================== */

/* Перемикач «Що приготувати / Раціон» і кнопку холодильника в шапці замінило меню */
#view-tabs, #fridge-btn { display: none !important; }

/* ---------- Нижнє меню: плаваюча скляна капсула, як в iOS 26 ---------- */
.tabbar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 25;
  max-width: 460px;
  margin: 0 auto;
  height: 66px;
  box-sizing: border-box;
  padding: 5px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
  border-radius: 33px;
  border: 1px solid rgba(255, 255, 255, .7);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .12), 0 1px 3px rgba(0, 0, 0, .06);
}
.tabbar button {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 4px;
  border: 0;
  border-radius: 28px;
  background: transparent;
  color: var(--text);
  font-size: 11px;
  line-height: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.tabbar button[aria-current="page"] { background: rgba(118, 118, 128, .14); color: var(--accent); }
.tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab-icon { position: relative; display: block; height: 22px; }
.tab-badge {
  position: absolute;
  top: -5px;
  left: 14px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  box-sizing: border-box;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 10px;
  line-height: 18px;
  font-weight: 700;
}
body { padding-bottom: 110px; }
@media (prefers-color-scheme: dark) {
  .tabbar { border-color: rgba(255, 255, 255, .08); }
}

/* ---------- Планшет горизонтально й комп'ютер: меню стає боковою панеллю ---------- */
@media (min-width: 1100px) {
  body { padding-bottom: 0; padding-left: 248px; }
  .tabbar {
    top: 84px;
    bottom: auto;
    left: 16px;
    right: auto;
    width: 216px;
    max-width: none;
    height: auto;
    margin: 0;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-radius: 22px;
    border-color: var(--line);
    background: var(--surface);
    box-shadow: none;
  }
  .tabbar button {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    height: 44px;
    padding: 0 12px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
  }
  .tab-icon { height: 22px; }
  .topbar { margin-left: -248px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

/* ---------- Кільця днів у смузі «Останні 7 днів» ---------- */
.week-grid { grid-template-columns: repeat(8, minmax(0, 1fr)) !important; }
.week-grid .week-cell:nth-child(n) { display: flex !important; }
.week-cell, .cal-cell.week-cell.ok, .cal-cell.week-cell.low, .cal-cell.week-cell.over {
  background: transparent;
  box-shadow: none;
  min-height: 0;
  padding: 6px 0;
  gap: 6px;
}
.week-cell:hover { background: var(--surface-2); }
.week-cell.today .week-label { color: var(--text); font-weight: 700; }
.week-ring { position: relative; width: 36px; height: 36px; display: grid; place-items: center; }
.week-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.week-ring .cal-num, .week-cell.ok .week-ring .cal-num, .week-cell.low .week-ring .cal-num { position: relative; font-size: .8rem; font-weight: 600; color: var(--text); }
.week-cell.over .week-ring .cal-num { color: #fff; }
.week-cell .cal-kcal { color: var(--muted) !important; font-size: .7rem; }
.ring-track { fill: none; stroke: var(--seg); stroke-width: 4; }
.ring-ok { fill: none; stroke: var(--accent); stroke-width: 4; }
.ring-low { fill: none; stroke: #2f6fd6; stroke-width: 4; stroke-linecap: round; }
.ring-over { fill: #c8641a; }
.week-legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 16px; margin-top: 10px; font-size: .8rem; color: var(--muted); }
.week-legend span { display: inline-flex; align-items: center; gap: 6px; }
.week-legend svg { width: 14px; height: 14px; }
.week-legend .ring-ok, .week-legend .ring-low, .week-legend .ring-track { stroke-width: 5; }
.week-more .week-more-arrow { height: 36px; display: grid; place-items: center; }

/* ---------- Світлі блоки «Твій день», «З'їдено сьогодні», день у календарі ---------- */
.eaten, .cal-day {
  --ink: var(--surface);
  --ink-2: var(--surface-2);
  --ink-text: var(--text);
  --ink-muted: var(--muted);
  --ink-label: var(--muted);
  --ink-line: var(--line);
}
.cal-day { background: var(--surface-2); }
.cal-day .cal-stat { background: var(--surface); }
.eaten { border-radius: 20px; }
.eaten-list { gap: 0; border-radius: 16px; overflow: hidden; background: var(--surface-2); }
.eaten-row { background: transparent; border-radius: 0; padding-left: 14px; border-bottom: 1px solid var(--line); }
.eaten-row:last-child { border-bottom: 0; }
.eaten-row .check-circle { width: 22px; height: 22px; }
.eaten-main { padding: 12px 10px; }
.eaten .meal-slot { font-size: .75rem; text-transform: none; letter-spacing: 0; }
.tile:first-child { background: var(--surface-2); color: var(--text); }
.tile:first-child span { color: var(--muted); }
.more-btn { background: var(--surface); color: var(--accent); border-radius: 22px; }

/* На «Раціоні» замість блоку холодильника — власний заголовок сторінки */
.view-head { display: none; padding: 40px 0 8px; }
.view-head h1 { margin: 6px 0 0; font-family: var(--font-display); font-size: clamp(2rem, 4.6vw, 3rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.view-head .hero-date { margin: 0; }
body[data-view="plan"] .view-head { display: block; }
body[data-view="plan"] .hero { display: none; }
@media (max-width: 600px) { .view-head { padding-top: 20px; } .view-head h1 { font-size: 2rem; } }

/* Сьогодні в смузі днів — жирний підпис замість рамки; «Більше» — лише стрілка */
.week-cell.today, .cal-cell.week-cell.today, .cal-cell.week-cell.low.today { box-shadow: none; }
.week-more { border: 0; }
.week-more .week-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.week-more .week-more-arrow { margin-top: 18px; width: 36px; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: 1.3rem; }

/* Страва в раціоні: текст ліворуч, галочка праворуч по центру */
.meal { flex-direction: row; align-items: center; }
.meal-actions { margin-top: 0; padding: 0 10px 0 0; }
.meal-main { padding-right: 8px; }

/* ==========================================================================
   Етап 3: «Продукти» й «Щоденник» як сторінки; рецепт поруч зі списком; «Твій день» праворуч
   ========================================================================== */

/* ---------- Сторінки «Продукти» й «Щоденник» — ті самі вікна, але в потоці сторінки ---------- */
body[data-view="fridge"] main.wrap,
body[data-view="diary"] main.wrap { display: none; }
#fridge-dialog:not(:modal)[open],
#calendar-dialog:not(:modal)[open] {
  position: static;
  display: block;
  width: auto;
  max-width: 760px;
  max-height: none;
  margin: 0 auto;
  padding: 0;
  overflow: visible;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  animation: none;
}
#fridge-dialog:not(:modal)[open] .sheet-inner,
#calendar-dialog:not(:modal)[open] .sheet-inner { padding: 32px 24px 24px; }
#fridge-dialog:not(:modal)[open] .close-btn,
#calendar-dialog:not(:modal)[open] .close-btn { display: none; }
#fridge-dialog:not(:modal)[open] h2,
#calendar-dialog:not(:modal)[open] h2 { font-size: clamp(2rem, 4.6vw, 3rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
@media (max-width: 600px) {
  #fridge-dialog:not(:modal)[open] .sheet-inner,
  #calendar-dialog:not(:modal)[open] .sheet-inner { padding: 20px 16px; }
  #fridge-dialog:not(:modal)[open] h2,
  #calendar-dialog:not(:modal)[open] h2 { font-size: 2rem; }
}

@media (min-width: 1100px) {
  /* ---------- «Твій день» — права колонка поруч зі списком страв ---------- */
  body[data-view="dishes"] { padding-right: 392px; }
  body[data-view="dishes"] .topbar { margin-right: -392px; }
  body[data-view="dishes"] #dashboard {
    position: fixed;
    top: 84px;
    right: 16px;
    z-index: 5;
    width: 360px;
    max-height: calc(100vh - 100px);
    margin: 0;
    overflow-y: auto;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 16px;
    scrollbar-width: thin;
  }
  body[data-view="dishes"] #dashboard > * { flex: none; }
  body[data-view="dishes"] #dashboard .plan-summary, body[data-view="dishes"] #dashboard .eaten { padding: 18px; border-radius: 20px; }
  body[data-view="dishes"] .hero { flex-direction: column; align-items: stretch; }
  body[data-view="dishes"] .hero-text, body[data-view="dishes"] .fridge-panel { flex: none; }

  /* ---------- Рецепт відкривається в тій самій правій колонці, поверх «Твого дня» ---------- */
  #recipe-dialog.side-panel {
    position: fixed;
    top: 84px;
    right: 16px;
    left: auto;
    bottom: 16px;
    z-index: 15;
    width: 360px;
    max-height: none;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .10);
    overflow-y: auto;
    animation: none;
  }
  #recipe-dialog.side-panel .sheet-inner { padding: 22px 20px 24px; }
  #recipe-dialog.side-panel .macro-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #recipe-dialog.side-panel h2 { font-size: 1.35rem; }
}

/* Календар місяця — ті самі кільця, що й у смузі днів */
.cal-cell.ring-cell, .cal-cell.ring-cell.ok, .cal-cell.ring-cell.low, .cal-cell.ring-cell.over, .cal-cell.ring-cell.low.today {
  background: transparent;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 0;
  min-height: 0;
  height: auto;
}
.cal-cell.ring-cell:not(:disabled):hover { background: var(--surface-2); }
.cal-cell.ring-cell.selected { background: var(--surface-2); box-shadow: none; }
.cal-cell.ring-cell.today .cal-num { font-weight: 800; }
.cal-cell.ring-cell.over .cal-num { color: #fff; }
.cal-cell.ring-cell .cal-num { position: relative; font-size: .8rem; font-weight: 600; color: var(--text); }
.cal-cell.ring-cell.future .cal-num { color: var(--muted); }
.cal-cell.ring-cell .cal-kcal { font-size: .65rem; color: var(--muted); min-height: .8em; }
.cal-legend { justify-content: center; gap: 16px; color: var(--muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend svg { width: 14px; height: 14px; }
.cal-legend .ring-ok, .cal-legend .ring-low, .cal-legend .ring-track { stroke-width: 5; }
.cal-cell.ring-cell.selected { outline: 0; }
.cal-cell.ring-cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ==========================================================================
   Картка страви, варіант E: лише кнопка «•••», усі дії — в одному меню
   ========================================================================== */
.card { padding: 6px 8px 6px 14px; }
.card-more {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.card-more:hover, .card-more[aria-expanded="true"] { background: var(--seg); }
.card-more svg { width: 20px; height: 20px; fill: currentColor; }
.card h3 .fav-mark { width: 14px; height: 14px; margin-left: 6px; vertical-align: -1px; fill: var(--accent); }
.eaten-mark { display: inline-flex; align-items: center; gap: 5px; color: var(--accent); font-weight: 600; }
.eaten-mark::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

.card-menu {
  position: fixed;
  z-index: 40;
  width: 236px;
  padding: 6px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .16);
  display: flex;
  flex-direction: column;
}
.card-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
}
.card-menu button:hover, .card-menu button:focus-visible { background: var(--surface-2); outline: none; }
.card-menu svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.card-menu svg.check { stroke: var(--accent); stroke-width: 2.4; }
.card-menu svg.on { fill: var(--accent); stroke: var(--accent); }

/* Улюблені — червоне сердечко, як в iOS */
.card h3 .fav-mark { width: 20px; height: 20px; margin-left: 6px; vertical-align: -3px; fill: #ff3b30; }
.card-menu svg.on, .sheet-fav.on svg, .card-fav.on svg { fill: #ff3b30; stroke: #ff3b30; }

/* «Побачити ще» під списком страв */
#results > .more-btn { display: flex; width: fit-content; margin: 24px auto 0; gap: 8px; height: 48px; padding: 0 22px; font-size: 1rem; }
.more-count { min-width: 26px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); font-size: .8rem; font-weight: 700; display: inline-grid; place-items: center; }

/* ==========================================================================
   Холодильник на головній — як у новому дизайні: біла картка зі значком,
   «14 продуктів», перші назви одним рядком і стрілка; під нею — перемикач
   ========================================================================== */
.fridge-panel, .fridge-panel.empty {
  padding: 0;
  gap: 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.fridge-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 76px;
  padding: 16px;
  border: 0;
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: box-shadow .2s;
}
.fridge-card:hover { box-shadow: var(--shadow-lg); }
.fridge-card-icon {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  display: grid;
  place-items: center;
}
.fridge-card-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fridge-card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fridge-card .fridge-panel-title { font-family: inherit; font-size: 1.0625rem; font-weight: 600; letter-spacing: -.01em; }
.fridge-card-names { font-size: .875rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fridge-card-chevron, .fridge-card-plus { flex: none; width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.fridge-card-plus { display: none; width: 20px; height: 20px; stroke: var(--accent); }
.fridge-panel.empty .fridge-card-chevron { display: none; }
.fridge-panel.empty .fridge-card-plus { display: block; }
.fridge-panel.empty .fridge-card { box-shadow: inset 0 0 0 1.5px var(--accent); }
.fridge-panel.empty .selection { display: none; }
.selection { align-items: stretch; }
.selection #source-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.selection #source-tabs button { height: 34px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Свої рецепти — помітніший зелений фон і тонкий зелений контур */
.card.mine, .meal.mine { background: #e1f1e6; box-shadow: inset 0 0 0 1px #b9dcc5; }
.card.mine .card-more { background: rgba(255, 255, 255, .7); }
.card.mine .card-more:hover, .card.mine .card-more[aria-expanded="true"] { background: #fff; }
@media (prefers-color-scheme: dark) {
  .card.mine, .meal.mine { background: #1f3a2b; box-shadow: inset 0 0 0 1px #2f5a41; }
  .card.mine .card-more { background: rgba(255, 255, 255, .08); }
}
.card.mine .mine-badge { background: var(--accent); color: var(--on-accent); }

/* Кнопка «•••» — у квадратику із заокругленими кутами */
.card-more { border-radius: 12px; }

/* Свої рецепти — без кольорового фону, лише мітка «Мій рецепт» */
.card.mine, .meal.mine { background: var(--surface); box-shadow: none; }
.card.mine .card-more { background: var(--surface-2); }
.card.mine .card-more:hover, .card.mine .card-more[aria-expanded="true"] { background: var(--seg); }
@media (prefers-color-scheme: dark) {
  .card.mine, .meal.mine { background: var(--surface); box-shadow: none; }
  .card.mine .card-more { background: var(--surface-2); }
}

/* «Більше» під групою і окрема сторінка групи */
#results > .group-more { display: flex; width: fit-content; margin: 16px auto 0; gap: 8px; height: 44px; padding: 0 20px; font-size: 1rem; }
body[data-group-page] .hero,
body[data-group-page] .controls,
body[data-group-page] #week-strip,
body[data-group-page] #dishes-toolbar,
body[data-group-page] #search-results { display: none !important; }
@media (max-width: 1099px) { body[data-group-page] #dashboard { display: none !important; } }
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 44px;
  margin: 24px 0 0 -8px;
  padding: 0 12px 0 4px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--accent);
  font-size: 1.0625rem;
  font-weight: 500;
  cursor: pointer;
}
.back-btn:hover { background: var(--surface); }
.back-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
body[data-group-page] .back-btn + .group-title { margin-top: 8px; font-size: clamp(1.75rem, 4vw, 2.25rem); }

/* ==========================================================================
   iPad горизонтально й комп'ютер: цілісна бокова панель на всю висоту
   (логотип угорі, розділи під ним), шапка й контент — праворуч від неї
   ========================================================================== */
@media (min-width: 1100px) {
  body { padding-left: 248px; }
  .topbar { margin-left: 0; }
  body[data-view="dishes"] .topbar { margin-right: -392px; }
  .topbar .brand {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 26;
    width: 248px;
    height: 64px;
    box-sizing: border-box;
    padding: 0 20px;
  }
  .topbar .brand-name { display: inline; }
  .topbar-inner { justify-content: flex-end; min-height: 64px; padding-top: 14px; padding-bottom: 14px; box-sizing: border-box; }
  .tabbar {
    top: 0;
    bottom: 0;
    left: 0;
    width: 248px;
    height: auto;
    padding: 76px 14px 20px;
    gap: 2px;
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    background: var(--surface);
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .tabbar button { position: relative; height: 44px; padding: 0 12px; border-radius: 12px; font-size: 16px; font-weight: 500; color: var(--text); }
  .tabbar button:hover { background: var(--surface-2); }
  .tabbar button[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
  .tab-icon { position: static; }
  .tabbar .tab-badge {
    top: 50%;
    right: 12px;
    left: auto;
    transform: translateY(-50%);
    background: var(--surface-2);
    color: var(--muted);
  }
  .tabbar button[aria-current="page"] .tab-badge { background: var(--surface); color: var(--accent-strong); }
  body[data-view="dishes"] #dashboard, #recipe-dialog.side-panel { top: 76px; }
}

/* iPad вертикально й невеликі планшети: нижнє меню ширше й пропорційне екрану */
@media (min-width: 700px) and (max-width: 1099px) {
  .tabbar { max-width: 520px; height: 70px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
  .tabbar button { font-size: 12px; }
  .tabbar svg { width: 24px; height: 24px; }
  .tab-icon { height: 24px; }
}

/* Вікно «Додати в холодильник» з кількістю */
.amount-dialog {
  width: min(360px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
.amount-dialog::backdrop { background: rgba(0, 0, 0, .35); }
.amount-form { display: flex; flex-direction: column; gap: 12px; padding: 22px 20px 18px; text-align: center; }
.amount-form h2 { margin: 0; font-size: 1.15rem; font-weight: 700; }
.amount-product { margin: -6px 0 4px; font-size: 1rem; color: var(--muted); }
.amount-field { display: flex; align-items: center; justify-content: center; gap: 10px; }
.amount-field input {
  width: 110px;
  height: 52px;
  border: 0;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
}
.amount-field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.amount-unit { min-width: 28px; font-size: 1.05rem; font-weight: 600; color: var(--muted); text-align: left; }
.amount-step {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--accent);
  font-size: 1.4rem;
  font-weight: 600;
  cursor: pointer;
}
.amount-step:hover { background: var(--seg); }
.amount-form .hint { margin: 0; }
.amount-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 6px; }
.amount-actions button { height: 48px; margin: 0; border-radius: 14px; text-decoration: none; }
.amount-actions .text-btn { background: var(--surface-2); color: var(--text); font-weight: 500; }
.chip-amount { color: var(--muted); font-weight: 500; }
.amount-field input { -moz-appearance: textfield; appearance: textfield; }
.amount-field input::-webkit-outer-spin-button, .amount-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Галочка біля продукту з холодильника в рецепті — кнопка «прибрати» */
.ing-remove { display: inline-grid; place-items: center; width: 32px; height: 32px; margin: -5px 0 -5px -5px; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; vertical-align: middle; }
.ing-remove:hover { background: var(--surface-2); }
.ing-list .mark .ing-remove .check-circle { width: 22px; height: 22px; }

/* Бокова панель рецепта прокручується сама, а не сторінка під нею */
@media (min-width: 1100px) {
  #recipe-dialog.side-panel { height: auto; max-height: none; height: calc(100vh - 92px); height: calc(100dvh - 92px); overscroll-behavior: contain; }
  body[data-view="dishes"] #dashboard { overscroll-behavior: contain; }
}
dialog { overscroll-behavior: contain; }

/* Картка рецепта прокручується сама, а не сторінка під нею.
   Явна висота бокової панелі: інакше Safari на iPad розтягує вікно на всю довжину рецепта й прокручує сторінку */
dialog { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
@media (min-width: 1100px) {
  #recipe-dialog.side-panel {
    height: calc(100vh - 92px);
    height: calc(100dvh - 92px);
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }
}

/* Хрестик закриття — намальований значок рівно по центру кола (символ «×» у шрифті зміщений вниз) */
.close-btn { display: flex; align-items: center; justify-content: center; padding: 0; font-size: 0; line-height: 0; color: var(--text); }
.close-btn::before {
  content: "";
  width: 14px;
  height: 14px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M5 5l14 14M19 5L5 19'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M5 5l14 14M19 5L5 19'/%3E%3C/svg%3E") center / contain no-repeat;
}
.close-btn:hover { background: var(--seg); }

/* Плюс у кружечку біля продукту, якого бракує, і кнопки − / + у вікні кількості — намальовані значки рівно по центру */
.ing-add, .amount-step { display: inline-flex; align-items: center; justify-content: center; padding: 0; font-size: 0; line-height: 0; }
.ing-add::before, .amount-step::before {
  content: "";
  width: 12px;
  height: 12px;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.amount-step::before { width: 16px; height: 16px; }
.ing-add, .amount-step[data-amount-step="1"] {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.2' stroke-linecap='round'%3E%3Cpath d='M12 4v16M4 12h16'/%3E%3C/svg%3E");
}
.amount-step[data-amount-step="-1"] {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.2' stroke-linecap='round'%3E%3Cpath d='M4 12h16'/%3E%3C/svg%3E");
}

/* Плюс і мінус — намальовані значки рівно по центру (символи «+» і «−» у шрифті зміщені) */
.ing-add, .amount-step { display: inline-flex; align-items: center; justify-content: center; padding: 0; font-size: 0; line-height: 0; }
.ing-add::before, .amount-step::before {
  content: "";
  width: 12px;
  height: 12px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='M12 4v16M4 12h16'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='M12 4v16M4 12h16'/%3E%3C/svg%3E") center / contain no-repeat;
}
.amount-step::before { width: 16px; height: 16px; }
.amount-step[data-amount-step="-1"]::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='M4 12h16'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='M4 12h16'/%3E%3C/svg%3E");
}

/* Списання з холодильника після «З'їдено» */
.stock-list { list-style: none; margin: 4px 0 0; padding: 0; border-radius: 14px; background: var(--surface-2); text-align: left; }
.stock-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 6px 14px; border-bottom: 1px solid var(--line); }
.stock-row:last-child { border-bottom: 0; }
.stock-name { display: flex; flex-direction: column; gap: 2px; font-size: 1rem; font-weight: 500; }
.stock-name small { font-size: .8rem; font-weight: 400; color: var(--muted); }
.stock-used { display: flex; align-items: center; gap: 4px; font-size: .95rem; color: var(--muted); }
.stock-used input { width: 64px; height: 36px; padding: 0 8px; border: 0; border-radius: 10px; background: var(--surface); font: inherit; color: var(--text); text-align: right; }
.stock-out { display: flex; align-items: center; gap: 6px; font-size: .95rem; cursor: pointer; }
.stock-out input { width: 20px; height: 20px; accent-color: var(--accent); }
.switch-note { display: block; margin-top: 2px; font-size: .8rem; color: var(--muted); }
.switch-row > span { padding: 8px 0; }
.stock-dialog .amount-actions button { padding: 0 12px; white-space: nowrap; }

/* ==========================================================================
   Холодильник: пошук і дві іконки в одному рядку, продукти — за категоріями,
   у кожній категорії — простий список (без «хмари» з чипсів)
   ========================================================================== */
.fridge-tools { display: flex; align-items: center; gap: 8px; margin-top: 20px; }
.fridge-tools .fridge-search { flex: 1; min-width: 0; margin: 0; }
.fridge-tools .receipt-btn, #fridge-dialog .fridge-tools .receipt-btn {
  flex: none;
  width: 48px;
  height: 48px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  display: grid;
  place-items: center;
}
.fridge-tools .receipt-btn:hover { background: var(--seg); }
.fridge-tools .receipt-btn svg { width: 22px; height: 22px; }
.fridge-tools .receipt-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#fridge-dialog:not(:modal)[open] .fridge-tools .receipt-btn { background: var(--surface); }

#fridge-dialog .quick { margin-top: 16px; text-align: left; }
#fridge-dialog .quick-chips { justify-content: flex-start; }
#fridge-dialog .quick-chips button { border: 0; background: var(--surface-2); color: var(--text); }
#fridge-dialog:not(:modal)[open] .quick-chips button { background: var(--surface); }

.fridge-list { margin-top: 28px; }
.fridge-head { margin-bottom: 4px; }
.fridge-title { font-size: 1.25rem; letter-spacing: -.01em; }
.fridge-groups { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 20px; }
.fridge-group-title {
  margin: 0 0 8px 16px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.fridge-group-title span { margin-left: 4px; font-weight: 500; }
.fridge-rows { list-style: none; margin: 0; padding: 0; border-radius: 16px; background: var(--surface-2); overflow: hidden; }
#fridge-dialog:not(:modal)[open] .fridge-rows { background: var(--surface); }
.fridge-row { display: flex; align-items: center; min-height: 48px; border-bottom: 1px solid var(--line); }
.fridge-row:last-child { border-bottom: 0; }
.fridge-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 4px 0 16px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
}
.fridge-row-main .check-circle { display: none; width: 22px; height: 22px; }
.fridge-row.selected .fridge-row-main .check-circle { display: inline-grid; }
.fridge-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.fridge-row-name small { display: block; font-size: .75rem; color: var(--danger); }
.fridge-row.unknown .fridge-row-name { color: var(--muted); }
.fridge-row-amount { flex: none; font-size: .9rem; color: var(--muted); }
.fridge-row-remove {
  flex: none;
  width: 44px;
  height: 44px;
  margin-right: 2px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #8e8e93;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.fridge-row-remove:hover { background: var(--seg); color: var(--text); }
.fridge-row-remove svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.fridge-tools { align-items: stretch; }
.fridge-tools .receipt-btn, #fridge-dialog .fridge-tools .receipt-btn { height: auto; min-height: 48px; width: 52px; border-radius: 16px; }
@media (min-width: 900px) {
  #fridge-dialog:not(:modal)[open] .fridge-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 24px 16px; }
}
#fridge-dialog .fridge-tools #receipt-btn, #fridge-dialog .fridge-tools #barcode-btn { margin: 0; align-self: stretch; height: auto; }

/* Облік залишків увімкнено: кількість біля кожного продукту, натискання — змінити */
button.fridge-row-amount.edit {
  flex: none;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
}
#fridge-dialog:not(:modal)[open] button.fridge-row-amount.edit { background: var(--bg); }
button.fridge-row-amount.edit:hover { background: var(--seg); }
button.fridge-row-amount.edit.empty { color: var(--accent); background: transparent; }
button.fridge-row-amount.edit.empty:hover { background: var(--accent-soft); }
#fridge-dialog:not(:modal)[open] button.fridge-row-amount.edit.empty, button.fridge-row-amount.edit.empty { background: transparent; color: var(--accent); }
.amount-skip { display: block; margin: 10px auto 0; color: var(--muted); }

/* «Продукти» й «Щоденник» — тієї ж ширини, що й решта сторінок (як .wrap) */
#fridge-dialog:not(:modal)[open],
#calendar-dialog:not(:modal)[open] { max-width: 1200px; padding: 0 24px; box-sizing: border-box; }
#fridge-dialog:not(:modal)[open] .sheet-inner,
#calendar-dialog:not(:modal)[open] .sheet-inner { padding: 32px 0 24px; max-width: none; }
@media (min-width: 900px) {
  #fridge-dialog:not(:modal)[open] .fridge-groups { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}
@media (max-width: 600px) {
  #fridge-dialog:not(:modal)[open],
  #calendar-dialog:not(:modal)[open] { padding: 0 16px; }
  #fridge-dialog:not(:modal)[open] .sheet-inner,
  #calendar-dialog:not(:modal)[open] .sheet-inner { padding: 20px 0 24px; }
}

/* Картка холодильника на головній не виходить за межі сторінки, навіть коли продуктів багато:
   довгий рядок назв обрізається трьома крапками */
.hero, .hero > *, .fridge-panel, .fridge-card, .selection { min-width: 0; max-width: 100%; box-sizing: border-box; }
.fridge-panel { width: 100%; }
.fridge-card-text { overflow: hidden; }
/* «Мій рецепт» у раціоні — та сама зелена мітка, що й на картках страв */
.meal .mine-badge { background: var(--accent); color: var(--on-accent); }
.meal-top { flex-wrap: wrap; row-gap: 4px; }

/* Заміна інгредієнта: три способи плитками */
.swap-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0 4px; }
.swap-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 76px;
  padding: 10px 6px;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font-size: .85rem;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}
.swap-option:hover { background: var(--seg); }
.swap-option.active { background: var(--accent-soft); color: var(--accent-strong); box-shadow: inset 0 0 0 1.5px var(--accent); }
.swap-option svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.swap-panel .fridge-pick, .swap-panel .add-ingredient { margin-top: 10px; }
.swap-note { margin: 6px 0 0; font-size: .8rem; }
.swap-panel .swap-actions { justify-content: flex-end; }
.swap-panel .fridge-pick-label { display: none; }
/* Плитки заміни: однакова висота, підпис в один рядок */
.swap-option { min-height: 68px; gap: 7px; font-size: .82rem; white-space: nowrap; }
.swap-option span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
/* «‹ Раціон» — лише коли календар відкритий як сторінка «Щоденник» */
.cal-back { display: none; }
#calendar-dialog:not(:modal)[open] .cal-back { display: inline-flex; margin: 0 0 4px -8px; }

/* ==========================================================================
   Один вигляд для всіх випадаючих списків (сортування, активність, прийом їжі):
   «пігулка» з тонким контуром і стрілкою — як кнопка мови в шапці
   ========================================================================== */
.sort select,
.norm-form select,
.pref-form select {
  -webkit-appearance: none;
  appearance: none;
  height: 40px;
  padding: 0 34px 0 14px;
  border: 0;
  border-radius: 20px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center / 12px 12px;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--text);
  font-size: .94rem;
  font-weight: 500;
  cursor: pointer;
}
.sort select:hover, .norm-form select:hover, .pref-form select:hover { background-color: var(--surface-2); }
.sort select:focus-visible, .norm-form select:focus-visible, .pref-form select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.norm-form select { width: 100%; }

/* Випадаючі списки: кнопка-«пігулка» і меню, як у мови в шапці */
.ui-select { position: relative; display: inline-flex; min-width: 0; }
.ui-select > select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.ui-select-btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 40px;
  min-width: 0;
  max-width: 100%;
  padding: 0 12px 0 14px;
  border: 0;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--text);
  font-size: .94rem;
  font-weight: 500;
  cursor: pointer;
}
.ui-select-btn:hover { background: var(--surface-2); }
.ui-select-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-select-btn .lang-chevron { flex: none; width: 12px; height: 12px; fill: none; stroke: var(--muted); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.ui-select-btn[aria-expanded="true"] .lang-chevron { transform: rotate(180deg); }
.ui-select-menu { left: 0; right: auto; width: max-content; max-width: min(320px, calc(100vw - 16px)); }
.ui-select-menu.align-right { left: auto; right: 0; }
.ui-select-menu .check-circle { width: 20px; height: 20px; }
.ui-select-menu .check-circle:not(.on) { border-color: transparent; }
.norm-form .ui-select, .norm-form .ui-select-btn { width: 100%; }
.card-menu { border-radius: 18px; }

/* Шапка з мовою й акаунтом лишається видимою під час прокрутки (напівпрозора, як в iOS) */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  transition: box-shadow .2s;
}
body.scrolled .topbar { box-shadow: 0 1px 0 var(--line); }

/* Поле кількості: число й одиниця — в одній «пігулці», одиниця одразу після цифр */
.amount-field .amount-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 132px;
  height: 52px;
  padding: 0 16px;
  box-sizing: border-box;
  border-radius: 14px;
  background: var(--surface-2);
  cursor: text;
}
.amount-field .amount-box:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.amount-field .amount-box input {
  width: 3ch;
  min-width: 0;
  height: 34px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 1.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  line-height: 34px;
  text-align: center;
}
.amount-field .amount-box input:focus-visible { outline: none; }
.amount-field .amount-box .amount-unit {
  min-width: 0;
  margin-top: 7px; /* опускаємо до лінії цифр */
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1;
}
.amount-field { align-items: center; min-height: 56px; }
.amount-field .amount-box { margin: 0; }
.amount-field .amount-step { align-self: center; }

/* ==========================================================================
   Фото страв: мініатюра в картці та фото зверху картки страви
   ========================================================================== */
.card-photo { display: block; overflow: hidden; background: var(--surface-2); }
.card-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card-photo.empty { display: grid; place-items: center; color: #c7c7cc; }
.card-photo.empty svg { width: 34%; height: 34%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* Картки страв — сітка з квадратними фото (варіант C) */
.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; }
.card { position: relative; flex-direction: column; align-items: stretch; padding: 0; overflow: hidden; border-radius: 18px; min-height: 0; }
.card-main { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 0 0 12px; text-align: left; }
.card-main > .card-photo { order: 0; width: 100%; aspect-ratio: 1 / 1; margin-bottom: 6px; border-radius: 0; }
.card-main > .card-photo img { transition: transform .35s ease; }
.card-main > div, .card-main > .card-stats, .card-main > .tag { margin-left: 12px; margin-right: 12px; }
.card-main > .tag { width: fit-content; }
.card h3 { font-size: .98rem; line-height: 1.25; }
.card .meta { font-size: .8rem; margin-top: 2px; }
.card-stats { gap: 8px; }
.card .stat-big, .card .stat { font-size: .85rem; }
.card-more { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; background: rgba(255,255,255,.88); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.card-more:hover, .card-more[aria-expanded="true"] { background: #fff; }
.card.mine, .card.mine:hover { background: var(--surface); }

/* Планшет (будь-яка орієнтація) — 3 картки в ряд */
@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px 16px; }
  .card h3 { font-size: 1rem; }
}
/* Комп'ютер (миша/тачпад) — 2 картки в ряд, як на телефоні */
@media (min-width: 1100px) and (hover: hover) and (pointer: fine) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 20px; }
  .card { transition: box-shadow .2s, transform .2s; }
  .card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0,0,0,.08); }
  .card:hover .card-photo img { transform: scale(1.04); }
  .card-main { padding-bottom: 14px; }
  .card-main > div, .card-main > .card-stats, .card-main > .tag { margin-left: 16px; margin-right: 16px; }
  .card h3 { font-size: 1.1rem; }
  .card .meta { font-size: .88rem; }
  .card-more { top: 12px; right: 12px; width: 38px; height: 38px; }
}
@media (prefers-reduced-motion: reduce) { .card, .card-photo img { transition: none !important; } .card:hover { transform: none; } .card:hover .card-photo img { transform: none; } }

/* Фото у картці страви */
.sheet-photo { position: relative; margin: -28px -28px 20px; height: 260px; overflow: hidden; background: var(--surface-2); }
.photo-credit { position: absolute; right: 8px; bottom: 8px; max-width: calc(100% - 16px); padding: 3px 8px; border-radius: 8px; background: rgba(0,0,0,.45); color: rgba(255,255,255,.92); font-size: .68rem; line-height: 1.3; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.photo-credit:hover { color: #fff; text-decoration: underline; }
.sheet-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 600px) { .sheet-photo { margin: -24px -20px 18px; height: 240px; } }
#recipe-dialog.side-panel .sheet-photo { margin: -22px -20px 18px; height: 220px; }

/* Картка страви без рамки: заокруглене фото з легкою тінню, назва просто на фоні сторінки */
.card, .card:hover, .card.mine, .card.mine:hover { background: transparent; box-shadow: none; transform: none; border-radius: 0; overflow: visible; }
.card-main { padding: 0; gap: 3px; }
.card-main > .card-photo { border-radius: 18px; margin-bottom: 8px; box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.card-main > div, .card-main > .card-stats, .card-main > .tag { margin-left: 2px; margin-right: 2px; }
.card h3 { font-size: 1rem; }
.card-main:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 18px; }
@media (min-width: 1100px) and (hover: hover) and (pointer: fine) {
  .card-main { padding-bottom: 0; }
  .card-main > div, .card-main > .card-stats, .card-main > .tag { margin-left: 2px; margin-right: 2px; }
  .card:hover .card-photo { box-shadow: 0 10px 26px rgba(0,0,0,.12); }
  .card-main > .card-photo { transition: box-shadow .2s; }
}

/* Маленькі фото страв у списках: раціон, «З'їдено сьогодні», календар, пошук */
.thumb { display: block; flex: none; width: 64px; height: 64px; border-radius: 14px; overflow: hidden; background: var(--surface-2); box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb.empty { display: grid; place-items: center; color: #c7c7cc; }
.thumb.empty svg { width: 40%; height: 40%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.thumb.small { width: 40px; height: 40px; border-radius: 10px; }
.cal-dish { display: flex; align-items: center; gap: 10px; }

/* ==========================================================================
   Однаковий дизайн картки скрізь: раціон, «З'їдено сьогодні», пошук — як картки страв
   ========================================================================== */
.tile-grid { list-style: none; margin: 0; padding: 0; display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; background: transparent !important; border-radius: 0 !important; overflow: visible !important; }
@media (min-width: 700px) { .tile-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px 16px; } }
@media (min-width: 1100px) and (hover: hover) and (pointer: fine) { .tile-grid { grid-template-columns: repeat(2, minmax(0, 360px)); gap: 24px 20px; } } /* розмір як у карток страв */
body[data-view="dishes"] #dashboard .tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 10px; }

.tile-grid > .meal, .tile-grid > .eaten-row, .search-results .search-item {
  position: relative; display: block; padding: 0; margin: 0; border: 0; border-radius: 0;
  background: transparent !important; box-shadow: none !important; overflow: visible;
}
.tile-grid > .meal > .meal-main, .tile-grid > .eaten-row > .eaten-main, .search-results .search-item-main {
  display: flex !important; flex-direction: column; align-items: stretch; gap: 3px; width: 100%;
  padding: 0 !important; border: 0; background: transparent; color: var(--text); text-align: left;
}
.tile-grid .thumb, .search-results .search-item-main > .thumb {
  width: 100% !important; height: auto !important; aspect-ratio: 1 / 1; border-radius: 18px !important;
  margin-bottom: 8px; box-shadow: 0 2px 10px rgba(0,0,0,.06); align-self: stretch !important;
}
.tile-grid .thumb.empty svg, .search-results .thumb.empty svg { width: 34%; height: 34%; }
.tile-grid .meal-top { margin: 0 2px; gap: 6px; justify-content: flex-start; }
.tile-grid .meal-slot, .tile-grid .eaten-row .meal-slot { font-size: .7rem; letter-spacing: .04em; color: var(--muted); }
.tile-grid .meal-name, .tile-grid .eaten-name, .search-results .search-item-main b { margin: 0 2px; font-size: 1rem; font-weight: 600; line-height: 1.25; color: var(--text); }
.tile-grid .meal-kcal, .tile-grid .eaten-main .meta, .search-results .search-item-main .meta { margin: 0 2px; font-size: .8rem; color: var(--muted); }
.tile-grid .meal-macros { display: none; }
.tile-grid .meal .tag, .search-results .search-item-main .tag { margin: 2px 2px 0; width: fit-content; }
.tile-grid .meal-main:hover .meal-name, .search-results .search-item-main:hover b { color: var(--accent); }

/* кнопка «з'їдено» (галочка) — у куточку фото, як «•••» на картках страв */
.tile-grid .meal-actions { position: absolute; top: 8px; right: 8px; margin: 0; padding: 0; border: 0; background: transparent; }
.tile-grid .meal-actions .log-btn { width: 36px; height: 36px; padding: 0; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.88); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.tile-grid > .eaten-row > .check-circle { position: absolute; z-index: 1; top: 10px; left: 10px; }
.tile-grid > .eaten-row > .remove-btn { position: absolute; z-index: 1; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.88); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.tile-grid .eaten-main:hover .eaten-name { text-decoration: none; color: var(--accent); }

/* пошук у раціоні: результати сіткою карток */
.search-results:not([hidden]) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; padding: 12px; }
@media (min-width: 700px) { .search-results:not([hidden]) { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.search-results > .meta { grid-column: 1 / -1; }
.search-results .search-item .slot-buttons { margin: 0; padding: 0; }
.search-results .search-item .slot-btn { display: none; } /* додати в раціон — у картці рецепта */
.search-results .search-item .eaten-btn { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.88); box-shadow: 0 1px 4px rgba(0,0,0,.1); display: grid; place-items: center; }

/* Своє фото страви: кнопки поверх фото в картці рецепта та порожній стан */
.photo-tools { position: absolute; left: 10px; bottom: 10px; display: flex; gap: 6px; flex-wrap: wrap; max-width: calc(100% - 20px); }
.photo-tool { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: 0; border-radius: 17px; background: rgba(255,255,255,.88); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); color: var(--text); font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.photo-tool svg, .photo-add svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.photo-tool:hover { background: #fff; }
.sheet-photo .photo-credit { left: auto; right: 8px; bottom: auto; top: 8px; }
.sheet-photo.empty { height: 170px; display: grid; place-items: center; background: var(--surface-2); }
.photo-add { display: inline-flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 22px; border: 1.5px dashed #c7c7cc; border-radius: 16px; background: transparent; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }
.photo-add svg { width: 28px; height: 28px; }
.photo-add:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ==========================================================================
   Картка рецепта, спрощена: фото ≈ ⅓, назва, один рядок поживності, інгредієнти, кроки,
   дві дії внизу. Плюс плавний перехід з картки страви (див. app.js → openRecipe)
   ========================================================================== */
.sheet-v2 { padding: 0 !important; display: flex; flex-direction: column; min-height: 100%; }
.sheet-v2 .sheet-hero { position: relative; flex: none; }
.sheet-v2 .sheet-photo { margin: 0 !important; height: clamp(200px, 32vh, 340px) !important; border-radius: 0; }
#recipe-dialog.side-panel .sheet-v2 .sheet-photo { height: clamp(200px, 30vh, 300px) !important; }
.sheet-v2 .sheet-photo.empty { height: clamp(160px, 22vh, 220px) !important; }
.sheet-v2 .sheet-hero .sheet-head-actions { position: absolute; top: 12px; right: 12px; z-index: 2; display: flex; gap: 8px; }
.sheet-v2 .sheet-hero .sheet-fav, .sheet-v2 .sheet-hero .close-btn { width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.88); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 1px 6px rgba(0,0,0,.12); border: 0; }
.sheet-v2 .photo-credit { top: auto; bottom: 10px; right: 10px; left: auto; }
.sheet-v2 .photo-tools { left: 12px; bottom: 12px; }

.sheet-v2 .sheet-body { flex: 1; padding: 20px 22px 8px; }
.sheet-v2 .sheet-head { display: block; }
.sheet-v2 #sheet-title { margin: 0; font-size: 1.6rem; line-height: 1.15; letter-spacing: -.02em; }
.sheet-v2 .sheet-head .meta { margin-top: 6px; font-size: .92rem; }

.sheet-nutri { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 18px 0 6px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.sheet-nutri span { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .72rem; color: var(--muted); text-align: center; }
.sheet-nutri span + span { border-left: 1px solid var(--line); }
.sheet-nutri b { font-size: 1.12rem; font-weight: 700; color: var(--text); letter-spacing: -.01em; }

.sheet-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 22px 0 4px; }
.sheet-section-head h3 { margin: 0; font-size: 1.12rem; }
.sheet-v2 .missing-note { margin: 6px 0 4px; padding: 10px 12px; border-radius: 12px; font-size: .88rem; }
.sheet-v2 .ing-list li { padding: 11px 0; align-items: center; }
.sheet-v2 .ing-list .swap-icon { opacity: .35; margin-left: 8px; }
.sheet-v2 .ing-list li:hover .swap-icon { opacity: .8; }
.sheet-v2 .swap-hint { margin: 6px 0 0; font-size: .8rem; }
.sheet-v2 .steps li { padding-bottom: 16px; line-height: 1.5; }
.sheet-v2 .review-actions { display: flex; flex-wrap: wrap; gap: 4px 16px; justify-content: flex-start; margin: 8px 0 0; padding: 0; border: 0; }

/* дії внизу — завжди під рукою */
.sheet-actions { position: sticky; bottom: 0; z-index: 3; flex: none; padding: 12px 22px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(to bottom, rgba(255,255,255,0), var(--surface) 26%); }
.sheet-actions-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.sheet-actions .primary-btn, .sheet-actions .secondary-btn { height: 50px; margin: 0; border-radius: 25px; font: inherit; font-weight: 600; font-size: 1rem; cursor: pointer; }
.sheet-actions .secondary-btn { border: 0; background: var(--surface-2); color: var(--text); }
.sheet-actions .secondary-btn[aria-expanded="true"] { background: var(--seg); }
.slot-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.slot-picker[hidden] { display: none; }
.slot-picker .slot-btn { flex: 1 1 auto; height: 38px; border-radius: 19px; }

/* перехід «картка ↔ вікно рецепта» (анімується саме вікно: clip-path + зсув) */
.morph-source { visibility: hidden !important; }
#recipe-dialog.morphing { overflow: hidden !important; will-change: transform, clip-path; }
#recipe-dialog.morphing .sheet-hero { z-index: 2; }
#recipe-dialog.morphing .sheet-photo { overflow: visible !important; background: transparent !important; }
#recipe-dialog.morphing .morph-pic { position: absolute !important; left: 0; top: 0; max-width: none; object-fit: cover; z-index: 1; }
#recipe-dialog.morphing .sheet-photo.morph-pic { background: var(--surface-2) !important; }
#recipe-dialog.morphing .photo-tools, #recipe-dialog.morphing .photo-credit, #recipe-dialog.morphing .sheet-head-actions { z-index: 3; }
#recipe-dialog.sheet::backdrop { transition: opacity .5s cubic-bezier(.32,.72,0,1); }
#recipe-dialog.dim-off::backdrop { opacity: 0; }
/* жодних рамок фокусу від мишки/дотику — лише з клавіатури */
#recipe-dialog, #recipe-dialog:focus { outline: none; }
.card-main:focus:not(:focus-visible), .meal-main:focus:not(:focus-visible), .search-item-main:focus:not(:focus-visible), #recipe-dialog :focus:not(:focus-visible) { outline: none; }
.card-main, .meal-main, .search-item-main, .eaten-main { -webkit-tap-highlight-color: transparent; }

#recipe-dialog.morph-opened[open] { animation: none !important; }
.sheet-actions:has(.slot-picker:not([hidden])) { background: var(--surface); box-shadow: 0 -8px 24px rgba(0,0,0,.06); }

/* ==========================================================================
   Рецепти: група = великий заголовок (+ «Усі» праворуч) і рівна сітка під ним; групи розділені лінією
   ========================================================================== */
:root { --bg: #fbfaf8; }
body { background: var(--bg); }
.dish-group + .dish-group { margin-top: 34px; padding-top: 26px; border-top: 1px solid var(--line); }
.dish-group:first-child .group-head { margin-top: 28px; }
.group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 14px; }
.group-head .group-title { margin: 0; font-size: 1.6rem; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; }
.group-head .group-count { vertical-align: 4px; }
.group-all { flex: none; border: 0; background: none; padding: 6px 2px; color: var(--accent); font: inherit; font-size: 1rem; font-weight: 600; cursor: pointer; }
.group-all:hover { text-decoration: underline; }
.dish-group .group-note { margin: -6px 0 14px; }
@media (min-width: 1100px) { .group-head .group-title { font-size: 1.85rem; } }

/* ==========================================================================
   Раціон на день — таймлайн: лінія дня з галочками, фото поруч із назвою
   ========================================================================== */
.meals.timeline { list-style: none; margin: 8px 0 0; padding: 0; display: block; background: transparent; }
.timeline > .meal { position: relative; display: grid !important; grid-template-columns: 30px minmax(0, 1fr); column-gap: 14px; padding: 0 0 22px; margin: 0; border: 0; background: transparent !important; box-shadow: none !important; }
.timeline > .meal:last-child { padding-bottom: 0; }
/* вертикальна лінія між галочками */
.timeline > .meal::before { content: ""; position: absolute; left: 14px; top: 36px; bottom: 4px; width: 2px; border-radius: 1px; background: var(--line); }
.timeline > .meal:last-child::before { display: none; }
.timeline > .meal.done::before { background: var(--accent); }
.timeline .meal-actions { grid-column: 1; grid-row: 1; position: static; margin: 0; padding: 0; border: 0; background: transparent; align-self: start; }
.timeline .meal-actions .log-btn { width: 30px; height: 30px; padding: 0; margin: 0; border: 0; background: transparent; display: grid; place-items: center; box-shadow: none; }
.timeline .meal-actions .check-circle { width: 28px; height: 28px; }
.timeline .meal-main { grid-column: 2; grid-row: 1; display: grid !important; grid-template-columns: 96px minmax(0, 1fr); grid-template-areas: "top top" "thumb name" "thumb kcal" "thumb tag" "thumb ."; grid-template-rows: auto auto auto auto 1fr; column-gap: 14px; row-gap: 2px; align-items: start; padding: 0 !important; border: 0; background: transparent; text-align: left; color: var(--text); width: 100%; }
.timeline .meal-main > .thumb { grid-area: thumb; width: 96px !important; height: 96px !important; aspect-ratio: auto; border-radius: 16px !important; margin: 0; align-self: start; box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.timeline .meal-top { grid-area: top; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 5px 0 8px; }
.timeline .meal-slot { font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.timeline > .meal.done .meal-slot { color: var(--accent); }
.timeline .meal-name { grid-area: name; align-self: end; margin: 8px 0 0; font-size: 1.06rem; font-weight: 600; line-height: 1.25; color: var(--text); }
.timeline .meal-kcal { grid-area: kcal; font-size: .84rem; color: var(--muted); margin: 2px 0 0; }
.timeline .meal-macros { display: none; }
.timeline .meal-main > .tag { grid-area: tag; width: fit-content; margin-top: 6px; }
.timeline > .meal.done .meal-name { color: var(--muted); }
.timeline > .meal.done .thumb { opacity: .8; }
.timeline .meal-main:hover .meal-name { color: var(--accent); }
.timeline > .meal.done .meal-main:hover .meal-name { color: var(--accent); }
@media (min-width: 700px) {
  .timeline .meal-main { grid-template-columns: 120px minmax(0, 1fr); }
  .timeline .meal-main > .thumb { width: 120px !important; height: 120px !important; }
}
