/* Тёмная тема в стиле YAZIO */
@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@500;600;700;800;900&display=swap");

:root {
  --bg: #121212;
  --card: #262626;
  --card2: #303030;
  --border: #3a3a3a;
  --text: #ffffff;
  --hint: #9a9a9a;
  --accent: #1de9b6;          /* бирюзовый акцент */
  --accent-dark: #0b5e4b;     /* зелёная полоса статуса */
  --accent-text: #0d0d0d;
  --link: #1de9b6;
  --sep: #3a3a3a;
  --danger: #ff5a5f;
  --green: #1de9b6;
  --carbs: #1de9b6;
  --prot: #1de9b6;
  --fat: #1de9b6;
  --radius: 22px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 600 15px/1.35 "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(110px + env(safe-area-inset-bottom)); overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--text); background: var(--card2); border: 1.5px solid var(--border);
  border-radius: 14px; padding: 12px 13px; width: 100%; outline: none; }
input::placeholder, textarea::placeholder { color: #777; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 74px; }
small, .hint { color: var(--hint); font-weight: 600; }
.loader { padding: 80px 0; text-align: center; color: var(--hint); }
main { padding: 10px 16px 8px; max-width: 640px; margin: 0 auto; }

/* заголовки секций */
.h-row { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 2px 12px; }
.h-row h2 { margin: 0; font-size: 27px; font-weight: 900; letter-spacing: -.3px; }
.h-row .link { font-size: 17px; font-weight: 800; }

/* карточки */
.card { background: var(--card); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 12px; font-size: 18px; font-weight: 800; }

/* шапка дня */
.dayhead { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 0; }
.dayhead .date { font-size: 32px; font-weight: 900; letter-spacing: -.5px; line-height: 1.1; }
.dayhead .date small { display: block; font-size: 14px; font-weight: 700; letter-spacing: 0; margin-top: 2px; }
.pill { display: flex; align-items: center; gap: 2px; background: rgba(60,60,60,.85); border: 1.5px solid #4a4a4a;
  border-radius: 24px; padding: 4px; backdrop-filter: blur(10px); }
.pill button { min-width: 38px; height: 36px; border-radius: 18px; font-size: 20px; font-weight: 800; padding: 0 10px; }
.pill button.today { font-size: 14px; background: #4a4a4a; }
.round { width: 38px; height: 38px; border-radius: 50%; background: var(--card2); font-size: 20px;
  display: inline-flex; align-items: center; justify-content: center; flex: none; }

/* сводка */
.summary { padding: 18px 0 0; overflow: hidden; }
.summary .ring-row { display: flex; align-items: center; justify-content: space-between; padding: 0 8px; }
.stat { text-align: center; flex: 1; min-width: 0; }
.stat b { display: block; font-size: 21px; font-weight: 900; }
.stat span { font-size: 14px; color: #e0e0e0; font-weight: 700; }
.ring { position: relative; width: 148px; height: 140px; flex: none; }
.ring svg { display: block; width: 100%; height: 100%; }
.ring .center { position: absolute; inset: 0 0 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring .center b { font-size: 30px; font-weight: 900; letter-spacing: -.5px; }
.ring .center span { font-size: 14px; color: #e0e0e0; font-weight: 700; }
.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 4px 16px 16px; }
.macro { text-align: center; }
.macro small { display: block; font-size: 14px; color: #e0e0e0; margin-bottom: 8px; }
.macro .bar { height: 8px; border-radius: 4px; background: #4a4a4a; overflow: hidden; }
.macro .bar i { display: block; height: 100%; border-radius: 4px; }
.macro .val { font-size: 14px; font-weight: 800; margin-top: 8px; }
.status { background: var(--accent-dark); text-align: center; padding: 12px; font-size: 15px; font-weight: 700; }

/* питание */
.meals { padding: 0; overflow: hidden; }
.meal { display: flex; align-items: center; gap: 14px; padding: 16px; border-top: 1.5px solid var(--border); cursor: pointer; }
.meal:first-child { border-top: 0; }
.meal-ico { position: relative; width: 64px; height: 64px; flex: none; }
.meal-ico svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.meal-ico span { position: absolute; inset: 9px; border-radius: 50%; background: #3a3a3a; display: flex;
  align-items: center; justify-content: center; font-size: 26px; }
.meal .t { flex: 1; min-width: 0; }
.meal .t b { display: block; font-size: 19px; font-weight: 900; }
.meal .t .kc { font-size: 16px; color: #e8e8e8; font-weight: 700; margin-top: 2px; }
.meal .t .names { font-size: 16px; color: #e8e8e8; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.add-btn { width: 52px; height: 52px; border-radius: 50%; background: #fff; color: #111; font-size: 32px; font-weight: 500;
  line-height: 52px; text-align: center; flex: none; }
.add-btn.dim { background: #4a4a4a; color: #1e1e1e; }
.add-btn.sm { width: 36px; height: 36px; line-height: 36px; font-size: 24px; }

/* строки списков */
.rows { margin-top: 4px; }
.row { display: flex; align-items: center; gap: 10px; padding: 13px 0; border-top: 1.5px solid var(--border); cursor: pointer; }
.row:first-child { border-top: 0; }
.row .nm { flex: 1; min-width: 0; }
.row .nm div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 800; }
.row .kc { font-weight: 900; white-space: nowrap; }
.link { color: var(--link); font-weight: 800; }

/* нижняя навигация — плавающая пилюля */
#tabs { position: fixed; left: 14px; right: 14px; bottom: calc(10px + env(safe-area-inset-bottom)); display: flex;
  background: rgba(38,38,38,.92); border: 1.5px solid #444; border-radius: 34px; padding: 6px; z-index: 5;
  backdrop-filter: blur(14px); max-width: 560px; margin: 0 auto; }
#tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 13px;
  font-weight: 800; color: #fff; padding: 8px 0 6px; border-radius: 28px; }
#tabs button svg { width: 26px; height: 26px; }
#tabs button.active { background: #3d3d3d; color: var(--accent); }

/* шторка */
#sheet { position: fixed; inset: 0; z-index: 10; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.sheet-body { position: absolute; left: 0; right: 0; bottom: 0; max-height: 93vh; overflow-y: auto;
  background: #1c1c1c; border-top: 1.5px solid var(--border); border-radius: 26px 26px 0 0;
  padding: 6px 16px calc(20px + env(safe-area-inset-bottom)); animation: up .22s ease-out; max-width: 640px; margin: 0 auto; }
@keyframes up { from { transform: translateY(50px); opacity: .4; } }
.sheet-grip { width: 42px; height: 5px; border-radius: 3px; background: #555; margin: 6px auto 12px; }
.sheet-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sheet-title b { flex: 1; font-size: 22px; font-weight: 900; }

/* кнопки */
.btn { display: block; width: 100%; text-align: center; padding: 15px; border-radius: 18px; font-weight: 900; font-size: 16px;
  background: var(--accent); color: var(--accent-text); margin-top: 12px; }
.btn.secondary { background: var(--card2); color: var(--text); font-weight: 800; border: 1.5px solid var(--border); }
.btn.danger { background: transparent; color: var(--danger); }
.btn[disabled] { opacity: .5; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.quick button { background: var(--card); border: 1.5px solid var(--border); border-radius: 18px; padding: 12px 2px 10px;
  font-size: 12px; font-weight: 800; text-align: center; }
.quick button span { display: block; font-size: 26px; margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip { padding: 8px 14px; border-radius: 20px; background: var(--card2); border: 1.5px solid var(--border); font-size: 14px; font-weight: 800; }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.seg { display: flex; background: var(--card2); border-radius: 16px; padding: 3px; margin: 8px 0; }
.seg button { flex: 1; padding: 9px 4px; border-radius: 13px; font-size: 13px; font-weight: 800; color: var(--hint); }
.seg button.on { background: #474747; color: #fff; }

/* продукт */
.prod-head { font-size: 22px; font-weight: 900; }
.per100 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; text-align: center; }
.per100 div { background: var(--card2); border-radius: 16px; padding: 10px 2px; }
.per100 b { display: block; font-size: 18px; font-weight: 900; }
.per100 small { font-size: 12px; }
.grams-row { display: flex; gap: 10px; align-items: center; }
.grams-row input { font-size: 26px; font-weight: 900; text-align: center; }
.grams-row span { font-size: 18px; font-weight: 800; }
.badge { font-size: 13px; color: var(--hint); font-weight: 700; }

/* поиск */
.search { display: flex; gap: 8px; }
.search input { flex: 1; border-radius: 18px; }
.list .item { display: flex; align-items: center; gap: 12px; padding: 13px 2px; border-bottom: 1.5px solid var(--border); cursor: pointer; }
.list .item .nm { flex: 1; min-width: 0; }
.list .item .nm div { overflow: hidden; text-overflow: ellipsis; font-weight: 800; }
.list .empty { padding: 26px 0; text-align: center; color: var(--hint); }

/* сканер */
.scanner { position: relative; border-radius: 22px; overflow: hidden; background: #000; aspect-ratio: 3 / 4; max-height: 52vh; width: 100%; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; left: 10%; right: 10%; top: 35%; height: 30%; border: 3px solid var(--accent);
  border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.45); }
.scanner .laser { position: absolute; left: 12%; right: 12%; top: 50%; height: 2px; background: var(--accent);
  box-shadow: 0 0 10px var(--accent); animation: scan 1.6s ease-in-out infinite; }
@keyframes scan { 0%,100% { transform: translateY(-36px); } 50% { transform: translateY(36px); } }
.file-btn input { display: none; }

/* разбор ИИ */
.rv { background: var(--card); border: 1.5px solid var(--border); border-radius: 20px; padding: 12px; margin-bottom: 12px; }
.rv .rv-name { font-weight: 900; font-size: 16px; }
.rv-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 10px; }
.rv-grid label { font-size: 11px; color: var(--hint); text-align: center; font-weight: 700; }
.rv-grid input { padding: 9px 2px; text-align: center; font-size: 15px; font-weight: 800; margin-top: 3px; border-radius: 12px; }
.rv-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.rv-actions .badge { flex: 1; }
.rv-actions button { padding: 8px 12px; border-radius: 14px; background: var(--card2); border: 1.5px solid var(--border); font-size: 13px; font-weight: 800; }
.note { background: rgba(29,233,182,.12); border: 1.5px solid rgba(29,233,182,.35); border-radius: 16px; padding: 12px; font-size: 14px; margin-bottom: 12px; }

/* формы */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; color: var(--hint); margin: 0 0 6px 4px; font-weight: 800; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; font-weight: 800; }
.switch input { width: 50px; height: 30px; appearance: none; background: #4a4a4a; border-radius: 15px; position: relative; border: 0; padding: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { left: 23px; }
.codebox { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; background: var(--card2); padding: 12px; border-radius: 14px; }
details summary { cursor: pointer; color: var(--link); margin: 10px 0; font-weight: 800; }
ol { padding-left: 20px; margin: 6px 0; }
ol li { margin-bottom: 8px; font-weight: 600; }
code { color: var(--accent); }

/* вес */
.big { font-size: 40px; font-weight: 900; letter-spacing: -.5px; }
.chart { width: 100%; height: 200px; }
.chart text { fill: var(--hint); font-size: 10px; font-weight: 700; }

#toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #f2f2f2; color: #111; padding: 12px 18px; border-radius: 18px; z-index: 20; font-size: 15px; font-weight: 800;
  max-width: 90vw; text-align: center; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
