/* ui/base.css */
/* SSH — вигляд. УСІ кольори й розміри — змінні в цьому блоці; гілки своїх кольорів не заводять.
   Значення зняті з макетів власника (docs/design/01-light.png, 02-dark.png), розбір — docs/DESIGN.md. */

:root {
  color-scheme: only light;
  --bg-a: #dce8f0; --bg-b: #c1d5e2; --bg-c: #d4e3ec;
  --glow-1: rgba(255, 255, 255, .92); --glow-2: rgba(255, 255, 255, .55); --glow-3: rgba(166, 198, 221, .7);
  --glass: rgba(255, 255, 255, .44); --glass-2: rgba(255, 255, 255, .66); --glass-3: rgba(255, 255, 255, .86);
  --stroke: rgba(255, 255, 255, .9); --stroke-2: rgba(120, 160, 190, .22);
  --shadow: 0 10px 28px rgba(64, 100, 132, .16), inset 0 1px 0 rgba(255, 255, 255, .8);
  --ink: #1d3852; --ink-2: #4a6883; --mute: #7f97ab;
  --accent: #35aee3; --accent-2: #7fe0fb; --accent-ink: #1785bd;
  --cta-a: #6b89a1; --cta-b: #46627a; --cta-ink: #ffffff;
  --track: rgba(120, 155, 185, .28);
  --m-protein: #2fb3a4; --m-fat: #9a90d6; --m-carbs: #3aa7df;
  --danger: #c9485b; --ok: #2f9e7a;
  --blur: 18px; --r-card: 22px; --r-pill: 999px;
}

:root[data-theme="dark"] {
  color-scheme: only dark;
  --bg-a: #071624; --bg-b: #020b13; --bg-c: #010810;
  --glow-1: rgba(44, 118, 158, .34); --glow-2: rgba(22, 74, 104, .3); --glow-3: rgba(10, 40, 60, .5);
  --glass: rgba(14, 32, 46, .58); --glass-2: rgba(24, 48, 66, .7); --glass-3: rgba(36, 66, 88, .82);
  --stroke: rgba(126, 206, 236, .2); --stroke-2: rgba(126, 206, 236, .1);
  --shadow: 0 14px 34px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(170, 232, 255, .1);
  --ink: #eef6fa; --ink-2: #a9bdca; --mute: #6c8596;
  --accent: #57cee2; --accent-2: #9aeaf7; --accent-ink: #7fe0f1;
  --cta-a: #5b7186; --cta-b: #3a4f63; --cta-ink: #f2f9fc;
  --track: rgba(110, 160, 190, .2);
  --m-protein: #45d3ea; --m-fat: #e3b24a; --m-carbs: #b388ea;
  --danger: #ff7d8d; --ok: #58d6a6;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; color: var(--ink);
  font: 15px/1.4 Inter, "SF Pro Text", "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  background: var(--bg-b); -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}
/* Фон нерухомий і окремим шаром: на телефоні background-attachment: fixed смикається */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(120% 55% at 18% 0%, var(--glow-1), transparent 62%),
    radial-gradient(80% 45% at 96% 28%, var(--glow-2), transparent 66%),
    radial-gradient(95% 55% at 6% 84%, var(--glow-3), transparent 62%),
    linear-gradient(162deg, var(--bg-a) 0%, var(--bg-b) 56%, var(--bg-c) 100%);
}
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#view { max-width: 480px; margin: 0 auto; }
.screen { padding: calc(14px + env(safe-area-inset-top)) 16px 28px; display: flex; flex-direction: column; gap: 14px; min-height: 100dvh; }
.has-tabbar .screen { padding-bottom: calc(104px + env(safe-area-inset-bottom)); }

/* ── Скло ─────────────────────────────────────────── */
.card {
  background: var(--glass); border: 1px solid var(--stroke); border-radius: var(--r-card);
  box-shadow: var(--shadow); backdrop-filter: blur(var(--blur)) saturate(1.2); -webkit-backdrop-filter: blur(var(--blur)) saturate(1.2);
}
.pad { padding: 16px; }
.inner { background: var(--glass-2); border: 1px solid var(--stroke-2); border-radius: 18px; padding: 12px 14px; }

