:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --border: #e5e7eb;
  --text: #374151;
  --text-strong: #111827;
  /* Было #6b7280 (~4.6:1 на белой панели) — впритык к WCAG AA (4.5:1) для мелкого текста:
     весь .hint (12px) использует именно эту переменную. #565f6c — тот же оттенок серого, но
     темнее (~6.3:1), даёт запас по контрасту, оставаясь заметно светлее --text/--text-strong. */
  --text-muted: #565f6c;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-contrast: #ffffff;
  --accent-soft: #eff6ff;

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --input-bg: #f8fafc;
  --input-border: #dde3ea;
  --tag-bg: #f3f4f6;

  --radius-card: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow-card: 0 2px 8px rgba(15, 23, 42, 0.04);

  /* Состояния этапов: пройден (зелёный) / нужно пройти заново (жёлтый). */
  --chip-done-bg: #e3f6ec;
  --chip-done-fg: #0d7a4b;
  --chip-stale-bg: #fdf0d3;
  --chip-stale-fg: #8a5700;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141a;
    --panel: #1a1d24;
    --border: #2a2e37;
    --text: #d5d8dd;
    --text-strong: #f3f4f6;
    --text-muted: #9ca3af;

    --accent: #5b93f5;
    --accent-hover: #7aa6f7;
    --accent-contrast: #0d1117;
    --accent-soft: rgba(59, 130, 246, 0.16);

    --input-bg: #1f232b;
    --input-border: #333944;
    --tag-bg: #232832;

    --shadow-card: 0 2px 10px rgba(0, 0, 0, 0.25);

    --chip-done-bg: rgba(16, 185, 129, 0.18);
    --chip-done-fg: #4ade9c;
    --chip-stale-bg: rgba(245, 158, 11, 0.18);
    --chip-stale-fg: #fbbf4a;
  }
}

* { box-sizing: border-box; }

/* Глобальный предохранитель: любой элемент с собственным display:flex/grid/... перебивает
   встроенное правило браузера [hidden]{display:none} (та же специфичность, но наше правило
   в каскаде позже) — атрибут hidden молча переставал скрывать элемент. Нарвались на это дважды
   (.auth-form, затем .progress-section/.agent-status-line/.progress-done показывались всегда,
   независимо от hidden) — фиксируем на уровне всего сайта одним правилом, а не точечно. */
[hidden] { display: none !important; }

/* Место под вертикальную полосу прокрутки резервируется всегда: иначе при переходе между вкладками
   (короткая страница без полосы <-> длинная с полосой) центрированная шапка сдвигалась на её ширину
   и пункты меню «прыгали». */
