
/* tgAtlas — атлас каналов.
   Громкий элемент один: карта графа рекомендаций на ночной полосе главной.
   Всё остальное — светлая бумага, чернила и один морской синий для ссылок и
   измеренных значений. Янтарь и прочие цвета островов живут только на карте.
   Радиусы по иерархии: панель 14, кнопка 8, строчный код 4.
   Текстовые ступени серого проходят AA на --bg, --paper-2 и --panel:
   --muted 5.7, --faint 4.6 в худшем случае. --line и --line-2 — только линейки.
   Старые имена (--paper, --cite, --rule…) оставлены псевдонимами: на них
   ссылаются инлайн-стили страниц. */

:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #152033;
  --ink-2: #3a475b;
  --muted: #536076;
  --faint: #5f6b80;
  --line: #dce2ea;
  --line-2: #c5ceda;

  --night: #0e1a2b;
  --night-2: #16263d;
  --night-line: #26374f;
  --on-night: #e6ecf5;
  --on-night-2: #9fb0c8;

  --sea: #0f5fa8;
  --sea-bg: #e3eef9;
  --amber: #f2a93b;

  --paper: var(--bg);
  --paper-2: #e9edf3;
  --card: var(--panel);
  --rule: var(--line-2);
  --rule-soft: var(--line);
  --cite: var(--sea);
  --cite-bg: var(--sea-bg);
  --rank: #8a5d14;
  --rank-bg: #f3e8d2;

  --wrap: 1200px;
  --prose: 66ch;
  --r-panel: 14px;
  --r-btn: 8px;
  --r-code: 4px;
  --sans: 'Onest', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; caret-color: var(--sea); accent-color: var(--sea); scrollbar-color: var(--line-2) var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-weight: 600; margin: 0; text-wrap: balance; color: var(--ink); }
h1 { font-size: clamp(34px, 5vw, 56px); line-height: 1.04; letter-spacing: -0.03em; }
h2 { font-size: clamp(24px, 2.6vw, 32px); line-height: 1.15; letter-spacing: -0.02em; }
h3 { font-size: 18px; line-height: 1.3; letter-spacing: -0.01em; }

p { margin: 0 0 14px; }
p:last-child { margin-bottom: 0; }

a { color: var(--sea); text-decoration-color: color-mix(in srgb, var(--sea) 35%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--sea); }

::selection { background: var(--sea-bg); color: var(--ink); }
:focus-visible { outline: 2px solid var(--sea); outline-offset: 2px; border-radius: 3px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding-left: 28px; padding-right: 28px; }
.wrap-narrow { max-width: 800px; margin: 0 auto; padding-left: 28px; padding-right: 28px; }
.wrap-read { max-width: 760px; margin: 0 auto; padding-left: 28px; padding-right: 28px; }
.prose { max-width: var(--prose); }
.prose h2 { font-size: 24px; margin: 38px 0 12px; }
.prose h2:first-child { margin-top: 0; }
.prose ol { margin: 0 0 14px; padding: 0 0 0 26px; }
.prose ol li { margin: 0 0 12px; }
.prose ol li:last-child { margin-bottom: 0; }
.prose ol li::marker { color: var(--muted); }

.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: -9999px; top: 0; background: var(--ink); color: #fff;
  padding: 10px 16px; z-index: 20; border-radius: var(--r-btn);
}
.skip:focus { left: 8px; top: 8px; }

.preview {
  background: var(--rank-bg); border-bottom: 1px solid var(--rank); color: var(--rank);
  padding: 10px 24px; font-size: 14px; text-align: center;
}
.preview b { font-weight: 700; }

/* ── Шапка ─────────────────────────────────────────────────────────── */

.top { background: var(--panel); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 28px; min-height: 64px; flex-wrap: wrap; }
.logo {
  display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none;
  font-size: 20px; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap;
}
.logo svg { width: 24px; height: 24px; flex: none; }
.logo b { font-weight: 600; color: var(--sea); }
.nav { display: flex; gap: 22px; margin-left: auto; flex-wrap: wrap; }
.nav a { font-size: 15px; font-weight: 500; text-decoration: none; color: var(--ink-2); padding: 6px 0; }
.nav a:hover { color: var(--sea); }
.top-cta {
  font-size: 15px; font-weight: 500; text-decoration: none; color: #fff; background: var(--ink);
  padding: 8px 15px; border-radius: var(--r-btn);
}
.top-cta:hover { background: var(--sea); }

/* ── Кнопки ────────────────────────────────────────────────────────── */

