/*
 * YouTube Niche Scout — dark research surface.
 *
 * Design tokens are adapted from the Bolt "niche-scout-src" reference:
 * neutral near-black surfaces, hairline borders, a single restrained green
 * accent, dense research-oriented layout, compact cards and tabular numbers.
 *
 * Server-rendered only: no framework, no build step. The mobile navigation is a
 * checkbox disclosure driven by a cheap `transform: translateX()` (no layout
 * animation, no blur); the Mini App layer (bottom of this file) only adapts the
 * same pages to the Telegram WebView.
 *
 * Priority order for this surface: speed → usability → clarity → density →
 * aesthetics. No decorative gradients, no giant headers, no nested card towers.
 */

:root {
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 8px;

  --bg: oklch(0.165 0.005 285);
  --surface: oklch(0.196 0.005 285);
  --surface-raised: oklch(0.224 0.006 285);
  --sidebar-bg: oklch(0.152 0.005 285);

  --ink: oklch(0.968 0.002 285);
  --ink-dim: oklch(0.86 0.003 285);
  --muted: oklch(0.645 0.008 285);

  --accent: oklch(0.72 0.135 168);
  --accent-soft: oklch(0.72 0.135 168 / 12%);
  --accent-ink: oklch(0.17 0.02 168);
  --accent-ring: oklch(0.72 0.135 168 / 55%);

  --ok: oklch(0.74 0.14 158);
  --warn: oklch(0.79 0.13 78);
  --bad: oklch(0.63 0.19 24);
  --info: oklch(0.72 0.11 245);

  --line: oklch(1 0 0 / 8%);
  --line-strong: oklch(1 0 0 / 15%);
  --input-line: oklch(1 0 0 / 12%);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --sidebar-width: 14rem;
  /* One cheap drawer transition. Short enough to feel instant, long enough not
     to look broken. */
  --drawer-motion: 140ms ease;
}

* { box-sizing: border-box; }

html { color-scheme: dark; -webkit-font-smoothing: antialiased; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

h1, h2, h3, h4 { letter-spacing: -0.018em; margin: 0; color: var(--ink); }

/* Numerals: tabular everywhere the data matters. */
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  color: var(--ink-dim);
  word-break: break-word;
}

.eyebrow {
  font-size: 0.6875rem;
  line-height: 1rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
/* External (YouTube) link marker: a small, non-shifting suffix. */
.ext { margin-left: 3px; font-size: 0.9em; color: var(--muted); }
a:hover > .ext { color: inherit; }

/* ------------------------------------------------------------------ shell */

.shell { min-height: 100vh; }

.mobilebar {
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 8px 12px;
  /* Solid, not translucent: a backdrop blur is the single most expensive thing
     a sticky bar can ask a phone to composite on every scroll frame. */
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.mobilebar__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.mobilebar__btn:hover { color: var(--ink); background: var(--surface-raised); }

.shell__body { display: flex; align-items: stretch; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 46;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 16px 10px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  /* Off-canvas via transform only: the compositor moves it, the layout engine
     does not run. visibility keeps the off-screen links out of the tab order. */
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform var(--drawer-motion), visibility 0s linear 140ms;
  will-change: transform;
}
html.nav-open .sidebar,
.nav-toggle:checked ~ .shell__body .sidebar {
  transform: none;
  visibility: visible;
  transition: transform var(--drawer-motion), visibility 0s;
}

/* The page under the drawer must not receive clicks — or scroll gestures. */
.nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 44;
  background: oklch(0.08 0 0 / 62%);
  touch-action: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--drawer-motion), visibility 0s linear 140ms;
}
html.nav-open .nav-backdrop,
.nav-toggle:checked ~ .nav-backdrop {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--drawer-motion), visibility 0s;
}

/* No scrolling behind an open drawer. */
html.nav-open,
html.nav-open body,
html:has(.nav-toggle:checked),
html:has(.nav-toggle:checked) body { overflow: hidden; }

.wordmark { display: flex; align-items: center; gap: 8px; padding: 4px 8px; }
.wordmark__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
}
.wordmark__text { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }

.nav { display: flex; flex-direction: column; gap: 1px; margin-top: 16px; }
.nav__group { margin: 12px 8px 4px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--muted);
}
.nav a:hover { background: var(--surface-raised); color: var(--ink); }
.nav a.active { background: var(--surface-raised); color: var(--ink); }
.nav a.active .nav__dot { background: var(--accent); }
.nav__dot { width: 5px; height: 5px; border-radius: 999px; background: transparent; flex: none; }
.nav__badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 10.5px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 1px 6px;
}