html { scrollbar-gutter: stable; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

h1, h2, h3 { color: var(--text-strong); margin: 0; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }

.layout {
  display: flex;
  gap: 20px;
  padding: 24px;
  max-width: 1240px;
  margin: 0 auto;
  align-items: flex-start;
}

.models-panel {
  width: 280px;
  flex-shrink: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 16px;
}

@media (max-width: 800px) {
  .layout { flex-direction: column; padding: 16px; }
  .models-panel { width: 100%; }
}

.models-group + .models-group { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

.group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-strong);
  font-weight: 600;
  font-size: 14px;
  padding: 8px 12px;
  margin-bottom: 2px;
  cursor: pointer;
  outline: none;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.group-toggle:hover, .group-toggle:focus-visible {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.group-toggle .chevron { color: var(--text-muted); font-size: 16px; line-height: 1; transition: transform 0.15s ease, color 0.12s ease; }
.group-toggle:hover .chevron, .group-toggle:focus-visible .chevron { color: #fff; }
.group-toggle.collapsed .chevron { transform: rotate(-90deg); }

.model-list { list-style: none; margin: 0; padding: 0; max-height: 400px; overflow-y: auto; overflow-x: hidden; }
.model-list.collapsed { display: none; }

.model-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 9px 10px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: background 0.12s ease;
  min-width: 0; /* иначе flex/grid-родитель не даёт сжаться длинному имени -> горизонтальный скролл */
}
.model-item:hover { background: var(--accent-soft); }

/* Грид с фиксированными колонками — иначе "?" оказывается на разной высоте/позиции в
   зависимости от длины бейджа роли ("eeat" короче "fact_checking"). Чекбокс есть не у всех
   строк (нет смысла пропускать уже отключённую модель) — .model-include-placeholder держит
   ту же колонку пустой, чтобы остальное не съезжало. */
.model-item-row {
  display: grid;
  grid-template-columns: 14px 9px minmax(0, 1fr) 62px 18px;
  align-items: center;
  column-gap: 6px;
  min-width: 0;
}

.model-include, .model-include-placeholder {
  width: 14px;
  height: 14px;
  margin: 0;
}
.model-include { accent-color: var(--accent); cursor: pointer; }

.model-info-btn {
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.model-info-btn:hover, .model-info-btn.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

.model-info-text {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
  padding: 6px 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--border);
}
.status-dot-ready { background: var(--success); border-color: var(--success); }
.status-dot-error { background: var(--danger); border-color: var(--danger); }
.status-dot-pending { background: var(--text-muted); border-color: var(--text-muted); }

.model-name {
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-role {
  color: var(--text-muted);
  font-size: 11px;
  background: var(--tag-bg);
  padding: 2px 6px;
  border-radius: 999px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-error {
  grid-column: 1 / -1;
  color: var(--danger);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.model-item-controls { grid-column: 1 / -1; justify-self: end; }
.model-empty { color: var(--text-muted); font-size: 13px; padding: 6px 4px; }

.model-item-controls { display: flex; gap: 4px; }
.model-item-controls button {
  padding: 3px 8px;
  font-size: 11px;
  background: var(--panel);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.add-model-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.add-model-form select,
.add-model-form input {
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
  width: 100%;
}
.add-model-form select:focus, .add-model-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.add-model-form button { font-size: 13px; padding: 9px 10px; background: var(--success); font-weight: 600; }
#add-model-error { font-size: 11px; margin: 0; }

.main { flex: 1; min-width: 0; }

.input-section, .result-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 22px;
  margin-bottom: 20px;
}

/* --- Сегментированные табы (Текст/Код, Wordstat/Bukvarix) --- */

.mode-toggle {
  display: inline-flex;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 12px;
}

.mode-toggle label {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--input-bg);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.mode-toggle label:not(:last-child) { border-right: 1px solid var(--input-border); }
.mode-toggle label:has(input:checked) { background: var(--accent); color: var(--accent-contrast); }
.mode-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }

/* Пояснение к переключателю HTML/URL на /audit — раньше был один плотный абзац класса .hint
   (12px, без акцентов), из-за чего "HTML" и "URL" терялись в сплошном тексте, хотя это и есть
   ключевые слова, объясняющие разницу режимов. */
.audit-mode-hint {
  background: var(--accent-soft);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 12px;
}
.audit-mode-hint p { color: var(--text-muted); font-size: 12.5px; line-height: 1.5; margin: 0; }
.audit-mode-hint p + p { margin-top: 4px; }
.audit-mode-hint-label {
  display: inline-block;
  color: var(--accent-hover);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.02em;
}

.segmented-toggle {
  display: flex;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 12px;
}
.segmented-toggle .source-tab {
  flex: 1;
  height: auto;
  padding: 9px 0;
  font-size: 13px;
  border: none;
  border-radius: 0;
  background: var(--input-bg);
  color: var(--text-muted);
}
.segmented-toggle .source-tab:not(:last-child) { border-right: 1px solid var(--input-border); }
.segmented-toggle .source-tab.active { background: var(--accent); color: var(--accent-contrast); }
.segmented-toggle .source-tab:hover:not(:disabled):not(.active) { background: var(--accent-soft); color: var(--accent-hover); }

/* Заблокированный переключатель (например, до входа) не должен размываться общим
   button:disabled{opacity:.45} — на нём и так активная/неактивная вкладки различаются
   только цветом фона, при полупрозрачности превращается в нечитаемое пятно. */
.segmented-toggle .source-tab:disabled {
  opacity: 1;
  cursor: not-allowed;
  background: var(--input-bg);
  color: var(--text-muted);
}
.segmented-toggle .source-tab.active:disabled { background: var(--tag-bg); color: var(--text-muted); }

.hint { color: var(--text-muted); font-size: 12px; margin: 4px 0 12px; }
.hint-warning { color: var(--warning); }

/* Раньше это была просто строка оранжевого текста над всей раскладкой — для сообщений вроде
   "Большинство моделей не ответили" (провал целого раунда) этого маловато веса, легко
   пропустить, особенно если страница уже проскроллена. Полноширинная полоса-баннер с иконкой
   заметнее, но не блокирует контент модальным окном. */
#connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 24px;
  background: rgba(245, 158, 11, 0.14);
  border-bottom: 1px solid rgba(245, 158, 11, 0.4);
  color: var(--text-strong);
  font-size: 13.5px;
  font-weight: 600;
}
#connection-status::before { content: "⚠️"; font-size: 14px; }

textarea#article-input, #keywords-input, #audit-html-input {
  width: 100%;
  max-width: 100%;
  min-height: 180px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--text);
  font-family: ui-monospace, monospace;
  font-size: 13px;
}

#keywords-input { min-height: 90px; font-family: inherit; }
textarea::placeholder, input::placeholder { color: #9ca3af; }
textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-actions { margin-top: 14px; display: flex; gap: 10px; align-items: center; }

button {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  height: 42px;
  padding: 0 20px;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-contrast);
  transition: background 0.12s ease, border-color 0.12s ease;
}
button:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button.secondary {
  background: var(--panel);
  color: var(--accent-hover);
  border: 1px solid var(--accent);
}
button.secondary:hover:not(:disabled) { background: var(--accent-soft); }

/* Мелкие управляющие кнопки (в таблицах/списках) не должны раздувать интерфейс */
.model-item-controls button, .issue-controls button, .add-model-form button,
.audit-check button, #source-filter button, .keywords-table ~ * button {
  height: auto;
}

.progress-section {
  /* Раньше была отдельной карточкой ниже блока "Ключевые слова" — от кнопки не видно
     без прокрутки, из-за чего анализ выглядел зависшим. Теперь встроена прямо под
     кнопками "Анализировать"/"Отменить", внутри той же карточки — без своей рамки/тени. */
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.progress-bar-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: #f1f5f9;
  border-radius: 999px;
  overflow: hidden;
}
@media (prefers-color-scheme: dark) { .progress-bar { background: var(--border); } }

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.2s ease;
}
#progress-label { color: var(--text-muted); font-size: 13px; white-space: nowrap; }

.agent-status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  padding-left: 2px;
}
.agent-status-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
  animation: agent-status-pulse 1.4s ease-in-out infinite;
}
@keyframes agent-status-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

.progress-fill.complete { background: var(--success); }

.progress-done {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--success);
}
.progress-done button { height: auto; padding: 6px 14px; font-size: 12px; }

.score-block { text-align: center; margin-bottom: 20px; position: relative; }
.score-ring { width: 140px; height: 140px; transform: rotate(-90deg); }
.score-ring-bg { fill: none; stroke: var(--border); stroke-width: 10; }
.score-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s ease;
}
.score-number {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-strong);
}
.score-zone { margin-top: 4px; color: var(--text-muted); font-size: 13px; }

