/* yt-web — vanilla CSS, no external deps */

/* ── СВЕТЛАЯ ТЕМА (по умолчанию) ── */
:root {
  --bg: #f4f5f7;
  --bg2: #ffffff;
  --bg3: #eef0f5;
  --border: #d1d5e0;
  --accent: #6c63ff;
  --accent-hover: #857df9;
  --text: #1a1d2e;
  --text-muted: #5a5e78;
  --text-dim: #9098b0;
  --success: #16a369;
  --warning: #d97706;
  --danger: #dc2626;
  --stage-done: #16a369;
  --stage-active: #6c63ff;
  --stage-idle: #d1d5e0;
  --guide-max-width: 760px;
  --radius: 10px;
  --radius-sm: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Mono", "Consolas", monospace;
  /* Цвета для графиков Chart.js (читаются через getComputedStyle) */
  --chart-tick: #5a5e78;
  --chart-grid: #d1d5e0;
  --chart-legend: #5a5e78;
  --chart-title: #9098b0;
  --log-bg: #f0f1f5;
  --log-line: #7a7f99;
  --code-pre-bg: #eef0f5;
  --code-color: #5046e5;
}

/* ── ТЁМНАЯ ТЕМА ── */
[data-theme="dark"] {
  --bg: #0f1117;
  --bg2: #181b24;
  --bg3: #1e2130;
  --border: #2a2d3e;
  --accent: #6c63ff;
  --accent-hover: #857df9;
  --text: #e2e4ef;
  --text-muted: #8b8fa8;
  --text-dim: #5a5e78;
  --success: #3ecf8e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --stage-done: #3ecf8e;
  --stage-active: #6c63ff;
  --stage-idle: #2a2d3e;
  --chart-tick: #8b8fa8;
  --chart-grid: #2a2d3e;
  --chart-legend: #8b8fa8;
  --chart-title: #5a5e78;
  --log-bg: #0b0d14;
  --log-line: #6b7280;
  --code-pre-bg: #0b0d14;
  --code-color: #a5b4fc;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  overflow-x: hidden; /* защита от горизонтального переполнения */
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden; /* страхуем body тоже */
}

/* ── HEADER ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  min-width: 0; /* не распирает по горизонтали */
}
@media (max-width: 480px) {
  .header { padding: 12px 16px; }
}
.header-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-brand span { color: var(--text); font-weight: 400; }
.btn-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 14px; /* мин. 40px высота на мобиле */
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .85rem;
  transition: border-color .2s, color .2s;
  min-height: 40px;
  white-space: nowrap;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ── КНОПКА ПЕРЕКЛЮЧЕНИЯ ТЕМЫ ── */
.btn-theme {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: border-color .2s, color .2s, background .2s;
  min-height: 40px;
  min-width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-theme:hover { border-color: var(--accent); color: var(--accent); }

/* Группа кнопок в правой части шапки */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── MAIN LAYOUT ── */
.main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 32px 20px 60px;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 28px;
  align-items: start;
  /* гарантируем, что грид не вылезает за вьюпорт */
  min-width: 0;
}
@media (max-width: 860px) {
  .main {
    grid-template-columns: 1fr;
    padding: 20px 16px 48px;
  }
  .sidebar { order: 2; }
  .content-col { order: 1; }
}
@media (max-width: 480px) {
  .main { padding: 16px 16px 40px; }
}

/* ── CARDS ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  min-width: 0; /* грид-ячейка не распирается содержимым */
}
@media (max-width: 480px) {
  .card { padding: 18px 16px; }
}
.card-title {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 18px;
}

/* ── FORM ── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: .95rem;
  padding: 9px 12px;
  transition: border-color .2s;
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
}
.form-textarea {
  resize: vertical;
  min-height: 72px;
}
.form-select option { background: var(--bg3); }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 480px) {
  .form-row { grid-template-columns: 1fr; }
}

/* ── ADVANCED PARAMS TOGGLE ── */
.params-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: .85rem;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 14px;
  transition: color .2s;
}
.params-toggle:hover { color: var(--accent); }
.params-toggle .arrow {
  display: inline-block;
  transition: transform .2s;
  font-size: .7rem;
}
.params-toggle.open .arrow { transform: rotate(90deg); }
.params-advanced { display: none; }
.params-advanced.open { display: block; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  min-height: 44px; /* тач-таргет iOS */
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .2s, opacity .2s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 6px 14px; font-size: .85rem; min-height: 40px; }

