:root {
  /* Цвета групп ссылок: внутренние посты — синий, внешние — красный. */
  --scope-internal: #1f63c6;
  --scope-internal-soft: #e8f0fc;
  --scope-internal-line: #9dbdea;
  --scope-external: #c0392b;
  --scope-external-soft: #fcebe9;
  --scope-external-line: #ecaaa3;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #dde3ea;
  --border-strong: #c6cfd9;
  --text: #17222d;
  --muted: #5b6876;
  --faint: #8a96a3;
  --accent: #244766;
  --accent-hover: #1a3650;
  --accent-soft: #e6edf5;
  --accent-text: #ffffff;
  --link: #1f5a8c;
  --ok: #1d7448;
  --ok-soft: #e4f3ea;
  --warn: #8f5b00;
  --warn-soft: #fcf1dc;
  --danger: #b0302f;
  --danger-soft: #fbe9e8;
  --info: #3d4fa3;
  --info-soft: #eaedfa;
  --neutral-soft: #eef1f4;
  --shadow: 0 1px 2px rgba(16, 32, 48, .06), 0 2px 8px rgba(16, 32, 48, .04);
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}

.benchmark-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ai-proposal, .test-case { min-width: 0; }
/* Чат с ИИ: одно окно переписки, правка правил — внутри ответа ИИ, история — свёрнутым списком ниже */
.chat-page { max-width: 980px; margin: 0 auto; }
.card.chat-box { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.chat-head { padding: 16px 20px 12px; border-bottom: 1px solid var(--border); }
.chat-head h2 { margin-bottom: 4px; }
.chat-head p { margin: 0; font-size: .9rem; }
.chat-thread { display: flex; flex-direction: column; gap: 14px; padding: 18px 20px; min-height: 260px;
  max-height: min(64vh, 760px); overflow-y: auto; background: var(--bg); }
.chat-empty { margin: auto; max-width: 560px; text-align: center; color: var(--muted); }
.msg { display: flex; flex-direction: column; max-width: 86%; min-width: 0; }
.msg-user { align-self: flex-end; align-items: flex-end; }
.msg-ai { align-self: flex-start; }
.msg-bubble { padding: 10px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface);
  overflow-wrap: anywhere; min-width: 0; max-width: 100%; }
