/* Стили AI Copywriter. Цвета, отступы и радиусы — только токены --ui-* из
   ui-tokens.css: test_ui_tokens.py запрещает здесь литералы цвета и прямые
   брендовые токены. Кнопка без класса — второстепенная; главная — .primary,
   одна на экран (спека 2026-10-06-ui-appearance §5.1). */
* { box-sizing: border-box; }
html { font-size: 15px; }
body { font: 400 1rem/1.5 var(--ui-font); margin: 0; color: var(--ui-text); background: var(--ui-page); }
h1 { font-size: var(--ui-h1-size); line-height: var(--ui-h1-line); font-weight: 700;
  color: var(--ui-heading); margin: 0 0 var(--ui-space-sm); }
h2, h3 { font-weight: 700; color: var(--ui-text-strong); margin: 0 0 var(--ui-space-sm); }
.h3 { font-size: var(--ui-h2-size); }
.h4 { font-size: 1rem; margin-bottom: var(--ui-space-xs); }
a { color: var(--ui-accent); }
:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; }

/* кнопки */
button { padding: 9px 18px; border: 1px solid transparent; border-radius: var(--ui-radius-sm);
  background: var(--ui-secondary-bg); color: var(--ui-text); cursor: pointer;
  font: 400 .933rem/1.4 var(--ui-font); transition: background-color .15s; }
button:hover { background: var(--ui-secondary-hover); }
a.primary { display: inline-block; padding: 9px 18px; border-radius: var(--ui-radius-sm);
  text-decoration: none; font: 400 .933rem/1.4 var(--ui-font); }
.primary { background: var(--ui-cta); color: var(--ui-cta-text); }
button.primary:hover, a.primary:hover { background: var(--ui-cta-hover); }
button.danger { background: var(--ui-surface); color: var(--ui-fail-text); border-color: var(--ui-fail-line); }
button.danger:hover { background: var(--ui-fail-bg); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.del { background: none; color: var(--ui-text-muted); padding: 2px 8px; border: 0; min-height: 24px; }
button.del:hover { background: var(--ui-fail-bg); color: var(--ui-fail-text); }

/* поля */
input, select, textarea { width: 100%; padding: 8px 10px; margin: 4px 0 12px;
  border: 1px solid var(--ui-border-input); border-radius: var(--ui-radius-sm);
  font: inherit; color: var(--ui-text); background: var(--ui-surface); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ui-accent); outline-offset: 0;
  border-color: var(--ui-accent); }
input[type=checkbox] { width: 18px; height: 18px; padding: 0; margin: 0; accent-color: var(--ui-cta); }
label { font-size: .867rem; font-weight: 600; color: var(--ui-text); }
textarea.md { min-height: 320px; font-family: var(--ui-mono); font-size: .867rem; }
/* вся строка — цель клика, а не только квадратик чекбокса */
.check-line { display: flex; gap: 10px; align-items: center; min-height: 40px; margin: 8px 0 4px;
  padding: 0 10px; border-radius: var(--ui-radius-sm); cursor: pointer; font-weight: 400; }
.check-line:hover { background: var(--ui-surface-soft); }
.check-line input[type=checkbox] { width: 20px; height: 20px; flex: none; }
fieldset.bf-length { border: 0; padding: 0; margin: 4px 0 12px; }
fieldset.bf-length legend { font-size: .867rem; font-weight: 600; padding: 0; margin-bottom: 4px; }
fieldset.bf-length label { font-weight: 400; margin-right: 6px; }
fieldset.bf-length input { width: 8em; margin-right: 12px; }
details > summary { min-height: 28px; padding: 3px 0; cursor: pointer; }

/* меню */
nav { display: flex; align-items: center; gap: var(--ui-space-lg); padding: 0 var(--ui-space-lg);
  height: 52px; background: var(--ui-nav-bg); }
nav a, nav .link { color: var(--ui-nav-text); text-decoration: none; background: none; border: 0;
  border-radius: 0; font: 600 .933rem var(--ui-font); padding: 14px 0;
  border-bottom: 3px solid transparent; cursor: pointer; }
nav a[aria-current="page"] { border-bottom-color: var(--ui-cta); }
nav a:hover { opacity: .85; }
nav .link { margin-left: auto; font-weight: 400; }
nav .link:hover { background: none; opacity: .85; }
/* акцент на тёмном меню — 1,84 : 1, кольцо фокуса не видно */
nav :focus-visible { outline-color: var(--ui-nav-text); }
main { max-width: var(--ui-container); margin: var(--ui-space-lg) auto; padding: 0 var(--ui-space-lg); }

/* список статей */
.list-head { display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--ui-space-sm); }
.list-head h1 { margin: 0; }
table { width: 100%; border-collapse: collapse; background: var(--ui-surface); }
th { text-align: left; padding: 10px 12px; font-size: .8rem; font-weight: 600;
  color: var(--ui-text-muted); text-transform: uppercase; letter-spacing: .03em;
  border-bottom: 1px solid var(--ui-border); }