/* ── STEPPER ── */
.stepper {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 20px 0;
}
.step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  position: relative;
}
.step:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 12px;
  top: 34px;
  bottom: -2px;
  width: 2px;
  background: var(--stage-idle);
  transition: background .4s;
}
.step.done::after { background: var(--stage-done); }
.step.active::after { background: var(--accent); }

.step-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--stage-idle);
  border: 2px solid var(--stage-idle);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  transition: background .3s, border-color .3s;
  position: relative;
  z-index: 1;
}
.step.done .step-dot {
  background: var(--stage-done);
  border-color: var(--stage-done);
  color: #fff;
}
.step.active .step-dot {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  animation: pulse-dot 1.4s infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(108,99,255,.5); }
  50%       { box-shadow: 0 0 0 6px rgba(108,99,255,0); }
}
.step-info { flex: 1; min-width: 0; }
.step-name {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-dim);
  transition: color .3s;
}
.step.done .step-name  { color: var(--stage-done); }
.step.active .step-name { color: var(--text); }
.step-msg {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 2px;
  word-break: break-word;
}

/* ── ANALYZE SUB-PROGRESS ── */
.analyze-bar-wrap {
  margin-top: 6px;
  display: none;
}
.analyze-bar-wrap.visible { display: block; }
.analyze-bar-bg {
  height: 4px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: hidden;
}
.analyze-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width .3s;
  width: 0%;
}
.analyze-bar-label {
  font-size: .75rem;
  color: var(--text-dim);
  margin-top: 3px;
}

