/* Контент-платформа: оформление поверх Pico CSS.
   Главный приём: «красный карандаш редактора» отмечает только то, что ждёт решения человека.
   Синий — агент работает, зелёный — готово. Всё остальное спокойное и нейтральное. */

/* Шрифты лежат в проекте: Golos Text (интерфейс) и PT Serif (текст статьи), лицензия SIL OFL */
@font-face { font-family: 'Golos Text'; font-style: normal; font-weight: 400 900; font-display: swap; src: url(fonts/golos-text-cyrillic-wght-normal.woff2) format('woff2'); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: 'Golos Text'; font-style: normal; font-weight: 400 900; font-display: swap; src: url(fonts/golos-text-latin-wght-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'PT Serif'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/pt-serif-cyrillic-400-normal.woff2) format('woff2'); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: 'PT Serif'; font-style: italic; font-weight: 400; font-display: swap; src: url(fonts/pt-serif-cyrillic-400-italic.woff2) format('woff2'); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: 'PT Serif'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/pt-serif-cyrillic-700-normal.woff2) format('woff2'); unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: 'PT Serif'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/pt-serif-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'PT Serif'; font-style: italic; font-weight: 400; font-display: swap; src: url(fonts/pt-serif-latin-400-italic.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'PT Serif'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/pt-serif-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

:root[data-theme=light] {
  --paper: #f3f4f6;
  --surface: #ffffff;
  --ink: #18202b;
  --ink-soft: #3a4553;
  --muted: #5f6977;
  --line: #dde1e7;
  --line-strong: #c8ced6;
  --pencil: #c2362b;
  --pencil-soft: #fbeceb;
  --agent: #2d62a8;
  --agent-soft: #e8eff9;
  --done: #2e7a4e;
  --done-soft: #e6f3ec;
  --warn: #8a5a00;
  --warn-soft: #fdf3dc;

  --pico-font-family: "Golos Text", system-ui, -apple-system, "Segoe UI", sans-serif;
  --pico-font-size: 100%;
  --pico-line-height: 1.5;
  --pico-background-color: var(--paper);
  --pico-color: var(--ink);
  --pico-muted-color: var(--muted);
  --pico-muted-border-color: var(--line);
  --pico-h1-color: var(--ink);
  --pico-h2-color: var(--ink);
  --pico-h3-color: var(--ink);
  --pico-card-background-color: var(--surface);
  --pico-card-sectioning-background-color: var(--surface);
  --pico-card-box-shadow: none;
  --pico-border-radius: 6px;
  --pico-spacing: 1rem;
  --pico-typography-spacing-vertical: 1rem;
  --pico-form-element-spacing-vertical: 0.6rem;
  --pico-form-element-spacing-horizontal: 0.8rem;
  --pico-form-element-background-color: var(--surface);
  --pico-form-element-border-color: var(--line-strong);
  --pico-form-element-focus-color: var(--agent);

  --pico-primary: var(--agent);
  --pico-primary-hover: #224d86;
  --pico-primary-underline: rgba(45, 98, 168, 0.4);
  --pico-primary-background: var(--ink);
  --pico-primary-border: var(--ink);
  --pico-primary-hover-background: #2c3746;
  --pico-primary-hover-border: #2c3746;
  --pico-primary-inverse: #ffffff;
  --pico-primary-focus: rgba(45, 98, 168, 0.35);

  --pico-secondary: var(--ink-soft);
  --pico-secondary-background: var(--surface);
  --pico-secondary-border: var(--line-strong);
  --pico-secondary-hover-background: #eceef2;
  --pico-secondary-hover-border: var(--muted);
  --pico-secondary-inverse: var(--ink);
  --pico-secondary-focus: rgba(58, 69, 83, 0.25);
}

h1, h2, h3 { letter-spacing: -0.01em; font-weight: 650; }
h1 { font-size: 1.75rem; line-height: 1.2; margin-bottom: 0.5rem; }
h2 { font-size: 1.25rem; margin-top: 2.25rem; }
h3 { font-size: 1.05rem; }
:where(button, [role=button], input[type=submit]) { font-weight: 550; }
button.secondary, [role=button].secondary { color: var(--ink); }
:focus-visible { outline: 2px solid var(--agent); outline-offset: 2px; }

.muted { color: var(--muted); font-size: 0.9rem; }
.inline-form { margin: 0; display: inline; }
.link-button { background: none; border: none; padding: 0; margin: 0; color: var(--pico-primary); cursor: pointer; width: auto; font-weight: 400; }
.narrow { max-width: 440px; margin: 3rem auto; }
.container.wide { max-width: 1480px; padding-left: 1.5rem; padding-right: 1.5rem; }
@media (max-width: 575px) { .container.wide { padding-left: 1rem; padding-right: 1rem; } }

/* ---------- шапка ---------- */

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); margin-bottom: 1.75rem; }
.topbar nav { min-height: 3.5rem; }
.topbar nav ul { gap: 0.25rem; }
.topbar nav li { padding: 0.5rem 0.6rem; }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.nav-link { color: var(--ink-soft); text-decoration: none; padding-bottom: 3px; border-bottom: 2px solid transparent; }
.nav-link:hover { color: var(--ink); }
.nav-link.current { color: var(--ink); border-bottom-color: var(--ink); }
.nav-user { color: var(--muted); }
.topbar .link-button { color: var(--muted); }
.topbar .link-button:hover { color: var(--ink); }
@media (max-width: 720px) {
  .topbar nav { flex-wrap: wrap; }
  .topbar nav ul:last-child { flex-wrap: wrap; }
  .topbar nav li { padding: 0.35rem 0.5rem; }
}