/* ── Шапка екрана ─────────────────────────────────── */
.hdr { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.hdr h1 { font-size: 24px; font-weight: 650; letter-spacing: -.01em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hdr .sub { font-size: 12px; color: var(--mute); }
.h2 { font-size: 17px; font-weight: 650; }
.muted { color: var(--mute); } .small { font-size: 12.500px; } .ink2 { color: var(--ink-2); }
.grow { flex: 1; min-width: 0; } .center { text-align: center; }
.rowx { display: flex; align-items: center; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.ico { width: 22px; height: 22px; flex: none; }
.ibtn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--glass-2); border: 1px solid var(--stroke); box-shadow: var(--shadow); color: var(--ink-2); }
.ibtn.accent { color: var(--accent-ink); }
.ibtn.sq { width: 48px; height: 48px; border-radius: 16px; }

/* ── Кнопки ───────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px;
  border-radius: var(--r-pill); background: var(--glass-3); border: 1px solid var(--stroke); box-shadow: var(--shadow);
  color: var(--accent-ink); font-weight: 600; width: 100%; }
.btn.primary { background: linear-gradient(180deg, var(--cta-a), var(--cta-b)); color: var(--cta-ink); border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 36px; padding: 0 14px; width: auto; font-size: 13px; }
.btn:active, .ibtn:active, .tab:active, .row:active { transform: scale(.985); }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ── Перемикачі ───────────────────────────────────── */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 14px; border-radius: var(--r-pill); font-size: 13px; color: var(--ink-2);
  background: var(--glass); border: 1px solid var(--stroke-2); }
.chip.on { background: var(--glass-3); color: var(--accent-ink); border-color: var(--stroke); box-shadow: var(--shadow); font-weight: 600; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: var(--r-pill);
  background: var(--glass); border: 1px solid var(--stroke-2); }
.seg button { min-height: 34px; border-radius: var(--r-pill); font-size: 13px; color: var(--ink-2); padding: 0 6px; }
.seg button.on { background: var(--glass-3); color: var(--accent-ink); font-weight: 600; box-shadow: var(--shadow); }