/* Динамика между раундами (Модель_системы.md п.3.1): было -> стало после проверки правок. */
.score-delta { margin-top: 4px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.score-delta.up { color: var(--success); }
.score-delta.down { color: var(--danger); }

/* Подсказка про "Применить решения" видна только вместе с самой кнопкой. */
#submit-rulings-btn[hidden] + .submit-rulings-hint { display: none; }
.submit-rulings-hint { max-width: 60ch; }

/* Кто из моделей заметил замечание — раньше в списках не было видно вообще. */
.issue-agents { margin-top: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 11px; color: var(--text-muted); }
.issue-agent-chip {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-radius: 999px;
  padding: 1px 8px;
  font-weight: 600;
  cursor: help;
}

/* Раздел "По моделям": по строке на модель, замечания раскрываются по клику. */
.by-model-block { margin-bottom: 20px; }
.by-model-block h3 { margin-bottom: 4px; }
.by-model-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.by-model-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel);
}
.by-model-item summary, .by-model-item .by-model-static {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  font-size: 13px;
}
.by-model-item summary { cursor: pointer; list-style: none; }
.by-model-item summary::-webkit-details-marker { display: none; }
.by-model-item summary::before { content: "▸"; color: var(--text-muted); font-size: 11px; }
.by-model-item details[open] > summary::before { content: "▾"; }
.by-model-name { font-weight: 600; color: var(--text-strong); }
.by-model-role { background: var(--tag-bg); color: var(--text-muted); border-radius: 999px; padding: 1px 8px; font-size: 11px; }
.by-model-count { margin-left: auto; color: var(--text-muted); font-size: 12px; }
.by-model-count.has-issues { color: var(--warning); font-weight: 600; }
.by-model-count.is-error { color: var(--danger); font-weight: 600; }
.by-model-issues { list-style: none; margin: 0; padding: 0 12px 10px; display: flex; flex-direction: column; gap: 8px; }
.by-model-issues li { font-size: 13px; padding-top: 8px; border-top: 1px solid var(--border); }
.by-model-kind { margin-left: 6px; font-size: 10px; color: var(--text-muted); background: var(--tag-bg); border-radius: 4px; padding: 1px 6px; }

/* Информационная (не аварийная) полоса — например "Загружен исправленный текст из истории". */
#connection-status.is-info { background: var(--accent-soft); border-bottom-color: var(--accent); }
#connection-status.is-info::before { content: "ℹ️"; }


/* После сборки текста: прозрачно предлагаем прогнать исправленную версию через анализ ещё раз. */
.next-round-callout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  font-size: 13px;
}
.next-round-callout-text { display: flex; flex-direction: column; gap: 2px; color: var(--text-strong); }
.next-round-callout-text span { color: var(--text-muted); font-size: 12.5px; }

.seo-audit-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.source-filter { display: flex; gap: 6px; margin-bottom: 14px; }
.source-filter-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  height: auto;
  background: var(--panel);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.source-filter-btn.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

.issue-source-badge {
  display: inline-block;
  background: var(--tag-bg);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 4px;
}

.issue-decision-badge {
  display: inline-block;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  margin-left: 4px;
  color: #fff;
}
.issue-decision-badge.decision-accepted { background: var(--success); }
.issue-decision-badge.decision-rejected { background: var(--danger); }
.issue-decision-badge.decision-skipped { background: var(--text-muted); }

.issues-block h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.badge {
  background: var(--tag-bg);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 12px;
  font-weight: 600;
}

.issue-list { list-style: none; margin: 0 0 20px; padding: 0; }
.issue-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 13px;
}

.issue-severity {
  display: inline-block;
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 700;
  margin-right: 6px;
  text-transform: uppercase;
  color: #fff;
}
.issue-severity-critical { background: var(--danger); }
.issue-severity-important { background: var(--warning); }
.issue-severity-minor { background: var(--text-muted); }

.issue-location { color: var(--text-muted); font-size: 11px; }

.issue-controls { margin-top: 8px; display: flex; gap: 6px; }
.issue-controls button {
  padding: 5px 12px;
  font-size: 12px;
  height: auto;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
}
.issue-controls button.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

.output-tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.tab-btn {
  height: auto;
  padding: 6px 14px;
  font-size: 13px;
  background: var(--input-bg);
  color: var(--text-muted);
  border: 1px solid var(--input-border);
}
.tab-btn.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

.preview-frame {
  width: 100%;
  height: 400px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
}

.code-view {
  width: 100%;
  height: 400px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  font-size: 12px;
  white-space: pre-wrap;
  background: var(--input-bg);
}

.output-actions { margin-top: 12px; display: flex; gap: 8px; }
.output-actions button {
  height: auto;
  padding: 8px 14px;
  font-size: 13px;
  background: var(--panel);
  color: var(--accent-hover);
  border: 1px solid var(--accent);
}
.output-actions button:hover:not(:disabled) { background: var(--accent-soft); }

.keywords-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 13px;
}
.keywords-table th, .keywords-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.keywords-table th { color: var(--text-muted); font-weight: 600; font-size: 12px; }

.humanize-block { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 18px; }
.humanize-block h3 { margin-bottom: 10px; }
.humanize-controls { display: flex; gap: 8px; align-items: center; }
.humanize-controls select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
}
.humanize-controls button { height: auto; padding: 9px 16px; font-size: 13px; }
#humanize-status { margin: 8px 0 0; }
#humanize-diff { height: 200px; margin-top: 8px; }
#humanize-revert-block {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
#humanize-revert-block button { height: auto; padding: 6px 12px; font-size: 12px; }

/* --- Пошаговый анализ (analyze_stages.html/analyze_stages.js) --- */

/* Этапы остаются на виду при прокрутке длинной страницы этапа: прилипают под шапкой (64px + отступ). */
.stage-stepper-panel {
  width: 260px;
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 104px);
  overflow-y: auto;
}
@media (max-width: 800px) {
  /* На телефоне панель стоит над содержимым во всю ширину — прилипание закрыло бы полэкрана. */
  .stage-stepper-panel { position: static; max-height: none; }
}
.stage-stepper-panel h3 { margin-bottom: 10px; }
.back-link { display: inline-block; margin-bottom: 14px; font-size: 13px; font-weight: 600; color: var(--accent-hover); text-decoration: none; }
.back-link:hover { text-decoration: underline; }