.btn {
  display: inline-block; background: var(--ink); color: #fff; border: 1px solid var(--ink);
  padding: 12px 20px; border-radius: var(--r-btn); text-decoration: none; font-size: 16px; font-weight: 500;
}
.btn:hover { background: var(--sea); border-color: var(--sea); }
.btn-2 { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn-2:hover { background: var(--panel); color: var(--ink); border-color: var(--ink); }

/* ── Главная: первый экран ─────────────────────────────────────────── */

.hero {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 56px;
  align-items: center; padding-top: 72px; padding-bottom: 80px;
}
.hero h1 { max-width: 13ch; }
.hero-sub { font-size: 19px; line-height: 1.55; color: var(--ink-2); max-width: 44ch; margin: 22px 0 0; }
.hero-acts { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 30px; }
.hero .note { margin-top: 22px; }

/* Настоящий ответ API — карточка справа от заголовка. */
.resp { margin: 0; background: var(--night); color: var(--on-night); border-radius: var(--r-panel); overflow: hidden; }
.resp-q {
  display: flex; gap: 10px; align-items: baseline; padding: 14px 18px; border-bottom: 1px solid var(--night-line);
  font-family: var(--mono); font-size: 13px; color: var(--on-night-2); overflow-x: auto; white-space: nowrap;
}
.resp-q b { color: var(--amber); font-weight: 500; }
.resp pre { background: none; border-radius: 0; margin: 0; padding: 16px 18px 18px; font-size: 13px; }
.resp-cap { padding: 14px 18px 16px; border-top: 1px solid var(--night-line); font-size: 14.5px; color: var(--on-night-2); margin: 0; }
.resp-cap b { color: var(--on-night); font-weight: 600; }

/* ── Главная: ночная полоса с картой ───────────────────────────────── */

.band { background: var(--night); color: var(--on-night); padding: 72px 0 64px; }
.band h2 { color: #fff; max-width: 22ch; }
.band-sub { color: var(--on-night-2); font-size: 17px; max-width: 60ch; margin: 16px 0 0; }
.band a { color: var(--on-night); text-decoration-color: rgba(230, 236, 245, 0.35); }
.band a:hover { text-decoration-color: var(--on-night); }

.map { position: relative; margin: 40px 0 0; }
.map img { display: block; width: 100%; height: auto; }
.map-l {
  position: absolute; transform: translate(-50%, calc(-100% - 6px)); white-space: nowrap;
  font-size: 13px; line-height: 1.2; color: var(--on-night);
  padding: 2px 7px; border-radius: 5px; background: rgba(14, 26, 43, 0.86);
}
.map-l.island { font-size: 14px; font-weight: 600; color: var(--c); }
.map-l a { color: inherit; }

.legend { display: flex; flex-wrap: wrap; gap: 10px 26px; margin: 26px 0 0; padding: 0; list-style: none; font-size: 14.5px; color: var(--on-night-2); }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.legend b { color: var(--on-night); font-weight: 600; }

.stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px 32px;
  margin: 48px 0 0; padding: 28px 0 0; border-top: 1px solid var(--night-line);
}
.stat-v { font-size: clamp(28px, 3vw, 36px); font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; color: #fff; }
.stat-k { font-size: 15px; color: var(--on-night); margin-top: 6px; }
.stat-s { font-size: 13.5px; color: var(--on-night-2); margin-top: 2px; }

/* ── Главная: разделы под полосой ──────────────────────────────────── */

.home-sec { padding-top: 72px; }
.home-sec > h2 { max-width: 24ch; }
.home-sub { color: var(--ink-2); font-size: 17px; max-width: 60ch; margin: 12px 0 0; }

.eps { margin: 28px 0 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel); }
.ep { display: grid; grid-template-columns: 17.5rem minmax(0, 1fr); gap: 8px 32px; padding: 16px 24px; border-top: 1px solid var(--line); align-items: baseline; }
.ep:first-child { border-top: 0; }
.ep code { font-size: 14px; background: none; padding: 0; color: var(--ink); font-weight: 500; }
.ep p { margin: 0; color: var(--ink-2); }
.eps + .note { margin-top: 14px; }

.uses { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; margin: 28px 0 0; }
.uses > div { border-top: 2px solid var(--ink); padding-top: 18px; }
.uses h3 a { color: var(--ink); text-decoration: none; }
.uses h3 a:hover { color: var(--sea); }
.uses p { color: var(--ink-2); margin: 10px 0 0; }

.home-sec .bars { margin-top: 28px; max-width: 880px; }

.plans { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 28px 0 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; }
.plan { padding: 24px 24px 26px; border-left: 1px solid var(--line); }
.plan:first-child { border-left: 0; }
.plan-on { background: var(--sea-bg); }
.plan h3 { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.plan h3 span { font-size: 13px; font-weight: 500; color: var(--sea); letter-spacing: 0; }
.plan-p { font-size: 32px; font-weight: 600; letter-spacing: -0.02em; margin: 14px 0 0; line-height: 1.1; }
.plan-p small { font-size: 15px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.plan ul { list-style: none; padding: 0; margin: 16px 0 0; font-size: 15px; color: var(--ink-2); }
.plan li { padding: 3px 0; }
.plan-b { font-size: 14.5px; color: var(--muted); margin: 14px 0 0; }
.plans + .note { margin-top: 14px; }

.faq { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; margin: 28px 0 0; }
.faq p { color: var(--ink-2); margin: 10px 0 0; }

.home-end { padding-top: 72px; }

/* ── Внутренние страницы: шапка и разделы ──────────────────────────── */

.page-head { padding: 48px 0 12px; }
.page-head h1 { font-size: clamp(30px, 3.6vw, 44px); line-height: 1.1; letter-spacing: -0.025em; max-width: 24ch; }
.page-head .lede { margin-top: 14px; }
.page-head .week { margin-top: 12px; }
.crumbs { font-size: 14px; color: var(--muted); padding: 20px 0 0; display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); padding: 3px 0; }
.crumbs span[aria-hidden] { color: var(--faint); }

.section { padding: 40px 0 0; }
.section-h { margin: 0 0 18px; }
.section-h:empty { display: none; }
.section-h .mark { display: none; }
.section-b { min-width: 0; }
.lede { font-size: 19px; line-height: 1.55; color: var(--ink-2); max-width: 60ch; }
.note { font-size: 14.5px; color: var(--muted); max-width: var(--prose); }
.week { font-size: 14px; color: var(--muted); }

/* ── Данные ────────────────────────────────────────────────────────── */

.readout { margin: 0 0 8px; }
.readout-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 22px 30px; align-items: end; }
.ro-k { font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.ro-v { font-size: clamp(26px, 3vw, 34px); font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; }
.ro-s { font-size: 13.5px; color: var(--faint); margin-top: 4px; }
.ro-spark { grid-column: span 2; min-width: 200px; }
.spark { display: block; width: 100%; height: 46px; }
.spark path { fill: none; stroke: var(--sea); stroke-width: 1.6; }
.spark .area { fill: var(--sea-bg); stroke: none; }
.spark circle { fill: var(--sea); }
.weeks-x { display: flex; justify-content: space-between; font-size: 13px; color: var(--faint); margin-top: 5px; max-width: 220px; }

.tw {
  overflow-x: auto; margin: 0 0 4px; overscroll-behavior-x: contain;
  scrollbar-color: var(--line-2) var(--paper-2);
  background:
    linear-gradient(to right, var(--bg) 30%, rgba(244, 246, 249, 0)) left center / 28px 100% no-repeat local,
    linear-gradient(to left, var(--bg) 30%, rgba(244, 246, 249, 0)) right center / 28px 100% no-repeat local,
    linear-gradient(to right, rgba(21, 32, 51, 0.14), rgba(21, 32, 51, 0)) left center / 12px 100% no-repeat scroll,
    linear-gradient(to left, rgba(21, 32, 51, 0.14), rgba(21, 32, 51, 0)) right center / 12px 100% no-repeat scroll;
}
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); vertical-align: baseline; }
th { font-size: 13.5px; font-weight: 500; color: var(--muted); border-bottom: 1px solid var(--line-2); white-space: nowrap; }
th + th, td + td { padding-left: 16px; }
td a { padding: 4px 0; }
tr > :last-child { padding-right: 0; }
td.n, th.n { text-align: right; }
tbody tr:hover { background: var(--panel); }

