/* ── Токены ─────────────────────────────────────────────── */
:root {
  color-scheme: light;
  --bg: #f4f1e8;
  --bg-deep: #ece7da;
  --surface: #fffdf8;
  --surface-2: #f9f6ee;
  --surface-3: #f1ede1;
  --ink: #242a20;
  --ink-soft: #3b4336;
  --muted: #6d7464;
  --dim: #969c8c;
  --line: #e3dfd1;
  --line-strong: #d4cfbe;
  --accent: #5c8a4d;
  --accent-2: #7fa86c;
  --accent-soft: #e8f0df;
  --accent-ink: #3d6031;
  --warm: #cf8757;
  --warm-soft: #f7e8d9;
  --danger: #b45c43;
  --danger-soft: #f7e3dc;
  --blue: #587d9c;
  --blue-soft: #e6eef4;
  --shadow-sm: 0 1px 2px rgba(42, 46, 32, .05);
  --shadow: 0 2px 4px rgba(42, 46, 32, .04), 0 18px 46px -30px rgba(42, 46, 32, .35);
  --shadow-lg: 0 30px 80px -30px rgba(25, 31, 18, .45);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 26px;
  --font: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar: 258px;
  --nav-h: 68px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11150e;
  --bg-deep: #0b0e09;
  --surface: #191e15;
  --surface-2: #1e2419;
  --surface-3: #242b1e;
  --ink: #eef2e7;
  --ink-soft: #d6dccb;
  --muted: #a3ab98;
  --dim: #7b8371;
  --line: #2b3224;
  --line-strong: #3a4331;
  --accent: #8cbb75;
  --accent-2: #a4cc8e;
  --accent-soft: #24301d;
  --accent-ink: #c3e3b2;
  --warm: #e0a173;
  --warm-soft: #32251a;
  --danger: #e08a72;
  --danger-soft: #35221c;
  --blue: #8fb4cf;
  --blue-soft: #1d2933;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 2px 4px rgba(0, 0, 0, .25), 0 24px 60px -34px rgba(0, 0, 0, .8);
  --shadow-lg: 0 40px 90px -30px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 520px at 8% -12%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 62%),
    radial-gradient(760px 480px at 96% 4%, color-mix(in srgb, var(--warm) 10%, transparent), transparent 60%);
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4, p { margin: 0; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }

/* ── Каркас ─────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 20px;
  padding: 26px 18px 20px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 62%, transparent);
  backdrop-filter: blur(14px);
  z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 8px 18px; text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.brand-mark { color: var(--accent); display: grid; place-items: center; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--serif); font-size: 23px; letter-spacing: -.02em; font-weight: 600; }
.brand-text small { color: var(--muted); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 11px;
  color: var(--muted); text-decoration: none; font-weight: 500;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.nav a:hover { background: var(--surface-3); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-icon {
  width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: 8px; background: color-mix(in srgb, var(--ink) 5%, transparent);
  font-size: 14px;
}
.nav a.active .nav-icon { background: color-mix(in srgb, var(--accent) 20%, transparent); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.source-note {
  padding: 13px 14px; border: 1px solid var(--line); border-radius: 13px;
  background: var(--surface-2); color: var(--muted); font-size: 12.5px; line-height: 1.45;
}
.source-note b { display: block; color: var(--ink); font-size: 12.5px; margin-bottom: 3px; }
.tg-link {
  color: var(--accent-ink); text-decoration: none; font-weight: 600; font-size: 13px;
  padding: 10px 12px; border-radius: 11px; background: var(--accent-soft);
}
.tg-link:hover { filter: brightness(.97); }

.content { min-width: 0; padding: 0 38px; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 18px 0 14px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.menu-toggle { display: none; }
.topbar-title { min-width: 0; }
.eyebrow {
  font: 600 10.5px/1 var(--mono);
  letter-spacing: .14em; text-transform: uppercase; color: var(--dim);
}
.topbar h1 {
  font-family: var(--serif); font-size: clamp(24px, 2.6vw, 31px);
  letter-spacing: -.02em; font-weight: 600; line-height: 1.1; margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.kcal-chip {
  display: flex; align-items: baseline; gap: 5px;
  padding: 8px 13px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); box-shadow: var(--shadow-sm);
  font-family: var(--mono); font-weight: 600; font-size: 13px;
}
.kcal-chip small { color: var(--muted); font-size: 10.5px; font-weight: 500; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface); color: var(--ink-soft);
  transition: background .16s ease, border-color .16s ease;
}
.icon-btn:hover { background: var(--surface-3); border-color: var(--line-strong); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  background: var(--accent-soft); color: var(--accent-ink);
  font-weight: 700; font-size: 14px;
}
.app-main { flex: 1; padding: 24px 0 44px; max-width: 1220px; width: 100%; margin: 0 auto; outline: none; }
.app-footer {
  display: flex; flex-wrap: wrap; gap: 6px 22px; justify-content: space-between;
  padding: 18px 0 26px; border-top: 1px solid var(--line);
  color: var(--dim); font-size: 12px;
}
.app-footer a { color: var(--muted); text-decoration: none; }
.bottom-nav { display: none; }

/* ── Общие блоки ────────────────────────────────────────── */
.page-head { display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .lead { color: var(--muted); max-width: 640px; font-size: 14.5px; margin-top: 4px; }
.page-head-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.section { margin-top: 26px; }
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.section-head h2 { font-family: var(--serif); font-size: 21px; font-weight: 600; letter-spacing: -.01em; }
.section-head .section-link { margin-left: auto; color: var(--accent-ink); text-decoration: none; font-size: 13px; font-weight: 600; }
.section-head .muted { margin-left: auto; color: var(--dim); font-size: 12.5px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 12.5px; }
.tiny { font-size: 11px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.span-2 { grid-column: span 2; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-hover { transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-title h3 { font-size: 15.5px; font-weight: 650; letter-spacing: -.01em; }
.card-title .muted { margin-left: auto; font-size: 12px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; border: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 15px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: 13.5px;
  text-decoration: none; transition: background .16s ease, border-color .16s ease, transform .16s ease;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-3); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); border-color: transparent; }
[data-theme="dark"] .btn-primary { color: #10180c; }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { padding: 7px 11px; font-size: 12.5px; border-radius: 9px; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2);
  color: var(--muted); font-size: 12px; font-weight: 500;
  text-decoration: none; white-space: nowrap;
}
button.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); color: var(--accent-ink); font-weight: 600; }
.chip-warm { background: var(--warm-soft); color: var(--warm); border-color: transparent; }
.chip-blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 7px;
  background: var(--surface-3); color: var(--muted);
  font: 600 10.5px/1.4 var(--mono); letter-spacing: .03em; text-transform: uppercase;
}
.badge-accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge-warm { background: var(--warm-soft); color: var(--warm); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-3); border: 1px solid var(--line); border-radius: 11px;
}
.segmented button {
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 13px; border-radius: 8px; font-size: 12.5px; font-weight: 600;
}
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.empty {
  padding: 36px 22px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}
.empty b { display: block; color: var(--ink); margin-bottom: 4px; }