.msg-user .msg-bubble { background: var(--accent-soft); border-color: transparent; border-bottom-right-radius: 4px; }
.msg-ai .msg-bubble { border-bottom-left-radius: 4px; }
.msg-text { white-space: pre-wrap; }
.msg-quote { border-left: 3px solid var(--border-strong); padding: 2px 0 2px 10px; margin-bottom: 8px; font-size: .9rem; }
.quote-text { white-space: pre-wrap; }
.msg-meta { color: var(--faint); font-size: .78rem; margin-top: 4px; padding: 0 4px; }
.chat-image { display: block; max-width: 100%; max-height: 320px; object-fit: contain; margin-top: 10px; border-radius: 8px; }
.ai-proposal { margin-top: 12px; padding: 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-2); }
.proposal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.proposal-focus, .proposal-note { font-size: .9rem; margin: 0 0 6px; }
.proposal-diff > summary { cursor: pointer; color: var(--link); font-size: .9rem; }
.proposal-diff[open] > summary { margin-bottom: 6px; }
.proposal-change { border-top: 1px solid var(--border); padding: 8px 0; }
.proposal-change > summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
.proposal-change pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: .86rem; max-height: 280px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; margin: 4px 0 0; }
.diff-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 6px; }
.diff-cols p { margin: 0; font-size: .8rem; }
.proposal-actions { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-start; margin-top: 10px; }
.proposal-actions form { margin: 0; }
.ai-proposal .hint { margin: 8px 0 0; font-size: .8rem; color: var(--muted); }
.proposal-redo > summary { list-style: none; }
.proposal-redo > summary::-webkit-details-marker { display: none; }
.proposal-redo[open] { flex-basis: 100%; }
.proposal-redo form { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; align-items: flex-start; }
.proposal-redo textarea { min-height: 64px; font-family: inherit; font-size: .9rem; }
.msg-typing .msg-bubble { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.typing { display: inline-flex; gap: 3px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: typing 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .typing i { animation: none; opacity: .6; } }
.inline-form { display: inline; margin: 0; }
.chat-composer { border-top: 1px solid var(--border); padding: 12px 16px 14px; background: var(--surface); }
.chat-composer textarea { min-height: 72px; max-height: 260px; font-family: inherit; font-size: .95rem; resize: vertical; }
.chat-composer.dragging { outline: 2px dashed var(--accent); outline-offset: -6px; }
.composer-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.composer-bar .hint { flex: 1; min-width: 200px; color: var(--muted); font-size: .8rem; }
select.composer-model { width: auto; max-width: 260px; min-height: 36px; padding: 4px 8px; font-size: .86rem; }
.composer-preview { position: relative; display: inline-block; margin-bottom: 8px; }
.composer-preview[hidden] { display: none; }
.composer-preview img { display: block; max-height: 140px; max-width: 260px; border-radius: 8px; border: 1px solid var(--border); }
.preview-remove { position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 1rem; line-height: 1; cursor: pointer; }
.composer-attached { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; font-size: .9rem; background: var(--surface-2); }
.composer-attached-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 6px; }
.composer-attached-row select { width: auto; min-height: 32px; padding: 3px 8px; }
.inline-label { margin: 0; }
.chat-history { margin-top: 16px; }
.chat-history > summary { cursor: pointer; }
.chat-history[open] > summary { margin-bottom: 10px; }
.history-list { list-style: none; margin: 0; padding: 0; }
.history-list > li { border-top: 1px solid var(--border); padding: 10px 0; }
.history-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.history-request { margin: 6px 0; font-size: .9rem; overflow-wrap: anywhere; }
.history-list details > summary { cursor: pointer; color: var(--link); font-size: .9rem; }
@media (max-width: 640px) {
  .msg { max-width: 96%; }
  .chat-thread { padding: 12px; max-height: 70vh; }
  .diff-cols { grid-template-columns: minmax(0, 1fr); }
  .chat-composer { padding: 10px 12px; }
}
.test-case { padding: 16px 0; border-top: 1px solid var(--border); }
.test-case > summary { overflow-wrap: anywhere; }
.test-case .chip { margin-left: 12px; }
.case-excerpt { display: block; font-weight: normal; margin: 8px 0 0 20px; }
.ai-state p { overflow-wrap: anywhere; }
@media (max-width: 800px) { .benchmark-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c;
    --surface: #182029;
    --surface-2: #1d2631;
    --border: #2a3542;
    --border-strong: #3a4756;
    --text: #e4e9ee;
    --muted: #a3afbb;
    --faint: #7c8895;
    --accent: #5b8fc4;
    --accent-hover: #74a3d3;
    --accent-soft: #1e2d3d;
    --accent-text: #0d1620;
    --link: #8dbbe8;
    --ok: #6fcf9a;
    --ok-soft: #173326;
    --warn: #e7b65c;
    --warn-soft: #362a12;
    --danger: #f08a86;
    --danger-soft: #3a1c1c;
    --info: #a5b2f2;
    --info-soft: #232a4a;
    --neutral-soft: #222c37;
    --shadow: none;
    --scope-internal: #6ea8ff;
    --scope-internal-soft: #172741;
    --scope-internal-line: #2f4f80;
    --scope-external: #ff8a7f;
    --scope-external-soft: #3a1d1d;
    --scope-external-line: #7a3530;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; font-weight: 650; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
.faint { color: var(--faint); }
code, .mono { font-family: var(--mono); font-size: .88em; }

/* --- Шапка -------------------------------------------------------------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  max-width: 1320px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 24px; min-height: 56px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand-logo { display: block; width: 32px; height: 32px; flex: none; }
.auth .brand-logo { width: 40px; height: 40px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; font-size: .85rem; font-weight: 800;
}
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 7px; font-weight: 550; }
.nav a:hover { background: var(--neutral-soft); color: var(--text); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--accent-soft); }
.userbox { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9rem; }
.userbox form { margin: 0; }

.page { max-width: 1320px; margin: 0 auto; padding: 24px 16px 48px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.footer { text-align: center; color: var(--faint); font-size: .8rem; padding: 0 16px 24px; }

/* --- Карточки и сетки ---------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; min-width: 0;
}
.card > h2:first-child, .card > h3:first-child { margin-bottom: .75rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: .75rem; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.projects-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.project-card { display: flex; flex-direction: column; gap: 10px; margin: 0; color: var(--text); }
.project-card:hover { border-color: var(--border-strong); text-decoration: none; }
.project-card h2 { margin: 0; font-size: 1.08rem; }
.project-card .person { color: var(--muted); font-size: .92rem; }
.project-card .numbers { display: flex; gap: 18px; flex-wrap: wrap; }
.project-card .numbers b { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.project-card .numbers span { color: var(--muted); font-size: .82rem; }
.project-card .state { margin-top: auto; font-size: .88rem; color: var(--muted); }

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
@media (max-width: 760px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tile .value { font-size: 1.45rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile .label { color: var(--muted); font-size: .84rem; }
.tile.warn .value { color: var(--warn); }
.tile.danger .value { color: var(--danger); }
.tile.ok .value { color: var(--ok); }

/* --- Кнопки и формы ------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 7px 14px; font: inherit; font-weight: 600; cursor: pointer;
  min-height: 36px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: .88rem; }
.btn.link { border: none; background: none; color: var(--link); padding: 0; min-height: 0; font-weight: 500; }
.btn.link:hover { text-decoration: underline; background: none; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .hint { color: var(--muted); font-size: .84rem; margin-top: 4px; font-weight: 400; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; min-height: 38px;
}
textarea { min-height: 140px; resize: vertical; font-family: var(--mono); font-size: .88rem; }
input:focus, select:focus, textarea:focus, .btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
input[type=file] { font: inherit; font-size: .9rem; max-width: 100%; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; margin-bottom: 10px; }
.check input { margin-top: 4px; }
.row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
fieldset.plain-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
details.more { border: 1px dashed var(--border-strong); border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; }
details.more summary { cursor: pointer; font-weight: 600; }
details.more[open] summary { margin-bottom: 10px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin: 0; min-width: 160px; }
.filters .grow { flex: 1; min-width: 200px; }
.filters .check { margin: 0 0 8px; }

/* --- Сообщения ----------------------------------------------------------- */
.flash { border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; border: 1px solid; }
.flash.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.flash.error { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.flash.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.flash.info { background: var(--info-soft); border-color: transparent; color: var(--info); }

/* --- Вкладки ------------------------------------------------------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a {
  padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { color: var(--faint); font-weight: 500; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* --- Таблицы ------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 650;
     background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.url { max-width: 380px; overflow-wrap: anywhere; }
td.text { min-width: 280px; max-width: 560px; white-space: pre-wrap; overflow-wrap: anywhere; }
td.reason { min-width: 200px; max-width: 340px; color: var(--muted); font-size: .86rem; }
td .meta { color: var(--faint); font-size: .8rem; margin-top: 4px; white-space: normal; }
table.plain th { background: none; }
table.compact td, table.compact th { padding: 6px 10px; }
tr.saved td { background: var(--ok-soft); transition: background .6s; }

.pager { display: flex; gap: 6px; align-items: center; justify-content: space-between; margin-top: 12px; flex-wrap: wrap; }
.pager .pages { display: flex; gap: 6px; }

/* --- Метки --------------------------------------------------------------- */
.chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: var(--neutral-soft); color: var(--muted); white-space: nowrap;
}
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.accent { background: var(--accent-soft); color: var(--link); }
.tone-позитив { background: var(--ok-soft); color: var(--ok); }
.tone-негатив { background: var(--danger-soft); color: var(--danger); }
.tone-вопрос { background: var(--info-soft); color: var(--info); }
.tone-спам { background: var(--warn-soft); color: var(--warn); }
select.category { min-width: 190px; min-height: 32px; padding: 4px 8px; font-size: .88rem; }

/* --- Ход работы ---------------------------------------------------------- */
progress {
  width: 100%; height: 10px; border: none; border-radius: 999px; overflow: hidden;
  background: var(--neutral-soft); appearance: none; -webkit-appearance: none;
}
progress::-webkit-progress-bar { background: var(--neutral-soft); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
progress.thin { height: 6px; }
.progress-line { display: flex; justify-content: space-between; gap: 12px; font-size: .88rem; color: var(--muted); margin: 10px 0 4px; flex-wrap: wrap; }
.current { font-size: .88rem; color: var(--muted); overflow-wrap: anywhere; margin-top: 8px; }
.log {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  font-family: var(--mono); font-size: .8rem; line-height: 1.55; max-height: 320px; overflow-y: auto;
  white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted);
}
.log .time { color: var(--faint); margin-right: 8px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); margin-right: 6px; vertical-align: middle; }
.dot.ok { background: var(--ok); }
.dot.busy { background: var(--accent); animation: pulse 1.4s infinite; }
.dot.bad { background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .dot.busy { animation: none; } }

