/* EH : Stats Tracker — тёмная тема в стиле Edits : Helper. Цвета темы Telegram намеренно не используются. */
:root {
  --bg: #000;
  --surface: #0b0b0b;
  --surface-2: #0d0d0d;
  --tile: #141414;

  --line: #1a1a1a;
  --line-row: #1c1c1c;
  --line-strip: #1f1f1f;
  --line-btn: #262626;
  --line-chip: #2a2a2a;
  --line-strong: #333;

  --text: #fff;
  --text-2: #bfbfbf;
  --muted: #8f8f8f;
  --faint: #8a8a8a;
  --index: #5a5a5a;

  --green: #4ade80;
  --green-text: #6ff59c;
  --green-glow: 0 0 10px rgba(74, 222, 128, .6);
  --red: #ff3b30;
  --red-text: #ff5a50;

  --f-display: "Unbounded", system-ui, sans-serif;
  --f-body: "Golos Text", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, monospace;

  --pad: 16px;
  --gap: 20px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { background: var(--bg); color: var(--text); }
body {
  font: 400 15px/1.4 var(--f-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input { font: inherit; color: inherit; background: none; border: 0; outline: 0; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--f-mono); font-weight: 500; }

.ic {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.ic--muted { color: var(--muted); }

/* ---------- каркас ---------- */
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; }
.screen {
  display: flex; flex-direction: column; gap: var(--gap);
  padding: 12px var(--pad) calc(32px + env(safe-area-inset-bottom));
}
/* Уходящий экран на время анимации перехода: остаётся на месте поверх, пока уезжает (см. showScreen) */
.screen.is-leaving {
  position: fixed; left: 0; right: 0; z-index: 5; width: 100%; max-width: 480px; margin: 0 auto;
  background: var(--bg); pointer-events: none;
}

.block { display: flex; flex-direction: column; gap: 12px; }

/* ---------- шапки ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; height: 44px; }
.topbar--back { justify-content: flex-start; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand__mark {
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center; background: #fff; color: #000;
}
.brand__mark .ic { width: 18px; height: 18px; stroke-width: 2.4; }
.brand__name { font: 600 16px var(--f-display); letter-spacing: -.01em; }
.brand__name i { font-style: normal; color: var(--index); }

.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; flex: none;
  border: 1px solid var(--line-btn);
  display: grid; place-items: center;
}
.icon-btn:active { background: var(--surface); border-color: var(--line-strong); }

.kicker { font: 500 12px var(--f-mono); letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }

.section-title {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 24px; font: 500 15px var(--f-display);
}
.section-title > span:first-child { white-space: nowrap; }
.mono-count { font: 500 12px var(--f-mono); color: var(--muted); white-space: nowrap; }
.mono-meta {
  font: 500 11px/1.5 var(--f-mono); color: var(--faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- карточка аккаунта ---------- */
.account {
  background: var(--surface); border: 1px solid var(--line-row); border-radius: 22px;
  padding: 16px; display: flex; flex-direction: column; gap: 14px;
}
.account__head { display: flex; align-items: center; gap: 12px; }
.account__who { flex: 1; min-width: 0; }
/* Длинное имя переносится на вторую строку, как на референсе, а не обрезается */
.account__name {
  font: 600 16px/1.25 var(--f-body); overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.account__head .mono-meta { white-space: nowrap; }
.account__chart { display: flex; flex-direction: column; gap: 4px; }
.account__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font: 500 11px var(--f-mono); color: #7a7a7a; letter-spacing: .08em; text-transform: uppercase;
}
.avatar {
  width: 52px; height: 52px; flex: none; border-radius: 50%; overflow: hidden;
  border: 1px solid var(--line-strong); display: grid; place-items: center; color: var(--muted);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.link-mono {
  font: 500 11px var(--f-mono); color: var(--muted); letter-spacing: .08em; text-transform: uppercase;
  padding: 10px 0 10px 12px;
}
.at { font: 500 15px var(--f-mono); color: var(--muted); margin-right: -8px; }
.chart__wrap--sm { height: 110px; }

/* ---------- поле ссылки ---------- */
.link-input {
  display: flex; align-items: center; gap: 12px;
  height: 60px; padding: 0 8px 0 16px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line-row);
  transition: border-color .15s;
}
.link-input:focus-within { border-color: var(--line-strong); }
.link-input.is-error { border-color: rgba(255, 59, 48, .55); }
/* 16px — меньше iOS при фокусе приближает страницу и сдвигает её вбок */
.link-input input { flex: 1; min-width: 0; height: 100%; font-size: 16px; outline: none; }
.account .link-input { gap: 10px; }
.link-input input::placeholder { color: #6f6f6f; }
.round-btn {
  width: 44px; height: 44px; flex: none; border-radius: 50%;
  border: 1px solid var(--line-strong); display: grid; place-items: center;
  transition: opacity .15s, transform .12s;
}
.round-btn .ic { width: 20px; height: 20px; }
.round-btn--solid { background: #fff; color: #000; border-color: #fff; }
.round-btn--solid .ic { stroke-width: 2.4; }
.round-btn:active { transform: scale(.94); }
.round-btn:disabled { opacity: .4; cursor: default; }
.round-btn.is-busy .ic { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hint { font: 500 11px var(--f-mono); color: #7a7a7a; padding: 0 4px; letter-spacing: .02em; }
.hint.is-error { color: var(--red-text); }

/* ---------- список видео ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 14px;
  min-height: 72px; padding: 12px 14px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line-row);
  text-align: left; width: 100%;
  transition: background .15s, border-color .15s;
}
.row:active { background: var(--surface-2); border-color: var(--line-strong); }
.row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { font: 500 15px/1.3 var(--f-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb {
  width: 44px; height: 56px; flex: none; border-radius: 10px;
  background: linear-gradient(160deg, #1a1a1a, #0f0f0f); border: 1px solid var(--line-strip);
  display: grid; place-items: center; color: var(--index);
}
.thumb svg { width: 16px; height: 16px; fill: currentColor; }
.num { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.num b { font: 500 15px var(--f-mono); white-space: nowrap; }
.num em { font: 500 11px var(--f-mono); font-style: normal; color: var(--green-text); text-shadow: var(--green-glow); white-space: nowrap; }
.num em.is-flat { color: #7a7a7a; text-shadow: none; }

.pill {
  height: 26px; padding: 0 10px; flex: none; display: inline-flex; align-items: center;
  border-radius: 999px; font: 500 11px var(--f-mono); letter-spacing: .08em; text-transform: uppercase;
}
.pill--muted { border: 1px solid var(--line-strong); color: var(--muted); }
.pill--warn { border: 1px solid #fff; color: #fff; }
.pill--pro { background: #fff; color: #000; font-weight: 600; }

/* ---------- подписка ---------- */
.thumb--star { color: #fff; }
.thumb--star svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.sub-row.is-active .thumb--star svg { fill: currentColor; filter: drop-shadow(0 0 6px rgba(255, 255, 255, .45)); }
.perks {
  list-style: none; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line-row); border-radius: 16px; padding: 4px 16px;
}
.perk { display: flex; gap: 12px; padding: 12px 0; }
.perk + .perk { border-top: 1px solid var(--line); }
.perk__mark {
  width: 22px; flex: none; font: 600 15px/1.35 var(--f-mono); color: #fff;
  text-shadow: 0 0 10px rgba(255, 255, 255, .45);
}
.terms .perk__note { font-size: 12px; color: var(--text-2); }
.section-title--start { justify-content: flex-start; gap: 10px; }

/* Звезда Telegram Stars: белая (или чёрная на белой кнопке), скруглённые лучи */
.tg-star {
  width: .9em; height: .9em; margin-left: .25em; vertical-align: -.08em;
  fill: currentColor; stroke: currentColor; stroke-width: 2.4; stroke-linejoin: round;
}
.big .tg-star { width: .8em; height: .8em; }
.btn-primary .tg-star { margin-left: -5px; } /* у кнопки уже есть gap между детьми */
.pill--stars { gap: 0; color: var(--text-2); }
.sub-row__end { flex: none; display: flex; align-items: center; }

/* Активная подписка: зелёная галочка светится, вокруг кружат светлячки */
.fireflies { position: relative; width: 44px; height: 44px; display: grid; place-items: center; }
.pro-check {
  width: 24px; height: 24px; fill: none; stroke: var(--green-text); stroke-width: 2.8;
  stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 0 6px rgba(74, 222, 128, .75)); animation: star-glow 2.8s ease-in-out infinite;
}
.firefly {
  position: absolute; width: 3px; height: 3px; border-radius: 50%; opacity: 0;
  background: var(--green-text); box-shadow: 0 0 6px 1px rgba(74, 222, 128, .8);
  animation: firefly 4s ease-in-out infinite;
}
@keyframes star-glow { 50% { filter: drop-shadow(0 0 11px rgba(74, 222, 128, .95)); } }
@keyframes firefly {
  0% { transform: translate(0, 0); opacity: 0; }
  25% { opacity: 1; }
  50% { transform: translate(var(--dx), var(--dy)); opacity: .85; }
  75% { opacity: 1; }
  100% { transform: translate(0, 0); opacity: 0; }
}
/* .v-title ниже по файлу задаёт display: -webkit-box — перебиваем двумя классами */
.v-title.sub-title { display: flex; align-items: center; gap: 12px; }
/* ---------- раннее отслеживание ---------- */
.early-panel { gap: 10px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch-row__title { font: 600 15px var(--f-body); }
.early-panel__text { font: 400 13px/1.45 var(--f-body); color: var(--text-2); }
.switch {
  position: relative; width: 52px; height: 32px; flex: none; border-radius: 999px;
  background: #1a1a1a; border: 1px solid var(--line-chip); transition: background .25s, border-color .25s;
}
.switch__knob {
  position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--muted); transition: transform .28s cubic-bezier(.3, .7, .2, 1), background .25s;
}
.switch[aria-checked="true"] { background: #fff; border-color: #fff; box-shadow: 0 0 14px rgba(255, 255, 255, .18); }
.switch[aria-checked="true"] .switch__knob { transform: translateX(20px); background: #000; }
.switch.is-locked { opacity: .45; }

.pill--inline { height: 20px; padding: 0 8px; margin-left: 8px; font-size: 10px; vertical-align: 2px; }
.pill--title { height: 32px; padding: 0 14px; font-size: 15px; letter-spacing: .1em; }
.perk__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.perk__title { font: 600 15px/1.35 var(--f-body); }
.perk__note { font: 500 11px/1.5 var(--f-mono); color: var(--faint); }
.toggle button.is-locked { color: var(--index); }
.toggle button.is-locked::after { content: "✦"; position: absolute; top: 5px; right: 8px; font-size: 9px; color: var(--muted); }
.actions.is-single { grid-template-columns: minmax(0, 1fr); }
.price { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.price__old { font: 500 15px var(--f-mono); color: var(--index); }
.link-mono--left { align-self: flex-start; padding: 4px; }

.empty {
  padding: 32px 16px; text-align: center; color: var(--faint);
  border: 1px dashed var(--line-btn); border-radius: 16px; font-size: 14px;
}

/* ---------- карточка видео ---------- */
.v-head { display: flex; flex-direction: column; gap: 10px; }
.v-title {
  font: 700 28px/1.06 var(--f-display); letter-spacing: -.02em; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.v-meta { font: 500 12px var(--f-mono); color: var(--muted); }
.status-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.status-row .mono-meta { white-space: normal; }
.chip-mono {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-chip);
  font: 500 11px var(--f-mono); color: var(--text-2);
}
.live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); box-shadow: var(--green-glow);
  animation: pulse 2.4s ease-in-out infinite;
}
.live-dot.is-off { background: #5a5a5a; box-shadow: none; animation: none; }
.live-dot.is-paused { background: #5a5a5a; box-shadow: none; animation: none; }
@keyframes pulse { 50% { opacity: .35; } }

.banner {
  padding: 10px 14px; border-radius: 14px; font-size: 13px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid rgba(255, 59, 48, .45);
}
.banner.is-info { border-color: var(--line-strong); }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.metric {
  background: var(--surface); border: 1px solid var(--line-row); border-radius: 14px;
  padding: 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.metric b { font: 500 18px var(--f-mono); white-space: nowrap; }
.metric span { font-size: 12px; color: var(--muted); }
.metric em { font: 500 11px var(--f-mono); font-style: normal; color: var(--green-text); }
.metric em.is-flat { color: #7a7a7a; }
.metric em.is-down { color: var(--red-text); }

.seg {
  display: inline-flex; padding: 3px; gap: 2px; flex: none;
  background: #000; border: 1px solid var(--line-chip); border-radius: 12px;
}
.seg button {
  height: 28px; padding: 0 8px; border-radius: 9px;
  font: 500 12px var(--f-mono); color: var(--muted);
  transition: background .15s, color .15s;
}
.seg button[aria-checked="true"] { background: #fff; color: #000; }
/* Периоды графиков — своей строкой на всю ширину: с вкладкой «Старт» их шесть */
.seg--full { display: flex; width: 100%; }
.seg--full button { flex: 1; height: 32px; padding: 0 4px; }
.seg--modes button { height: 38px; font-size: 12px; }

/* ---------- графики ---------- */
.charts { display: flex; flex-direction: column; gap: 12px; transition: opacity .15s; }
.charts.is-loading { opacity: .45; }
.chart {
  background: var(--surface); border: 1px solid var(--line-row); border-radius: 16px;
  padding: 14px 14px 10px; display: flex; flex-direction: column; gap: 6px;
}
.chart__head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chart__name { font: 600 14px var(--f-body); }
.chart__period { font: 500 11px var(--f-mono); color: var(--faint); letter-spacing: .06em; text-transform: uppercase; }
.chart__row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.big { font: 500 24px/1.2 var(--f-mono); letter-spacing: -.02em; }
.glow { color: var(--green-text); text-shadow: var(--green-glow); }
.glow.is-flat { color: var(--muted); text-shadow: none; }
.glow.is-down { color: var(--red-text); text-shadow: 0 0 10px rgba(255, 59, 48, .45); }
.sub { font: 500 11px/1.5 var(--f-mono); color: var(--faint); }
.sub--note { color: #7a7a7a; }
.chart__wrap { position: relative; height: 150px; margin-top: 8px; }
.chart__hint { font: 500 11px var(--f-mono); color: var(--faint); text-align: center; padding: 6px 0; }

/* ---------- настройки отслеживания ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line-row); border-radius: 16px;
  padding: 16px; display: flex; flex-direction: column; gap: 14px;
}
.panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--muted); }
.panel__head .mono { font-size: 13px; color: #fff; }

.toggle {
  position: relative; display: grid; grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr));
  height: 52px; padding: 4px; border-radius: 999px;
  background: #000; border: 1px solid var(--line-chip);
}
.toggle__pill {
  position: absolute; top: 4px; bottom: 4px; left: 4px;
  width: calc((100% - 8px) / var(--n, 6)); border-radius: 999px;
  background: #fff; box-shadow: 0 0 14px rgba(255, 255, 255, .18);
  transition: transform .28s cubic-bezier(.3, .7, .2, 1);
}
.toggle button {
  position: relative; z-index: 1; border-radius: 999px;
  font: 500 14px var(--f-mono); color: var(--muted); transition: color .2s;
}
.toggle button[aria-checked="true"] { color: #000; font-weight: 600; }

.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.btn-ghost {
  height: 52px; border-radius: 16px; border: 1px solid var(--line-strong);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 15px var(--f-body); transition: transform .12s, background .15s;
}
.btn-ghost .ic { width: 18px; height: 18px; }
.btn-ghost:active { transform: scale(.98); background: var(--surface-2); }
.btn-primary {
  height: 56px; width: 100%; border-radius: 16px; background: #fff; color: #000;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 15px var(--f-body); transition: transform .12s, opacity .15s;
}
.btn-primary .ic { width: 20px; height: 20px; stroke-width: 2.4; }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .4; cursor: default; }
.btn-primary.is-busy { opacity: .6; cursor: progress; }
.danger-link { height: 44px; color: var(--red-text); font: 500 14px var(--f-body); }

/* ---------- тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px); max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: 12px; background: #fff; color: #000; font: 500 13px var(--f-body);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20;
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