/* ---------- метки статусов ---------- */

.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 0.8rem; font-weight: 500; white-space: nowrap; background: #eceef2; color: var(--ink-soft); }
.badge.outline_running, .badge.draft_running, .badge.factcheck_running, .badge.revision_running { background: var(--agent-soft); color: var(--agent); }
.badge.outline_review, .badge.review, .badge.idea, .badge.outline_approved, .badge.approved,
.badge.changes_requested, .badge.text_changes_requested { background: var(--pencil-soft); color: var(--pencil); }
.badge.failed { background: var(--pencil); color: #fff; }
.badge.published { background: var(--done-soft); color: var(--done); }
.badge.supported { background: var(--done-soft); color: var(--done); }
.badge.unsupported { background: var(--warn-soft); color: var(--warn); }
.badge.contradicted { background: var(--pencil-soft); color: var(--pencil); }

.ok-note, .error-note, .warn-note { padding: 10px 14px; border-radius: 6px; }
.ok-note { background: var(--done-soft); color: var(--done); }
.error-note { background: var(--pencil-soft); color: var(--pencil); }
.warn-note { background: var(--warn-soft); color: var(--warn); }

/* ---------- доска статей ---------- */

.board-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.board-head h1 { margin: 0; }
.board-tally { margin: 0.35rem 0 0; color: var(--muted); }
.board-tally strong { color: var(--pencil); font-weight: 600; }
.board-tools { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
@media (max-width: 575px) { .board-tools { width: 100%; } .board-tools form { flex: 1; } .board-tools select { min-width: 0; } }
.board-tools form { margin: 0; }
.board-tools select { margin: 0; min-width: 14rem; }
.board-tools [role=button] { white-space: nowrap; }

.board { display: grid; grid-template-columns: repeat(5, minmax(15rem, 1fr)); gap: 1rem; overflow-x: auto; padding-bottom: 1rem; align-items: start; }
.column-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 0.15rem 0.6rem; border-bottom: 2px solid var(--line-strong); margin-bottom: 0.75rem; }
.column-head h2 { font-size: 0.95rem; margin: 0; }
.column-count { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.column-empty { color: var(--muted); font-size: 0.85rem; padding: 0.5rem 0.15rem; }
.column-more { display: block; font-size: 0.85rem; padding: 0.4rem 0.15rem; }

.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 0.7rem 0.85rem 0.75rem; margin-bottom: 0.6rem; text-decoration: none; color: var(--ink); }
.card:hover { border-color: var(--line-strong); background: #fcfcfd; }
.card-title { font-weight: 550; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 0.4rem; color: var(--muted); font-size: 0.8rem; }
.card-meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta span:last-child { white-space: nowrap; }
.card-step { margin-top: 0.55rem; font-size: 0.85rem; font-weight: 550; }

.card.waiting { border-left: 4px solid var(--pencil); padding-left: calc(0.85rem - 3px); }
.card.waiting .card-step { color: var(--pencil); }
.card.working .card-step { color: var(--agent); }
.card.failed { border-left: 4px solid var(--pencil); padding-left: calc(0.85rem - 3px); background: var(--pencil-soft); }
.card.failed .card-step { color: var(--pencil); }
.card.done .card-step { color: var(--done); font-weight: 500; }

.pulse { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--agent); margin-right: 6px; vertical-align: 1px; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

.board-foot { margin-top: 0.5rem; font-size: 0.9rem; }

.stage-list td, .stage-list th { font-size: 0.95rem; }

/* ---------- страница статьи ---------- */

.article-layout { display: grid; grid-template-columns: minmax(0, 1fr) 18rem; gap: 2.5rem; align-items: start; }
@media (max-width: 960px) { .article-layout { grid-template-columns: minmax(0, 1fr); gap: 1rem; } }

.back { display: inline-block; margin-bottom: 0.75rem; font-size: 0.9rem; }
.article-head h1 { max-width: 40rem; }
.article-head .head-line { display: flex; flex-wrap: wrap; gap: 0.5rem 0.9rem; align-items: center; color: var(--muted); margin-bottom: 1.5rem; }

/* Панель «что сейчас нужно» — главный блок страницы */
.decision { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1.1rem 1.25rem 1.2rem; margin-bottom: 2rem; }
.decision h2 { margin: 0 0 0.4rem; font-size: 1.2rem; }
.decision p { margin-bottom: 0.75rem; }
.decision > :last-child { margin-bottom: 0; }
.decision.waiting { border-left: 5px solid var(--pencil); }
.decision.waiting h2 { color: var(--pencil); }
.decision.working { border-left: 5px solid var(--agent); }
.decision.working h2 { color: var(--agent); }
.decision.done { border-left: 5px solid var(--done); }
.decision.failed { border-left: 5px solid var(--pencil); background: var(--pencil-soft); }
.decision.failed h2 { color: var(--pencil); }
.decision .reason { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 0.6rem 0.8rem; font-size: 0.9rem; }

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-start; }
.actions form { margin: 0; }
.actions button { margin: 0; }
form button[type=submit] { width: auto; }
.narrow form button[type=submit] { width: 100%; }
.second-thoughts { margin-top: 0.9rem; }
.second-thoughts summary { color: var(--ink-soft); font-weight: 550; }
.second-thoughts[open] summary { margin-bottom: 0.6rem; }
.second-thoughts textarea { margin-bottom: 0.6rem; }
.option-line { font-size: 0.9rem; color: var(--ink-soft); margin-top: 1rem; padding-top: 0.9rem; border-top: 1px solid var(--line); }
.option-line form { display: inline; }
.option-line button { padding: 0.35rem 0.8rem; font-size: 0.9rem; margin: 0.4rem 0 0; }

/* Текст статьи для чтения */
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.25rem 1rem; margin: 2rem 0 0.75rem; }
.section-head h2 { margin: 0; }
.section-head .muted { font-size: 0.85rem; }
.reading { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 2rem 2.25rem; font-family: "PT Serif", Georgia, serif; font-size: 1.075rem; line-height: 1.65; }
.reading h1, .reading h2, .reading h3 { font-family: var(--pico-font-family); }
.reading h1 { font-size: 1.6rem; margin-top: 0; }
.reading h2 { font-size: 1.3rem; margin-top: 2rem; }
.reading h3 { font-size: 1.1rem; margin-top: 1.5rem; }
.reading > * { max-width: 42rem; }
.reading table { font-family: var(--pico-font-family); font-size: 0.92rem; display: block; overflow-x: auto; }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1.25rem 1.5rem; }
.box > :last-child { margin-bottom: 0; }
@media (max-width: 720px) { .box { padding: 1rem; } }
@media (max-width: 720px) { .reading { padding: 1.25rem 1rem; font-size: 1rem; } }