.stage-stepper { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

/* Этапы — кнопки: любой можно открыть в любой момент. Цвет значка = состояние этапа:
   зелёный — пройден, жёлтый — пройден, но надо пройти заново, серый — не пройден. Открытый сейчас
   этап выделяется фоном и не перекрашивает значок — иначе пропал бы его статус. */
.stage-stepper .stage-step {
  width: 100%;
  height: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
}
.stage-stepper .stage-step:hover:not(:disabled) { background: var(--tag-bg); border-color: transparent; }
.stage-stepper .stage-step.is-current,
.stage-stepper .stage-step.is-current:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text-strong);
  font-weight: 600;
}
.stage-step-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  background: var(--tag-bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.stage-step-done .stage-step-icon { background: var(--success); border-color: var(--success); color: #fff; }
.stage-step-stale .stage-step-icon { background: var(--warning); border-color: var(--warning); color: #3b2a00; }
.stage-step-draft {
  margin-left: auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.stage-legend { list-style: none; margin: 14px 0 0; padding: 12px 0 0; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-muted); }
.stage-legend li { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--input-border); border: 1px solid var(--input-border); }
.legend-dot-done { background: var(--success); border-color: var(--success); }
.legend-dot-stale { background: var(--warning); border-color: var(--warning); }

.project-head { margin-bottom: 14px; }
.project-title-input {
  width: 100%;
  padding: 6px 10px;
  margin-left: -10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-strong);
  font: inherit;
  font-size: 24px;
  font-weight: 700;
}
.project-title-input:hover:not(:disabled) { border-color: var(--input-border); }
.project-title-input:focus { background: var(--input-bg); }
.project-head .hint { margin: 2px 0 0; }

/* Этап пройден, но текст, на котором он строился, потом изменили — этап надо пройти заново. */
.stale-callout {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 1px solid var(--chip-stale-fg);
  border-radius: var(--radius-md);
  background: var(--chip-stale-bg);
  color: var(--chip-stale-fg);
  font-size: 13px;
}
.stale-callout strong { color: inherit; }

/* Обычный текст (не HTML) читается как текст, а не как код. */
.code-view.plain-text-view { font-family: inherit; font-size: 14px; line-height: 1.6; height: auto; min-height: 120px; max-height: 480px; }

/* .code-view — фиксированные 400px; текст предыдущего этапа может быть коротким. */
#article-readonly { height: auto; min-height: 90px; max-height: 320px; }
.source-block { margin-bottom: 4px; }
.mode-block { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.mode-block .stage-field-label { margin-top: 0; }
.mode-block .hint { margin-bottom: 0; }
.source-block .stage-field-label { margin-top: 4px; }

/* --- Проекты (projects.html/projects.js) --- */

.projects-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.projects-head h1 { margin-bottom: 4px; }
.projects-head .hint { max-width: 62ch; margin: 0; }
.projects-head button { flex-shrink: 0; }
.main > .stage-legend { border-top: none; padding-top: 0; margin: 0 0 16px; }

.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }

.project-card {
  position: relative;
  min-height: 140px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.project-card:hover { border-color: var(--accent); }
.project-card-link { display: block; padding: 16px 18px; color: inherit; text-decoration: none; border-radius: inherit; }
.project-card-title { padding-right: 26px; font-size: 16px; overflow-wrap: anywhere; }
.project-card-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.project-card-date { margin: 0; font-size: 12px; color: var(--text-muted); }

.project-card .project-card-delete {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
}
.project-card .project-card-delete:hover:not(:disabled) { background: var(--tag-bg); color: var(--danger); border-color: transparent; }

.project-card-new {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: auto;
  border: 1px dashed var(--input-border);
  background: transparent;
  box-shadow: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
}
.project-card.project-card-new:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-hover); }

/* Чипы этапов — та же цветовая логика, что у степпера: зелёный / жёлтый / серый. */
.stage-chip {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}
.stage-chip-done { background: var(--chip-done-bg); color: var(--chip-done-fg); }
.stage-chip-stale { background: var(--chip-stale-bg); color: var(--chip-stale-fg); }

/* Панель выбора сохранённого промта над полем ввода: список + действия над выбранным. */
.prompt-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.prompt-toolbar select {
  flex: 1 1 220px;
  min-width: 0;
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
}
.prompt-toolbar button { height: auto; padding: 8px 14px; font-size: 13px; }
#prompt-hint { margin: 6px 0 0; }

.stage-field-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin: 14px 0 6px; }
#stage-prompt-input {
  width: 100%;
  min-height: 90px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

.stage-model-pickers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.stage-model-pickers { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stage-model-slot { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stage-model-slot label { font-size: 12px; color: var(--text-muted); }
.stage-model-slot-row { display: flex; gap: 6px; }
.stage-model-pickers select,
.editor-slot select {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
}
.stage-model-pickers .catalog-btn,
.editor-slot .catalog-btn { height: auto; padding: 0 12px; font-size: 12px; flex-shrink: 0; }

/* Окно выбора модели из каталога OpenRouter. */
.modal-dialog.modal-wide { max-width: 720px; display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.catalog-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 4px 0 10px; }
.catalog-tools input[type="search"] {
  flex: 1 1 240px;
  font: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
}
.catalog-tools label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
.catalog-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 220px; border: 1px solid var(--border); border-radius: var(--radius-md); }
.catalog-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 2px 12px;
  width: 100%;
  height: auto;
  padding: 9px 14px;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-weight: 500;
  text-align: left;
}
.catalog-item:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--border); }
.catalog-item:disabled { opacity: 0.5; }
.catalog-item.is-selected { background: var(--accent-soft); }
.catalog-item-name { font-size: 13px; color: var(--text-strong); font-weight: 600; }
.catalog-item-id { flex-basis: 100%; font-size: 11px; color: var(--text-muted); order: 3; overflow-wrap: anywhere; }
.catalog-item-meta { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.catalog-badge-free { color: var(--success); font-weight: 700; }
.catalog-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 13px; }

.stage-agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.stage-agent-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--bg);
  font-size: 13px;
}
.stage-agent-name { font-weight: 600; color: var(--text-strong); margin-bottom: 6px; }
.stage-agent-body { color: var(--text); white-space: pre-wrap; line-height: 1.55; overflow-wrap: anywhere; }
.stage-agent-card.is-error .stage-agent-body { color: var(--danger); }

/* Текст кросс-проверки. Раньше лежал в .by-model-issues (flex-колонка для списка замечаний) —
   каждый кусок текста и каждый <strong> становился отдельной строкой, абзац рассыпался. */
.stage-cross-body {
  padding: 2px 12px 12px 30px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.stage-cross-body.is-error { color: var(--danger); }

/* Пока анализ идёт, блоку процесса нужен запас высоты: без него страница короткая и его нельзя поставить под шапку. */
#stage-progress-section.is-running { min-height: calc(100vh - 140px); }

/* Прокрутка к блокам процесса не должна прятать их заголовок под липкой шапкой (64px). */
#stage-progress-section, #cross-review-block, #synthesize-status, #stage-result-section, #stage-output-section {
  scroll-margin-top: 80px;
}