.bars td { padding-top: 6px; padding-bottom: 6px; }
.bars progress { height: 8px; min-width: 80px; }

/* --- Вход ---------------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 420px; padding: 28px; }
.auth .brand { margin-bottom: 18px; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty h2 { color: var(--text); }
.split { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.stack > * + * { margin-top: 8px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }

@media (max-width: 640px) {
  .page { padding: 16px 16px 40px; }
  .topbar-inner { gap: 10px; padding: 8px 16px; }
  .nav { order: 3; flex-basis: 100%; }
  h1 { font-size: 1.35rem; }
  .card { padding: 14px; }
  .filters .field, .filters .grow { min-width: 100%; }
}
.inline-check { display: inline-flex; margin: 0 0 0 4px; font-weight: 400; font-size: inherit; }
.task { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; background: var(--surface-2); }
.task-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.task-head .muted { margin-left: auto; font-size: .88rem; }
.key-box { font-family: var(--mono); font-size: .9rem; background: var(--surface-2); border: 1px dashed var(--border-strong);
  border-radius: 8px; padding: 10px 12px; overflow-wrap: anywhere; user-select: all; }
.mt { margin-top: 14px; }
.compare-list { margin-top: 6px; }
.compare-list .differs { color: var(--warn); }
.compare-list .same { color: var(--faint); }
.category-rule, .example-rule { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin: 12px 0; }
.category-rule .row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.category-rule .grow { grid-column: 1 / -1; }
.example-rule summary { cursor: pointer; overflow-wrap: anywhere; }
.example-rule form { margin-top: 12px; }
.comment-quote { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 360px; overflow-y: auto; }
.reply-parent { border-left: 3px solid var(--border-strong); padding: 6px 10px; margin-top: 8px; color: var(--muted); font-size: .88rem; }
#comments td.text { white-space: normal; }
.comment-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.category-rule input, .category-rule textarea, .category-rule select, .example-rule textarea, .example-rule select { font-weight: 400; }
@media (max-width: 640px) { .category-rule .row { grid-template-columns: minmax(0, 1fr); } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.method-flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 18px 0 24px; }
.method-flow > div { display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: var(--surface-2); }
.method-flow span { color: var(--link); font-size: .85rem; font-weight: 600; }
.method-flow small { color: var(--muted); line-height: 1.5; }
.knowledge-section { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin: 10px 0 14px; }
.knowledge-section > summary { display: flex; align-items: center; gap: 10px; cursor: pointer; flex-wrap: wrap; }
.knowledge-section > summary::before { content: '▸'; color: var(--faint); }
.knowledge-section[open] > summary::before { content: '▾'; }
.knowledge-section > summary .chip { margin-left: auto; }
.section-number { color: var(--link); font-size: .85rem; }
.knowledge-section textarea { font-weight: 400; min-height: 180px; }
.knowledge-section [name=preview_comment], .knowledge-section [name=preview_context] { min-height: 100px; }
.knowledge-section > p { margin-top: 12px; }
.category-rule > summary { display: flex; flex-direction: column; gap: 3px; cursor: pointer; }
.category-rule > summary small { color: var(--muted); font-weight: 400; }
.category-rule[open] > summary { margin-bottom: 14px; }
.method-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.method-stats b { display: block; font-size: 1.6rem; }
.method-stats span { color: var(--muted); font-size: .85rem; }
.methodology-form { max-width: 1040px; margin: 0 auto; }
.reference-fragment { border-left: 3px solid var(--border-strong); margin: 12px 0; padding: 8px 12px; background: var(--surface-2); }
.prompt-preview { max-height: 420px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .82rem; padding: 12px; background: var(--surface-2); border-radius: 8px; }
@media (max-width: 1050px) { .method-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1051px) { .knowledge-layout { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); } }
@media (max-width: 640px) { .knowledge-section { padding: 10px; } .knowledge-section > summary .chip { margin-left: 0; } }

/* Обзор: итоги за период и ИИ-отчёт */
.period-form .quick { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.tile .sub { color: var(--faint); font-size: .8rem; margin-top: 2px; }
.delta { font-weight: 600; white-space: nowrap; color: var(--muted); }
.delta.good { color: var(--ok); }
.delta.bad { color: var(--danger); }
.tone-bar-позитив::-webkit-progress-value { background: var(--ok); }
.tone-bar-позитив::-moz-progress-bar { background: var(--ok); }
.tone-bar-негатив::-webkit-progress-value { background: var(--danger); }
.tone-bar-негатив::-moz-progress-bar { background: var(--danger); }
.daily { display: grid; gap: 4px; }
.daily-row { display: grid; grid-template-columns: 74px minmax(0, 1fr) 44px; gap: 8px; align-items: center; font-size: .85rem; }
.daily-day { white-space: nowrap; font-variant-numeric: tabular-nums; }
.daily-bar { display: block; width: 100%; height: 12px; background: var(--accent-soft); border-radius: 3px; overflow: hidden; }
.daily-bar .pos { fill: var(--ok); }
.daily-bar .neg { fill: var(--danger); }
.daily-bar .oth { fill: var(--accent); fill-opacity: .55; }
.dot.pos { background: var(--ok); }
.dot.neg { background: var(--danger); }
.dot.oth { background: var(--accent); opacity: .55; }
.legend { color: var(--muted); font-size: .82rem; margin-top: 10px; }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 10px; vertical-align: -1px; }
.legend .dot:first-child { margin-left: 0; }
.post-list, .topic-list { margin: 0; padding-left: 20px; }
.post-list li, .topic-list li { margin-bottom: 10px; overflow-wrap: anywhere; }
.post-list .topic { font-weight: 550; }
.report-text { white-space: pre-line; overflow-wrap: anywhere; }
.report-block { border-left: 3px solid var(--border-strong); padding-left: 12px; }
.report-block.pos { border-color: var(--ok); }
.report-block.neg { border-color: var(--danger); }
tr.current td { background: var(--accent-soft); }
.report-pick > summary { cursor: pointer; font-weight: 600; }
.report-pick[open] > summary { margin-bottom: 8px; }
.danger-zone { border-color: var(--danger); }
@media (max-width: 640px) {
  .report-list tr { display: block; padding: 6px 0; border-bottom: 1px solid var(--border); }
  .report-list tr:last-child { border-bottom: 0; }
  .report-list td { display: inline; padding: 0 8px 0 0; border: 0; white-space: normal; }
  .report-list td:first-child { display: block; }
}