details.block { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0.8rem 1.1rem; margin-bottom: 0.75rem; }
details.block > summary { font-weight: 550; }
details.block[open] > summary { margin-bottom: 0.9rem; }

.change { margin: 1rem 0; }
.diff-removed, .diff-added { padding: 8px 12px; margin-bottom: 4px; border-radius: 6px; white-space: pre-wrap; }
.diff-removed { background: #fdecec; border-left: 4px solid #e08080; }
.diff-added { background: #e9f7ee; border-left: 4px solid #5cb27a; }

.claim { border-top: 1px solid var(--line); padding: 0.9rem 0; }
.claim:first-of-type { border-top: none; }
.claim-title { font-weight: 550; margin-bottom: 0.35rem; }
.claim p { margin-bottom: 0.4rem; }
.claim ul { margin-bottom: 0; font-size: 0.9rem; }

.outline-section { border-top: 1px solid var(--line); padding: 0.85rem 0; }
.outline-section h3 { margin-bottom: 0.4rem; }
.outline-section ul { margin-bottom: 0.4rem; }

/* История в виде ленты */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { list-style: none; display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); gap: 0.25rem 1rem; padding: 0.55rem 0; border-top: 1px solid var(--line); font-size: 0.9rem; }
.timeline li:first-child { border-top: none; }
.timeline time { color: var(--muted); font-variant-numeric: tabular-nums; }
.timeline .who { color: var(--muted); }
@media (max-width: 720px) { .timeline li { grid-template-columns: minmax(0, 1fr); } }

/* Боковая колонка */
.side { position: sticky; top: 1rem; font-size: 0.9rem; }
@media (max-width: 960px) { .side { position: static; } .side .jump-block { display: none; } }
.side-block { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0.9rem 1rem; margin-bottom: 0.9rem; }
.side-block h3 { font-size: 0.85rem; color: var(--muted); font-weight: 600; margin-bottom: 0.6rem; }

.stages { list-style: none; padding: 0; margin: 0; counter-reset: stage; }
.stages li { list-style: none; position: relative; padding: 0 0 0.75rem 1.75rem; color: var(--muted); counter-increment: stage; }
.stages li:last-child { padding-bottom: 0; }
.stages li::before { content: counter(stage); position: absolute; left: 0; top: 0.05rem; width: 1.2rem; height: 1.2rem; border-radius: 50%; border: 1.5px solid var(--line-strong); font-size: 0.7rem; line-height: 1.05rem; text-align: center; background: var(--surface); }
.stages li::after { content: ""; position: absolute; left: 0.58rem; top: 1.3rem; bottom: 0.1rem; width: 1.5px; background: var(--line-strong); }
.stages li:last-child::after { display: none; }
.stages li.passed { color: var(--ink-soft); }
.stages li.passed::before { content: "✓"; border-color: var(--done); background: var(--done); color: #fff; }
.stages li.current { color: var(--ink); font-weight: 600; }
.stages li.current::before { border-color: var(--ink); background: var(--ink); color: #fff; }
.stages li.current.waiting::before { border-color: var(--pencil); background: var(--pencil); }
.stages li.current.working::before { border-color: var(--agent); background: var(--agent); }
.stages li.current.failed::before { border-color: var(--pencil); background: var(--pencil); }
.stages .stage-note { display: block; font-weight: 400; font-size: 0.8rem; color: var(--muted); }

.facts { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.3rem 0.75rem; }
.facts dt { color: var(--muted); font-weight: 400; margin: 0; }
.facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.meta-tag { margin-bottom: 0.7rem; }
.meta-tag:last-child { margin-bottom: 0; }
.meta-tag .label { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.8rem; }
.meta-tag .label .over { color: var(--pencil); }
.jump { list-style: none; padding: 0; margin: 0; }
.jump li { list-style: none; padding: 0.15rem 0; }

/* ---------- проекты ---------- */

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.9rem; }
.page-head h1 { margin-bottom: 0.25rem; }
.lead-note { max-width: 46rem; margin-bottom: 1.25rem; }

.tabs { display: flex; justify-content: flex-start; align-items: flex-end; flex-wrap: wrap; gap: 0.25rem 1.5rem; border-bottom: 1px solid var(--line-strong); margin: 0.75rem 0 1.5rem; }
.tabs a { color: var(--ink-soft); text-decoration: none; padding: 0.5rem 0 0.6rem; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs .tabs-aside { margin-left: auto; font-weight: 400; color: var(--pico-primary); }
@media (max-width: 575px) { .tabs .tabs-aside { margin-left: 0; } }

.box.form-box { max-width: 46rem; }
.article-layout .box.form-box { max-width: none; }
.form-box label { font-weight: 500; }
.form-box label small { display: block; font-weight: 400; color: var(--muted); margin-top: -0.4rem; }
.form-box textarea { font-weight: 400; }
.form-box input[type=checkbox] + small, .form-box label:has(input[type=checkbox]) small { margin-top: 0.2rem; }
.side-note { font-size: 0.8rem; margin: 0.6rem 0 0; }

.model-row { display: grid; grid-template-columns: minmax(0, 15rem) minmax(0, 1fr); gap: 0.5rem 1.5rem; padding: 1rem 0; border-top: 1px solid var(--line); }
.model-row:first-child { border-top: none; padding-top: 0.25rem; }
.model-step strong { display: block; margin-bottom: 0.15rem; }
.model-step .muted { font-size: 0.85rem; line-height: 1.4; display: block; }
.model-pick input { margin-bottom: 0; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 0.9rem; }
.model-pick small { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 0.45rem; }
.model-pick .over { color: var(--pencil); }
@media (max-width: 720px) { .model-row { grid-template-columns: minmax(0, 1fr); } }

.project-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.project-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.1rem; text-decoration: none; color: var(--ink); }
.project-card:hover { border-color: var(--line-strong); }
.project-card.inactive { opacity: 0.65; }
.project-card-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; font-size: 1.05rem; }
.project-niche { color: var(--muted); font-size: 0.88rem; line-height: 1.4; margin: 0.4rem 0 0.9rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.project-meta { display: flex; justify-content: space-between; gap: 0.75rem; margin-top: auto; font-size: 0.85rem; color: var(--ink-soft); }
.project-meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-waiting { color: var(--pencil); margin-top: 0.5rem; }

.danger-zone { max-width: none; margin-top: 1.5rem; }
details.danger-zone > summary, details.danger-zone[open] > summary, details.danger-zone > summary:hover { color: var(--pencil); }
.danger-zone form { margin: 0; }
button.danger { background: var(--pencil); border-color: var(--pencil); color: #fff; width: auto; }
button.danger:hover { background: #a42c23; border-color: #a42c23; }