td { text-align: left; padding: 12px; border-bottom: 1px solid var(--ui-border); vertical-align: top; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--ui-surface-soft); }
tr.waiting-row td:first-child { box-shadow: inset 3px 0 0 var(--ui-cta); }
a.job-topic { font-weight: 600; color: var(--ui-text-strong); text-decoration: none; }
a.job-topic:hover { text-decoration: underline; }
.job-sub { font-size: .8rem; color: var(--ui-text-muted); }
.status-pill { display: inline-block; padding: 2px 10px; border-radius: var(--ui-radius-pill);
  font-size: .8rem; font-weight: 600; background: var(--ui-info-bg); color: var(--ui-info-text); }
.status-pill.waiting { background: var(--ui-cta-soft); color: var(--ui-cta); }
.status-pill.warn { background: var(--ui-warn-bg); color: var(--ui-warn-text); }
.status-pill.done { background: var(--ui-ok-bg); color: var(--ui-ok-text); }
.status-pill.failed { background: var(--ui-fail-bg); color: var(--ui-fail-text); }

/* шапка статьи */
.job-head { margin-bottom: var(--ui-space-md); }
.job-head h1 { margin-bottom: 2px; }
.job-meta { display: flex; flex-wrap: wrap; gap: var(--ui-space-xs); align-items: center;
  font-size: .867rem; color: var(--ui-text-muted); }
.job-meta a { color: var(--ui-accent); font-weight: 600; text-decoration: none; }

/* этапы */
.layout { display: grid; grid-template-columns: 240px 1fr; gap: var(--ui-space-lg); align-items: start; }
/* без overflow: hidden — иначе обрезается всплывающая подсказка «?» */
.stepper { list-style: none; padding: 0; margin: 0; background: var(--ui-surface);
  border-radius: var(--ui-radius); }
.stepper li { position: relative; display: flex; align-items: center; padding-right: 12px;
  border-left: 3px solid transparent; border-bottom: 1px solid var(--ui-border); }
.stepper li:first-child { border-top-left-radius: var(--ui-radius); border-top-right-radius: var(--ui-radius); }
.stepper li:last-child { border-bottom: 0; border-bottom-left-radius: var(--ui-radius);
  border-bottom-right-radius: var(--ui-radius); }
.stepper .step { flex: 1; text-align: left; background: none; border: 0; border-radius: 0;
  padding: 11px 6px 11px 13px; color: var(--ui-text); font-size: .933rem; }
.stepper .step:hover { background: var(--ui-surface-soft); }
.stepper .step:focus-visible { outline-offset: -2px; }
.stepper .step::before { content: ''; display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--ui-dot-pending); margin-right: 8px; vertical-align: 1px; }
.stepper li.done .step::before { background: var(--ui-ok-line); }
.stepper li.waiting .step::before { background: var(--ui-cta); }
.stepper li.running .step::before { background: var(--ui-accent); }
.stepper li.active { border-left-color: var(--ui-accent); background: var(--ui-accent-soft); }
.stepper li.active .step { font-weight: 600; }
.hint { display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 16px; height: 16px; border-radius: 50%; background: var(--ui-text-muted);
  color: var(--ui-cta-text); font-size: .733rem; font-weight: 700; cursor: help;
  position: relative; }
.hint:hover::after { content: attr(data-tip); position: absolute; left: 22px; top: -6px; width: 240px;
  padding: 8px 10px; z-index: 20; background: var(--ui-nav-bg); color: var(--ui-nav-text);
  font-size: .8rem; font-weight: 400; line-height: 1.4; white-space: normal;
  border-radius: var(--ui-radius-sm); box-shadow: var(--ui-shadow); }

.panel { background: var(--ui-surface); padding: var(--ui-space-lg); border-radius: var(--ui-radius);
  margin-bottom: var(--ui-space-md); }
.cost { color: var(--ui-text-muted); font-size: .867rem; }
.error { color: var(--ui-fail-text); }

/* сводка проверок: провалы раскрыты, остальное свёрнуто */
.checks { margin: 0 0 var(--ui-space-md); }
.checks-line { display: flex; gap: var(--ui-space-xs); align-items: center; flex-wrap: wrap;
  font-size: .867rem; margin-bottom: var(--ui-space-xs); }
.checks-count { font-weight: 600; padding: 2px 10px; border-radius: var(--ui-radius-pill); }
.checks-count.fail { background: var(--ui-fail-bg); color: var(--ui-fail-text); }
.checks-count.ok { background: var(--ui-ok-bg); color: var(--ui-ok-text); }
.checks-count.info { background: var(--ui-info-bg); color: var(--ui-info-text); }
.check-row { display: grid; grid-template-columns: 22px 1fr; gap: 6px; padding: 7px 10px;
  border-radius: var(--ui-radius-sm); font-size: .867rem; margin: 3px 0; max-width: var(--ui-reading); }
