/* ===== Токени ===== */
:root {
  --font: 'Manrope', -apple-system, system-ui, 'Segoe UI', Roboto, sans-serif;
  --r-lg: 26px; --r-md: 20px; --r-sm: 14px;
  --gap: clamp(8px, 1.4vh, 12px);
  --pad: 16px;
  --blur: 26px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --c-excellent: #34d399; --c-good: #a3e635; --c-moderate: #facc15; --c-poor: #fb923c; --c-bad: #f43f5e;
  --accent: #f5a524;
  /* Безпечні зони Telegram (fullscreen) + звичайні */
  --safe-top: calc(max(var(--tg-safe-area-inset-top, 0px), env(safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(var(--tg-safe-area-inset-bottom, 0px), env(safe-area-inset-bottom, 0px));
  --tabbar-h: 64px;
  --vh: var(--tg-viewport-stable-height, 100dvh);
}
/* Темний фон → світлий текст */
:root[data-tone="dark"] {
  --ink: #ffffff; --ink-2: rgba(255,255,255,.78); --ink-3: rgba(255,255,255,.55); --ink-4: rgba(255,255,255,.28);
  --glass: rgba(255,255,255,.11); --glass-2: rgba(255,255,255,.18); --glass-brd: rgba(255,255,255,.20);
  --glass-hl: rgba(255,255,255,.28); --shadow: 0 10px 40px rgba(0,0,0,.18);
  --scrim: linear-gradient(180deg, rgba(4,10,24,.42) 0%, rgba(4,10,24,.12) 30%, rgba(4,10,24,.18) 60%, rgba(4,10,24,.55) 100%);
  --txt-shadow: 0 1px 12px rgba(0,0,0,.25);
  --seg-on: rgba(255,255,255,.92); --seg-on-ink: #0d1b2a;
  --tabbar-bg: rgba(18,28,48,.62);
}
/* Світлий фон → темний текст */
:root[data-tone="light"] {
  --ink: #0b1a2c; --ink-2: rgba(11,26,44,.76); --ink-3: rgba(11,26,44,.55); --ink-4: rgba(11,26,44,.25);
  --glass: rgba(255,255,255,.34); --glass-2: rgba(255,255,255,.5); --glass-brd: rgba(255,255,255,.62);
  --glass-hl: rgba(255,255,255,.85); --shadow: 0 10px 40px rgba(20,40,80,.12);
  --scrim: linear-gradient(180deg, rgba(255,255,255,.30) 0%, rgba(255,255,255,.06) 35%, rgba(255,255,255,.08) 65%, rgba(255,255,255,.35) 100%);
  --txt-shadow: 0 1px 10px rgba(255,255,255,.35);
  --seg-on: rgba(11,26,44,.88); --seg-on-ink: #ffffff;
  --tabbar-bg: rgba(255,255,255,.62);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d1a2e; overscroll-behavior: none; }
body {
  font-family: var(--font); color: var(--ink); font-size: 15px; line-height: 1.35;
  -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none;
  transition: color .9s var(--ease);
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; } .tiny { font-size: 11.5px; } .center { text-align: center; }
.label { font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; }
.label svg { width: 15px; height: 15px; }

/* ===== Фон ===== */
#bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: #0d1a2e; }
#sky, #vid { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#vid { opacity: 0; transition: opacity 1.6s var(--ease); transform: scale(1.04); }
#vid.on { opacity: 1; }
.scrim { position: absolute; inset: 0; background: var(--scrim); transition: background 1s var(--ease); }
:root[data-bg="off"] #vid { display: none; }

/* ===== Скло ===== */
.glass {
  position: relative;
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(170%);
  backdrop-filter: blur(var(--blur)) saturate(170%);
  border: 1px solid var(--glass-brd);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow), inset 0 1px 0 var(--glass-hl);
  transition: background .9s var(--ease), border-color .9s var(--ease);
}

/* ===== Каркас і вкладки ===== */
#app { position: fixed; inset: 0; z-index: 1; }
.view {
  position: absolute; inset: 0;
  padding: calc(var(--safe-top) + 12px) var(--pad) calc(var(--safe-bottom) + var(--tabbar-h) + 22px);
  display: none;
}
.view.active { display: block; }
#view-home.active { display: flex; }
.view.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.view.scroll > * + * { margin-top: 12px; }

#tabbar {
  position: fixed; z-index: 5; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 10px);
  width: min(360px, calc(100% - 32px)); height: var(--tabbar-h);
  display: grid; grid-template-columns: repeat(3, 1fr); padding: 6px; border-radius: 24px;
  background: var(--tabbar-bg); -webkit-backdrop-filter: blur(34px) saturate(180%); backdrop-filter: blur(34px) saturate(180%);
}
#tabbar button { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--ink-3); transition: color .3s; }
#tabbar button svg { width: 22px; height: 22px; }
#tabbar button.on { color: var(--ink); }
.tab-ind { position: absolute; top: 6px; bottom: 6px; left: 6px; width: calc((100% - 12px) / 3); border-radius: 18px; background: var(--glass-2); box-shadow: inset 0 1px 0 var(--glass-hl); transition: transform .5s var(--ease), background .9s; }