/* Оформленный просмотр итога: та же рамка, что у поля правки, чтобы переключение режимов не «прыгало». */
.synthesis-view {
  min-height: 120px;
  padding: 14px 16px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.synthesis-view code, .stage-agent-body code, .stage-cross-body code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--tag-bg);
  font-size: 0.92em;
}

/* Итог синтезатора — основной текст, который пользователь читает и правит. Раньше у поля не было
   ни ширины, ни шрифта: оно сжималось до ~160px в моноширинном шрифте. */
#synthesis-text {
  display: block;
  width: 100%;
  min-height: 260px;
  resize: vertical;
  padding: 14px 16px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
}


/* --- Всплывающие уведомления (static/js/toast.js). Цвета — из палитры сайта, поэтому сами
   переключаются вместе со светлой/тёмной темой. --- */

.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 320px;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}
/* Липкая шапка (64px) с кнопками входа/выхода справа — уведомления встают под неё, а не поверх. */
body:has(.top-nav) .toast-container { top: 76px; }

.toast {
  --toast-accent: var(--danger);
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 56px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
  font-size: 12px;
  line-height: 1.4;
  cursor: default;
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.toast-visible { opacity: 1; transform: translateY(0); }
.toast-success { --toast-accent: var(--success); }
.toast-warning { --toast-accent: var(--warning); }
.toast-info { --toast-accent: var(--accent); }

.toast-body { display: flex; align-items: center; gap: 8px; min-width: 0; }
.toast-icon {
  flex-shrink: 0;
  display: flex;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: var(--tag-bg);
  color: var(--toast-accent);
}
.toast-icon svg { width: 24px; height: 24px; }
.toast-text { min-width: 0; overflow-wrap: anywhere; }
.toast-title { margin: 0; color: var(--text-strong); font-weight: 600; }
.toast-desc { margin: 0; color: var(--text-muted); }

.toast .toast-close {
  flex-shrink: 0;
  display: flex;
  height: auto;
  padding: 4px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  transition: background 0.12s linear;
}
.toast .toast-close:hover:not(:disabled) { background: var(--tag-bg); border-color: transparent; }
.toast .toast-close svg { width: 24px; height: 24px; }

@media (max-width: 640px) {
  /* Шапка на телефоне многострочная и высокая — не пытаемся встать под неё, уведомление коротко перекрывает её. */
  .toast-container, body:has(.top-nav) .toast-container { top: 12px; left: 16px; width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; transform: none; }
}

/* --- Модальное окно подтверждения (static/js/modal.js) --- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.16s ease;
}
.modal-overlay.modal-visible { opacity: 1; }

.modal-dialog {
  width: 100%;
  max-width: 420px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.28);
  transform: translateY(8px) scale(0.98);
  transition: transform 0.16s ease;
}
.modal-visible .modal-dialog { transform: none; }

.modal-header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.modal-icon {
  flex-shrink: 0;
  display: flex;
  padding: 6px;
  border-radius: var(--radius-sm);
  background: var(--tag-bg);
  color: var(--danger);
}
.modal-icon svg { width: 24px; height: 24px; }
.modal-title { font-size: 17px; margin: 0; }
.modal-message { margin: 0; color: var(--text); font-size: 14px; line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere; }

.modal-field { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.modal-field-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.modal-field input {
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
}
.modal-field input.modal-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15); }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.modal-actions button { height: auto; padding: 9px 18px; font-size: 13px; }
.modal-actions .modal-confirm-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.modal-actions .modal-confirm-danger:hover:not(:disabled) { background: #dc2626; border-color: #dc2626; }

body.modal-open { overflow: hidden; }

@media (prefers-color-scheme: dark) {
  .modal-overlay { background: rgba(0, 0, 0, 0.6); }
}
@media (prefers-reduced-motion: reduce) {
  .modal-overlay, .modal-dialog { transition: none; transform: none; }
}

/* --- Навигация + авторизация --- */

/* Фон и линия шапки — на всю ширину экрана; содержимое (.top-nav) при этом выровнено по
   той же колонке 1240px, что и страница. Раньше фон стоял на самом .top-nav и на широких
   экранах шапка выглядела белым блоком с оборванными краями. */
.top-nav-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 28px;
  height: 64px;
  padding: 0 24px;
  max-width: 1240px;
  margin: 0 auto;
}

.logo {
  font-weight: 700;
  font-size: 18px;
  color: var(--text-strong);
  text-decoration: none;
  white-space: nowrap;
}

.nav-links { display: flex; gap: 22px; }

.top-nav a.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}
.top-nav a.nav-link.active { color: var(--accent); border-bottom-color: var(--accent); }

.auth-bar {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.auth-form { display: flex; gap: 8px; }
.auth-form input {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
  width: 150px;
}
.auth-bar button { height: 38px; padding: 0 16px; font-size: 13px; }
.auth-status { color: var(--text-muted); font-weight: 600; }

/* .top-nav раньше был жёстким однострочным flex без единого правила для узких экранов — логотип
   + 5 пунктов меню + email/кнопка "Выйти" (или форма логина с двумя 150px-полями) физически не
   помещались в ширину телефона, вызывая горизонтальный скролл/обрезание. Переносим пункты меню
   на отдельную (при необходимости — переносящуюся) строку под логотипом и авторизацией, вместо
   полноценного бургер-меню — набор ссылок небольшой, скрывать их за доп. кликом не требуется. */
@media (max-width: 800px) {
  .top-nav {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 16px;
    row-gap: 8px;
  }
  .nav-links { order: 3; width: 100%; flex-wrap: wrap; gap: 10px 18px; }
  .auth-bar { order: 2; }
  .auth-form { flex-wrap: wrap; }
  .auth-form input { width: 130px; }
}

/* --- SEO-аудит --- */

.preset-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
}

.preset-row select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
}

input#audit-url-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--text);
  font-size: 13px;
}

.audit-category { margin-bottom: 18px; }
.audit-category h3 { margin-bottom: 10px; }