.check-row .mark { font-weight: 700; }
.check-row.fail { background: var(--ui-fail-bg); color: var(--ui-fail-text); }
.check-row.ok .mark { color: var(--ui-ok-text); }
.check-row.info { color: var(--ui-text-muted); }
.check-row .det { display: block; font-size: .8rem; margin-top: 2px; }
.check-tabs { display: flex; flex-wrap: wrap; gap: 2px; margin: var(--ui-space-xs) 0;
  border-bottom: 1px solid var(--ui-border); }
.check-tabs [role=tab] { background: none; border: 0; border-bottom: 3px solid transparent; border-radius: 0;
  padding: 8px 12px; margin-bottom: -1px; color: var(--ui-text-muted); font-weight: 600; font-size: .867rem; }
.check-tabs [role=tab]:hover { background: var(--ui-surface-soft); }
.check-tabs [role=tab][aria-selected="true"] { color: var(--ui-accent); border-bottom-color: var(--ui-accent); }
ul.check-list { list-style: none; margin: 0; padding: 0; }
.checks-more > summary { font-size: .867rem; color: var(--ui-accent); font-weight: 600; }

.badge { display: inline-block; padding: 2px 10px; border-radius: var(--ui-radius-pill);
  font-size: .8rem; margin: 2px 4px 2px 0; }
.badge.ok, .badge-list.ok { background: var(--ui-ok-bg); color: var(--ui-ok-text); }
.badge.fail, .badge-list.fail { background: var(--ui-fail-bg); color: var(--ui-fail-text); }
.badge.warn, .badge-list.warn { background: var(--ui-warn-bg); color: var(--ui-warn-text); }
.badge.info, .badge-list.info { background: var(--ui-info-bg); color: var(--ui-info-text); }
.badge-list { display: block; margin: 4px 0; padding: 6px 10px; border-radius: var(--ui-radius-sm);
  font-size: .8rem; max-width: var(--ui-reading); }
.badge-list ul { margin: 6px 0 0 16px; padding: 0; }
.badge-list li { margin: 2px 0; white-space: normal; }
.textru-plate { margin-left: .5rem; }

div.warn { background: var(--ui-warn-bg); border-left: 3px solid var(--ui-warn-line);
  color: var(--ui-warn-text); padding: 10px 14px; border-radius: var(--ui-radius-sm); margin: 8px 0; }
.error-box { background: var(--ui-fail-bg); border-left: 3px solid var(--ui-fail-line);
  color: var(--ui-fail-text); padding: 12px 16px; border-radius: var(--ui-radius-sm);
  margin: 0 0 var(--ui-space-md); }
.error-box b { display: block; margin-bottom: 4px; }
/* job.error — полный traceback: без ограничения он растянет экран */
.error-box .error-text { white-space: pre-wrap; max-height: 240px; overflow: auto; }
.error-actions { margin-top: 10px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: var(--ui-space-sm) 0; }
.toolbar > p { margin: 0; display: flex; align-items: center; gap: 8px; }
.export-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.export-row input { flex: 1; min-width: 260px; margin: 0; }

/* текст этапа и бриф */
pre.result { white-space: pre-wrap; background: var(--ui-surface-soft); padding: 14px 16px;
  border: 1px solid var(--ui-border); border-radius: var(--ui-radius-sm); max-height: 480px;
  overflow: auto; font-family: var(--ui-mono); font-size: .867rem; line-height: 1.6;
  max-width: var(--ui-reading); }
.result.brief { background: var(--ui-surface-soft); padding: 14px 16px; border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-sm); max-height: 600px; overflow: auto; }
.b-row { display: grid; grid-template-columns: 180px 1fr; gap: 12px; padding: 7px 0;
  border-bottom: 1px solid var(--ui-border); }
.b-row:last-child { border-bottom: 0; }
.b-label { color: var(--ui-text-muted); font-size: .867rem; padding-top: 2px; }
.b-pre { white-space: pre-wrap; }
.st-h2 { font-weight: 600; margin-top: 8px; }
.st-tree .st-h2:first-child { margin-top: 0; }
.st-sub { padding-left: 18px; position: relative; }
.st-sub::before { content: '–'; position: absolute; left: 4px; color: var(--ui-text-muted); }
.st-pre { color: var(--ui-text-muted); }
table.b-kw { width: auto; min-width: 60%; }
table.b-kw th, table.b-kw td { padding: 4px 10px; font-size: .933rem; }
table.fc { width: 100%; margin: 8px 0; }
table.fc th, table.fc td { padding: 6px 10px; font-size: .933rem; vertical-align: top;
  border-bottom: 1px solid var(--ui-border); }