/* ── Главная ────────────────────────────────────────────── */
.hero {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(260px, .65fr);
  gap: 20px; padding: 28px 30px;
  border-radius: var(--radius-lg); border: 1px solid var(--line);
  background:
    radial-gradient(600px 300px at 100% 0%, color-mix(in srgb, var(--warm) 18%, transparent), transparent 70%),
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, var(--surface)) 0%, var(--surface) 62%);
  box-shadow: var(--shadow);
}
.hero-copy { position: relative; z-index: 2; display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.hero h2 { font-family: var(--serif); font-size: clamp(27px, 3.1vw, 38px); line-height: 1.06; letter-spacing: -.025em; font-weight: 600; max-width: 520px; }
.hero p { color: var(--muted); max-width: 480px; font-size: 14.5px; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.hero-art {
  position: relative; z-index: 1; min-height: 220px; border-radius: 22px; overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  background: var(--surface-2);
}
.hero-art img { width: 100%; height: 100%; object-fit: cover; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .78fr); gap: 18px; align-items: start; }
.layout-main-side { grid-template-columns: minmax(0, 1.55fr) minmax(280px, .72fr); align-items: start; }
.layout-side-main { grid-template-columns: minmax(300px, .85fr) minmax(0, 1.15fr); align-items: start; }
.hero-stats { display: flex; gap: 26px; flex-wrap: wrap; margin-top: 4px; }
.hero-stat b { display: block; font-family: var(--serif); font-size: 25px; line-height: 1.1; font-weight: 600; }
.hero-stat span { color: var(--muted); font-size: 11.5px; }

.ring-wrap { display: flex; align-items: center; gap: 18px; }
.ring { position: relative; width: 138px; height: 138px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
}
.ring-center b { font-family: var(--serif); font-size: 25px; line-height: 1; font-weight: 600; }
.ring-center span { color: var(--muted); font-size: 10.5px; margin-top: 3px; }
.ring-legend { display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; }
.ring-legend div { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.dot-warm { background: var(--warm); }
.dot-blue { background: var(--blue); }
.dot-line { background: var(--line-strong); }

.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat {
  padding: 14px 15px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.stat b { display: block; font-family: var(--serif); font-size: 22px; font-weight: 600; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 11.5px; }
.stat small { display: block; color: var(--dim); font-size: 10.5px; margin-top: 2px; }

/* Приёмы пищи */
.meal-list { display: flex; flex-direction: column; gap: 14px; }
.meal {
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface);
  overflow: hidden;
}
.meal-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 15px;
  background: color-mix(in srgb, var(--surface-3) 55%, transparent);
  border-bottom: 1px solid var(--line);
}
.meal-head h3 { font-size: 13.5px; font-weight: 700; letter-spacing: .01em; }
.meal-head .meal-icon { font-size: 15px; }
.meal-head .meal-time { color: var(--dim); font-size: 11.5px; }
.meal-kcal { margin-left: auto; font: 600 12px var(--mono); color: var(--accent-ink); }
.meal-body { display: flex; flex-direction: column; }
.food-row {
  display: flex; align-items: center; gap: 11px; padding: 10px 15px;
  border-top: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  transition: background .14s ease;
}
.food-row:first-child { border-top: 0; }
.food-row:hover { background: var(--surface-2); }
.row-actions { display: flex; gap: 3px; margin-left: 4px; }
.row-action {
  width: 24px; height: 24px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); font-size: 12px; line-height: 1;
  display: grid; place-items: center; padding: 0;
}
.row-action:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.row-action.remove:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.food-check { position: relative; flex: none; width: 20px; height: 20px; }
.food-check input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.food-check span {
  position: absolute; inset: 0; border: 1.5px solid var(--line-strong);
  border-radius: 6px; background: var(--surface); transition: all .14s ease;
}
.food-check span::after {
  content: "✓"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12px; color: #fff; opacity: 0; transform: scale(.6); transition: all .14s ease;
}
.food-check input:checked + span { background: var(--accent); border-color: var(--accent); }
.food-check input:checked + span::after { opacity: 1; transform: scale(1); }
.food-check input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.food-main { min-width: 0; flex: 1; }
.food-name { font-size: 13.5px; font-weight: 500; }
.food-name small { color: var(--muted); font-weight: 400; }
.food-link {
  border: 0; background: none; padding: 0; font: inherit; color: inherit;
  text-align: left; border-bottom: 1px dashed transparent;
}
.food-link:hover { color: var(--accent-ink); border-bottom-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.food-meta { color: var(--dim); font-size: 11px; margin-top: 1px; }
.food-kcal { font: 600 12px var(--mono); color: var(--muted); white-space: nowrap; }
.food-row.done .food-name { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.meal-total {
  display: flex; justify-content: space-between; padding: 9px 15px;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 11.5px;
  background: color-mix(in srgb, var(--surface-3) 30%, transparent);
}
.meal-total b { color: var(--ink); }

/* Вода и шаги */
.water-glasses { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.water-glass {
  width: 30px; height: 38px; border-radius: 5px 5px 9px 9px;
  border: 1.5px solid var(--line-strong); background: transparent;
  position: relative; overflow: hidden; padding: 0;
}
.water-glass.filled { border-color: var(--blue); }
.water-glass.filled::after {
  content: ""; position: absolute; inset: 18% 0 0;
  background: color-mix(in srgb, var(--blue) 55%, transparent);
}
.water-glass:hover { border-color: var(--blue); }
.progress-track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress-fill { height: 100%; border-radius: inherit; background: var(--accent); transition: width .3s ease; }
.progress-fill.warm { background: var(--warm); }
.progress-fill.blue { background: var(--blue); }
.steps-row { display: flex; align-items: center; gap: 10px; }
.steps-input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); font-family: var(--mono);
}

/* ── Меню ───────────────────────────────────────────────── */
.week-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.week-nav .week-range { font-weight: 650; font-size: 14px; }
.day-tabs { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; margin: 14px 0 18px; }
.day-tab {
  flex: none; min-width: 92px; padding: 9px 11px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); text-align: left;
  transition: all .15s ease;
}
.day-tab:hover { border-color: var(--line-strong); }
.day-tab.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.day-tab.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.day-tab .dt-day { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.day-tab .dt-date { font-weight: 700; font-size: 14px; margin-top: 1px; }
.day-tab .dt-kcal { font: 600 10.5px var(--mono); color: var(--accent-ink); margin-top: 2px; }

.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 9px; }
.week-day {
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  padding: 11px; min-height: 220px; display: flex; flex-direction: column; gap: 8px;
  transition: border-color .15s ease, box-shadow .15s ease;
  font: inherit; color: inherit; text-align: left; width: 100%; cursor: pointer;
}
.week-meal { display: block; }
.week-day:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.week-day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.week-day-head { display: flex; align-items: baseline; gap: 5px; }
.week-day-head b { font-size: 12px; text-transform: capitalize; }
.week-day-head span { color: var(--dim); font-size: 10.5px; }
.week-day-kcal { font: 650 11px var(--mono); color: var(--accent-ink); margin-left: auto; }
.week-meal { border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); padding-top: 6px; }
.week-meal .wm-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--dim); }
.week-meal .wm-text { font-size: 10.5px; color: var(--ink-soft); line-height: 1.32; margin-top: 1px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.week-day-foot { margin-top: auto; display: flex; gap: 5px; padding-top: 6px; }

/* Календарь */
.calendar-head { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-bottom: 5px; }
.calendar-head span { text-align: center; font-size: 10.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; padding: 4px 0; }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-cell {
  position: relative; min-height: 82px; padding: 7px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  text-align: left; display: flex; flex-direction: column; gap: 2px;
  transition: all .14s ease; font: inherit; color: inherit; cursor: pointer;
}
.cal-cell:hover { border-color: var(--line-strong); }
.cal-cell.empty { background: transparent; border-color: transparent; pointer-events: none; }
.cal-cell.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-cell.selected { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.cal-cell .cc-day { font-size: 12px; font-weight: 600; }
.cal-cell .cc-kcal { font: 600 10px var(--mono); color: var(--accent-ink); }
.cal-cell .cc-menu { font-size: 9.5px; color: var(--dim); line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.cal-cell .cc-mark { position: absolute; top: 6px; right: 6px; font-size: 9px; color: var(--accent); }

/* Замена блюд */
.swap-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow: auto; padding-right: 4px; }
.swap-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  text-align: left; width: 100%;
}
.swap-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.swap-item .swap-kcal { margin-left: auto; font: 600 11px var(--mono); color: var(--muted); }

/* ── Рецепты ────────────────────────────────────────────── */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.search {
  position: relative; flex: 1 1 240px; min-width: 200px;
}
.search input {
  width: 100%; padding: 10px 13px 10px 36px;
  border: 1px solid var(--line); border-radius: 11px; background: var(--surface);
}
.search input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
.search::before { content: "⌕"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--dim); font-size: 18px; }
select.select {
  padding: 10px 32px 10px 12px; border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%236d7464' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  appearance: none; font-size: 13px;
}
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.recipe-card {
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface);
  overflow: hidden; display: flex; flex-direction: column;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  cursor: pointer; text-align: left; padding: 0;
}
.recipe-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.recipe-img { position: relative; aspect-ratio: 4 / 2.7; overflow: hidden; background: var(--surface-3); }
.recipe-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.recipe-card:hover .recipe-img img { transform: scale(1.04); }
.recipe-img .kcal-badge {
  position: absolute; left: 9px; bottom: 9px;
  padding: 4px 8px; border-radius: 7px;
  background: color-mix(in srgb, #fff 88%, transparent); color: #2c3427;
  font: 700 10.5px var(--mono); backdrop-filter: blur(4px);
}
.recipe-img .fav-btn {
  position: absolute; top: 8px; right: 8px; width: 29px; height: 29px;
  border: 0; border-radius: 50%; background: color-mix(in srgb, #fff 84%, transparent);
  color: #7a5a4a; font-size: 14px; display: grid; place-items: center;
}
.recipe-img .fav-btn.active { color: #c0533f; }
.recipe-body { padding: 12px 13px 13px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.recipe-body h3 { font-size: 14px; font-weight: 650; line-height: 1.28; letter-spacing: -.01em; }
.recipe-body p { color: var(--muted); font-size: 11.5px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.recipe-meta { display: flex; gap: 7px; flex-wrap: wrap; margin-top: auto; padding-top: 5px; }
.recipe-meta .badge { font-size: 9px; padding: 2px 6px; }
.recipe-card.hidden { display: none; }

.recipe-detail { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 0; }
.recipe-detail-art { min-height: 260px; background: var(--surface-3); }
.recipe-detail-art img { width: 100%; height: 100%; object-fit: cover; }
.recipe-detail-body { padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.recipe-detail-body h2 { font-family: var(--serif); font-size: 25px; font-weight: 600; line-height: 1.12; letter-spacing: -.02em; }
.nutri-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.nutri {
  padding: 8px 6px; text-align: center; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.nutri b { display: block; font: 650 14px var(--mono); }
.nutri span { color: var(--dim); font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em; }
.ing-list { display: flex; flex-direction: column; gap: 5px; }
.ing-row { display: flex; align-items: baseline; gap: 8px; font-size: 12.5px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.ing-row .ing-name { flex: 1; }
.ing-row .ing-qty { color: var(--muted); font-family: var(--mono); font-size: 11.5px; white-space: nowrap; }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: step; display: flex; flex-direction: column; gap: 9px; }
.steps li { position: relative; padding-left: 31px; font-size: 12.8px; line-height: 1.48; color: var(--ink-soft); counter-increment: step; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 21px; height: 21px; display: grid; place-items: center;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink);
  font: 700 10.5px var(--mono);
}

/* ── Покупки ────────────────────────────────────────────── */
.shop-toolbar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 15px; }
.shop-summary {
  display: flex; gap: 18px; flex-wrap: wrap; align-items: center;
  padding: 13px 16px; border-radius: 14px; border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--accent-soft), var(--surface));
  margin-bottom: 16px;
}
.shop-summary b { font-family: var(--serif); font-size: 23px; font-weight: 600; }
.shop-summary .ss-item { display: flex; flex-direction: column; }
.shop-summary .ss-item span { color: var(--muted); font-size: 11px; }
.shop-cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, .7fr); gap: 16px; align-items: start; }
.shop-category { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; margin-bottom: 10px; }
.shop-cat-head {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 12px 14px;
  background: color-mix(in srgb, var(--surface-3) 55%, transparent); border: 0;
  text-align: left; border-bottom: 1px solid var(--line);
}
.shop-cat-head h3 { font-size: 13px; font-weight: 700; }
.shop-cat-head .cat-cost { margin-left: auto; font: 600 11.5px var(--mono); color: var(--muted); }
.shop-cat-head .cat-count { color: var(--dim); font-size: 10.5px; }
.shop-items { display: flex; flex-direction: column; }
.shop-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  border-top: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
}
.shop-item:first-child { border-top: 0; }
.shop-item:hover { background: var(--surface-2); }
.shop-item.checked .si-name { color: var(--dim); text-decoration: line-through; }
.shop-check { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.si-main { flex: 1; min-width: 0; }
.si-name { font-size: 12.8px; font-weight: 500; }
.si-store { color: var(--dim); font-size: 10.5px; margin-top: 1px; }
.si-store a { color: var(--dim); text-decoration: none; border-bottom: 1px dotted var(--line-strong); }
.si-store a:hover { color: var(--accent-ink); border-bottom-color: var(--accent); }
.si-qty { font: 600 11px var(--mono); color: var(--ink-soft); white-space: nowrap; }
.si-cost { font: 500 10.5px var(--mono); color: var(--dim); white-space: nowrap; }
.store-card { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); padding: 14px; margin-bottom: 10px; }
.store-card h3 { font-size: 13px; margin-bottom: 3px; }
.store-card .store-cost { font: 600 12px var(--mono); color: var(--accent-ink); }
.store-card ul { margin: 8px 0 0; padding-left: 17px; color: var(--muted); font-size: 11.5px; }
.store-card li { margin-bottom: 2px; }