/* The "Ещё" disclosure: a native <details>, so it costs no JavaScript and
   cannot animate layout on open. */
.nav-more { background: transparent; border: 0; border-radius: 0; padding: 0; margin: 0; }
.nav-more > summary {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
}
.nav-more > summary::-webkit-details-marker { display: none; }
.nav-more > summary::after {
  content: "›";
  margin-left: auto;
  font-size: 15px;
  line-height: 1;
  transition: transform 100ms ease;
}
.nav-more[open] > summary::after { transform: rotate(90deg); }
.nav-more > summary:hover,
.nav-more > summary.active { background: var(--surface-raised); color: var(--ink); }
.nav-more > summary.active .nav__dot { background: var(--accent); }
.nav-more[open] > summary { margin-bottom: 2px; }
.nav-more__body { display: flex; flex-direction: column; gap: 1px; }
.nav-more__body a { padding-left: 18px; }

.sidebar__aside {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 9px 11px;
}
.sidebar__aside + .sidebar__aside { margin-top: 10px; }
.sidebar__aside p { margin: 0; }

.main { flex: 1; min-width: 0; }
.page { padding: 16px 14px 48px; max-width: 1500px; }

@media (min-width: 1024px) {
  .mobilebar, .nav-backdrop { display: none; }
  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    transform: none;
    visibility: visible;
    transition: none;
    will-change: auto;
  }
  .page { padding: 24px 28px 56px; }
}

/* ------------------------------------------------------------- page heads */

.page-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}
.page-head__title { font-size: 19px; font-weight: 600; }
.page-head__desc { margin-top: 4px; max-width: 74ch; font-size: 13px; color: var(--muted); }
.page-head__actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
@media (min-width: 700px) {
  .page-head { flex-direction: row; align-items: flex-start; justify-content: space-between; }
  .page-head__title { font-size: 21px; }
  .page-head__actions { flex: none; }
}

.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.section-head h2 { font-size: 15px; font-weight: 500; }
.section-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.section-head--flat { margin-top: 24px; }

h2.block { font-size: 15px; font-weight: 500; margin: 24px 0 8px; }
h3.block { font-size: 13.5px; font-weight: 500; margin: 16px 0 6px; }

/* ---------------------------------------------------------------- panels */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.panel__head {
  display: flex;
  flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 13px;
  border-bottom: 1px solid var(--line);
}
.panel__title { font-size: 13px; font-weight: 500; }
.panel__desc { margin-top: 2px; font-size: 12px; color: var(--muted); }
.panel__body { padding: 12px 13px; }
.panel--pad { padding: 12px 13px; }

.stack > * + * { margin-top: 12px; }

.cards { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card-link {
  display: flex; flex-direction: column; gap: 8px;
  padding: 11px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.card-link:hover { background: var(--surface-raised); border-color: var(--line-strong); }
.card-link__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card-link__name { font-size: 13.5px; font-weight: 500; }
.card-link .handle { font-size: 11.5px; color: var(--muted); }
.card-link__niche { font-size: 12px; color: var(--muted); }
.card-link__stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line);
}

/* ------------------------------------------------------------- stat cards */

.grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
}
.stat__label { font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.stat__value { margin-top: 4px; font-size: 18px; color: var(--ink); }
.stat__value--accent { color: var(--accent); }
.stat__value--sm { font-size: 14px; }
.stat__sub { margin-top: 3px; font-size: 11.5px; color: var(--muted); }

/* Inline metric strip inside a card */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.metric__label { font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.metric__value { margin-top: 2px; font-size: 13px; }
.metric__value--accent { color: var(--accent); }

/* Segmented stat strip (borderless, hairline separated) */
.strip {
  display: grid; grid-template-columns: repeat(2, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--line);
  gap: 1px;
}
.strip > div { background: var(--surface); padding: 9px 12px; }
@media (min-width: 640px) { .strip { grid-template-columns: repeat(4, 1fr); } }

/* ---------------------------------------------------------------- tables */

.table-wrap {
  /* Wide research tables scroll inside their own box; the page never does. */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead tr { background: var(--surface); }
th {
  text-align: left;
  padding: 7px 10px;
  font-size: 10.5px; font-weight: 500; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in oklab, var(--surface) 70%, var(--bg)); }
th.num, td.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
td.strong, .strong { color: var(--accent); font-weight: 500; }
.cell-sub { display: block; font-size: 11.5px; color: var(--muted); }
.cell-name { font-weight: 500; color: var(--ink); }
tr:hover .cell-name { color: var(--accent); }

/* Compact detail table without heavy chrome */
table.kv-table th { width: 1%; white-space: nowrap; background: transparent; text-transform: none; letter-spacing: 0; font-size: 12.5px; color: var(--muted); font-weight: 400; border-bottom: 1px solid var(--line); }
table.kv-table td { border-bottom: 1px solid var(--line); }
table.kv-table tr:last-child th, table.kv-table tr:last-child td { border-bottom: 0; }

/* Small contextual row actions (Отчёт / YouTube / Сохранить / Сравнить). */
.row-actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.row-actions a, .row-actions button {
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.4;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}
.row-actions a:hover, .row-actions button:hover {
  color: var(--ink);
  background: var(--surface-raised);
  filter: none;
}

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-flex; align-items: center;
  padding: 1px 7px;
  border-radius: 5px;
  border: 1px solid transparent;
  font-size: 11px; font-weight: 500; letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge.ok { background: color-mix(in oklab, var(--ok) 14%, transparent); color: var(--ok); border-color: color-mix(in oklab, var(--ok) 30%, transparent); }
.badge.warn { background: color-mix(in oklab, var(--warn) 14%, transparent); color: var(--warn); border-color: color-mix(in oklab, var(--warn) 30%, transparent); }
.badge.bad { background: color-mix(in oklab, var(--bad) 16%, transparent); color: var(--bad); border-color: color-mix(in oklab, var(--bad) 32%, transparent); }
.badge.info { background: color-mix(in oklab, var(--info) 14%, transparent); color: var(--info); border-color: color-mix(in oklab, var(--info) 30%, transparent); }
.badge.plain { background: var(--surface-raised); color: var(--muted); border-color: var(--line); }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in oklab, var(--accent) 30%, transparent); }

.tag {
  display: inline-flex; align-items: center;
  padding: 1px 7px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--surface-raised);
  font-size: 11.5px;
  color: var(--ink-dim);
}
.tag--quiet { background: transparent; color: var(--muted); }

.flags { display: flex; flex-wrap: wrap; gap: 4px; }

/* --------------------------------------------------------------- buttons */

.btn, button {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 12.5px; font-weight: 500;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover, button:hover { filter: brightness(1.06); color: var(--accent-ink); }
.btn.secondary, button.secondary {
  background: var(--surface-raised);
  color: var(--ink-dim);
  border-color: var(--line-strong);
}
.btn.secondary:hover, button.secondary:hover { filter: none; background: var(--surface); color: var(--ink); }
.btn.ghost, button.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.ghost:hover, button.ghost:hover { background: var(--surface-raised); color: var(--ink); }
.btn.danger, button.danger { background: transparent; border-color: color-mix(in oklab, var(--bad) 45%, transparent); color: var(--bad); }
.btn.danger:hover, button.danger:hover { background: color-mix(in oklab, var(--bad) 12%, transparent); color: var(--bad); }
.btn.small, button.small { padding: 3px 8px; font-size: 11.5px; }
.btn.lg { padding: 8px 16px; font-size: 13.5px; }
.btn.block { width: 100%; justify-content: center; }
button.linklike { background: none; border: 0; color: var(--accent); padding: 0; font-size: inherit; }
button.linklike:hover { text-decoration: underline; filter: none; }

.actions-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0 6px 6px 0; }

/* ----------------------------------------------------------------- forms */

form.filters, form.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 12px 13px;
  margin: 12px 0;
}
.form-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 8px; }
form.filters .field, .form-grid .field { margin: 0; }
label { font-size: 11.5px; color: var(--muted); }
input, select, textarea {
  font: inherit; font-size: 13px;
  padding: 5px 8px;
  border: 1px solid var(--input-line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  width: 100%;
  max-width: 100%;
}
input::placeholder, textarea::placeholder { color: color-mix(in oklab, var(--muted) 80%, transparent); }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
}
input[type="checkbox"], input[type="radio"] { width: auto; }
select[multiple] { min-height: 72px; }
.checkline { display: inline-flex; align-items: center; gap: 6px; margin: 0 12px 6px 0; font-size: 12.5px; color: var(--ink-dim); }

.search-field { position: relative; }
.search-field input { padding-left: 32px; }
.search-field svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 15px; height: 15px; }