.pill {
  display: inline-block; font-size: 13.5px; padding: 2px 10px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--muted); margin: 0 4px 4px 0;
}
.pill-on { border-color: var(--sea); color: var(--sea); background: var(--sea-bg); }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 20px 28px; margin: 0 0 6px; }
.fact-k { font-size: 14px; color: var(--muted); }
.fact-v { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; margin-top: 2px; }
.fact-s { font-size: 13.5px; color: var(--faint); }

.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: minmax(110px, 1.3fr) 60px 2.4fr; gap: 14px; align-items: center; font-size: 15px; }
.bar a { padding: 4px 0; color: var(--ink); }
.bar a:hover { color: var(--sea); }
.bar-v { text-align: right; color: var(--muted); }
.bar-t { height: 10px; background: var(--paper-2); border-radius: 5px; overflow: hidden; }
.bar-f { display: block; height: 100%; background: var(--sea); border-radius: 5px; }
.bar-f[data-kind="rank"] { background: var(--rank); }

.links { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 24px; }
.links a { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; min-width: 0; padding: 7px 0; font-size: 15px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); }
.links a:hover { color: var(--sea); }
.links .l { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.links .c { flex: none; color: var(--faint); font-size: 13.5px; }

.notes a { display: flex; justify-content: space-between; align-items: baseline; gap: 18px; padding: 11px 0; font-size: 16px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); }
.notes a:hover { color: var(--sea); }
.notes .l { min-width: 0; }
.notes .c { flex: none; color: var(--faint); font-size: 14px; white-space: nowrap; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 20px 22px; }