.audit-check-list { list-style: none; margin: 0; padding: 0; }
.audit-check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 7px 4px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.audit-check-fail { color: var(--danger); }
.audit-check-warning { color: var(--warning); }
.audit-check-not_applicable { color: var(--text-muted); }

.audit-fix { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.audit-fix h3 { margin-bottom: 6px; }
.audit-fix-model { margin: 14px 0; max-width: 460px; }
.audit-fix-model label { display: block; margin-bottom: 4px; font-size: 12px; color: var(--text-muted); }
.audit-fix-model select { flex: 1; min-width: 0; font: inherit; font-size: 13px; padding: 8px 10px; border: 1px solid var(--input-border); border-radius: var(--radius-sm); background: var(--input-bg); color: var(--text); }
.audit-fix-model .catalog-btn { height: auto; padding: 0 12px; font-size: 12px; }
#audit-fix-proposal { width: 100%; min-height: 160px; resize: vertical; padding: 12px 14px; border: 1px solid var(--input-border); border-radius: var(--radius-md); background: var(--input-bg); color: var(--text); font-family: inherit; font-size: 13px; line-height: 1.55; }
.audit-fix-delta { font-weight: 700; color: var(--text-strong); margin: 16px 0 8px; }
.audit-fix-tag { margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-hover); font-size: 11px; font-weight: 600; white-space: nowrap; }
.audit-check-manual { display: block; margin-top: 2px; font-size: 12px; color: var(--text-muted); }
.audit-history-list { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; }
.audit-history-list li {
  padding: 7px 4px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

/* Примерная стоимость запроса к моделям (cost_estimate.js): страница этапа и SEO-аудит */
.cost-estimate { min-width: 0; margin: 14px 0; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--accent-soft); font-size: 13px; }
.cost-summary, .cost-line, .cost-note { overflow-wrap: anywhere; }
.cost-summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.cost-title { color: var(--text-muted); }
.cost-total { font-size: 17px; color: var(--text-strong); }
.cost-high { font-size: 12px; color: var(--text-muted); }
.cost-line { margin: 4px 0 0; font-size: 12px; color: var(--text-muted); }
.cost-warn { color: var(--warning); }
.cost-details { margin-top: 8px; }
.cost-details summary { cursor: pointer; font-size: 12px; color: var(--accent-hover); }
/* width: 0 + min-width: 100% — обёртка не расширяет колонку из-за широкой таблицы, а прокручивает её сама */
.cost-table-wrap { overflow-x: auto; width: 0; min-width: 100%; }
.cost-table { width: 100%; margin-top: 8px; border-collapse: collapse; font-size: 12px; }
.cost-table th, .cost-table td { padding: 4px 8px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border); }
.cost-table th { font-weight: 600; color: var(--text-muted); }
.cost-table .cost-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cost-note { margin: 8px 0 0; font-size: 12px; color: var(--text-muted); }
/* Отчёт о «машинности» текста (signal_report.js): сигнал, шкала, профиль признаков, штампы, вклады */
.signal-report {
  --signal-label-w: 200px; --signal-value-w: 104px; --signal-row-h: 36px;
  --sig-human: rgba(16, 185, 129, 0.16); --sig-human-strong: rgba(16, 185, 129, 0.32); --sig-machine: rgba(239, 68, 68, 0.10);
  min-width: 0;
}
.signal-head { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 8px 28px; align-items: start; }
.signal-caption { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.signal-number { font-size: 56px; font-weight: 300; line-height: 1.05; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--text-strong); }
.signal-below { color: var(--chip-done-fg); }
.signal-near { color: var(--chip-stale-fg); }
.signal-above { color: var(--danger); }
.signal-delta { display: inline-block; margin-top: 10px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--tag-bg); color: var(--text); }
.signal-delta-better { background: var(--chip-done-bg); color: var(--chip-done-fg); }
.signal-delta-worse { background: rgba(239, 68, 68, 0.14); color: var(--danger); }
.signal-verdict h4 { margin: 0 0 6px; font-size: 20px; color: var(--text-strong); }
.signal-verdict p { margin: 0 0 8px; line-height: 1.55; }
.signal-verdict .signal-percentile { font-size: 12px; color: var(--text-muted); }

.signal-dist { margin: 8px 0 0; }
.signal-dist-track { position: relative; height: 22px; margin-top: 34px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 4px; }
.sd-zone { position: absolute; top: 0; bottom: 0; background: var(--sig-machine); }
.sd-band90 { position: absolute; top: 5px; bottom: 5px; background: var(--sig-human); }
.sd-band50 { position: absolute; top: 3px; bottom: 3px; background: var(--sig-human-strong); }
.sd-typical { position: absolute; top: 2px; bottom: 2px; width: 2px; margin-left: -1px; background: var(--text-muted); opacity: 0.7; }
.sd-threshold { position: absolute; top: -8px; bottom: -8px; border-left: 1.5px dashed var(--danger); }
.sd-threshold em { position: absolute; top: calc(100% + 24px); left: 4px; font-size: 11px; font-style: normal; color: var(--danger); white-space: nowrap; }
.sd-marker { position: absolute; top: -6px; bottom: -6px; width: 4px; margin-left: -2px; border-radius: 2px; background: var(--text-strong); }
.sd-marker.sd-below { background: var(--chip-done-fg); }
.sd-marker.sd-near { background: var(--warning); }
.sd-marker.sd-above { background: var(--danger); }
.sd-marker-label { position: absolute; bottom: calc(100% + 12px); transform: translateX(-50%); font-size: 12px; font-weight: 700; color: var(--text-strong); white-space: nowrap; }
.signal-dist-scale { position: relative; height: 16px; margin: 10px 0 30px; font-size: 11px; color: var(--text-muted); }
.signal-dist-scale span { position: absolute; transform: translateX(-50%); font-variant-numeric: tabular-nums; }
.signal-legend, .signal-key { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--text-muted); }
.signal-legend i, .signal-key i { display: inline-block; width: 14px; height: 8px; margin-right: 6px; border-radius: 2px; vertical-align: middle; }
.sl-band90, .sk-band { background: var(--sig-human); }
.sl-band50, .sk-half { background: var(--sig-human-strong); }
.sl-typical { width: 2px !important; background: var(--text-muted); }
.sl-threshold { width: 0 !important; height: 12px !important; border-left: 1.5px dashed var(--danger); border-radius: 0 !important; }
.sl-zone { background: var(--sig-machine); }
.sk-ok, .sk-edge, .sk-out { width: 10px !important; height: 10px !important; border-radius: 50% !important; }
.sk-ok { background: var(--text-strong); }
.sk-edge { background: var(--warning); }
.sk-out { background: var(--danger); border-radius: 2px !important; transform: rotate(45deg); }