/* Segmented filter control */
.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.segmented button, .segmented a {
  padding: 4px 10px; font-size: 12.5px; border-radius: 5px; border: 0; background: transparent; color: var(--muted);
}
.segmented button:hover, .segmented a:hover { color: var(--ink); }
.segmented .is-active { background: var(--surface-raised); color: var(--ink); }
.segmented .count { font-family: var(--font-mono); margin-left: 6px; color: var(--muted); }
/* A tab that navigates somewhere else (Кандидаты) reads as a link, not a tab. */
.segmented .is-external { margin-left: 4px; border-left: 1px solid var(--line); border-radius: 0 5px 5px 0; }

/* --------------------------------------------------------------- notices */

.notice { padding: 9px 12px; border-radius: var(--radius-sm); margin: 10px 0; border: 1px solid; font-size: 13px; }
.notice.error { background: color-mix(in oklab, var(--bad) 10%, transparent); border-color: color-mix(in oklab, var(--bad) 35%, transparent); color: color-mix(in oklab, var(--bad) 80%, var(--ink)); }
.notice.info { background: color-mix(in oklab, var(--info) 10%, transparent); border-color: color-mix(in oklab, var(--info) 30%, transparent); color: color-mix(in oklab, var(--info) 75%, var(--ink)); }
.notice.warn { background: color-mix(in oklab, var(--warn) 10%, transparent); border-color: color-mix(in oklab, var(--warn) 30%, transparent); color: color-mix(in oklab, var(--warn) 78%, var(--ink)); }
.notice strong { color: inherit; }

.empty {
  padding: 24px 18px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  font-size: 13px;
}
.empty__title { color: var(--ink); font-weight: 500; margin-bottom: 4px; }

details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; margin: 8px 0; }
details > summary { cursor: pointer; font-size: 12.5px; color: var(--ink-dim); }
details[open] > summary { margin-bottom: 8px; }
details.details-plain { background: transparent; border: 0; padding: 0; }
details.details-plain > summary { color: var(--muted); }

/* --------------------------------------------------------------- lists */

.cards-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.rows { border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.rows > * + * { border-top: 1px solid var(--line); }
.rows a, .rows .row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 12px;
}
.rows a:hover { background: var(--surface-raised); }

