/* NutriLens — личный дневник питания
   Типографика: Roboto Flex (переменная ширина/вес — сжатые заголовки, «дышащие» буквы),
   Cormorant Garamond italic — рукописный голос дневника, JetBrains Mono — служебные метки. */

:root {
  --bg: #E8E9ED;
  --bg-2: #DFE1E7;
  --card: #FFFFFF;
  --ink: #0B0B0C;
  --fg: #0B0B0C;
  --pill-warn: #FFE3DB;
  --ink-2: #1C1D21;
  --lime: #BEFF4F;
  --lime-2: #A6F02A;
  --ghost: #C4C9D5;
  --mute: #585D6B;
  --line: #CDD1DA;
  --warn: #FF5A36;
  --blue: #AEB7CC;
  --r: 18px;
  --r-lg: 28px;
  --ease: cubic-bezier(.7, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --display: 'Roboto Flex', 'Arial Narrow', system-ui, sans-serif;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --gutter: clamp(16px, 3.2vw, 44px);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--fg);
  font-family: var(--display); font-variation-settings: 'wdth' 100, 'opsz' 14;
  font-size: 16px; line-height: 1.45; overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; }
img { max-width: 100%; display: block; }
::selection { background: var(--lime); color: var(--ink); }
:focus-visible { outline: 3px solid var(--fg); outline-offset: 3px; border-radius: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- typography ---------- */
.mega, .h1, .h2, .h3 {
  font-family: var(--display); text-transform: uppercase; margin: 0; letter-spacing: -.01em;
  font-variation-settings: 'wdth' 30, 'wght' 760, 'opsz' 144; line-height: .9;
}
.mega { font-size: clamp(64px, 13vw, 230px); line-height: .82; }
.h1 { font-size: clamp(46px, 7.6vw, 120px); }
.h2 { font-size: clamp(34px, 4.6vw, 64px); }
.h3 { font-size: clamp(22px, 2.4vw, 30px); font-variation-settings: 'wdth' 40, 'wght' 700, 'opsz' 72; line-height: .95; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: .02em; text-transform: none; }
.kicker { font-family: var(--mono); font-size: 12px; color: var(--mute); display: inline-flex; gap: .5em; align-items: center; }
.kicker::before { content: '/'; color: var(--fg); font-weight: 700; }
.serif { font-family: var(--serif); font-style: italic; font-weight: 500; letter-spacing: 0; }
.lead { font-size: clamp(16px, 1.4vw, 19px); max-width: 46ch; color: var(--ink-2); }
.muted { color: var(--mute); }
.num { font-variant-numeric: tabular-nums; }

/* Разбитые на буквы заголовки: буквы «вдыхаются» из широкого тонкого начертания в узкое жирное */
.split .ch {
  display: inline-block; white-space: pre;
  animation: chIn 1.1s var(--ease-out) both;
  animation-delay: calc(var(--i) * 28ms + var(--base, 0ms));
  transition: font-variation-settings .5s var(--ease-out), transform .5s var(--ease-out);
}
.split.hoverable .ch:hover { font-variation-settings: 'wdth' 151, 'wght' 300, 'opsz' 144; }
@keyframes chIn {
  0% { opacity: 0; transform: translateY(.45em) rotate(4deg); font-variation-settings: 'wdth' 151, 'wght' 150, 'opsz' 144; }
  60% { opacity: 1; }
  100% { opacity: 1; transform: none; font-variation-settings: 'wdth' 30, 'wght' 760, 'opsz' 144; }
}
.h3.split .ch { animation-name: chIn3; }
@keyframes chIn3 {
  0% { opacity: 0; transform: translateY(.4em); font-variation-settings: 'wdth' 151, 'wght' 200, 'opsz' 72; }
  100% { opacity: 1; transform: none; font-variation-settings: 'wdth' 40, 'wght' 700, 'opsz' 72; }
}

/* ---------- reveal ---------- */
.rv { opacity: 0; transform: translateY(46px) skewY(3deg); transform-origin: left top; transition: opacity .9s var(--ease-out), transform 1.1s var(--ease-out); transition-delay: calc(var(--d, 0) * 70ms); }
.rv.in { opacity: 1; transform: none; }
.rv-card { opacity: 0; transform: perspective(1200px) rotateX(18deg) rotateZ(-2deg) translateY(60px); transform-origin: 50% 100%; transition: opacity .8s var(--ease-out), transform 1.2s var(--ease-out); transition-delay: calc(var(--d, 0) * 80ms); }
.rv-card.in { opacity: 1; transform: none; }

/* ---------- preloader ---------- */
[hidden] { display: none !important; }
#preloader { position: fixed; inset: 0; z-index: 100; background: var(--lime); overflow: hidden; }
#preloader .bar { position: absolute; inset: 0 auto 0 0; width: 0; height: 100%; border-radius: 0; background: var(--ink); overflow: hidden; }
#preloader .layer { position: absolute; top: 0; bottom: 0; left: 0; width: 100vw; }
#preloader .cnt {
  position: absolute; right: var(--gutter); bottom: -.1em; font-size: clamp(140px, 30vw, 460px); line-height: 1;
  font-variation-settings: 'wdth' 25, 'wght' 900, 'opsz' 144; color: var(--ink); font-variant-numeric: tabular-nums;
}
#preloader .lbl { position: absolute; left: var(--gutter); top: var(--gutter); font-family: var(--mono); font-size: 12px; color: var(--ink); }
#preloader .lbl.r { left: auto; right: var(--gutter); }
#preloader .bar .cnt, #preloader .bar .lbl { color: var(--lime); }
#preloader.done { transform: translateY(-100%); transition: transform .9s var(--ease); }

/* ---------- page wipe ---------- */
#wipe { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
#wipe i { position: absolute; inset: 0; transform: scaleY(0); transform-origin: bottom; }
#wipe i:nth-child(1) { background: var(--lime); }
#wipe i:nth-child(2) { background: var(--ink); }
#wipe.cover i { transform: scaleY(1); transition: transform .42s var(--ease); }
#wipe.cover i:nth-child(2) { transition-delay: .07s; }
#wipe.reveal i { transform: scaleY(0); transform-origin: top; transition: transform .5s var(--ease); }
#wipe.reveal i:nth-child(1) { transition-delay: .08s; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 16px;
  padding: 14px var(--gutter); background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; margin-right: auto; }