table.fc td:nth-child(2) { white-space: nowrap; }

/* фактчекинг */
.fc-report, .fc-text { margin: 8px 0; }
.fc-report > summary, .fc-text > summary { font-weight: 700; padding: 4px 0; }
.fc-card { border: 1px solid var(--ui-border); border-left: 3px solid var(--ui-fail-line);
  border-radius: var(--ui-radius-sm); padding: 12px 16px; margin: 10px 0;
  background: var(--ui-surface); max-width: var(--ui-reading); }
.fc-card-head { font-weight: 700; margin-bottom: 6px; }
.fc-label { font-size: .733rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ui-text-muted); margin-top: 10px; font-weight: 600; }
.fc-claim, .fc-reason { font-size: .933rem; }
.fc-reason { margin-top: 4px; }
.fc-quote { color: var(--ui-text-muted); font-size: .867rem; margin-top: 4px; font-style: italic; }
blockquote.fc-quote { margin: 4px 0 0; }
.fc-ai-label { color: var(--ui-text-muted); font-size: .733rem; margin-top: 2px; }
.fc-fix { background: var(--ui-surface-soft); border-left: 3px solid var(--ui-accent);
  padding: 6px 10px; font-size: .933rem; margin-top: 4px; }
.fc-error { color: var(--ui-fail-text); }
.fc-dismissed, .fc-deleted { opacity: .55; }
.fc-delete-preview { border-left: 3px solid var(--ui-warn-line); padding: 6px 10px; margin: 6px 0; }
.fc-del { background: var(--ui-fail-bg); text-decoration: line-through; }
.fc-warn { color: var(--ui-warn-text); font-weight: 600; }
.fc-empty { color: var(--ui-text-muted); }

/* рекомендации */
.recs { margin: var(--ui-space-md) 0; }
.rec-note { color: var(--ui-text-muted); font-size: .867rem; margin: 0 0 8px; }
.rec-error { color: var(--ui-fail-text); }
.rec-card { border: 1px solid var(--ui-border); border-radius: var(--ui-radius-sm);
  padding: 12px 14px; margin-bottom: 8px; background: var(--ui-surface); }
.rec-card.with-check { display: flex; gap: 12px; align-items: flex-start; }
.rec-card.with-check > input[type=checkbox] { margin-top: 2px; flex: none; }
.rec-card .rec-body { flex: 1; min-width: 0; max-width: var(--ui-reading); }
.rec-card blockquote { margin: 0 0 6px; padding-left: 10px; border-left: 3px solid var(--ui-border);
  font-size: .867rem; color: var(--ui-text-muted); }
.rec-card p { margin: 4px 0; font-size: .933rem; }
.rec-card .rec-dismiss { margin-top: 6px; }
.rec-done { color: var(--ui-text-muted); font-size: .867rem; margin: 4px 0; }
.rec-done.rec-applied { color: var(--ui-ok-text); }
.rec-card.rec-blocked { border-left: 3px solid var(--ui-fail-line); background: var(--ui-fail-bg); }

/* подсветка запросов */
.hl-exact { background: var(--ui-hl-exact); border-radius: 3px; padding: 0 1px; }
.hl-wf { background: var(--ui-hl-wf); border-radius: 3px; padding: 0 1px; }
.hl-topic { background: var(--ui-hl-topic); border-radius: 3px; padding: 0 1px; }
.hl-diluted { background: var(--ui-hl-diluted); border-radius: 3px; padding: 0 1px; }
.hl-legend { font-size: .8rem; }
.hl-legend span { margin-right: 8px; padding: 1px 6px; }

.progress { height: 4px; background: var(--ui-border); border-radius: 2px; overflow: hidden; margin: 10px 0 4px; }
.progress .bar { width: 30%; height: 100%; background: var(--ui-cta);
  animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { margin-left: -30%; } to { margin-left: 100%; } }

/* цикл «Поведение»: окно подтверждения и панель «Принять» */
dialog.ui-confirm { border: 0; border-radius: var(--ui-radius); padding: 20px 24px; max-width: 460px;
  color: var(--ui-text); box-shadow: var(--ui-shadow); }
dialog.ui-confirm::backdrop { background: var(--ui-backdrop); }
dialog.ui-confirm h2 { margin: 0 0 8px; }
dialog.ui-confirm ul { margin: 8px 0 14px; padding-left: 20px; }
.accept-panel { border-left: 3px solid var(--ui-warn-line); background: var(--ui-warn-bg);
  border-radius: var(--ui-radius-sm); padding: 12px 16px; margin: 8px 0; }
.accept-panel ul { margin: 4px 0 8px; padding-left: 20px; }
.ap-info { color: var(--ui-text-muted); font-size: .867rem; }