/* Календарь выбора дат: период «Обзора» и неделя ИИ-отчёта */
.cal-anchor { position: relative; }
.cal-caption { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
.cal-trigger { gap: 4px 8px; font-weight: 600; font-variant-numeric: tabular-nums; flex-wrap: wrap; max-width: 100%;
  white-space: normal; justify-content: flex-start; text-align: left; }
.cal-trigger .cal-sub { color: var(--muted); font-weight: 400; font-size: .86rem; }
.cal-icon { fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; color: var(--link); flex: none; }
.cal-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 9; width: max-content; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(16, 32, 48, .18); padding: 12px 14px;
}
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cal-hint { flex: 1; text-align: center; color: var(--muted); font-size: .85rem; }
.cal-nav {
  width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--text); font: inherit; font-size: 1.15rem; line-height: 1; cursor: pointer;
}
.cal-nav:hover:not(:disabled) { background: var(--surface-2); }
.cal-nav:disabled { opacity: .35; cursor: default; }
.cal-months { display: flex; gap: 22px; }
.cal-title { text-align: center; font-weight: 650; margin-bottom: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 38px); row-gap: 3px; }
.cal-wd { text-align: center; color: var(--faint); font-size: .76rem; padding-bottom: 2px; }
.cal-day {
  position: relative; height: 36px; border: 0; background: none; color: var(--text); font: inherit;
  font-size: .9rem; font-variant-numeric: tabular-nums; cursor: pointer; border-radius: 8px;
}
.cal-day:hover:not(:disabled) { background: var(--neutral-soft); }
.cal-day:disabled { color: var(--faint); opacity: .45; cursor: default; }
.cal-day.is-today { font-weight: 750; text-decoration: underline; text-underline-offset: 3px; }
.cal-day.in-range { background: var(--accent-soft); border-radius: 0; }
.cal-day.edge-start { border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
.cal-day.edge-end { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }
.cal-day.edge-start, .cal-day.edge-end, .cal-day.edge-start:hover, .cal-day.edge-end:hover {
  background: var(--accent); color: var(--accent-text); opacity: 1;
}
.cal-day:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; z-index: 1; }
.cal-day.has-data::after {
  content: ""; position: absolute; left: 50%; bottom: 4px; width: 4px; height: 4px; margin-left: -2px;
  border-radius: 50%; background: var(--link);
}
.cal-day.edge-start.has-data::after, .cal-day.edge-end.has-data::after { background: var(--accent-text); }
.cal-day.has-report::before {
  content: ""; position: absolute; left: 7px; right: 7px; bottom: 0; height: 3px; border-radius: 2px; background: var(--ok);
}
.cal-foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
}
.cal-legend { color: var(--muted); font-size: .8rem; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.cal-key { display: inline-block; width: 14px; height: 14px; position: relative; margin-left: 6px; }
.cal-key:first-child { margin-left: 0; }
.cal-key.has-data::after { content: ""; position: absolute; left: 5px; top: 5px; width: 4px; height: 4px; border-radius: 50%; background: var(--link); }
.cal-key.has-report::before { content: ""; position: absolute; left: 1px; right: 1px; bottom: 3px; height: 3px; border-radius: 2px; background: var(--ok); }
.cal-summary { flex: 1; min-width: 180px; text-align: right; font-size: .88rem; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .cal-pop { position: fixed; left: 16px; right: 16px; top: auto; bottom: 16px; width: auto; max-width: none; z-index: 30; }
  .cal-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .cal-months > * { flex: 1; }
  .cal-summary { text-align: left; }
}

/* Правки для ИИ над таблицей комментариев */
.corrections-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.corrections-head h2 { margin-bottom: 4px; }
.corrections-head select { max-width: 280px; }

/* Группы ссылок: внутренние и внешние посты */
.scope-switch { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 10px; }
.scope-switch a { padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-weight: 550; }
.scope-switch a:hover { border-color: var(--border-strong); text-decoration: none; }
.scope-switch a.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.scope-switch a.scope-internal, .tab-group.scope-internal { --scope: var(--scope-internal); --scope-soft: var(--scope-internal-soft); --scope-line: var(--scope-internal-line); }
.scope-switch a.scope-external, .tab-group.scope-external { --scope: var(--scope-external); --scope-soft: var(--scope-external-soft); --scope-line: var(--scope-external-line); }
.scope-switch a.scope-internal, .scope-switch a.scope-external { color: var(--scope); border-color: var(--scope-line); }
.scope-switch a.scope-internal.is-current, .scope-switch a.scope-external.is-current { background: var(--scope-soft); border-color: var(--scope); }
.scope-switch a.scope-internal.active, .scope-switch a.scope-external.active { background: var(--scope); border-color: var(--scope); color: var(--surface); }
.tabs .tab-group { display: flex; gap: 2px; padding: 0 4px; margin: 0 6px -1px 0; border: 1px solid var(--scope-line, var(--border)); border-bottom: 0;
  border-radius: 10px 10px 0 0; background: var(--scope-soft, transparent); flex: none; }
.tabs .tab-group a.active { border-bottom-color: var(--scope, var(--accent)); color: var(--scope, var(--text)); }
.scope-switch a .count { margin-left: 6px; opacity: .75; font-weight: 400; }
.scope-legacy { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.scope-legacy form { display: inline; }
.scope-pick { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.scope-pick legend { font-weight: 600; padding: 0 4px; }
.scope-pick .required { color: var(--muted); font-weight: 400; font-size: .84rem; }
.move-link { display: block; margin-top: 4px; }
.link-button { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: .84rem; }
.link-button:hover { text-decoration: underline; }
.counted { margin: -6px 0 12px; }
.overview-pick .check { display: flex; }

/* Отбор публикаций по персоне (вкладка «Ссылки»). */
.focus-counts { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: baseline; }
.focus-counts a { text-decoration: none; }
.focus-counts a:hover b { text-decoration: underline; }
.focus-form { margin-top: 12px; }
.focus-form > summary { cursor: pointer; color: var(--link); }
.focus-form form { margin-top: 12px; }
td.focus-cell { min-width: 150px; max-width: 260px; font-size: .86rem; }
textarea.focus-details { min-height: 72px; font-family: inherit; font-size: inherit; }