.signal-section-block { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.signal-section-block h4 { margin: 0 0 6px; font-size: 15px; color: var(--text-strong); }
.signal-rows { position: relative; margin: 12px 0 14px; }
.signal-row { display: flex; align-items: center; height: var(--signal-row-h); cursor: help; }
.signal-row-label { flex: 0 0 var(--signal-label-w); padding-right: 12px; font-size: 13px; font-weight: 600; color: var(--text-strong); overflow-wrap: anywhere; }
.signal-track { position: relative; flex: 1; min-width: 0; height: 22px; background: var(--input-bg); border-radius: 3px; }
.sr-zone { position: absolute; top: 0; bottom: 0; background: var(--sig-machine); border-radius: 0 3px 3px 0; }
.sr-band80 { position: absolute; top: 6px; bottom: 6px; background: var(--sig-human); }
.sr-band50 { position: absolute; top: 6px; bottom: 6px; background: var(--sig-human-strong); }
.sr-typical { position: absolute; top: 4px; bottom: 4px; width: 2px; margin-left: -1px; background: var(--text-muted); opacity: 0.6; }
.sr-threshold { position: absolute; top: -3px; bottom: -3px; border-left: 1.5px dashed var(--danger); opacity: 0.8; }
.sr-dot { position: absolute; top: 50%; z-index: 3; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--text-strong); border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--border); }
.sr-dot.sr-edge { background: var(--warning); }
.sr-dot.sr-out { background: var(--danger); border-radius: 2px; transform: rotate(45deg); }
.sr-dot.sr-info { background: var(--text-muted); }
.signal-row-value { flex: 0 0 var(--signal-value-w); padding-left: 10px; text-align: right; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-strong); }
.signal-row-value small { display: block; font-size: 10px; font-weight: 400; color: var(--text-muted); }
.signal-row-value.sr-edge { color: var(--chip-stale-fg); }
.signal-row-value.sr-out { color: var(--danger); }
.signal-row-value.sr-info, .signal-row-value.sr-n\/a { color: var(--text-muted); }
.signal-connector { position: absolute; top: 0; left: var(--signal-label-w); z-index: 2; width: calc(100% - var(--signal-label-w) - var(--signal-value-w)); height: 100%; pointer-events: none; }
.signal-connector polyline { fill: none; stroke: var(--text-muted); stroke-opacity: 0.55; stroke-width: 1.2; vector-effect: non-scaling-stroke; }

.signal-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.signal-chips li { padding: 4px 11px; border-radius: 999px; background: var(--chip-stale-bg); color: var(--chip-stale-fg); font-size: 13px; }
.signal-contrib { margin-top: 12px; }
.signal-crow { display: flex; align-items: center; height: 30px; }
.signal-cbar { position: relative; flex: 1; min-width: 0; height: 18px; }
.sc-axis { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--text-muted); opacity: 0.5; }
.sc-fill { position: absolute; top: 3px; bottom: 3px; border-radius: 2px; }
.sc-fill.sc-machine { background: var(--danger); opacity: 0.85; }
.sc-fill.sc-human { background: var(--success); opacity: 0.55; }
.signal-crow-value { flex: 0 0 var(--signal-value-w); padding-left: 10px; text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.signal-crow-value.sc-machine-text { font-weight: 700; color: var(--danger); }
.signal-method { margin-top: 24px; font-size: 12px; color: var(--text-muted); }
.signal-method summary { cursor: pointer; color: var(--accent-hover); }
.signal-method p { margin: 8px 0 0; line-height: 1.55; }
.signal-card { min-width: 0; }
.signal-card > .hint:first-of-type { margin-top: 0; }

@media (max-width: 640px) {
  .signal-report { --signal-label-w: 118px; --signal-value-w: 76px; }
  .signal-head { grid-template-columns: 1fr; }
  .signal-number { font-size: 44px; }
  .signal-row-label { font-size: 12px; padding-right: 8px; }
  .signal-row-value { font-size: 13px; padding-left: 6px; }
}
/* Модель, вносящая правки, и сравнение версий текста («Изменения») */
.editor-slot { max-width: 480px; margin: 14px 0; }
.diff-view { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--input-bg); max-height: 480px; overflow: auto; }
.diff-summary { margin: 0 0 10px; font-size: 13px; color: var(--text-muted); }
.diff-added-count { font-weight: 700; color: var(--chip-done-fg); }
.diff-removed-count { font-weight: 700; color: var(--danger); }
.diff-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.6; color: var(--text); }
.diff-ins { text-decoration: none; background: var(--chip-done-bg); color: var(--chip-done-fg); border-radius: 3px; padding: 0 2px; }
.diff-del { background: rgba(239, 68, 68, 0.14); color: var(--danger); text-decoration: line-through; border-radius: 3px; padding: 0 2px; }
button.diff-gap { display: inline; height: auto; padding: 0 6px; border: 0; border-radius: 3px; background: var(--tag-bg); color: var(--text-muted); font-size: 12px; font-weight: 400; }
button.diff-gap:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent-hover); }
#edit-preview-frame { width: 100%; min-height: 360px; margin-bottom: 12px; }