pre {
  background: var(--night); color: #dce5f2; padding: 16px 18px; overflow-x: auto; border-radius: 12px;
  font-family: var(--mono); font-size: 13px; line-height: 1.65; margin: 0 0 14px;
}
pre b { color: #f5c26b; font-weight: 400; }
code { font-family: var(--mono); font-size: 0.88em; }
:not(pre) > code { background: var(--paper-2); padding: 1px 5px; border-radius: var(--r-code); }

.cta {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel);
  padding: 26px 28px; display: flex; gap: 24px; align-items: center; justify-content: space-between;
  flex-wrap: wrap; margin: 8px 0 0;
}
.cta p { margin: 0; }
.cta-h { font-size: 21px; font-weight: 600; letter-spacing: -0.01em; }
.cta .cta-s { font-size: 15px; color: var(--muted); max-width: 52ch; margin-top: 4px; }

/* ── Подвал ────────────────────────────────────────────────────────── */

.foot { border-top: 1px solid var(--line); background: var(--panel); margin-top: 88px; padding: 44px 0 48px; font-size: 15px; }
.foot-g { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 28px; }
.foot-g h2 { margin: 0 0 10px; color: var(--ink); font-size: 15px; font-weight: 600; letter-spacing: 0; }
.foot-g a { display: block; padding: 4px 0; text-decoration: none; color: var(--ink-2); }
.foot-g a:hover { color: var(--sea); }
.foot-b { margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap; }

/* ── Узкий экран ───────────────────────────────────────────────────── */

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; gap: 40px; padding-top: 48px; padding-bottom: 56px; }
  .plans { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plan:nth-child(3) { border-left: 0; }
  .plan:nth-child(n+3) { border-top: 1px solid var(--line); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  h1 { line-height: 1.1; }
  .wrap, .wrap-narrow, .wrap-read { padding-left: 20px; padding-right: 20px; }
  .top-in { gap: 14px; }
  .nav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; padding-bottom: 6px; gap: 18px; }
  .top-cta { margin-left: auto; }
  .ro-spark { grid-column: span 1; }
  .uses, .faq { grid-template-columns: 1fr; gap: 24px; }
  .ep { grid-template-columns: 1fr; padding: 14px 18px; }
  .band { padding: 52px 0 48px; }
  .home-sec, .home-end { padding-top: 56px; }

  .tw-stack { overflow-x: visible; overscroll-behavior-x: auto; background: none; }
  .tw-stack table.stack,
  .tw-stack table.stack tbody,
  .tw-stack table.stack tr,
  .tw-stack table.stack td { display: block; width: 100%; }
  .tw-stack table.stack thead {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  .tw-stack table.stack tr { padding: 12px 0 14px; border-bottom: 1px solid var(--line); }
  .tw-stack table.stack tr:last-child { border-bottom: 0; }
  .tw-stack table.stack tbody tr:hover { background: none; }
  .tw-stack table.stack td {
    display: grid; grid-template-columns: minmax(0, 10.5ch) minmax(0, 1fr);
    gap: 0 14px; align-items: baseline; padding: 2px 0; border: 0; text-align: left;
  }
  .tw-stack table.stack td + td { padding-left: 0; }
  .tw-stack table.stack td::before { content: attr(data-label); color: var(--muted); font-size: 13.5px; }
  .tw-stack table.stack td:first-child { display: block; font-size: 16px; padding-bottom: 3px; }
  .tw-stack table.stack td:first-child::before { content: none; }
}

/* Подписи на карте ниже 640 px наезжают друг на друга — остаётся легенда. */
@media (max-width: 640px) {
  .map-l { display: none; }
  .plans { grid-template-columns: 1fr; }
  .plan { border-left: 0; border-top: 1px solid var(--line); }
  .plan:first-child { border-top: 0; }
  .stats { gap: 22px 20px; }
  .bar { grid-template-columns: minmax(96px, 1.3fr) 52px 1.6fr; gap: 10px; font-size: 14.5px; }
}

a, .btn, .top-cta, .nav a, .links a, .notes a, .foot-g a {
  transition: color 120ms ease-out, background-color 120ms ease-out,
              border-color 120ms ease-out, text-decoration-color 120ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