/* ── Калькулятор ────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.field input, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); font-size: 13.5px;
}
.field input:focus, .field select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
.field .hint { color: var(--dim); font-size: 10.5px; }
.result-big { display: flex; align-items: baseline; gap: 8px; margin: 4px 0 2px; }
.result-big b { font-family: var(--serif); font-size: 48px; line-height: 1; font-weight: 600; letter-spacing: -.03em; }
.result-big span { color: var(--muted); font-size: 13px; }
.macro-bars { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.macro-bar .mb-head { display: flex; justify-content: space-between; font-size: 11.5px; margin-bottom: 4px; }
.macro-bar .mb-head b { font-family: var(--mono); font-size: 11px; }
.macro-bar .mb-head span { color: var(--muted); }
.macro-track { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.macro-track i { display: block; height: 100%; border-radius: inherit; }
.macro-protein { background: var(--accent); }
.macro-fat { background: var(--warm); }
.macro-carbs { background: var(--blue); }
.bmi-scale { position: relative; height: 8px; border-radius: 999px; margin: 20px 0 8px; background: linear-gradient(90deg, #8fb4cf 0 18%, #7fa86c 18% 48%, #d8b45e 48% 68%, #c9795f 68% 100%); }
.bmi-marker { position: absolute; top: -5px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 2px solid var(--ink); transform: translateX(-50%); }
.bmi-labels { display: flex; justify-content: space-between; color: var(--dim); font-size: 10px; }

/* ── Прогресс ───────────────────────────────────────────── */
.chart-card { padding: 18px; }
.chart-wrap { position: relative; width: 100%; height: 260px; }
.chart-wrap canvas { width: 100% !important; height: 100% !important; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; color: var(--muted); font-size: 11.5px; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.log-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.log-table th { text-align: left; color: var(--dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.log-table td { padding: 8px; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.log-table tr:last-child td { border-bottom: 0; }
.history-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.history-item:last-child { border-bottom: 0; }
.history-item .hi-date { color: var(--muted); font-size: 12px; }
.history-item .hi-kcal { margin-left: auto; font: 600 12px var(--mono); }

/* ── Источники и правила ────────────────────────────────── */
.rules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.rule { display: flex; gap: 11px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.rule .rule-icon { font-size: 18px; line-height: 1.2; flex: none; }
.rule b { display: block; font-size: 12.5px; margin-bottom: 2px; }
.rule p { color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.source-card { display: flex; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); align-items: flex-start; }
.source-card .source-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; font-size: 20px; flex: none; }
.source-card h3 { font-size: 14px; margin-bottom: 3px; }
.source-card p { color: var(--muted); font-size: 12px; }
.source-card .source-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.callout {
  padding: 14px 16px; border-radius: 13px; border: 1px solid color-mix(in srgb, var(--warm) 30%, var(--line));
  background: var(--warm-soft); color: color-mix(in srgb, var(--warm) 65%, var(--ink));
  font-size: 12.5px; line-height: 1.5;
}

/* ── Модальные окна ─────────────────────────────────────── */
.modal-root { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 22px; }
.modal-root[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(18, 22, 14, .52); backdrop-filter: blur(5px); }
.modal-card {
  position: relative; z-index: 1; width: min(900px, 100%); max-height: min(86vh, 900px);
  overflow: auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; box-shadow: var(--shadow-lg);
  animation: pop .2s ease;
}
@keyframes pop { from { transform: translateY(10px) scale(.99); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-close {
  position: sticky; top: 10px; float: right; margin: 10px 10px -46px 0; z-index: 3;
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 17px; display: grid; place-items: center;
}
.modal-pad { padding: 24px; }
.modal-small { width: min(520px, 100%); }
.modal-head { margin-bottom: 14px; }
.modal-head h2 { font-family: var(--serif); font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.modal-head p { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }

/* ── Тост ───────────────────────────────────────────────── */
.toast-root { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  padding: 10px 16px; border-radius: 999px; background: var(--ink); color: var(--bg);
  font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow-lg);
  animation: toastIn .22s ease;
}
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Адаптив ────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .week-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .layout-main-side, .layout-side-main { grid-template-columns: 1fr; }
}
@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 1fr; }
  .home-grid { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 268px;
    transform: translateX(-104%); transition: transform .22s ease;
    box-shadow: var(--shadow-lg); background: var(--surface);
  }
  body.nav-open .sidebar { transform: none; }
  .menu-toggle { display: grid; }
  .content { padding: 0 22px; }
  .shop-cols { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .content { padding: 0 14px; }
  .topbar { padding: 12px 0 10px; gap: 10px; }
  .topbar h1 { font-size: 22px; }
  .topbar .eyebrow { font-size: 9.5px; }
  .kcal-chip { padding: 7px 10px; }
  .kcal-chip small { display: none; }
  .app-main { padding: 16px 0 92px; }
  .app-footer { display: none; }
  .bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    display: flex; justify-content: space-around; align-items: center;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    border-top: 1px solid var(--line); backdrop-filter: blur(16px);
  }
  .bottom-nav a {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 4px 6px; border-radius: 8px; text-decoration: none;
    color: var(--dim); font-size: 9.5px; font-weight: 600; min-width: 52px;
  }
  .bottom-nav a span { font-size: 17px; line-height: 1; }
  .bottom-nav a.active { color: var(--accent-ink); background: var(--accent-soft); }
  .hero { grid-template-columns: 1fr; padding: 22px; gap: 16px; }
  .hero-art { min-height: 180px; order: -1; }
  .hero h2 { font-size: 27px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .week-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cal-cell { min-height: 62px; padding: 5px; }
  .cal-cell .cc-menu { display: none; }
  .calendar-head span { font-size: 9px; }
  .recipe-grid { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 10px; }
  .recipe-body { padding: 10px; }
  .recipe-body h3 { font-size: 12.5px; }
  .recipe-body p { display: none; }
  .recipe-detail { grid-template-columns: 1fr; }
  .recipe-detail-art { min-height: 190px; }
  .recipe-detail-body { padding: 18px; }
  .nutri-row { grid-template-columns: repeat(5, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .shop-summary { gap: 12px; }
  .modal-root { padding: 0; align-items: end; }
  .modal-card { max-height: 92vh; border-radius: 22px 22px 0 0; width: 100%; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .page-head { align-items: flex-start; }
  .page-head-actions { margin-left: 0; width: 100%; }
  .section-head h2 { font-size: 18px; }
  .day-tabs { margin-left: -14px; margin-right: -14px; padding-left: 14px; padding-right: 14px; }
  .rules-grid { grid-template-columns: 1fr; }
  .source-card { flex-wrap: wrap; }
  .source-card .source-actions { margin-left: 58px; }
}
@media (max-width: 420px) {
  .week-grid { grid-template-columns: 1fr; }
  .week-day { min-height: 0; }
  .recipe-grid { grid-template-columns: 1fr 1fr; }
  .recipe-img { aspect-ratio: 1 / .85; }
  .nutri-row { gap: 3px; }
}

@media print {
  .sidebar, .topbar, .bottom-nav, .app-footer, .btn, .filters, .shop-toolbar { display: none !important; }
  .content { padding: 0; }
  .app-shell { display: block; }
  body { background: #fff; }
  .card, .shop-category, .shop-item { box-shadow: none; break-inside: avoid; }
}