.data-pairs { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.data-pair__label { font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.data-pair__value { margin-top: 4px; font-size: 13px; }

dl.kv { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: 6px 16px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }

ul.tight { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--muted); }
ul.tight li { margin: 2px 0; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* ------------------------------------------------------------- timeline */

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; border-left: 1px solid var(--line); padding: 0 0 12px 14px; margin-left: 3px; }
.timeline li::before { content: ""; position: absolute; left: -3.5px; top: 5px; width: 6px; height: 6px; border-radius: 999px; background: var(--accent); }
.timeline .when { display: block; font-size: 11.5px; color: var(--muted); }
.timeline li:last-child { padding-bottom: 0; }

/* --------------------------------------------------------------- charts */

.sparkline { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }

pre.summary {
  background: oklch(0.14 0.005 285);
  color: var(--ink-dim);
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.55;
}

/* --------------------------------------------------------------- layout */

.two-col { display: grid; gap: 12px; }
@media (min-width: 1100px) { .two-col { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; } }
.aside { display: flex; flex-direction: column; gap: 12px; }

.hero {
  border: 1px solid color-mix(in oklab, var(--accent) 25%, transparent);
  background: color-mix(in oklab, var(--accent) 5%, transparent);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.hero .eyebrow { color: var(--accent); }

.centered-form { max-width: 640px; margin: 28px auto 0; text-align: center; }
.centered-form h1 { font-size: 21px; }
.centered-form .lead { margin: 10px auto 0; max-width: 52ch; font-size: 13.5px; color: var(--muted); }
/* The guest-code form is a normal labelled form, not a centred headline block. */
.centered-form .code-form { margin-top: 18px; text-align: left; }
.centered-form .code-form .field { max-width: 420px; }
.big-input-row { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
@media (min-width: 640px) { .big-input-row { flex-direction: row; } }
.big-input-row input { height: 42px; }
.big-input-row .btn { height: 42px; }

footer.footer {
  border-top: 1px solid var(--line);
  margin-top: 28px;
  padding: 14px 14px 26px;
  font-size: 12px;
  color: var(--muted);
  max-width: 1500px;
}
@media (min-width: 1024px) { footer.footer { padding-left: 28px; } }

.pagination { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0; font-size: 12.5px; }

.tree { border-left: 1px solid var(--line); margin-left: 6px; padding-left: 14px; }

.mono-sm { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }

/* A one-time secret (a freshly minted access code): selectable, unbroken, and
   never wrapped in a way that hides a character. */
.code-reveal {
  font-size: 18px;
  letter-spacing: 0.06em;
  background: oklch(0.14 0.005 285);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  color: var(--ink);
  user-select: all;
  overflow-wrap: anywhere;
}

/* ----------------------------------------------- mobile and Telegram WebView */

/*
 * The Mini App WebView is not the browser: it can be shorter than 100vh (the
 * Telegram header and the on-screen keyboard), and the phone's home indicator
 * overlaps whatever is at the bottom. The script publishes the measured height
 * and the device insets as custom properties; every value here falls back to the
 * plain-vh / safe-area-inset behaviour when the script has not run (desktop, or
 * a browser outside Telegram).
 */

html { height: 100%; }
body { min-height: 100%; overflow-x: hidden; }

.shell { min-height: var(--tg-viewport-height, 100vh); }
@supports (min-height: 100dvh) {
  .shell { min-height: var(--tg-viewport-height, 100dvh); }
}

/* Never let a page scroll sideways: wide tables scroll inside .table-wrap. */
.main, .page { min-width: 0; max-width: 100%; }

/* Only the bottom/inset padding is added globally; the horizontal values are
   scoped so the desktop rhythm set above is untouched. */
.page {
  padding-bottom: calc(48px + var(--tg-safe-bottom, env(safe-area-inset-bottom, 0px)));
}
@media (min-width: 1024px) {
  .page { padding-bottom: calc(56px + var(--tg-safe-bottom, env(safe-area-inset-bottom, 0px))); }
}
@media (max-width: 1023px) {
  .page {
    padding-left: calc(14px + var(--tg-safe-left, env(safe-area-inset-left, 0px)));
    padding-right: calc(14px + var(--tg-safe-right, env(safe-area-inset-right, 0px)));
  }
}
/* Telegram reserves its own header area, so only the browser case needs the
   device's top inset added to the sticky bar. */
.mobilebar { padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
.sidebar { padding-top: calc(16px + env(safe-area-inset-top, 0px)); }

html.telegram-mini-app .mobilebar { padding-top: 8px; }
html.telegram-mini-app .sidebar { padding-top: 16px; }
html.telegram-mini-app footer.footer { padding-bottom: 26px; }
/* Telegram closes the Mini App on a downward swipe at the very top of the page;
   keeping the overscroll local makes an accidental swipe much less likely. */
html.telegram-mini-app, html.telegram-mini-app body { overscroll-behavior-y: contain; }

/* Login page: exactly one of the two blocks is relevant per context. */
.tg-only { display: none; }
html.telegram-mini-app .tg-only { display: block; }
html.telegram-mini-app .browser-only { display: none; }
html.tg-authenticating .tg-only { opacity: .65; }

@media (pointer: coarse) {
  /* Comfortable touch targets; nothing is hidden, only made reachable. */
  input, select, textarea { min-height: 40px; }
  .btn, button { min-height: 36px; }
  .nav a, .nav-more > summary { padding: 10px; }
  .nav-more__body a { padding-left: 20px; }
  .mobilebar__btn { width: 40px; height: 40px; }
  .segmented button, .segmented a { padding: 7px 12px; }
  .row-actions a, .row-actions button { min-height: 30px; padding: 5px 9px; font-size: 12px; }
}

@media (max-width: 1023px) {
  /* The global research disclaimer is not useful in a phone-sized viewport;
     every page already carries the disclaimers that matter for its own data. */
  footer.footer { display: none; }
}

@media (max-width: 430px) {
  .page {
    padding-left: calc(12px + var(--tg-safe-left, env(safe-area-inset-left, 0px)));
    padding-right: calc(12px + var(--tg-safe-right, env(safe-area-inset-right, 0px)));
  }
  .page-head__title { font-size: 18px; }
  /* Four fixed columns of numbers do not fit a phone; two still read as a grid. */
  .metrics, .card-link__stats { grid-template-columns: repeat(2, 1fr); }
  .cards { grid-template-columns: 1fr; }
  .cards-grid { grid-template-columns: 1fr; }
  /* Key/value pairs stack instead of squeezing the value into a narrow column. */
  dl.kv { grid-template-columns: 1fr; gap: 0; }
  dl.kv dt { margin-top: 8px; }
  dl.kv dd { margin-bottom: 4px; }
  table.kv-table th { white-space: normal; }
  .mobilebar__btn { width: 42px; height: 42px; }
}

/* A user who asked for less motion gets a drawer that is simply there. */
@media (prefers-reduced-motion: reduce) {
  .sidebar, .nav-backdrop, .nav-more > summary::after {
    transition-duration: 1ms;
    transition-delay: 0s;
  }
}