.brand .logo { width: 38px; height: 38px; border-radius: 50%; background: var(--ink); display: grid; place-items: center; transition: transform .6s var(--ease-out); }
.brand:hover .logo { transform: rotate(-180deg); }
.brand .logo svg { width: 20px; height: 20px; }
.brand b { font-variation-settings: 'wdth' 35, 'wght' 800; text-transform: uppercase; font-size: 20px; letter-spacing: .01em; line-height: 1; }
.brand .serif { font-size: 18px; color: var(--mute); line-height: 1; }
.nav { display: flex; gap: 4px; background: var(--card); border-radius: 999px; padding: 4px; box-shadow: 0 1px 0 rgba(0,0,0,.04); }
.nav a { text-decoration: none; padding: 9px 16px; border-radius: 999px; font-size: 14px; font-variation-settings: 'wdth' 90, 'wght' 500; position: relative; transition: color .3s; white-space: nowrap; }
.nav a.on { background: var(--ink); color: var(--lime); }
.nav a:not(.on):hover { background: var(--bg); }
.top .when { font-family: var(--mono); font-size: 12px; color: var(--mute); }

/* mobile dock */
.dock { display: none; }
@media (max-width: 860px) {
  .nav, .top .when { display: none; }
  .dock {
    display: flex; position: fixed; z-index: 45; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom));
    background: var(--ink); border-radius: 22px; padding: 6px; justify-content: space-between; box-shadow: 0 12px 30px rgba(0,0,0,.25);
  }
  .dock a { flex: 1; display: grid; place-items: center; gap: 2px; padding: 8px 2px 6px; border-radius: 16px; color: #8d93a3; text-decoration: none; font-size: 10px; font-family: var(--mono); }
  .dock a svg { width: 22px; height: 22px; }
  .dock a.on { color: var(--ink); background: var(--lime); }
  main { padding-bottom: 110px !important; }
}