/* ── Рядки списку ─────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 18px; width: 100%; text-align: left;
  background: var(--glass); border: 1px solid var(--stroke); box-shadow: var(--shadow); backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur)); }
.row .t { font-weight: 600; } .row .d { font-size: 12.500px; color: var(--mute); }
.row .v { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.row > .ico:last-child { color: var(--mute); width: 18px; height: 18px; }
.badge { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; flex: none;
  background: var(--glass-3); border: 1px solid var(--stroke-2); color: var(--accent-ink); }
.pill { display: inline-flex; align-items: center; padding: 6px 12px; border-radius: var(--r-pill); font-size: 13px; font-weight: 600;
  background: var(--glass-3); border: 1px solid var(--stroke-2); color: var(--ink-2); }

/* ── Смужки й кільце ──────────────────────────────── */
.bar { height: 5px; border-radius: 3px; background: var(--track); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.bar.p > i { background: var(--m-protein); } .bar.f > i { background: var(--m-fat); } .bar.c > i { background: var(--m-carbs); }
.ring { position: relative; display: grid; place-items: center; }
.ring svg { display: block; max-width: 100%; height: auto; }
.ring-in { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-track { stroke: var(--track); }
.ring-a { stop-color: var(--accent-2); } .ring-b { stop-color: var(--accent); }
.area { width: 100%; height: 130px; display: block; }
.area-a { stop-color: var(--accent); stop-opacity: .38; } .area-b { stop-color: var(--accent); stop-opacity: 0; }
.area-line { stroke: var(--accent); }
.num { font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.num.xl { font-size: 30px; } .num.lg { font-size: 22px; }

/* ── Нижнє меню ───────────────────────────────────── */
.tabbar { position: fixed; z-index: 20; left: 50%; transform: translateX(-50%); bottom: calc(10px + env(safe-area-inset-bottom));
  width: min(448px, calc(100vw - 24px)); display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; padding: 6px;
  border-radius: 26px; background: var(--glass-2); border: 1px solid var(--stroke); box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.3); -webkit-backdrop-filter: blur(22px) saturate(1.3); }
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 2px 6px; border-radius: 20px;
  font-size: 10.500px; color: var(--mute); min-width: 0; }
.tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab.on { color: var(--ink); background: var(--glass-3); box-shadow: var(--shadow); font-weight: 600; }
.tab.on .ico { color: var(--accent-ink); }

/* ── Форми ────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.500px; color: var(--ink-2); min-width: 0; }
.field input, .field select { min-height: 46px; padding: 0 14px; border-radius: 14px; font-size: 16px; width: 100%; min-width: 0;
  background: var(--glass-3); border: 1px solid var(--stroke-2); color: var(--ink); appearance: none; -webkit-appearance: none; }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.field select option { color: #1d3852; background: #fff; }
.form { display: flex; flex-direction: column; gap: 12px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; }
.note { font-size: 12.500px; color: var(--mute); }

/* ── Панель знизу ─────────────────────────────────── */
#sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet-back { position: absolute; inset: 0; background: rgba(4, 16, 26, .42); }
.sheet-panel { position: relative; width: min(480px, 100vw); max-height: 88dvh; display: flex; flex-direction: column;
  border-radius: 26px 26px 0 0; background: var(--glass-3); padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet-hdr { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sheet-hdr h2 { flex: 1; font-size: 18px; font-weight: 650; }
.sheet-body { overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.sheet-on { overflow: hidden; }

.banner { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; font-size: 13.500px; }
.banner span { flex: 1; }
.empty { text-align: center; color: var(--mute); padding: 18px 8px; font-size: 13.500px; }

@media (prefers-reduced-motion: no-preference) {
  .btn, .ibtn, .tab, .row { transition: transform .12s ease; }
  .bar > i { transition: width .5s ease; }
}

/* branches/coach/style.css */
.co-badge { margin: 0 auto; width: 56px; height: 56px; border-radius: 18px; }
.co-badge .ico { width: 28px; height: 28px; }

/* branches/home/style.css */
.hm-ava { width: 46px; height: 46px; border-radius: 50%; flex: none; font-weight: 650; font-size: 19px; color: var(--cta-ink);
  background: linear-gradient(160deg, var(--cta-a), var(--cta-b)); border: 2px solid var(--stroke); box-shadow: var(--shadow); }
.hm-today { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 12px; align-items: stretch; }
.hm-left { display: flex; flex-direction: column; gap: 2px; }
.hm-left .ring { margin: auto 0; padding-top: 8px; }
.hm-right { display: flex; flex-direction: column; gap: 9px; justify-content: center; }
.hm-metric { display: flex; flex-direction: column; gap: 3px; }
.hm-tile { display: flex; flex-direction: column; gap: 8px; text-align: left; min-width: 0; }
.hm-tile .t { font-weight: 600; font-size: 14px; }
.hm-tile .ibtn { width: 34px; height: 34px; }
.hm-tile .ibtn .ico { width: 16px; height: 16px; }
.hm-week { display: flex; flex-direction: column; gap: 12px; text-align: left; width: 100%; }
.hm-bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; }
.hm-bar { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.hm-col { height: 64px; width: 10px; display: flex; align-items: flex-end; border-radius: 6px; background: var(--track); overflow: hidden; }
.hm-col i { display: block; width: 100%; height: 0; border-radius: 6px; background: linear-gradient(180deg, var(--accent-2), var(--accent)); }
.hm-bar em { font-style: normal; font-size: 10.500px; color: var(--mute); }

/* branches/more/style.css */
.screen-more .hdr .hm-ava, .screen-account .hm-ava { display: grid; place-items: center; }
.screen-more .row .v { max-width: 46%; overflow: hidden; text-overflow: ellipsis; }

/* branches/nutrition/style.css */
.nt-date { justify-content: center; min-height: 40px; }
.nt-macro { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.nt-macro .num.lg { font-size: 18px; white-space: nowrap; }
.screen-nutrition .ring { margin: 4px 0; }

/* branches/progress/style.css */
.screen-progress .field input[type="date"] { min-width: 0; }

/* branches/training/style.css */
.tr-prog { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; min-height: 84px; }
.tr-line { padding: 6px 0; border-bottom: 1px solid var(--stroke-2); }
.tr-line:last-child { border-bottom: 0; }
.tr-timer { font-size: 17px; }
.tr-grp { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-size: 13px; font-weight: 600; color: var(--ink); }
.tr-grp .ico { color: var(--accent-ink); width: 26px; height: 26px; }
.tr-set { flex-direction: row; align-items: center; gap: 10px; }
.tr-set .num { width: 18px; text-align: center; font-size: 15px; color: var(--mute); }
.tr-done { flex: none; }
.tr-done input { position: absolute; opacity: 0; width: 46px; height: 46px; margin: 0; }
.tr-done span { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--glass-3); border: 1px solid var(--stroke-2); color: transparent; }
.tr-done input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.tr-done input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* branches/welcome/style.css */
/* Знайомство: картинка з макета згори, текст і кнопка знизу */
.screen-welcome { padding: 0; gap: 0; position: relative; overflow: hidden; }
.wl-hero { position: absolute; inset: 0 0 34% 0; background: url("branches/welcome/hero-light.webp") center top / cover no-repeat;
  -webkit-mask-image: linear-gradient(#000 62%, transparent); mask-image: linear-gradient(#000 62%, transparent); }
[data-theme="dark"] .wl-hero { background-image: url("branches/welcome/hero-dark.webp"); }
.wl-lang { position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 16px; display: flex; align-items: center; gap: 6px;
  padding: 6px 10px 6px 12px; border-radius: 999px; color: var(--ink-2); }
.wl-lang select { background: none; border: 0; font-size: 14px; color: var(--ink); appearance: none; -webkit-appearance: none; padding-right: 4px; }
.wl-lang select option { color: #1d3852; background: #fff; }
.wl-text { position: relative; margin-top: auto; padding: 0 22px calc(30px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.wl-logo { color: var(--ink); }
.wl-logo .ico { width: 34px; height: 34px; }
.wl-title { font-size: 40px; line-height: 1.12; font-weight: 650; letter-spacing: -.02em; }
.wl-sub { color: var(--ink-2); font-size: 15.500px; max-width: 22em; margin-bottom: 10px; }
.wl-have { color: var(--ink-2); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; min-height: 40px; }