/* ── LOG PANEL ── */
.log-toggle {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: .8rem;
  cursor: pointer;
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
}
.log-toggle:hover { color: var(--text-muted); }
.log-toggle .arrow { font-size: .65rem; display: inline-block; transition: transform .2s; }
.log-toggle.open .arrow { transform: rotate(90deg); }
.log-panel {
  display: none;
  background: var(--log-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 8px;
  max-height: 260px;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.log-panel.open { display: block; }
.log-line {
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--log-line);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}
.log-line.highlight { color: var(--text-muted); }

/* ── ERROR BANNER ── */
.error-banner {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: var(--radius-sm);
  color: #b91c1c; /* тёмно-красный — читаемо на светлом фоне */
  padding: 12px 16px;
  font-size: .9rem;
  margin: 16px 0;
  display: none;
}
.error-banner.visible { display: block; }
/* Тёмная тема — светлый текст читается на тёмном полупрозрачном фоне */
[data-theme="dark"] .error-banner { color: #fca5a5; }

/* ── GUIDE CONTAINER ── */
.guide-wrap { display: none; }
.guide-wrap.visible { display: block; }
.guide-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.guide-content {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 40px;
  line-height: 1.8;
  font-size: 1rem;
  color: var(--text);
  max-width: min(var(--guide-max-width), 100%); /* не вылезает за вьюпорт */
  min-width: 0;
  box-sizing: border-box;
}
@media (max-width: 600px) {
  .guide-content { padding: 22px 18px; font-size: .95rem; }
}

/* Guide typography */
.guide-content h1 { font-size: 1.7rem; margin: 0 0 20px; color: var(--text); line-height: 1.3; }
.guide-content h2 { font-size: 1.3rem; margin: 32px 0 12px; color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.guide-content h3 { font-size: 1.1rem; margin: 24px 0 8px; color: var(--accent-hover); }
.guide-content h4 { font-size: 1rem; margin: 18px 0 6px; color: var(--text-muted); }
.guide-content p  { margin: 0 0 14px; }
.guide-content ul, .guide-content ol { padding-left: 22px; margin: 0 0 14px; }
.guide-content li { margin-bottom: 6px; }
.guide-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 16px;
  margin: 16px 0;
  color: var(--text-muted);
  background: var(--bg3);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.guide-content code {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: .88em;
}
.guide-content pre {
  background: var(--code-pre-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  overflow-x: auto;
  margin: 14px 0;
}
.guide-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: .87rem;
  color: var(--code-color);
}
.guide-content strong { color: var(--text); }
.guide-content a { color: var(--accent); text-decoration: underline; }
.guide-content a:hover { color: var(--accent-hover); }
.guide-content table { border-collapse: collapse; width: 100%; max-width: 100%; margin: 14px 0; font-size: .9rem; display: block; overflow-x: auto; }
.guide-content th { background: var(--bg3); padding: 8px 12px; text-align: left; border: 1px solid var(--border); white-space: nowrap; }
.guide-content td { padding: 8px 12px; border: 1px solid var(--border); }
.guide-content tr:nth-child(even) td { background: rgba(255,255,255,.02); }
.guide-content hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* ── HISTORY SIDEBAR ── */
.history-list { list-style: none; }
.history-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
  border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }
.history-item:hover { background: var(--bg3); }
.history-item.active { background: rgba(108,99,255,.12); }
.history-topic {
  font-size: .88rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-date {
  font-size: .75rem;
  color: var(--text-dim);
  margin-top: 2px;
}
.history-empty {
  font-size: .85rem;
  color: var(--text-dim);
  text-align: center;
  padding: 16px 0;
}

/* ── IDLE / PROGRESS STATE ── */
#progress-section { display: none; }
#progress-section.visible { display: block; }

/* ── LOADING SPINNER (inline, no img) ── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── LOGIN PAGE ── */
.login-body {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-sizing: border-box;
}
@media (max-width: 420px) {
  .login-card { padding: 28px 20px; }
  .login-body { padding: 16px; align-items: flex-start; padding-top: 40px; }
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
}
.login-logo span { color: var(--text); font-weight: 400; }
.login-error {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  color: #b91c1c; /* тёмно-красный на светлом фоне */
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .88rem;
  margin-bottom: 16px;
  display: none;
}
.login-error.visible { display: block; }
[data-theme="dark"] .login-error { color: #fca5a5; }

/* ══════════════════════════════════════════════
   DASHBOARD — KPI, Charts, Video Cards, Tabs
   ══════════════════════════════════════════════ */

/* ── KPI плашки ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
@media (max-width: 700px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
/* 2 колонки до 560px — компактнее чем стопка */
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
.kpi-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
@media (max-width: 560px) {
  .kpi-card {
    /* 2 колонки — стандартная вертикальная карточка */
    padding: 12px 14px;
    gap: 4px;
  }
}
.kpi-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}
@media (max-width: 560px) {
  .kpi-label { font-size: .68rem; }
  .kpi-value { font-size: clamp(1rem, 5vw, 1.2rem); }
}
.kpi-value {
  font-size: clamp(1.2rem, 4vw, 1.45rem);
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.kpi-sub {
  font-size: .78rem;
  color: var(--text-dim);
}
.kpi-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
}
.badge-hot   { background: rgba(239,68,68,.18); color: #f87171; }
.badge-warm  { background: rgba(245,158,11,.18); color: #fbbf24; }
.badge-cold  { background: rgba(99,102,241,.18); color: #a5b4fc; }
.badge-transcript { background: rgba(62,207,142,.15); color: var(--success); }

/* ── Outlier-бейдж (цветовая шкала Viewstats-стиль) ── */
.outlier-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: .02em;
  line-height: 1.3;
  cursor: default;
  white-space: nowrap;
}
/* <2 — серый (ниже радара) */
.outlier-gray   { background: rgba(144,152,176,.18); color: #9098b0; }
/* 2–5 — синий (немного выше нормы) */
.outlier-blue   { background: rgba(96,165,250,.2);  color: #60a5fa; }
/* 5–10 — зелёный (хит) */
.outlier-green  { background: rgba(62,207,142,.22); color: var(--success); }
/* 10–25 — оранжевый (горячо) */
.outlier-orange { background: rgba(245,158,11,.22); color: #f59e0b; }
/* >25 — красный-огонь */
.outlier-fire   { background: rgba(239,68,68,.22);  color: #ef4444; }

[data-theme="dark"] .outlier-gray   { background: rgba(144,152,176,.13); }
[data-theme="dark"] .outlier-blue   { background: rgba(96,165,250,.15); }
[data-theme="dark"] .outlier-green  { background: rgba(62,207,142,.15); }
[data-theme="dark"] .outlier-orange { background: rgba(245,158,11,.15); }
[data-theme="dark"] .outlier-fire   { background: rgba(239,68,68,.15); }

/* tooltip-подпись под outlier-чипом */
.outlier-hint {
  font-size: .7rem;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ── Секция графиков ── */
.charts-section {
  margin-bottom: 28px;
  min-width: 0;
}
.charts-section .section-title {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 700px) {
  .charts-grid { grid-template-columns: 1fr; }
}
.chart-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  min-width: 0; /* грид-ячейка не раздувается canvas-ом */
  overflow: hidden;
}
.chart-card-title {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.chart-card-hint {
  font-size: .72rem;
  color: var(--text-dim);
  margin-top: 8px;
}
.chart-wrap {
  position: relative;
  width: 100%;
  height: 240px;              /* фиксируем высоту — иначе Chart.js раздувает холст на всю ширину */
  overflow: hidden;           /* обрезаем микропереполнение холста, чтобы график не вылезал за карточку */
}
.chart-wrap canvas { display: block; max-width: 100% !important; }

/* Жёсткий запрет контейнерам дашборда вылезать за экран (Chart.js-холст распирал колонку) */
.content-col, .dashboard-wrap, .charts-section, .charts-grid,
.video-cards-grid, .video-card, .chart-card, .guide-tabs-bar, .guide-tab-panel,
.guide-tabs-wrap, .kpi-grid, .kpi-card {
  min-width: 0;
  max-width: 100%;
}
@media (max-width: 700px) {
  .chart-wrap { height: 220px; }
}
.chart-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 160px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: .82rem;
}

/* ── Карточки видео ── */
.videos-section {
  margin-bottom: 28px;
}
.videos-section .section-title {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.video-cards-grid {
  display: grid;
  /* minmax 260px — на 560px+ влезут 2 колонки с gap, ниже 1 */
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
@media (max-width: 560px) {
  .video-cards-grid { grid-template-columns: 1fr; }
}
.video-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .2s;
  min-width: 0;
}
.video-card:hover { border-color: var(--accent); }
.video-card-header {
  padding: 14px 16px 10px;
  cursor: pointer;
  user-select: none;
}
.video-card-rank {
  font-size: .7rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 5px;
}
.video-card-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.video-card-channel {
  font-size: .78rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.video-card-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.metric-chip {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: .73rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.metric-chip strong {
  color: var(--text);
  font-weight: 600;
}
.video-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.video-card-link {
  display: inline-flex;
  align-items: center;
  font-size: .78rem;
  color: var(--accent);
  text-decoration: none;
  padding: 0 16px;
  min-height: 44px; /* тач-таргет */
  margin-bottom: 2px;
}
.video-card-link:hover { color: var(--accent-hover); text-decoration: underline; }
.video-card-accordion {
  display: none;
  border-top: 1px solid var(--border);
  padding: 14px 16px 16px;
}
.video-card-accordion.open { display: block; }
.accordion-toggle-btn {
  width: 100%;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: .78rem;
  padding: 8px 16px;
  min-height: 44px; /* тач-таргет */
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color .2s;
}
.accordion-toggle-btn:hover { color: var(--accent); }
.accordion-toggle-btn .arrow {
  display: inline-block;
  font-size: .65rem;
  transition: transform .2s;
}
.accordion-toggle-btn.open .arrow { transform: rotate(90deg); }
.analysis-block {
  margin-bottom: 12px;
}
.analysis-block:last-child { margin-bottom: 0; }
.analysis-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent);
  margin-bottom: 4px;
}
.analysis-text {
  font-size: .83rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.analysis-text ul {
  padding-left: 16px;
  margin: 4px 0 0;
}
.analysis-text li { margin-bottom: 3px; }
.analysis-verbatim {
  font-size: .8rem;
  color: var(--text);
  background: var(--bg3);
  border-left: 3px solid var(--accent);
  padding: 6px 10px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-top: 5px;
  line-height: 1.5;
  font-style: italic;
}

/* ── Вкладки гайда ── */
.guide-tabs-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
}
.guide-tabs-bar {
  display: flex;
  overflow-x: auto;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
  /* индикатор скролла: тень справа когда есть ещё контент */
  -webkit-overflow-scrolling: touch;
}
/* маска-индикатор скролла вправо */
.guide-tabs-bar::after {
  content: '';
  position: sticky;
  right: 0;
  min-width: 28px;
  flex-shrink: 0;
  background: linear-gradient(to right, transparent, var(--bg3));
  pointer-events: none;
}
.guide-tab-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: .82rem;
  font-weight: 500;
  padding: 12px 16px; /* мин. 44px высота тач-таргета */
  min-height: 44px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .2s, border-color .2s;
  font-family: var(--font);
}
.guide-tab-btn:hover { color: var(--text); }
.guide-tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.guide-tab-panel {
  display: none;
  padding: 28px 32px;
  overflow-wrap: anywhere;   /* проза переносится в любом случае, не вылезает за край */
  max-width: 880px;          /* читаемая ширина текста на широком десктопе */
}
.guide-tab-panel.active { display: block; }
@media (max-width: 600px) {
  .guide-tab-panel { padding: 18px 16px; }
}

/* Типография внутри вкладок — те же правила что .guide-content */
.guide-tab-panel h1 { font-size: clamp(1.3rem, 4.5vw, 1.6rem); margin: 0 0 18px; color: var(--text); line-height: 1.3; }
.guide-tab-panel h2 { font-size: clamp(1.1rem, 3.5vw, 1.25rem); margin: 28px 0 10px; color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: 5px; }
.guide-tab-panel h3 { font-size: clamp(1rem, 3vw, 1.05rem); margin: 20px 0 7px; color: var(--accent-hover); }
.guide-tab-panel h4 { font-size: .95rem; margin: 14px 0 5px; color: var(--text-muted); }
.guide-tab-panel p  { margin: 0 0 12px; line-height: 1.75; }
.guide-tab-panel ul, .guide-tab-panel ol { padding-left: 20px; margin: 0 0 12px; }
.guide-tab-panel li { margin-bottom: 5px; line-height: 1.6; }
.guide-tab-panel blockquote {
  border-left: 3px solid var(--accent);
  padding: 7px 14px;
  margin: 14px 0;
  color: var(--text-muted);
  background: var(--bg3);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.guide-tab-panel code {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: .87em;
}
.guide-tab-panel pre {
  background: var(--code-pre-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  overflow-x: auto;
  margin: 12px 0;
}
.guide-tab-panel pre code {
  background: none; border: none; padding: 0;
  font-size: .86rem; color: var(--code-color);
}
.guide-tab-panel strong { color: var(--text); }
.guide-tab-panel a { color: var(--accent); text-decoration: underline; }
.guide-tab-panel a:hover { color: var(--accent-hover); }
.guide-tab-panel table { border-collapse: collapse; width: 100%; max-width: 100%; margin: 12px 0; font-size: .88rem; display: block; overflow-x: auto; }
.guide-tab-panel th { background: var(--bg3); padding: 7px 10px; text-align: left; border: 1px solid var(--border); white-space: nowrap; }
.guide-tab-panel td { padding: 7px 10px; border: 1px solid var(--border); }
.guide-tab-panel tr:nth-child(even) td { background: rgba(255,255,255,.02); }
.guide-tab-panel hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── dashboard meta header ── */
.dash-meta {
  display: flex;
  align-items: flex-start;
  flex-direction: column; /* всегда колонка — тема сверху, чипсы снизу */
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
@media (min-width: 560px) {
  .dash-meta {
    flex-direction: row;
    align-items: center;
  }
}
.dash-topic {
  font-size: clamp(1rem, 3.5vw, 1.15rem);
  font-weight: 700;
  color: var(--text);
  flex: 1;
  min-width: 0; /* убираем жёсткий min-width — был распиратель */
  word-break: break-word;
}
.dash-params {
  display: flex;
  flex-wrap: wrap; /* чипсы переносятся, не распирают */
  gap: 6px;
  flex-shrink: 0;
}
.param-chip {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: .72rem;
  color: var(--text-dim);
  /* white-space не задаём — по умолчанию переносится при необходимости */
}

/* ── dashboard wrap ── */
.dashboard-wrap {
  display: none;
  min-width: 0;
}
.dashboard-wrap.visible {
  display: block;
}

/* ═══════════════════════════════════════════════
   GAPS HERO — «Дыра рынка» (EN→RU)
   ═══════════════════════════════════════════════ */
.gaps-hero {
  background: var(--bg2);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px 22px 24px;
  margin-bottom: 28px;
  min-width: 0;
  position: relative;
  overflow: hidden;
}
/* световой акцент сверху */
.gaps-hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, #3ecf8e 50%, #f59e0b 100%);
}
.gaps-hero-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}
.gaps-hero-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.02em;
  line-height: 1.2;
}
.gaps-hero-subtitle {
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: 18px;
  line-height: 1.5;
  max-width: 680px;
}
.gaps-hero-subtitle strong { color: var(--text); }

/* сетка карточек дыр */
.gaps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
@media (max-width: 560px) {
  .gaps-grid { grid-template-columns: 1fr; }
}

/* одна карточка-дыра */
.gap-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  transition: border-color .2s;
}
.gap-card:hover { border-color: var(--accent); }

.gap-card-phrase {
  font-size: .97rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
}

/* EN-спрос: доказательство */
.gap-en-demand {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.gap-en-rank {
  font-size: .73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--success);
}
.gap-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.gap-suggestion-chip {
  background: rgba(108,99,255,.1);
  border: 1px solid rgba(108,99,255,.25);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: .72rem;
  color: var(--text-muted);
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* RU-статус */
.gap-ru-target {
  font-size: .82rem;
  color: var(--text-muted);
  margin: 2px 0 4px;
}
.gap-ru-target strong { color: var(--text); }
.gap-ru-status {
  font-size: .78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  display: inline-block;
  align-self: flex-start;
}
/* Старый класс (обратная совместимость) — нейтральный, не «победный» */
.gap-ru-empty {
  background: rgba(148,163,184,.12);
  color: var(--text-muted);
}
.gap-ru-weak {
  background: rgba(245,158,11,.15);
  color: #f59e0b;
}
/* needs_manual_check: нет данных — нейтральный предупреждающий стиль */
.gap-ru-manual {
  background: rgba(148,163,184,.12);
  color: var(--text-muted);
  font-weight: 500;
  font-style: normal;
}
.gap-ru-manual em {
  font-style: italic;
  font-weight: 600;
  color: var(--text);
}

/* Чипы силы зазора (новый формат) */
.gap-strength-chip {
  font-size: .78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  display: inline-block;
  align-self: flex-start;
}
.gap-strength-fire {
  background: rgba(239,68,68,.15);
  color: #ef4444;
}
.gap-strength-hot {
  background: rgba(245,158,11,.15);
  color: #f59e0b;
}
.gap-strength-warm {
  background: rgba(62,207,142,.12);
  color: var(--success);
}
.gap-strength-cool {
  background: rgba(148,163,184,.12);
  color: var(--text-muted);
}
[data-theme="dark"] .gap-strength-fire { background: rgba(239,68,68,.2); }
[data-theme="dark"] .gap-strength-hot  { background: rgba(245,158,11,.2); }
[data-theme="dark"] .gap-strength-warm { background: rgba(62,207,142,.15); }
[data-theme="dark"] .gap-strength-cool { background: rgba(148,163,184,.1); }

/* Реальные RU-подсказки-доказательства */
.gap-ru-proofs {
  font-size: .75rem;
  color: var(--text-muted);
  line-height: 1.45;
}
.gap-ru-proofs em {
  font-style: normal;
  color: var(--text);
  font-weight: 500;
}

/* Предупреждение о переносимости */
.gap-not-transferable {
  font-size: .73rem;
  color: var(--text-dim);
  font-style: italic;
}

/* Шкала gap_score — теперь с текстовой категорией вместо «100%» */
.gap-score-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.gap-score-bar-bg {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.gap-score-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #3ecf8e);
  border-radius: 4px;
  transition: width .4s;
}
.gap-score-label {
  font-size: .7rem;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

/* кнопка «Сгенерировать гайд по дыре» */
.btn-gap-generate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  min-height: 40px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
  white-space: nowrap;
  margin-top: auto;
}
.btn-gap-generate:hover { background: var(--accent-hover); }
.btn-gap-generate:active { transform: scale(.97); }

/* title_pattern-чип в аккордеоне */
.title-pattern-chip {
  display: inline-block;
  background: rgba(108,99,255,.14);
  border: 1px solid rgba(108,99,255,.3);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: .72rem;
  font-weight: 700;
  color: var(--accent);
  margin-left: 6px;
  vertical-align: middle;
  letter-spacing: .02em;
}
[data-theme="dark"] .title-pattern-chip {
  background: rgba(108,99,255,.18);
}

/* ══════════════════════════════════════════════
   ЭКРАН ОЖИДАНИЯ — «Студия исследования» v12
   ══════════════════════════════════════════════ */

/* ── Строка статуса (таймер + hint) ── */
.waiting-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.waiting-timer {
  font-size: .85rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}
.waiting-hint {
  font-size: .78rem;
  color: var(--text-dim);
}

/* ── Тизер-строка ── */
.teaser-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(108,99,255,.07);
  border: 1px solid rgba(108,99,255,.18);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
}
[data-theme="dark"] .teaser-row {
  background: rgba(108,99,255,.12);
  border-color: rgba(108,99,255,.25);
}
.teaser-icon {
  font-size: 1rem;
  flex-shrink: 0;
  line-height: 1.5;
}
.teaser-text {
  font-size: .82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Карусель карточек-инсайтов ── */
.insight-carousel {
  margin: 16px 0 4px;
}

.insight-slide {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: opacity .25s, transform .25s;
  opacity: 0;
  transform: translateY(6px);
}
.insight-slide.insight-slide-in {
  opacity: 1;
  transform: translateY(0);
}
.insight-icon {
  font-size: 1.5rem;
  line-height: 1;
}
.insight-title {
  font-size: .97rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.insight-body {
  font-size: .82rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ── Точки-индикаторы ── */
.insight-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-top: 12px;
}
.insight-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background .2s, transform .2s;
}
.insight-dot.active {
  background: var(--accent);
  transform: scale(1.35);
}
.insight-dot:hover:not(.active) {
  background: var(--text-dim);
}

/* ── Nudge-строка (при молчании «Сбора») ── */
.waiting-nudge {
  font-size: .8rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  margin-top: 8px;
  min-height: 1.2em;
  opacity: 0;
  transition: opacity .5s;
}
.waiting-nudge.visible {
  opacity: 1;
}

/* ── Оверлей «Готово!» ── */
.done-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(0,0,0,0);
  backdrop-filter: blur(0px);
  transition: background .3s, backdrop-filter .3s;
  pointer-events: none;
}
.done-overlay.visible {
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
}
.done-overlay.fade-out {
  background: rgba(0,0,0,0);
  backdrop-filter: blur(0px);
  transition: background .35s, backdrop-filter .35s;
}
.done-checkmark {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  animation: pop-in .35s cubic-bezier(.34,1.56,.64,1) both;
}
.done-label {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.01em;
  animation: pop-in .35s .1s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(.6); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── Мобайл ── */
@media (max-width: 480px) {
  .insight-slide {
    padding: 16px 16px;
    min-height: 100px;
  }
  .insight-icon { font-size: 1.25rem; }
  .insight-title { font-size: .9rem; }
  .insight-body  { font-size: .78rem; }
  .teaser-row { padding: 9px 12px; }
  .teaser-text { font-size: .78rem; }
}

/* ══════════════════════════════════════════════
   МОБИЛЬНАЯ ИСТОРИЯ — кнопка в шапке + drawer
   ══════════════════════════════════════════════ */

/* Кнопка «История» в шапке — только на мобиле */
.btn-history-mobile {
  display: none; /* скрыта на десктопе */
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
  min-height: 44px;
  align-items: center;
  gap: 5px;
  transition: border-color .2s, color .2s;
  white-space: nowrap;
}
.btn-history-mobile:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 860px) {
  .btn-history-mobile { display: inline-flex; }
}

/* Затемняющий оверлей */
.history-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(2px);
  transition: opacity .25s;
  opacity: 0;
}
.history-drawer-overlay.open {
  display: block;
  opacity: 1;
}

/* Drawer-панель справа */
.history-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 201;
  width: min(320px, 88vw);
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
  overflow: hidden;
}
.history-drawer.open {
  transform: translateX(0);
}

.history-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-history-drawer-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  padding: 6px 8px;
  min-height: 36px;
  min-width: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .2s, background .2s;
}
.btn-history-drawer-close:hover { color: var(--text); background: var(--bg3); }

/* Список истории внутри drawer */
.history-drawer #history-list-mobile {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 8px 0;
}

/* Блокируем скролл body при открытом drawer */
body.drawer-open { overflow: hidden; }

/* На десктопе drawer полностью скрыт */
@media (min-width: 861px) {
  .history-drawer,
  .history-drawer-overlay,
  .btn-history-mobile {
    display: none !important;
  }
}

/* ══════════════════════════════════════════════
   BUBBLE-ГРАФИКИ НА МОБИЛЕ (≤600px)
   ══════════════════════════════════════════════ */

/* На узких экранах поднимаем высоту bubble-карточек и скрываем легенду через CSS
   (Chart.js тоже отключит её через responsive options, но CSS как запасной вариант) */
@media (max-width: 600px) {
  /* Карточки bubble-графиков: большая высота чтобы пузырьки не слипались */
  .chart-wrap { height: 290px; }
}

/* ══════════════════════════════════════════════
   ПОМЕТКИ «РЕКОНСТРУКЦИЯ» И «НИЖЕ НОРМЫ»
   ══════════════════════════════════════════════ */

/* Пометка реконструированного разбора (без субтитров) */
.reconstructed-note {
  display: inline-block;
  font-size: .68rem;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 7px;
  vertical-align: middle;
  white-space: normal;
  font-style: italic;
}

/* Outlier ниже нормы канала — нейтральный серый */
.outlier-below {
  background: rgba(148, 163, 184, .12);
  color: var(--text-muted);
}
[data-theme="dark"] .outlier-below {
  background: rgba(148, 163, 184, .08);
}

/* Пометка «ниже обычного для канала» */
.outlier-below-note {
  display: inline-block;
  font-size: .68rem;
  color: var(--text-dim);
  font-style: italic;
  margin-left: 6px;
  vertical-align: middle;
}

/* ══════════════════════════════════════════════
   LIVE DASHBOARD — живое наполнение по событиям
   ══════════════════════════════════════════════ */

.live-dashboard {
  margin-top: 16px;
}

/* ── Секция внутри live-dashboard ── */
.live-section {
  margin-bottom: 24px;
  animation: live-section-in .35s ease both;
}
@keyframes live-section-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.live-section-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.live-counter {
  font-size: .72rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(108,99,255,.1);
  border: 1px solid rgba(108,99,255,.2);
  border-radius: 20px;
  padding: 1px 8px;
}

/* ── Блок степпера: полоска прогресса у каждого шага ── */
.step-bar-wrap {
  display: none;
  margin-top: 5px;
}
.step-bar-wrap.visible { display: block; }
.step-bar-bg {
  height: 3px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}
.step-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #3ecf8e);
  border-radius: 3px;
  transition: width .5s ease;
  width: 0%;
}
.step-bar-lbl {
  font-size: .7rem;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ── Запросы-чипы (expand) ── */
.live-queries-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.live-query-chip {
  display: inline-block;
  background: rgba(108,99,255,.1);
  border: 1px solid rgba(108,99,255,.25);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: .82rem;
  color: var(--text);
  animation: chip-fly-in .4s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes chip-fly-in {
  from { opacity: 0; transform: scale(.7) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
[data-theme="dark"] .live-query-chip {
  background: rgba(108,99,255,.15);
  border-color: rgba(108,99,255,.3);
}

/* ── Стена превью (collect) ── */
.live-wall-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}
@media (max-width: 560px) {
  .live-wall-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 6px;
  }
}
.live-preview-card {
  display: block;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg2);
  text-decoration: none;
  color: var(--text);
  transition: border-color .2s, transform .15s;
}
.live-preview-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.live-card-appear {
  animation: card-appear .4s ease both;
}
@keyframes card-appear {
  from { opacity: 0; transform: scale(.92); }
  to   { opacity: 1; transform: scale(1); }
}
.live-preview-img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  background: var(--bg3);
}
.live-preview-info {
  padding: 6px 8px;
}
.live-preview-title {
  font-size: .73rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-bottom: 3px;
}
.live-preview-meta {
  font-size: .68rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Лидеры ниши (rank) ── */
.live-rank-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.live-rank-placeholder {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: .82rem;
  color: var(--text-muted);
  min-width: 180px;
  flex: 1 1 180px;
  transition: border-color .3s, background .3s;
}
.live-rank-placeholder.live-rank-done {
  border-style: solid;
  border-color: var(--stage-done);
  background: rgba(62,207,142,.06);
  color: var(--text);
}
[data-theme="dark"] .live-rank-placeholder.live-rank-done {
  background: rgba(62,207,142,.08);
}
.live-rank-num {
  font-size: .72rem;
  font-weight: 800;
  color: var(--accent);
  flex-shrink: 0;
}
.live-rank-dots {
  font-size: .8rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ── Карусель карточек-инсайтов: навигация стрелками ── */
.insight-nav-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}
.insight-nav-btn {
  flex-shrink: 0;
  width: 32px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .2s, color .2s, background .2s;
  min-height: 44px; /* тач-таргет */
  padding: 0;
  line-height: 1;
  user-select: none;
}
.insight-nav-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(108,99,255,.07);
}
.insight-nav-btn:active { transform: scale(.93); }
/* Слайд занимает оставшееся место */
.insight-nav-row .insight-slide {
  flex: 1;
  min-width: 0;
}

@media (max-width: 480px) {
  .insight-nav-btn { width: 28px; font-size: 1.1rem; }
}