/* ===== Головна ===== */
#view-home { flex-direction: column; gap: var(--gap); }
.hello { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; text-shadow: var(--txt-shadow); padding: 2px 4px 0; }
.hello-sub { font-size: clamp(13px, 1.9vh, 15px); color: var(--ink-2); font-weight: 500; }
.hello-name { font-size: clamp(26px, 4.2vh, 34px); font-weight: 300; letter-spacing: -.02em; line-height: 1.1; }
.live { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 12px; color: var(--ink-2); font-weight: 500; }
.live-row { display: inline-flex; align-items: center; gap: 7px; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--c-excellent); box-shadow: 0 0 0 0 rgba(52,211,153,.7); animation: pulse 2.4s infinite; }
.pulse.stale { background: var(--c-poor); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(52,211,153,.6); } 70% { box-shadow: 0 0 0 9px rgba(52,211,153,0); } 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); } }
.chip { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--glass-2); border: 1px solid var(--glass-brd); letter-spacing: .03em; }
.demo-chip { color: var(--accent); }

.aq { padding: clamp(12px, 2vh, 18px) 18px clamp(12px, 1.8vh, 16px); overflow: hidden; }
.aq::before { content: ''; position: absolute; inset: -40% -20% auto auto; width: 70%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, var(--aq-c, transparent) 0%, transparent 65%); opacity: .35; transition: background 1s; pointer-events: none; }
.aq-top { display: flex; justify-content: space-between; align-items: center; }
.aq-trend { font-size: 12px; color: var(--ink-2); font-weight: 600; display: inline-flex; gap: 4px; align-items: center; }
.aq-word { font-size: clamp(32px, 5.6vh, 46px); font-weight: 300; letter-spacing: -.03em; line-height: 1.08; margin: 4px 0 clamp(8px, 1.4vh, 12px); text-shadow: var(--txt-shadow); }
.aq-scale { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; height: 6px; }
.aq-scale i { border-radius: 4px; opacity: .9; }
.aq-scale i:nth-child(1) { background: var(--c-excellent); } .aq-scale i:nth-child(2) { background: var(--c-good); }
.aq-scale i:nth-child(3) { background: var(--c-moderate); } .aq-scale i:nth-child(4) { background: var(--c-poor); } .aq-scale i:nth-child(5) { background: var(--c-bad); }
.aq-scale b { position: absolute; top: 50%; left: 0; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px var(--aq-c, #fff), 0 2px 10px rgba(0,0,0,.3); transition: left 1.2s var(--ease); }
.aq-tech { margin-top: clamp(8px, 1.4vh, 11px); font-size: 12.5px; color: var(--ink-3); font-weight: 500; letter-spacing: .01em; font-variant-numeric: tabular-nums; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.tile { padding: clamp(9px, 1.5vh, 13px) 11px; border-radius: var(--r-md); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile .label svg { display: none; }
.tile .label { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; gap: 4px; letter-spacing: 0; display: flex; }
.tile .label svg { width: 13px; height: 13px; }
.val { display: flex; align-items: baseline; gap: 2px; white-space: nowrap; margin-top: clamp(2px, .6vh, 6px); text-shadow: var(--txt-shadow); }
.num { font-size: clamp(23px, 3.7vh, 30px); font-weight: 300; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.05; }
.num.small { font-size: clamp(15px, 2.3vh, 18px); font-weight: 500; letter-spacing: -.01em; white-space: nowrap; }
.unit { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.sub { font-size: 11px; color: var(--ink-3); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compass-val { align-items: center; gap: 8px; }
.compass { position: relative; width: clamp(28px, 4.2vh, 36px); aspect-ratio: 1; border-radius: 50%; border: 1.5px solid var(--ink-4); flex: none; }
.compass .n { position: absolute; top: 2px; left: 50%; width: 2px; height: 4px; margin-left: -1px; border-radius: 1px; background: var(--ink-2); }
.compass .arrow { position: absolute; inset: 15%; width: 70%; height: 70%; fill: var(--ink); stroke: none; transition: transform 1.4s var(--ease); }

.chart-card { flex: 1; min-height: 140px; display: flex; flex-direction: column; padding: 12px 14px 10px; overflow: hidden; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; height: clamp(74px, 11vh, 96px); }
.day { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; font-size: 11px; font-weight: 600; color: var(--ink-3); position: relative; }
.day .bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.day .bar { width: 10px; border-radius: 6px; min-height: 6px; background: var(--c); box-shadow: 0 0 14px -2px var(--c); transform-origin: bottom; animation: grow .9s var(--ease) both; }
.day .t { font-size: 11px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.day .t s { text-decoration: none; color: var(--ink-3); font-weight: 500; }
.day.today .dn { color: var(--ink); }
@keyframes grow { from { transform: scaleY(0); } }
.today-head { display: flex; justify-content: space-between; align-items: center; margin: 10px 0 2px; padding-top: 9px; border-top: 1px solid var(--ink-4); }
.today-wrap { position: relative; flex: 1; min-height: 50px; }
#today { position: absolute; inset: 0; width: 100%; height: 100%; }
.today-tip { position: absolute; top: 0; padding: 3px 8px; border-radius: 8px; font-size: 11px; font-weight: 700; background: var(--seg-on); color: var(--seg-on-ink); opacity: 0; transform: translateX(-50%); pointer-events: none; transition: opacity .2s; white-space: nowrap; }
.today-tip.on { opacity: 1; }

/* ===== Сегменти, перемикачі ===== */
.seg { display: flex; gap: 2px; padding: 3px; border-radius: 13px; background: var(--glass); border: 1px solid var(--glass-brd); overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1; padding: 7px 10px; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; transition: none; }
.seg button.on { background: var(--seg-on); color: var(--seg-on-ink); box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.seg button:disabled { opacity: .3; }
.seg.mini { border-radius: 11px; }
.seg.mini button { padding: 4px 9px; font-size: 12px; border-radius: 8px; }

.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input, .switch-inline input { position: absolute; opacity: 0; pointer-events: none; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--ink-4); transition: background .3s; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25); transition: transform .35s var(--ease); }
.switch input:checked + i { background: var(--c-excellent); }
.switch input:checked + i::after { transform: translateX(18px); }

/* ===== Історія ===== */
.page-head { padding: 4px 4px 2px; text-shadow: var(--txt-shadow); }
.page-head h2 { font-size: 32px; font-weight: 300; letter-spacing: -.03em; }
.page-head p { margin-top: 4px; font-size: 14px; color: var(--ink-2); min-height: 19px; }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 12px calc(-1 * var(--pad)) 0; padding: 2px var(--pad); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; padding: 8px 14px; border-radius: 99px; font-size: 13px; font-weight: 600; background: var(--glass); border: 1px solid var(--glass-brd); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); color: var(--ink-2); transition: all .25s; }
.chips button.on { background: var(--seg-on); color: var(--seg-on-ink); border-color: transparent; }
.panel { padding: 12px; border-radius: var(--r-md); }
.nav-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.nav-label { font-weight: 600; font-size: 15px; text-align: center; flex: 1; }
.icon-btn { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--glass); border: 1px solid var(--glass-brd); }
.icon-btn:disabled { opacity: .3; }
.custom-row { display: flex; gap: 10px; margin-top: 10px; }
.custom-row label { flex: 1; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-3); }
.custom-row input { flex: 1; min-width: 0; font: inherit; font-size: 14px; color: var(--ink); background: var(--glass); border: 1px solid var(--glass-brd); border-radius: 10px; padding: 7px 8px; color-scheme: dark; }
:root[data-tone="light"] .custom-row input { color-scheme: light; }
.agg-row { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.agg-row .label { padding-left: 4px; }
.agg-row .seg button { padding: 5px 4px; font-size: 11.5px; }

.chart-panel { padding: 12px 6px 10px; }
.readout { padding: 0 8px 6px; display: flex; align-items: baseline; gap: 10px; min-height: 34px; }
.ro-val { font-size: 24px; font-weight: 300; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.ro-meta { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.h-chart { height: 260px; touch-action: pan-y; }
.legend-row { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 8px 8px 0; font-size: 11.5px; color: var(--ink-3); font-weight: 600; align-items: center; }
.legend-row > span { display: inline-flex; align-items: center; gap: 6px; }
.lg-line { width: 14px; height: 2.5px; border-radius: 2px; background: var(--ink); }
.lg-band { width: 14px; height: 9px; border-radius: 3px; background: var(--ink-4); }
.lg-who { width: 14px; border-top: 2px dashed var(--c-moderate); }
.switch-inline { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; position: relative; }
.switch-inline i { width: 32px; height: 19px; border-radius: 99px; background: var(--ink-4); position: relative; transition: background .3s; }
.switch-inline i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: #fff; transition: transform .3s var(--ease); }
.switch-inline input:checked + i { background: var(--accent); }
.switch-inline input:checked + i::after { transform: translateX(13px); }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { padding: 12px 14px; border-radius: var(--r-md); }
.stat .k { font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
.stat .v { font-size: 22px; font-weight: 300; letter-spacing: -.02em; margin-top: 3px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; color: var(--ink-2); font-weight: 500; margin-left: 2px; letter-spacing: 0; }
.stat .d { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }
.stat.wide { grid-column: span 2; }
.delta-up { color: var(--c-poor); } .delta-down { color: var(--c-excellent); }
:root[data-tone="light"] .delta-down { color: #0e9f6e; } :root[data-tone="light"] .delta-up { color: #d9480f; }

.levels-bar { display: flex; height: 14px; border-radius: 8px; overflow: hidden; margin-top: 10px; gap: 2px; }
.levels-bar i { display: block; height: 100%; transition: flex .8s var(--ease); }
.levels-legend { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 10px; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.levels-legend span { display: flex; align-items: center; gap: 7px; }
.levels-legend i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.levels-legend b { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.profile { width: 100%; height: 120px; display: block; margin-top: 8px; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 14px; border-radius: var(--r-md); font-weight: 600; font-size: 15px; }
.btn.wide { width: 100%; }
.btn:active, .row.link:active, .icon-btn:active { transform: scale(.98); }

/* ===== Налаштування ===== */
.profile-card { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: var(--r-md); margin-top: 12px; }
.avatar { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; font-weight: 700; color: #0b1a2c; background: linear-gradient(135deg, #fde68a, var(--accent)); }
.pc-name { font-size: 17px; font-weight: 600; }
h3.group { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); padding: 14px 6px 0; text-shadow: var(--txt-shadow); }
.list { border-radius: var(--r-md); padding: 2px 0; }
.list .row { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; font-size: 15px; font-weight: 500; text-align: left; }
.list .row + .row, .list .row + .scale-box, .list .scale-box + .row { border-top: 1px solid var(--ink-4); }
.list .row.col { flex-direction: column; align-items: stretch; gap: 9px; }
.list .row.link svg { color: var(--ink-3); }
.thr-head { display: flex; justify-content: space-between; }
.thr-head b { font-weight: 700; font-variant-numeric: tabular-nums; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 4px; background: linear-gradient(90deg, var(--c-excellent), var(--c-good) 12%, var(--c-moderate) 25%, var(--c-poor) 50%, var(--c-bad)); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 0; }
.scale-box { padding: 6px 14px 12px; font-size: 13px; }
.scale-box table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.scale-box td, .scale-box th { padding: 6px 4px; text-align: left; }
.scale-box th { font-size: 11px; color: var(--ink-3); font-weight: 600; }
.scale-box i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; }
.credits { padding: 8px 20px 0; line-height: 1.5; }
.credits a { color: inherit; }

/* ===== Службове ===== */
#toast { position: fixed; z-index: 30; left: 50%; bottom: calc(var(--safe-bottom) + var(--tabbar-h) + 24px); transform: translate(-50%, 20px); opacity: 0; padding: 10px 16px; border-radius: 14px; background: var(--seg-on); color: var(--seg-on-ink); font-size: 14px; font-weight: 600; transition: all .4s var(--ease); pointer-events: none; max-width: 86%; text-align: center; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#gate { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: #0d1a2e; color: #fff; transition: opacity .7s var(--ease); }
#gate.hide { opacity: 0; pointer-events: none; }
.gate-inner { text-align: center; padding: 30px; max-width: 320px; }
.gate-inner p { margin-top: 18px; color: rgba(255,255,255,.75); font-size: 15px; line-height: 1.5; }
.loader { width: 34px; height: 34px; margin: 0 auto; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.18); border-top-color: #fff; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Менше анімацій */
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .15s !important; }

/* Невисокі екрани (iPhone SE і подібні) */
@media (max-height: 700px) {
  .tile .sub { display: none; }
  .aq-tech { font-size: 11.5px; }
  .week { height: 66px; }
}
@media (max-width: 360px) {
  .tile { padding: 9px 9px; }
  .num { font-size: 22px; }
}

/* uPlot під скло */
.uplot { font-family: var(--font); }
.u-legend { display: none; }
.u-cursor-pt { border-width: 2px !important; }

/* ===================== ЗНАЙОМСТВО ===================== */
#guide { position: fixed; inset: 0; z-index: 20; color: #fff; opacity: 0; transition: opacity .6s var(--ease); overflow: hidden; touch-action: none; }
#guide.open { opacity: 1; }
#guide .g-bg { position: absolute; inset: 0; background: #0b1020; }
#guide .g-bg canvas, #guide .g-bg video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#guide .g-bg video { opacity: 0; transition: opacity 1.6s var(--ease); }
#guide .g-bg video.on { opacity: 1; }
.g-scrim { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(5,8,20,.55) 0%, rgba(5,8,20,.35) 40%, rgba(5,8,20,.72) 100%); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.g-progress { position: absolute; z-index: 3; left: 14px; right: 14px; top: calc(var(--safe-top) + 8px); display: flex; gap: 4px; }
.g-progress i { flex: 1; height: 3px; border-radius: 3px; background: rgba(255,255,255,.22); overflow: hidden; }
.g-progress b { display: block; height: 100%; width: 0; background: #fff; transition: width .5s var(--ease); }
.g-progress i.done b { width: 100%; }
.g-skip { display: none; position: absolute; z-index: 4; right: 12px; top: calc(var(--safe-top) + 20px); font-size: 13px; font-weight: 600; color: rgba(255,255,255,.75); padding: 8px 10px; }
.g-hint { position: absolute; z-index: 3; left: 0; right: 0; bottom: calc(var(--safe-bottom) + 14px); text-align: center; font-size: 12px; font-weight: 600; color: rgba(255,255,255,.55); transition: opacity .5s; animation: hint 2.4s ease-in-out infinite; }
.g-hint.hide { opacity: 0; }
@keyframes hint { 50% { transform: translateX(6px); } }
.g-stage { position: absolute; inset: 0; z-index: 2; }
.g-slide {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-start; gap: 14px;
  padding: calc(var(--safe-top) + 34px) 22px calc(var(--safe-bottom) + 40px);
  opacity: 0; visibility: hidden; transform: translateX(30px); transition: opacity .5s var(--ease), transform .6s var(--ease), visibility 0s .6s;
}
.g-slide.active { opacity: 1; visibility: visible; transform: none; transition: opacity .55s var(--ease), transform .7s var(--ease), visibility 0s; }
.g-slide.left { transform: translateX(-30px); }
.g-slide.right { transform: translateX(30px); }
.g-slide > * { max-width: 520px; width: 100%; margin-left: auto; margin-right: auto; position: relative; z-index: 1; }
.g-slide > .g-fullbg { position: absolute; inset: 0; z-index: 0; max-width: none; width: 100%; height: 100%; margin: 0; pointer-events: none; }

.g-in, .g-pop { opacity: 0; transform: translateY(16px); filter: blur(6px); transition: opacity .7s var(--ease), transform .8s var(--ease), filter .7s var(--ease); transition-delay: calc(var(--i, 0) * 120ms + 120ms); }
.g-pop { transform: translateY(12px) scale(.92); }
.g-slide.active .g-in, .g-slide.active .g-pop { opacity: 1; transform: none; filter: none; }

.g-visual { flex: 1; position: relative; min-height: 0; }
.g-visual.center { display: grid; place-items: center; }
.g-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.g-copy { display: flex; flex-direction: column; gap: 10px; }
.g-copy.top { margin-top: 6px; }
.g-copy.foot { margin-top: auto; }
.g-spacer { flex: 1; }
.g-eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.6); }
.g-title { font-size: clamp(27px, 7.4vw, 36px); font-weight: 600; letter-spacing: -.025em; line-height: 1.12; }
.g-lead { font-size: clamp(19px, 5.2vw, 23px); font-weight: 500; line-height: 1.3; letter-spacing: -.01em; }
.g-text { font-size: 16px; line-height: 1.5; color: rgba(255,255,255,.82); }
.g-text b, .g-lead b { color: #fff; font-weight: 700; }
.g-note { font-size: 14.5px; line-height: 1.45; padding: 12px 14px; border-radius: 16px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); color: rgba(255,255,255,.88); }
.g-note.good { background: rgba(52,211,153,.14); border-color: rgba(52,211,153,.35); }

/* 1 — лічильник + «дихання» */
.g-counter { position: relative; z-index: 1; font-size: clamp(52px, 16vw, 78px); font-weight: 200; letter-spacing: -.04em; font-variant-numeric: tabular-nums; text-shadow: 0 4px 40px rgba(120,180,255,.35); }
.g-counter small { font-size: .38em; font-weight: 400; margin-left: 6px; color: rgba(255,255,255,.7); letter-spacing: 0; }
.breath { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.breath i { position: absolute; width: min(70vw, 300px); aspect-ratio: 1; border-radius: 50%; border: 1px solid rgba(160,200,255,.25); background: radial-gradient(circle, rgba(120,170,255,.16), transparent 70%); animation: breathe 4.2s ease-in-out infinite; }
.breath i:nth-child(2) { animation-delay: .5s; width: min(52vw, 220px); }
.breath i:nth-child(3) { animation-delay: 1s; width: min(90vw, 380px); opacity: .5; }
@keyframes breathe { 0%, 100% { transform: scale(.82); opacity: .45; } 45% { transform: scale(1.06); opacity: 1; } }

/* 3 — масштаб */
.g-scale { width: min(100%, 420px); max-height: 100%; height: auto; overflow: visible; }
.g-scale .sc { opacity: 0; transform-box: fill-box; transform-origin: center; }
.g-slide.active .g-scale .sc { animation: scIn .9s var(--ease) both; }
.g-slide.active .sc0 { animation-delay: .3s !important; } .g-slide.active .sc1 { animation-delay: 1.1s !important; }
.g-slide.active .sc2 { animation-delay: 1.6s !important; } .g-slide.active .sc3 { animation-delay: 2.1s !important; } .g-slide.active .sc4 { animation-delay: .7s !important; }
@keyframes scIn { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
.g-scale text, .g-body text { stroke: none; }
.g-scale circle { stroke: none; }
.sc-t { fill: #fff; font: 700 14px Manrope, sans-serif; } .sc-s { fill: rgba(255,255,255,.6); font: 600 11px Manrope, sans-serif; }
.sc0 .sc-t { fill: #fff; font-size: 15px; paint-order: stroke; }
.sc-s.dark { fill: rgba(255,255,255,.88); }
.ping { animation: ping 1.8s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes ping { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }

/* 4 — тіло */
.g-body { width: min(100%, 360px); height: 100%; max-height: 330px; overflow: visible; }
.g-body .anat * { fill: rgba(255,255,255,.05); stroke: rgba(255,255,255,.4); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.g-body .anat .trachea, .g-body .anat .bronchi, .g-body .anat .nose { fill: none; stroke-width: 2.2; stroke: rgba(255,255,255,.55); }
.g-body .anat .torso, .g-body .anat .face { fill: none; }
.g-body .anat .face { stroke: rgba(255,255,255,.45); stroke-width: 1.6; }
.g-body .anat .lung { fill: rgba(255,170,190,.1); }
.g-body .anat .heart { fill: rgba(244,63,94,.35); stroke: rgba(244,63,94,.8); transform-box: fill-box; transform-origin: center; }
.g-body .track { fill: none; stroke: none; }
.g-body .pt { opacity: 0; filter: drop-shadow(0 0 5px currentColor); transition: opacity .3s; }
.g-body .lbl text { fill: #fff; font: 700 11.5px Manrope, sans-serif; }
.g-body .lbl { opacity: 0; transition: opacity .6s; }
.g-body .lbl.on { opacity: 1; }
.g-list { list-style: none; padding: 0; margin: 2px 0 0; display: flex; flex-direction: column; gap: 9px; }
.g-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 15.5px; line-height: 1.4; color: rgba(255,255,255,.86); }
.g-list li i { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: none; box-shadow: 0 0 10px currentColor; }

/* 5 — велике число */
.g-big { font-size: clamp(84px, 27vw, 140px); font-weight: 200; letter-spacing: -.05em; line-height: 1; font-variant-numeric: tabular-nums; background: linear-gradient(180deg, #fff 30%, #ffb4c0); -webkit-background-clip: text; background-clip: text; color: transparent; }
.g-big small { font-size: .3em; font-weight: 500; letter-spacing: 0; margin-left: 8px; -webkit-text-fill-color: rgba(255,255,255,.8); }

/* 6 — джерела */
.g-grid { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-content: center; }
.g-card { display: flex; flex-direction: column; gap: 3px; padding: 14px; border-radius: 18px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
.g-card b { font-size: 15px; } .g-card span:last-child { font-size: 12.5px; color: rgba(255,255,255,.7); line-height: 1.35; }
.g-emoji { font-size: 26px; line-height: 1.2; margin-bottom: 4px; }

/* 7 — погода */
.g-rows { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.g-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 18px; background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.14); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
.g-row > div { display: flex; flex-direction: column; gap: 3px; }
.g-row b { font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.g-row b em { font-style: normal; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: rgba(255,255,255,.9); color: #0b1a2c; }
.g-row span { font-size: 13.5px; color: rgba(255,255,255,.76); line-height: 1.4; }
.g-ico { font-size: 22px; line-height: 1.2; }

/* 8 — велике слово */
.g-reveal-wrap { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 22px; }
.g-pre { font-size: clamp(21px, 6vw, 28px); font-weight: 400; line-height: 1.3; color: rgba(255,255,255,.85); }
.g-reveal { font-size: clamp(50px, 15.5vw, 92px); font-weight: 800; letter-spacing: -.035em; line-height: .95; }
.g-reveal span { display: inline-block; opacity: 0; transform: translateY(40px) scale(.9); filter: blur(12px);
  background: linear-gradient(120deg, #fff 20%, #fde68a 45%, #f5a524 60%, #fff 85%); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; }
.g-slide.active .g-reveal span { animation: letter 1s var(--ease) forwards, shimmer 5s linear 2.6s infinite; animation-delay: calc(1.4s + var(--k) * 75ms), calc(2.6s + var(--k) * 60ms); }
@keyframes letter { to { opacity: 1; transform: none; filter: none; } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -200% 0; } }

/* 9 — лазер */
.g-count { text-align: center; font-size: 14px; color: rgba(255,255,255,.75); }
.g-count b { font-size: 20px; font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; margin-left: 4px; }

/* 10 — шлях даних */
.g-pipe { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.g-pipe-in { display: flex; flex-direction: column; gap: 16px; }
.g-step { position: relative; display: flex; align-items: flex-start; gap: 14px; }
.g-num { position: relative; z-index: 1; width: 32px; height: 32px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.3); transition: background .45s, border-color .45s, box-shadow .45s, transform .45s var(--ease), color .45s; }
.g-step > div { padding-top: 5px; }
/* З'єднання від кружечка до наступного — під текстом, не поверх цифр */
.g-link { position: absolute; left: 15px; top: 36px; bottom: -14px; width: 2px; border-radius: 2px; background: rgba(255,255,255,.16); overflow: hidden; }
.g-link::after { content: ''; position: absolute; inset: 0; background: var(--accent); transform: scaleY(0); transform-origin: top; transition: transform .8s var(--ease); }
.g-step:last-child .g-link { display: none; }
.g-step.passed .g-num { background: rgba(245,165,36,.22); border-color: rgba(245,165,36,.65); }
.g-step.passed .g-link::after { transform: none; }
.g-step.lit .g-num { background: var(--accent); border-color: var(--accent); color: #1b1206; transform: scale(1.1); box-shadow: 0 0 18px rgba(245,165,36,.6); }
.g-step b { display: block; font-size: 16px; } .g-step span { font-size: 13.5px; color: rgba(255,255,255,.72); line-height: 1.35; }

/* 11 — фінал */
.g-checks { list-style: none; margin: 0; padding: 0; flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.g-checks li { position: relative; padding-left: 38px; font-size: 18px; font-weight: 500; line-height: 1.35; }
.g-checks li::before { content: '✓'; position: absolute; left: 0; top: -1px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 800; background: rgba(52,211,153,.9); color: #062b1d; }
.g-live { display: flex; text-align: left; align-items: center; gap: 10px; font-size: 14px; padding: 12px 14px; border-radius: 16px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); line-height: 1.4; }
.g-live-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 12px currentColor; animation: pulse 2s infinite; }
.g-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.g-tabs div { padding: 10px; border-radius: 14px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); }
.g-tabs b { display: block; font-size: 13px; } .g-tabs span { font-size: 11.5px; color: rgba(255,255,255,.65); line-height: 1.3; display: block; margin-top: 2px; }
.g-go { width: 100%; padding: 16px; margin-top: 4px; border-radius: 18px; background: #fff; color: #0b1a2c; font-size: 17px; font-weight: 700; box-shadow: 0 10px 40px rgba(255,255,255,.18); }
.g-go:active { transform: scale(.98); }

#guide[data-motion="reduce"] * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
@media (max-height: 700px) {
  .g-text { font-size: 14.5px; } .g-title { font-size: 25px; } .g-lead { font-size: 18px; }
  .g-card { padding: 10px 12px; } .g-emoji { font-size: 20px; } .g-row { padding: 9px 12px; } .g-row span { font-size: 12.5px; }
  .g-tabs { display: none; } .g-checks li { font-size: 16px; }
}

/* Плитки, що відкривають графік */
.tap { cursor: pointer; transition: transform .18s var(--ease), background .9s var(--ease), border-color .9s var(--ease); }
.tap:active { transform: scale(.965); }

/* ===================== СХЕМА СТАНЦІЇ ===================== */
#scheme { position: fixed; inset: 0; z-index: 25; display: flex; flex-direction: column; gap: 10px; color: #fff;
  padding: calc(var(--safe-top) + 10px) 14px calc(var(--safe-bottom) + 10px);
  background: rgba(6,10,24,.62); -webkit-backdrop-filter: blur(24px) saturate(150%); backdrop-filter: blur(24px) saturate(150%);
  opacity: 0; transition: opacity .35s var(--ease); --ink: #fff; --ink-2: rgba(255,255,255,.78); --ink-3: rgba(255,255,255,.55); --ink-4: rgba(255,255,255,.25);
  --glass: rgba(255,255,255,.1); --glass-brd: rgba(255,255,255,.2); --seg-on: rgba(255,255,255,.92); --seg-on-ink: #0d1b2a; }
#scheme.open { opacity: 1; }
.sch-head { display: flex; align-items: flex-end; justify-content: space-between; padding: 0 4px; }
.sch-head h2 { font-size: 28px; font-weight: 300; letter-spacing: -.03em; }
.sch-tabs { flex: none; }
.sch-body { position: relative; flex: 1; min-height: 0; }
.sch-body section { position: absolute; inset: 0; display: none; }
.sch-body section.on { display: block; }
.sch-stage { position: absolute; inset: 0; touch-action: none; border-radius: var(--r-lg); overflow: hidden; }
.sch-stage canvas { display: block; width: 100%; height: 100%; }
.sch-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.sch-lb { position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 99px;
  background: rgba(10,16,32,.62); border: 1px solid rgba(255,255,255,.22); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.sch-lb::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: 1px; }
.sch-msg { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,.7); }
.sch-2d { position: absolute; inset: 0; overflow: hidden; border-radius: var(--r-lg); touch-action: none; display: grid; place-items: center; }
.sch-svg { width: 100%; height: 100%; transform-origin: 0 0; stroke: none; stroke-width: 1; fill: none; }
.sch-svg rect, .sch-svg polygon { stroke-linejoin: round; }
.sch-svg .lb2 path { stroke: rgba(255,255,255,.55); stroke-width: 1; }
.sch-svg .lb2 circle { fill: #fff; }
.sch-svg text { font-family: var(--font); }
.sch-svg text:not([fill]) { fill: #fff; }
.sch-svg .t { font-size: 12px; font-weight: 700; }
.sch-svg .s { font-size: 9.5px; font-weight: 500; fill: rgba(255,255,255,.62); }
.sch-svg .bt { font-size: 14px; font-weight: 700; }
.sch-svg .bs { font-size: 10px; font-weight: 500; fill: rgba(255,255,255,.7); }
.sch-svg .pn { font-size: 10.5px; font-weight: 700; }
.sch-svg .wl { font-size: 9.5px; font-weight: 700; }
.sch-svg .note text { font-size: 11.5px; font-weight: 500; fill: rgba(255,255,255,.82); }
.sch-bar { flex: none; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.sch-bar::-webkit-scrollbar { display: none; }
.sch-bar button { flex: none; padding: 9px 14px; border-radius: 99px; font-size: 13px; font-weight: 600; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); }
.sch-bar button.on { background: var(--accent); border-color: var(--accent); color: #1b1206; }
.sch-hint { flex: none; text-align: center; font-size: 11.5px; color: rgba(255,255,255,.5); }