/* ---------- layout ---------- */
main { padding: 8px var(--gutter) 80px; max-width: 1480px; margin: 0 auto; position: relative; }
.view-enter > * { animation: viewIn .8s var(--ease-out) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.grid { display: grid; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.section { margin-top: clamp(40px, 6vw, 88px); }
.sec-head { display: flex; align-items: flex-end; gap: 24px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 22px; }

/* ---------- ghost marquee ---------- */
.ghost { position: absolute; left: 0; right: 0; overflow: hidden; pointer-events: none; z-index: 0; user-select: none; }
.ghost .track { display: flex; width: max-content; animation: marquee 40s linear infinite; }
.ghost span {
  font-size: clamp(110px, 17vw, 280px); line-height: .85; text-transform: uppercase; white-space: nowrap; color: var(--ghost);
  font-variation-settings: 'wdth' 28, 'wght' 800, 'opsz' 144; padding-right: .25em;
}
.ghost.outline span { color: transparent; -webkit-text-stroke: 1.5px var(--ghost); }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- buttons ---------- */
.btn {
  --bg-b: var(--ink); --fg-b: #fff;
  display: inline-flex; align-items: center; gap: 12px; padding: 7px 7px 7px 22px; border-radius: 999px;
  background: var(--bg-b); color: var(--fg-b); font-size: 15px; font-variation-settings: 'wdth' 90, 'wght' 600;
  position: relative; overflow: hidden; isolation: isolate; white-space: nowrap; transition: transform .4s var(--ease-out);
  min-height: 48px;
}
.btn::before { content: ''; position: absolute; inset: 0; background: var(--lime); transform: translateX(-101%); transition: transform .55s var(--ease); z-index: -1; }
.btn .arr { width: 36px; height: 36px; border-radius: 50%; background: var(--lime); color: var(--ink); display: grid; place-items: center; transition: transform .55s var(--ease), background .3s; flex: none; }
.btn .arr svg { width: 16px; height: 16px; }
.btn:hover::before { transform: none; }
.btn:hover { color: var(--ink); }
.btn:hover .arr { transform: rotate(-45deg); background: var(--ink); color: var(--lime); }
.btn:disabled { opacity: .35; pointer-events: none; }
.btn.big { font-size: 17px; padding-left: 28px; min-height: 60px; }
.btn.big .arr { width: 46px; height: 46px; }
.btn.light { --bg-b: var(--card); --fg-b: var(--fg); }
.btn.lime { --bg-b: var(--lime); --fg-b: var(--ink); }
.btn.lime::before { background: var(--ink); }
.btn.lime:hover { color: var(--lime); }
.btn.lime .arr { background: var(--ink); color: var(--lime); }
.btn.lime:hover .arr { background: var(--lime); color: var(--ink); }

.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: var(--card);
  font-size: 14px; font-variation-settings: 'wdth' 92, 'wght' 500; border: 1.5px solid transparent; transition: background .25s, border-color .25s, transform .3s var(--ease-out);
  min-height: 40px; white-space: nowrap;
}
.pill:hover { border-color: var(--fg); }
.pill.on, .pill[aria-pressed="true"] { background: var(--ink); color: var(--lime); }
.pill .tick { width: 22px; height: 22px; border-radius: 50%; background: var(--lime); display: grid; place-items: center; flex: none; }
.pill .tick svg { width: 12px; height: 12px; }
.pill.ghosty { background: transparent; border-color: var(--line); }
.pill.warn { background: var(--pill-warn); }
.pill.warn .tick { background: var(--warn); color: #fff; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--card); transition: background .25s, transform .4s var(--ease-out); flex: none; }
.icon-btn:hover { background: var(--ink); color: var(--lime); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.sm { width: 34px; height: 34px; }
.icon-btn.dark { background: var(--ink); color: var(--lime); }
.icon-btn.dark:hover { background: var(--lime); color: var(--ink); }
.link { text-decoration: none; border-bottom: 1.5px solid currentColor; padding-bottom: 1px; font-size: 14px; }

/* ---------- inputs ---------- */
.field { display: grid; gap: 8px; }
.field > span { font-family: var(--mono); font-size: 12px; color: var(--mute); }
.input, .textarea, .select {
  width: 100%; background: var(--card); border: 1.5px solid transparent; border-radius: 14px; padding: 14px 16px; font-size: 16px;
  transition: border-color .25s, box-shadow .25s; outline: none;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--fg); box-shadow: 0 0 0 4px rgba(190,255,79,.55); }
.input.big { font-size: clamp(30px, 4vw, 48px); font-variation-settings: 'wdth' 35, 'wght' 700, 'opsz' 144; padding: 10px 16px; }
.textarea { resize: vertical; min-height: 120px; }
.seg { display: inline-flex; background: var(--card); border-radius: 999px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg button { padding: 9px 16px; border-radius: 999px; font-size: 14px; font-variation-settings: 'wdth' 90, 'wght' 500; transition: background .25s, color .25s; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--lime); }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 6px; background: linear-gradient(to right, var(--fg) var(--p, 50%), var(--line) var(--p, 50%)); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; background: var(--lime); border: 3px solid var(--fg); cursor: grab; transition: transform .2s; }
input[type=range]::-webkit-slider-thumb:active { transform: scale(1.2); cursor: grabbing; }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--lime); border: 3px solid var(--fg); }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: var(--r); padding: clamp(18px, 2vw, 28px); position: relative; }
.card.dark { background: var(--ink); color: #fff; }
.card.lime { background: var(--lime); }
.blob {
  position: relative; overflow: hidden; background: #0d0f0b;
}
.blob::before {
  content: ''; position: absolute; inset: -30%; background:
    radial-gradient(40% 50% at var(--bx, 30%) var(--by, 70%), var(--lime) 0%, rgba(166,240,42,.5) 35%, transparent 70%),
    radial-gradient(35% 45% at calc(var(--bx, 30%) + 40%) calc(var(--by, 70%) - 40%), #6fbf1c 0%, transparent 70%);
  filter: blur(30px); animation: blobDrift 14s ease-in-out infinite alternate;
}
.blob::after { content: ''; position: absolute; inset: 0; background-image: var(--grain); opacity: .5; mix-blend-mode: overlay; }
@keyframes blobDrift { to { transform: translate(8%, -6%) rotate(8deg) scale(1.08); } }

/* ---------- diary ---------- */
.diary-hero { position: relative; padding-top: clamp(10px, 3vw, 40px); }
.diary-hero .ghost { top: clamp(-10px, 1vw, 10px); }
.diary-hero .inner { position: relative; z-index: 1; }
.datebar { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.datebar .h1 { max-width: 12ch; }
.daynav { display: flex; gap: 8px; align-items: center; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin: 26px 0 0; max-width: 620px; }
.week a {
  text-decoration: none; background: var(--card); border-radius: 14px; padding: 8px 6px 10px; display: grid; justify-items: center; gap: 2px;
  transition: transform .35s var(--ease-out), background .25s; position: relative;
}
.week a:hover { transform: translateY(-3px); }
.week a .wd { font-family: var(--mono); font-size: 10px; color: var(--mute); text-transform: uppercase; }
.week a .dn { font-size: 22px; font-variation-settings: 'wdth' 35, 'wght' 750; line-height: 1; }
.week a .dot { width: 26px; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.week a .dot i { display: block; height: 100%; background: var(--fg); }
.week a.on { background: var(--ink); color: #fff; }
.week a.on .wd { color: #9aa0ae; }
.week a.on .dot { background: #333; }
.week a.on .dot i { background: var(--lime); }
.week a.future { opacity: .45; }

.summary { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 16px; margin-top: 28px; }
@media (max-width: 900px) { .summary { grid-template-columns: 1fr; } }
.ringcard { display: grid; grid-template-columns: auto 1fr; gap: clamp(16px, 3vw, 40px); align-items: center; min-height: 300px; border-radius: var(--r-lg); padding: clamp(20px, 3vw, 36px); }
@media (max-width: 520px) { .ringcard { grid-template-columns: 1fr; justify-items: center; text-align: center; } }
.ring { width: clamp(180px, 22vw, 250px); aspect-ratio: 1; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring .trk { stroke: #2a2c31; }
.ring .val { stroke: var(--lime); stroke-linecap: round; transition: stroke-dashoffset 1.6s var(--ease-out); filter: drop-shadow(0 0 14px rgba(190,255,79,.45)); }
.ring .val.over { stroke: var(--warn); filter: drop-shadow(0 0 14px rgba(255,90,54,.45)); }
.ring .mid { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .mid b { font-size: clamp(48px, 6vw, 78px); line-height: .85; font-variation-settings: 'wdth' 28, 'wght' 800, 'opsz' 144; color: var(--lime); }
.ring .mid b.over { color: var(--warn); }
.ring .mid span { font-family: var(--mono); font-size: 11px; color: #9aa0ae; margin-top: 6px; }
.ring-stats { display: grid; gap: 14px; }
.ring-stats .st { display: grid; gap: 2px; }
.ring-stats .st b { font-size: clamp(28px, 3vw, 40px); line-height: 1; font-variation-settings: 'wdth' 32, 'wght' 750, 'opsz' 144; }
.ring-stats .st span { font-family: var(--mono); font-size: 11px; color: #9aa0ae; }
.macros { display: grid; gap: 18px; align-content: center; border-radius: var(--r-lg); padding: clamp(20px, 3vw, 36px); }
.macro { display: grid; gap: 8px; }
.macro .top-l { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.macro .top-l b { font-size: clamp(22px, 2.4vw, 32px); text-transform: uppercase; font-variation-settings: 'wdth' 32, 'wght' 760, 'opsz' 144; line-height: 1; }
.macro .top-l span { font-family: var(--mono); font-size: 12px; color: var(--mute); }
.bar { height: 16px; border-radius: 16px; background: var(--bg); overflow: hidden; position: relative; }
.bar i {
  position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 16px; background: var(--fg); transition: width 1.4s var(--ease-out);
  background-image: repeating-linear-gradient(-45deg, rgba(190,255,79,.0) 0 8px, rgba(190,255,79,.18) 8px 16px);
}
.bar i.over { background-color: var(--warn); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }

.meals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
@media (max-width: 1180px) { .meals { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .meals { grid-template-columns: 1fr; } }
.meal { background: var(--card); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; min-height: 360px; transition: transform .5s var(--ease-out), box-shadow .5s; }
.meal:hover { transform: translateY(-4px); box-shadow: 0 24px 40px -24px rgba(0,0,0,.25); }
.meal .head { height: 128px; padding: 14px 16px; color: #fff; display: flex; justify-content: space-between; align-items: flex-start; }
.meal .head > * { position: relative; z-index: 1; }
.meal .head .mono { color: rgba(255,255,255,.75); }
.meal .badge { position: absolute; right: 16px; bottom: -22px; z-index: 2; width: 52px; height: 52px; border-radius: 50%; background: var(--ink); border: 4px solid var(--card); display: grid; place-items: center; color: var(--lime); }
.meal .badge svg { width: 20px; height: 20px; animation: spin 12s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.meal .body { padding: 22px 16px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; position: relative; }
.meal .title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding-right: 50px; }
.meal .title .h3 { font-size: clamp(26px, 2.4vw, 34px); }
.meal .kc { font-family: var(--mono); font-size: 12px; color: var(--mute); }
.meal .kc b { font-family: var(--display); font-size: 22px; color: var(--fg); font-variation-settings: 'wdth' 35, 'wght' 750; }
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.items li button {
  width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; text-align: left; padding: 9px 10px; border-radius: 10px; transition: background .2s;
}
.items li button:hover { background: var(--bg); }
.items .nm { font-size: 14px; font-variation-settings: 'wdth' 92, 'wght' 550; line-height: 1.25; }
.items .kk { font-size: 14px; font-variation-settings: 'wdth' 70, 'wght' 650; }
.items .sub { grid-column: 1 / -1; font-family: var(--mono); font-size: 11px; color: var(--mute); display: flex; gap: 8px; flex-wrap: wrap; }
.items li.flash button { animation: flash 1.6s var(--ease-out); }
@keyframes flash { 0%, 30% { background: var(--lime); } 100% { background: transparent; } }
.meal .empty { color: var(--mute); font-size: 14px; flex: 1; display: grid; place-content: center; text-align: center; padding: 10px; }
.meal .empty .serif { font-size: 22px; color: var(--fg); display: block; }
.meal .foot { display: flex; gap: 8px; align-items: center; margin-top: auto; padding-top: 8px; }

.note { margin-top: 18px; display: grid; grid-template-columns: minmax(0, 300px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 760px) { .note { grid-template-columns: 1fr; } }
.note textarea {
  width: 100%; min-height: 150px; border: 0; border-radius: var(--r); padding: 18px 22px; resize: vertical; outline: none;
  font-family: var(--serif); font-style: italic; font-size: 22px; line-height: 34px; background-color: var(--card);
  background-image: linear-gradient(transparent 33px, var(--line) 33px, var(--line) 34px); background-size: 100% 34px; background-position: 0 17px;
}
.note textarea:focus { box-shadow: 0 0 0 3px var(--fg); }

.fab {
  position: fixed; z-index: 46; right: var(--gutter); bottom: 28px; width: 72px; height: 72px; border-radius: 50%;
  background: var(--lime); color: var(--ink); display: grid; place-items: center; box-shadow: 0 16px 34px -10px rgba(80,120,0,.6);
  transition: transform .5s var(--ease-out), background .3s, color .3s; text-decoration: none;
}
.fab svg { width: 28px; height: 28px; transition: transform .6s var(--ease-out); }
.fab:hover { background: var(--ink); color: var(--lime); transform: scale(1.06); }
.fab:hover svg { transform: rotate(90deg); }
.fab::after { content: ''; position: absolute; inset: -6px; border-radius: 50%; border: 1.5px solid var(--fg); opacity: .0; animation: pulse 2.8s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(.85); opacity: .6; } 100% { transform: scale(1.35); opacity: 0; } }
@media (max-width: 860px) { .fab { bottom: calc(100px + env(safe-area-inset-bottom)); width: 62px; height: 62px; right: 18px; } }

/* ---------- add ---------- */
.add-wrap { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; margin-top: 26px; align-items: start; }
@media (max-width: 980px) { .add-wrap { grid-template-columns: 1fr; } }
.composer { border-radius: var(--r-lg); padding: clamp(18px, 2.4vw, 30px); display: grid; gap: 18px; position: relative; overflow: hidden; }
.drop {
  border: 2px dashed var(--line); border-radius: var(--r); min-height: 170px; display: grid; place-items: center; text-align: center; padding: 18px;
  transition: border-color .25s, background .25s; position: relative;
}
.drop.drag { border-color: var(--fg); background: rgba(190,255,79,.25); }
.drop .acts { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.thumbs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; width: 100%; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--bg); animation: pop .6s var(--ease-out) both; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; }
.thumb button svg { width: 12px; height: 12px; }
.thumb.addmore { display: grid; place-items: center; border: 2px dashed var(--line); background: transparent; color: var(--mute); }
@keyframes pop { from { opacity: 0; transform: scale(.7) rotate(-6deg); } to { opacity: 1; transform: none; } }
.composer .textarea { min-height: 120px; font-size: 18px; background: var(--bg); }
.composer .textarea:focus { background: var(--card); }
.note-ai { font-size: 13px; color: var(--mute); display: flex; gap: 8px; align-items: flex-start; }
.note-ai svg { flex: none; width: 16px; height: 16px; margin-top: 2px; }
.quick { display: grid; gap: 14px; }
.quick .list { display: flex; gap: 8px; flex-wrap: wrap; }

/* processing overlay */
.proc { position: absolute; inset: 0; z-index: 5; background: var(--ink); color: #fff; display: grid; align-content: space-between; padding: clamp(20px, 3vw, 36px); border-radius: inherit; animation: procIn .6s var(--ease) both; overflow: hidden; }
@keyframes procIn { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }
.proc .stages { display: grid; gap: 4px; position: relative; z-index: 1; }
.proc .stage { font-size: clamp(36px, 5vw, 64px); text-transform: uppercase; line-height: .95; font-variation-settings: 'wdth' 28, 'wght' 760, 'opsz' 144; color: #34363c; transition: color .4s; display: flex; align-items: center; gap: 14px; }
.proc .stage.on { color: var(--lime); }
.proc .stage.done { color: #fff; }
.proc .stage .dots::after { content: ''; animation: dots 1.2s steps(4) infinite; }
.proc .stage:not(.on) .dots { display: none; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
.proc .skel { display: grid; gap: 8px; position: relative; z-index: 1; }
.proc .skel i { height: 14px; border-radius: 8px; background: linear-gradient(90deg, #1d1f23 0%, #33363d 50%, #1d1f23 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.proc .skel i:nth-child(2) { width: 80%; } .proc .skel i:nth-child(3) { width: 60%; }
@keyframes shimmer { to { background-position: -200% 0; } }
.proc .scan { position: absolute; left: 0; right: 0; height: 40%; background: linear-gradient(to bottom, transparent, rgba(190,255,79,.14), transparent); animation: scan 2.2s var(--ease) infinite; }
@keyframes scan { from { top: -40%; } to { top: 100%; } }

/* ---------- result ---------- */
.res { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 16px; margin-top: 26px; align-items: start; }
@media (max-width: 980px) { .res { grid-template-columns: 1fr; } }
.res .photos { position: sticky; top: 90px; display: grid; gap: 10px; }
@media (max-width: 980px) { .res .photos { position: static; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); } }
.res .photos img { border-radius: var(--r); width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.res .inputq { border-radius: var(--r); padding: 20px; }
.res .inputq p { font-family: var(--serif); font-style: italic; font-size: 26px; line-height: 1.15; margin: 8px 0 0; }
.ritems { display: grid; gap: 10px; }
.ritem { background: var(--card); border-radius: var(--r); padding: 16px 18px; display: grid; gap: 12px; position: relative; transition: opacity .4s, transform .5s var(--ease-out), max-height .5s var(--ease); animation: viewIn .7s var(--ease-out) both; animation-delay: calc(var(--d, 0) * 80ms); }
.ritem.low { box-shadow: inset 0 0 0 2px var(--fg); background-image: repeating-linear-gradient(-45deg, transparent 0 12px, rgba(190,255,79,.22) 12px 24px); }
.ritem.removing { opacity: 0; transform: translateX(40px); }
.ritem .r1 { display: flex; align-items: flex-start; gap: 10px; }
.ritem .r1 .nm { font-size: 18px; font-variation-settings: 'wdth' 85, 'wght' 650; line-height: 1.2; flex: 1; text-align: left; }
.ritem .r1 .nm small { display: block; font-family: var(--mono); font-size: 11px; color: var(--mute); font-weight: 400; margin-top: 4px; }
.ritem .kc { font-size: 30px; line-height: .9; font-variation-settings: 'wdth' 30, 'wght' 780, 'opsz' 144; text-align: right; white-space: nowrap; }
.ritem .kc small { display: block; font-family: var(--mono); font-size: 10px; color: var(--mute); font-weight: 400; }
.ritem .r2 { display: grid; grid-template-columns: 1fr 110px; gap: 14px; align-items: center; }
.ritem .gram { display: flex; align-items: center; background: var(--bg); border-radius: 12px; padding: 0 10px 0 0; }
.ritem .gram input { width: 100%; border: 0; background: transparent; padding: 10px 6px 10px 12px; font-size: 18px; font-variation-settings: 'wdth' 60, 'wght' 650; outline: none; text-align: right; }
.ritem .gram span { font-family: var(--mono); font-size: 12px; color: var(--mute); }
.ritem .r3 { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tag { font-family: var(--mono); font-size: 11px; padding: 5px 9px; border-radius: 999px; background: var(--bg); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tag.dark { background: var(--ink); color: var(--lime); }
.tag.lime { background: var(--lime); }
.tag.warn { background: var(--warn); color: #fff; }
.tag button { text-decoration: underline; font-size: inherit; }
.confbar { width: 34px; height: 5px; border-radius: 4px; background: #cfd3db; overflow: hidden; display: inline-block; }
.confbar i { display: block; height: 100%; background: var(--fg); }
.qbox { border-radius: var(--r); padding: 18px; display: grid; gap: 14px; }
.qbox .q { display: grid; gap: 8px; }
.qbox .q p { margin: 0; font-family: var(--serif); font-style: italic; font-size: 24px; line-height: 1.1; }
.totals {
  position: sticky; bottom: 16px; z-index: 20; margin-top: 14px; background: var(--ink); color: #fff; border-radius: var(--r-lg);
  padding: 14px 14px 14px 24px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; box-shadow: 0 20px 40px -20px rgba(0,0,0,.5);
}
@media (max-width: 860px) { .totals { bottom: calc(96px + env(safe-area-inset-bottom)); } }
.totals .tbig { font-size: clamp(36px, 4vw, 54px); line-height: .9; font-variation-settings: 'wdth' 28, 'wght' 800, 'opsz' 144; color: var(--lime); }
.totals .tbig small { font-family: var(--mono); font-size: 12px; color: #9aa0ae; font-weight: 400; margin-left: 6px; }
.totals .mac { display: flex; gap: 14px; font-family: var(--mono); font-size: 12px; color: #c8ccd6; }
.totals .mac b { color: #fff; font-family: var(--display); font-size: 18px; font-variation-settings: 'wdth' 50, 'wght' 650; }
.disc { font-size: 12px; color: var(--mute); margin-top: 12px; font-family: var(--mono); }

/* ---------- modal / sheet ---------- */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: end center; pointer-events: none; }
.modal .scrim { position: absolute; inset: 0; background: rgba(11,11,12,.45); opacity: 0; transition: opacity .4s; backdrop-filter: blur(3px); }
.modal .sheet {
  position: relative; width: min(640px, 100%); max-height: 90vh; overflow: auto; background: var(--bg); border-radius: 28px 28px 0 0;
  padding: 26px clamp(18px, 3vw, 32px) calc(28px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .6s var(--ease);
}
@media (min-width: 760px) { .modal { place-items: center; } .modal .sheet { border-radius: 28px; transform: translateY(40px) scale(.96); opacity: 0; transition: transform .6s var(--ease-out), opacity .4s; } }
.modal.open { pointer-events: auto; }
.modal.open .scrim { opacity: 1; }
.modal.open .sheet { transform: none; opacity: 1; }
.sheet .x { position: absolute; top: 16px; right: 16px; }
.sheet .h2 { padding-right: 50px; }

.ntable { width: 100%; border-collapse: collapse; }
.ntable td, .ntable th { padding: 10px 0; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; vertical-align: middle; }
.ntable th { font-family: var(--mono); font-size: 11px; color: var(--mute); font-weight: 400; }
.ntable td.r, .ntable th.r { text-align: right; }
.ntable .pbar { width: 100%; height: 6px; background: var(--bg); border-radius: 6px; overflow: hidden; margin-top: 6px; }
.ntable .pbar i { display: block; height: 100%; background: var(--fg); border-radius: 6px; }
.ntable .pbar i.over { background: var(--warn); }

.search-res { display: grid; gap: 4px; margin-top: 12px; max-height: 50vh; overflow: auto; }
.search-res button { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--card); text-align: left; transition: background .2s; }
.search-res button:hover { background: var(--lime); }
.search-res small { font-family: var(--mono); font-size: 11px; color: var(--mute); }

/* ---------- toast ---------- */
#toasts { position: fixed; z-index: 95; left: 50%; bottom: 28px; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; width: min(92vw, 520px); pointer-events: none; }
@media (max-width: 860px) { #toasts { bottom: calc(100px + env(safe-area-inset-bottom)); } }
.toast { pointer-events: auto; background: var(--ink); color: #fff; border-radius: 999px; padding: 10px 10px 10px 20px; display: flex; gap: 14px; align-items: center; font-size: 14px; animation: toastIn .5s var(--ease-out) both; box-shadow: 0 14px 30px -12px rgba(0,0,0,.5); }
.toast.err { background: var(--warn); }
.toast .tick { width: 26px; height: 26px; border-radius: 50%; background: var(--lime); color: var(--ink); display: grid; place-items: center; flex: none; }
.toast .tick svg { width: 13px; height: 13px; }
.toast button { background: var(--lime); color: var(--ink); border-radius: 999px; padding: 6px 14px; font-size: 13px; font-variation-settings: 'wght' 600; }
.toast.out { animation: toastOut .4s var(--ease) both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(14px) scale(.95); } }

/* ---------- onboarding ---------- */
.onb { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; padding: var(--gutter); position: relative; overflow: hidden; }
.onb .ghost { bottom: 6vh; }
.onb .content { position: relative; z-index: 1; align-self: center; display: grid; gap: 26px; padding: 30px 0; }
.onb .steps { display: flex; gap: 6px; align-items: center; font-family: var(--mono); font-size: 12px; }
.onb .steps i { width: 36px; height: 4px; border-radius: 4px; background: var(--line); display: block; overflow: hidden; position: relative; }
.onb .steps i.on::after { content: ''; position: absolute; inset: 0; background: var(--fg); animation: grow .7s var(--ease-out) both; transform-origin: left; }
@keyframes grow { from { transform: scaleX(0); } }
.onb .nav-b { display: flex; justify-content: space-between; gap: 12px; position: relative; z-index: 1; flex-wrap: wrap; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.choice {
  background: var(--card); border-radius: var(--r); padding: 18px; text-align: left; display: grid; gap: 6px; border: 2px solid transparent;
  transition: transform .45s var(--ease-out), background .3s, border-color .3s; min-height: 120px; align-content: space-between; position: relative; overflow: hidden;
}
.choice:hover { transform: translateY(-4px); border-color: var(--fg); }
.choice b { font-size: 26px; text-transform: uppercase; line-height: .95; font-variation-settings: 'wdth' 35, 'wght' 760, 'opsz' 144; }
.choice span { font-family: var(--mono); font-size: 12px; color: var(--mute); }
.choice .idx { font-family: var(--mono); font-size: 11px; }
.choice[aria-pressed="true"] { background: var(--ink); color: #fff; }
.choice[aria-pressed="true"] span { color: #9aa0ae; }
.choice[aria-pressed="true"] .idx { color: var(--lime); }
.choice[aria-pressed="true"]::after { content: ''; position: absolute; right: 14px; top: 14px; width: 26px; height: 26px; border-radius: 50%; background: var(--lime) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230B0B0C' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center/13px no-repeat; animation: pop .5s var(--ease-out); }
.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; max-width: 900px; }
.unitfield { position: relative; }
.unitfield em { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-style: normal; font-family: var(--mono); font-size: 12px; color: var(--mute); pointer-events: none; }
.check { display: flex; gap: 10px; align-items: center; font-size: 15px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--fg); }
.callout { border-radius: var(--r); padding: 16px 18px; background: var(--card); border-left: 6px solid var(--lime); font-size: 15px; max-width: 760px; }
.callout.warn { border-left-color: var(--warn); }
.tgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tcell { background: var(--card); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 4px; }
.tcell label { font-family: var(--mono); font-size: 11px; color: var(--mute); }
.tcell input { border: 0; background: transparent; outline: none; font-size: 34px; font-variation-settings: 'wdth' 30, 'wght' 760, 'opsz' 144; width: 100%; padding: 0; border-bottom: 2px solid transparent; }
.tcell input:focus { border-bottom-color: var(--lime); }
.tcell.hero { background: var(--ink); color: #fff; grid-column: span 2; }
.tcell.hero input { color: var(--lime); font-size: 64px; }
.tcell.hero label { color: #9aa0ae; }

/* ---------- stats ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 900px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--card); border-radius: var(--r); padding: 18px; display: grid; gap: 6px; min-height: 140px; align-content: space-between; }
.kpi b { font-size: clamp(40px, 5vw, 70px); line-height: .85; font-variation-settings: 'wdth' 26, 'wght' 800, 'opsz' 144; }
.kpi span { font-family: var(--mono); font-size: 11px; color: var(--mute); }
.kpi.dark { background: var(--ink); color: #fff; } .kpi.dark b { color: var(--lime); } .kpi.dark span { color: #9aa0ae; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: var(--mono); font-size: 10px; fill: var(--mute); }
.chart .b { fill: var(--fg); transform-box: fill-box; transform-origin: bottom; animation: barUp 1s var(--ease-out) both; animation-delay: calc(var(--i) * 30ms); }
.chart .b.over { fill: var(--warn); }
.chart .b.today { fill: var(--lime); stroke: var(--fg); stroke-width: 1.5; }
.chart .tl { stroke: var(--fg); stroke-dasharray: 5 5; stroke-width: 1.5; }
.chart .grid-l { stroke: var(--line); }
.chart .bp { fill: var(--fg); } .chart .bf { fill: var(--lime-2); } .chart .bc { fill: var(--blue); }
@keyframes barUp { from { transform: scaleY(0); } }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-family: var(--mono); font-size: 12px; color: var(--mute); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.spark path { fill: none; stroke: var(--fg); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.spark circle { fill: var(--lime); stroke: var(--fg); stroke-width: 2; }

/* ---------- chat ---------- */
.chat { display: grid; grid-template-rows: 1fr auto; gap: 14px; margin-top: 22px; min-height: 55vh; }
.msgs { display: grid; gap: 12px; align-content: start; }
.msg { max-width: min(720px, 92%); padding: 14px 18px; border-radius: 22px; font-size: 16px; white-space: pre-wrap; animation: viewIn .5s var(--ease-out) both; }
.msg.user { justify-self: end; background: var(--ink); color: #fff; border-bottom-right-radius: 6px; }
.msg.assistant { justify-self: start; background: var(--card); border-bottom-left-radius: 6px; }
.msg.assistant.typing::after { content: '▍'; animation: blink 1s steps(2) infinite; color: var(--lime-2); }
@keyframes blink { 50% { opacity: 0; } }
.chatbar { position: sticky; bottom: 16px; display: flex; gap: 10px; background: var(--card); border-radius: 999px; padding: 6px 6px 6px 20px; box-shadow: 0 14px 34px -18px rgba(0,0,0,.35); align-items: center; }
@media (max-width: 860px) { .chatbar { bottom: calc(96px + env(safe-area-inset-bottom)); } }
.chatbar input { flex: 1; border: 0; outline: none; background: transparent; font-size: 16px; min-width: 0; }

/* ---------- settings ---------- */
.settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 26px; }
@media (max-width: 900px) { .settings { grid-template-columns: 1fr; } }
.settings .card { display: grid; gap: 16px; align-content: start; }
.settings .wide { grid-column: 1 / -1; }

.empty-state { text-align: center; padding: 50px 20px; display: grid; gap: 10px; justify-items: center; }
.empty-state .serif { font-size: 34px; line-height: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .rv, .rv-card { opacity: 1; transform: none; }
}

/* таблетки и сегменты внутри белых карточек */
.card .pill:not(.on):not(.warn), .meal .pill, .card .seg, .composer .seg { background: var(--bg); }
.card.dark .pill:not(.on) { background: #1c1d21; color: #fff; }
.field .seg { justify-self: start; }
.card .input, .card .select, .card .textarea, .sheet .tcell { background: var(--bg); }
.card .tcell { background: var(--bg); }
.card .tcell.hero, .sheet .tcell.hero { background: var(--ink); }
.sheet .input { background: var(--card); }
.search-res .card { background: var(--card); }
.settings .card > *, .add-wrap > *, .res > *, .summary > * { min-width: 0; }
.formgrid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); }

/* ===================== Тёмная тема ===================== */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0E0F11;
  --bg-2: #16171A;
  --card: #18191D;
  --ink: #000000;
  --fg: #ECEEF2;
  --ink-2: #C9CDD6;
  --ghost: #24262B;
  --mute: #959CAB;
  --line: #2C2E34;
  --blue: #5D6984;
  --pill-warn: #3A1C15;
}
:root[data-theme="dark"] body { background: var(--bg); }
/* сплошные чёрные поверхности получают тонкую обводку, чтобы не тонуть в фоне */
:root[data-theme="dark"] :is(.card.dark, .kpi.dark, .tcell.hero, .totals, .msg.user, .week a.on, .proc, .toast, .dock, .meal .badge) { box-shadow: inset 0 0 0 1px #2B2D33; }
:root[data-theme="dark"] .btn { --bg-b: var(--fg); --fg-b: #0B0B0C; }
:root[data-theme="dark"] .btn.light { --bg-b: var(--card); --fg-b: var(--fg); }
:root[data-theme="dark"] .btn.lime { --bg-b: var(--lime); --fg-b: #0B0B0C; }
:root[data-theme="dark"] .btn .arr { background: var(--lime); color: #0B0B0C; }
:root[data-theme="dark"] :is(.pill.on, .pill[aria-pressed="true"], .seg button[aria-pressed="true"], .nav a.on) { background: var(--lime); color: #0B0B0C; }
:root[data-theme="dark"] .choice[aria-pressed="true"] { background: #000; border-color: var(--lime); }
:root[data-theme="dark"] .week a.on { background: #000; }
:root[data-theme="dark"] .meal:hover { box-shadow: 0 24px 40px -24px rgba(0,0,0,.8); }
:root[data-theme="dark"] .meal .badge { border-color: var(--card); }
:root[data-theme="dark"] .bar i { background-image: repeating-linear-gradient(-45deg, rgba(0,0,0,0) 0 8px, rgba(0,0,0,.28) 8px 16px); }
:root[data-theme="dark"] .ritem.low { background-image: repeating-linear-gradient(-45deg, transparent 0 12px, rgba(190,255,79,.08) 12px 24px); }
:root[data-theme="dark"] .drop.drag { background: rgba(190,255,79,.08); }
:root[data-theme="dark"] .modal .scrim { background: rgba(0,0,0,.6); }
:root[data-theme="dark"] .tag.dark { background: #000; }
:root[data-theme="dark"] .fab:hover { background: var(--fg); color: #0B0B0C; }
:root[data-theme="dark"] .callout { background: var(--card); }
:root[data-theme="dark"] .search-res button:hover { color: #0B0B0C; }
:root[data-theme="dark"] .search-res button:hover small { color: #333; }

/* переключатель темы */
.theme-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--card); color: var(--fg); flex: none; transition: background .25s, transform .6s var(--ease-out); }
.theme-btn:hover { background: var(--lime); color: #0B0B0C; transform: rotate(-30deg); }
.theme-btn svg { width: 20px; height: 20px; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { z-index: 2; }
@media (max-width: 860px) { .top .theme-btn { width: 40px; height: 40px; } }

/* кухни мира */
.cuisines { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 6px; }
.cuisines .pill small { font-family: var(--mono); font-size: 11px; color: var(--mute); }
.cuisines .pill.on small { color: inherit; opacity: .7; }

/* логотип: монограмма NL — линия «пишется» одним росчерком, точка-линза появляется следом */
.brand .logo { background: none; width: 40px; height: 40px; color: var(--fg); }
.brand:hover .logo { transform: none; }
.brand .logo svg { width: 36px; height: 36px; overflow: visible; }
.mono-path { stroke-dasharray: 150; stroke-dashoffset: 0; animation: monoDraw 1.4s var(--ease) both .2s; }
.mono-dot { transform-box: fill-box; transform-origin: center; animation: monoDot .7s var(--ease-out) both 1.3s; }
.brand:hover .mono-path { animation: monoDraw2 1.1s var(--ease) both; }
.brand:hover .mono-dot { animation: monoDot2 .6s var(--ease-out) both .8s; }
@keyframes monoDraw { from { stroke-dashoffset: 150; } to { stroke-dashoffset: 0; } }
@keyframes monoDraw2 { from { stroke-dashoffset: 150; } to { stroke-dashoffset: 0; } }
@keyframes monoDot { from { transform: scale(0); } 60% { transform: scale(1.4); } to { transform: scale(1); } }
@keyframes monoDot2 { from { transform: scale(0); } 60% { transform: scale(1.4); } to { transform: scale(1); } }

/* ===================== Телефон (до 600 px) ===================== */
@media (max-width: 600px) {
  /* кольцо и цифры — в одну строку, а не столбиком */
  .ringcard { grid-template-columns: auto 1fr; justify-items: stretch; text-align: left; min-height: 0; gap: 18px; padding: 20px; }
  .ring { width: 136px; }
  .ring .mid b { font-size: 40px; }
  .ring .mid span { font-size: 10px; }
  .ring-stats { gap: 8px; }
  .ring-stats .st b { font-size: 24px; }
  .ring-stats .serif { font-size: 18px !important; }
  .macros { padding: 20px; gap: 14px; }
  /* дополнительные нутриенты — лента с прокруткой вбок */
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 12px -20px 0; padding: 0 20px 4px; scrollbar-width: none; scroll-snap-type: x proximity; }
  .chips::-webkit-scrollbar { display: none; }
  .chips .pill { flex: none; scroll-snap-align: start; }
  /* компактные карточки приёмов пищи */
  .meal { min-height: 0; }
  .meal .head { height: 64px; padding: 12px 14px; }
  .meal .badge { width: 44px; height: 44px; bottom: -18px; }
  .meal .badge svg { width: 16px; height: 16px; }
  .meal .body { padding-top: 18px; }
  .meal .empty { display: block; text-align: left; padding: 0; flex: none; }
  .meal .empty .serif { font-size: 20px; }
  .meal .empty .hint { display: none; }
  .link { display: inline-block; padding: 10px 0; border-bottom: 0; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1.5px; }
  .meal .foot .link { padding: 12px 0; }
  /* переключатели — в одну строку */
  .seg { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .seg::-webkit-scrollbar { display: none; }
  .seg button { flex: 1 0 auto; padding: 9px 12px; white-space: nowrap; }
  .datebar > .seg { width: 100%; }
  /* черновик */
  .res .photos { grid-template-columns: 1fr; }
  .res .photos img { aspect-ratio: 16 / 10; }
  .res .inputq p { font-size: 22px; }
  .ritem { padding: 14px; }
  .ritem .r2 { grid-template-columns: 1fr 96px; gap: 10px; }
  .totals { flex-wrap: nowrap; gap: 10px; padding: 10px 10px 10px 18px; }
  .totals .mac, .totals .spacer { display: none; }
  .totals .tbig { font-size: 34px; }
  .totals .btn.big { margin-left: auto; min-height: 50px; padding-left: 16px; font-size: 14px; gap: 8px; }
  .totals .btn.big .arr { width: 38px; height: 38px; }
  /* статистика */
  .kpi { min-height: 108px; padding: 14px; }
  .kpi b { font-size: 48px; }
  /* ассистент: кнопка отправки — только стрелка */
  .chatbar { padding-left: 16px; }
  .chatbar .btn { padding: 5px; min-height: 46px; }
  .chatbar .btn .lbl { display: none; }
  /* онбординг */
  .onb .content { gap: 20px; padding: 18px 0; }
  .choice { min-height: 96px; padding: 16px; }
  .tcell.hero { grid-column: 1 / -1; }
  .tcell.hero input { font-size: 52px; }
}

/* онбординг: колонка не шире экрана, иначе форма и кнопка «Дальше» уезжали за край */
.onb { grid-template-columns: minmax(0, 1fr); }
.onb > *, .onb .content > * { min-width: 0; }
@media (max-width: 600px) {
  .onb .input.big { font-size: 28px; }
  .onb .formgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .onb .formgrid .input.big { padding: 10px 12px; }
  .onb .nav-b .btn.big { padding-left: 20px; }
}

/* ===================== Аккаунт ===================== */
.authform { display: grid; gap: 16px; max-width: 520px; }
.pwwrap { position: relative; display: block; }
.pwwrap .input { padding-right: 96px; }
.pwtoggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-family: var(--mono); font-size: 12px; padding: 9px 12px; border-radius: 999px; background: var(--card); color: var(--fg); }
.autherr { color: var(--warn); font-size: 14px; font-variation-settings: 'wght' 550; }
.autherr:empty { display: none; }
.authform .link { justify-self: start; }
.onb.auth .nav-b { justify-content: flex-start; }
.onb .nav-b .row { gap: 10px; }
.onb .nav-b .link { align-self: center; }

/* индикатор синхронизации: точка + подпись */
.sync { display: inline-flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: 11px; color: var(--mute); white-space: nowrap; }
.sync i { width: 9px; height: 9px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 1.5px var(--fg); flex: none; }
.sync[data-state="saving"] i { animation: syncPulse 1s ease-in-out infinite; }
.sync[data-state="offline"] i { background: var(--mute); }
.sync[data-state="error"] i { background: var(--warn); }
.sync[data-state="off"] { display: none; }
@keyframes syncPulse { 50% { transform: scale(.55); opacity: .5; } }
@media (max-width: 860px) { .top .sync span { display: none; } }

/* На лаймовом фоне текст и значки всегда тёмные — в обеих темах */
.pill .tick, .tag.lime, .card.lime, .kpi.lime { --fg: #0B0B0C; --mute: #3A4420; color: #0B0B0C; }
.kpi.lime { background: var(--lime); }

/* Контурная бегущая строка: обводка рисуется под заливкой цветом фона,
   поэтому внутренние линии перекрывающихся частей букв не видны — остаётся только внешний контур */
.ghost.outline span { color: var(--bg); -webkit-text-stroke: 3px var(--ghost); paint-order: stroke fill; }