/* Чат со статьёй */
.chat-sidebar { display: flex; flex-direction: column; gap: 10px; }
.chat-new-btn { width: 100%; }
.chat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
/* Общее правило `button` задаёт высоту 42px, акцентный фон и белый текст при наведении — для строки списка это не нужно. */
button.chat-list-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; height: auto; padding: 9px 12px; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--text); text-align: left; font-weight: 400; }
button.chat-list-item:hover:not(:disabled) { background: var(--accent-soft); border-color: transparent; }
button.chat-list-item.is-current, button.chat-list-item.is-current:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
.chat-list-title { max-width: 100%; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 13px; color: var(--text-strong); }
.chat-list-meta { flex-shrink: 0; font-size: 11px; color: var(--text-muted); }
.chat-main { min-width: 0; }
.chat-model-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.chat-model-row label { font-size: 12px; color: var(--text-muted); }
.chat-model-row select { flex: 1 1 220px; min-width: 0; max-width: 380px; font: inherit; font-size: 13px; padding: 8px 10px; border: 1px solid var(--input-border); border-radius: var(--radius-sm); background: var(--input-bg); color: var(--text); }
.chat-model-row .catalog-btn, .chat-model-row #chat-delete-btn { height: auto; padding: 8px 12px; font-size: 12px; }
.chat-article-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chat-article-actions button { font-size: 13px; padding: 8px 14px; }
.chat-article-view { margin-top: 6px; font-size: 13px; }
.chat-article-view summary { cursor: pointer; color: var(--accent-hover); }
.chat-article-view .code-view { max-height: 300px; overflow: auto; }
.chat-thread { display: flex; flex-direction: column; gap: 14px; max-height: 62vh; min-height: 160px; overflow-y: auto; padding-right: 4px; }
.chat-empty { margin: auto; text-align: center; }
.chat-message { display: flex; flex-direction: column; gap: 4px; max-width: 92%; }
.chat-user { align-self: flex-end; align-items: flex-end; }
.chat-assistant { align-self: flex-start; }
.chat-author { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.chat-bubble { padding: 10px 14px; border-radius: var(--radius-md); font-size: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-user .chat-bubble { background: var(--accent); color: var(--accent-contrast); border-bottom-right-radius: 3px; }
.chat-assistant .chat-bubble { background: var(--input-bg); border: 1px solid var(--border); color: var(--text); border-bottom-left-radius: 3px; }
.chat-typing { padding: 10px 14px; border: 1px dashed var(--border); border-radius: var(--radius-md); color: var(--text-muted); font-size: 13px; }
.chat-typing small { font-size: 11px; }
.chat-typing span { animation: chat-dot 1.2s infinite; opacity: 0.2; }
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chat-dot { 0%, 60%, 100% { opacity: 0.2; } 30% { opacity: 1; } }
.chat-error { padding: 10px 14px; border: 1px solid var(--danger); border-radius: var(--radius-md); background: rgba(239, 68, 68, 0.08); color: var(--danger); font-size: 13px; }
.chat-proposal { margin-top: 8px; padding: 12px 14px; border: 1px solid var(--accent); border-radius: var(--radius-md); background: var(--accent-soft); }
.chat-proposal-head { margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--text-strong); }
.chat-diff { max-height: 320px; background: var(--panel); }
.chat-proposal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chat-proposal-state { margin-top: 6px; font-size: 12px; color: var(--text-muted); }
.chat-proposal-state.is-accepted { color: var(--chip-done-fg); font-weight: 600; }
.chat-composer textarea { width: 100%; min-height: 84px; resize: vertical; padding: 12px 14px; border: 1px solid var(--input-border); border-radius: var(--radius-md); background: var(--input-bg); color: var(--text); font: inherit; font-size: 14px; line-height: 1.55; }
.chat-composer textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.attach-sources { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.attach-file { display: inline-flex; align-items: center; padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; }
.attach-sources select { flex: 1 1 200px; min-width: 0; font: inherit; font-size: 13px; padding: 8px 10px; border: 1px solid var(--input-border); border-radius: var(--radius-sm); background: var(--input-bg); color: var(--text); }
#attach-text { width: 100%; resize: vertical; padding: 12px 14px; border: 1px solid var(--input-border); border-radius: var(--radius-md); background: var(--input-bg); color: var(--text); font: inherit; font-size: 13px; line-height: 1.55; }
#attach-text.modal-invalid { border-color: var(--danger); }

@media (max-width: 640px) {
  .chat-message { max-width: 100%; }
  .chat-thread { max-height: 55vh; }
}
/* Админка: общий ключ OpenRouter */
.shared-key-status { margin-bottom: 4px; font-size: 14px; font-weight: 600; color: var(--text-strong); }
.shared-key-status.is-set::before { content: "● "; color: var(--success); }
.shared-key-status.is-missing { color: var(--danger); }
.shared-key-status.is-missing::before { content: "● "; }
#shared-key-details .key-ok { color: var(--chip-done-fg); font-weight: 600; }
#shared-key-details .key-warn { color: var(--chip-stale-fg); font-weight: 600; }
#shared-key-details .key-problem { color: var(--danger); font-weight: 600; }
.shared-key-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.shared-key-row input { flex: 1 1 280px; min-width: 0; font: inherit; font-size: 13px; padding: 9px 12px; border: 1px solid var(--input-border); border-radius: var(--radius-sm); background: var(--input-bg); color: var(--text); }
.shared-key-row button { height: auto; padding: 9px 16px; font-size: 13px; }
#legacy-keys-card { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
#legacy-keys-card p { margin: 0; font-size: 13px; color: var(--text-muted); max-width: 70ch; }
#legacy-keys-card button { height: auto; padding: 8px 14px; font-size: 13px; }
/* «Правка» тремя моделями: карточка версии статьи */
.edit-version-state { color: var(--chip-done-fg); font-weight: 600; }
.edit-version-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
button.edit-version-btn { height: auto; padding: 5px 10px; font-size: 12px; }
.edit-version-diff { margin-top: 8px; max-height: 260px; font-size: 12px; }
/* Shared navigation and login feedback. */
.visually-hidden {position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.top-nav {height:auto;min-height:64px;flex-wrap:wrap;gap:12px 22px;padding-top:10px;padding-bottom:10px}
.nav-links {flex-wrap:wrap;gap:10px 16px}
.nav-link {white-space:nowrap}
.auth-bar {flex-wrap:wrap;max-width:100%;min-width:0}
.auth-status {max-width:220px;overflow:hidden;text-overflow:ellipsis}
.auth-retry {flex-basis:100%;font-size:12px;color:var(--warning);margin:0}
@media(max-width:800px) {.auth-bar {margin-left:0}.auth-form input {flex:1 1 130px;min-width:0}.auth-form {max-width:100%}.auth-status {max-width:200px}}
