:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --ink: #16150f;
  --ink-2: #4a4944;
  --muted: #85837c;
  --line: #e4e2dc;
  --line-2: #d6d3cb;
  --soft: #f0eee9;
  --accent: #b3122b;
  --accent-ink: #ffffff;
  --accent-soft: #fbeef0;
  --blue: #2a78d6;
  --blue-soft: #edf4fd;
  --green: #1f7a4a;
  --green-soft: #e9f5ee;
  --amber: #a26100;
  --amber-soft: #fdf3e2;
  --red: #c0352b;
  --red-soft: #fcecea;
  --radius: 8px;
  --serif: "PT Serif", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PT Sans", Roboto, Arial, sans-serif;
  --mono: "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--sans); color: var(--ink); background: var(--bg); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 20px;
  height: 52px; padding: 0 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 6px;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; letter-spacing: .02em;
}
.tabs { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; }
.tabs a {
  padding: 6px 10px; border-radius: 6px; color: var(--ink-2); white-space: nowrap;
}
.tabs a:hover { background: var(--soft); text-decoration: none; }
.tabs a.active { background: var(--ink); color: #fff; }
.tabs a .count { color: var(--muted); font-size: 12px; margin-left: 2px; }
.tabs a.active .count { color: #c9c7c0; }
.tabs-sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
.cycle { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.cycle .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 4px; }
.cycle .dot.busy { background: var(--amber); animation: pulse 1s infinite; }
.cycle .dot.err { background: var(--red); }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  height: 34px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--line-2);
  background: var(--panel); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--soft); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: #9a0f24; }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-dark:hover { background: #333; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.loading { pointer-events: none; opacity: .7; }
.btn.loading::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line-2); border-radius: 6px; background: #fff; padding: 7px 10px;
}
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
.textarea { resize: vertical; line-height: 1.55; }
.label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 4px; }

/* ---------- layout ---------- */
main { height: calc(100vh - 52px); }
.split { display: grid; grid-template-columns: minmax(340px, 420px) 1fr; height: 100%; }
.list-pane { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--panel); min-height: 0; }
.detail-pane { overflow-y: auto; min-height: 0; }
.page { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; overflow-y: auto; height: 100%; }
.page h1 { font: 700 22px/1.25 var(--serif); margin: 0 0 4px; }
.page .sub { color: var(--muted); margin: 0 0 20px; }

/* ---------- story list ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.filters .input { flex: 1 1 160px; height: 32px; }
.filters .select { width: auto; height: 32px; padding: 4px 8px; }
.list-meta { padding: 6px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.story-list { overflow-y: auto; flex: 1; }
.story {
  display: grid; grid-template-columns: 36px 1fr; gap: 10px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.story:hover { background: #faf9f6; }
.story.active { background: var(--blue-soft); box-shadow: inset 3px 0 0 var(--blue); }
.story.seen .story-title { color: var(--ink-2); font-weight: 500; }
.score {
  width: 34px; height: 24px; border-radius: 5px; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; background: var(--soft); color: var(--muted);
}
.score.s-hi { background: var(--accent); color: #fff; }
.score.s-mid { background: #f4d6db; color: var(--accent); }
.score.s-lo { background: var(--soft); color: var(--muted); }
.story-title { font-weight: 600; line-height: 1.3; }
.story-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.story-meta .src { color: var(--ink-2); }
.flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.flag { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--soft); color: var(--ink-2); white-space: nowrap; }
.flag.draft { background: var(--green-soft); color: var(--green); }
.flag.sens { background: var(--amber-soft); color: var(--amber); }
.flag.dp { background: var(--accent-soft); color: var(--accent); }
.flag.tier1 { background: var(--blue-soft); color: var(--blue); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------- story detail ---------- */
.detail { padding: 18px 28px 40px; }
.detail-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; margin-bottom: 4px; }
.detail-head h1 { font: 700 21px/1.3 var(--serif); margin: 0; }
.detail-sub { color: var(--ink-2); margin: 6px 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 14px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--ink-2); background: #fff; }
.banner { border-radius: var(--radius); padding: 10px 12px; margin-bottom: 14px; font-size: 13px; }
.banner.dp { background: var(--accent-soft); color: #6d0a1a; }
.banner.sens { background: var(--amber-soft); color: #6b4000; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 420px); gap: 20px; align-items: start; }
.grid-2.sources-collapsed { grid-template-columns: minmax(0, 1fr) 44px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.card-h h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0; font-weight: 700; }
.card-b { padding: 14px; }

/* sources */
.src-item { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.src-item:last-child { border-bottom: 0; }
.src-item.primary { background: #f7fbff; box-shadow: inset 3px 0 0 var(--blue); }
.src-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.src-name { font-weight: 600; color: var(--ink); font-size: 13px; }
.tier { font-size: 11px; padding: 1px 6px; border-radius: 4px; font-weight: 600; }
.tier-1 { background: var(--blue-soft); color: var(--blue); }
.tier-2 { background: var(--green-soft); color: var(--green); }
.tier-3 { background: var(--soft); color: var(--ink-2); }
.tier-4 { background: var(--amber-soft); color: var(--amber); }
.src-title { margin: 4px 0 2px; font-weight: 500; }
.src-text { color: var(--ink-2); font-size: 13px; white-space: pre-wrap; max-height: 4.4em; overflow: hidden; position: relative; }
.src-text.open { max-height: none; }
.src-actions { display: flex; gap: 6px; margin-top: 6px; }
.related a { display: block; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.related a:last-child { border-bottom: 0; }
.related .date { color: var(--muted); font-size: 12px; }

/* editor */
.editor .card-b { display: grid; gap: 12px; }
.versions { display: flex; gap: 4px; flex-wrap: wrap; }
.ver { font-size: 12px; padding: 2px 8px; border-radius: 5px; border: 1px solid var(--line-2); background: #fff; cursor: pointer; }
.ver.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.title-input { font: 700 23px/1.3 var(--serif); padding: 10px 14px; resize: none; overflow: hidden; display: block; }
.body-input { min-height: 420px; font: 17px/1.7 var(--serif); padding: 16px 18px; resize: none; overflow: hidden; display: block; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.seg button.on { background: var(--ink); color: #fff; }
.preview { border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; background: #fff; font: 15.5px/1.6 var(--serif); min-height: 340px; }
.preview h1 { font-size: 22px; margin: 0 0 12px; line-height: 1.25; }
.preview p { margin: 0 0 12px; }
.preview blockquote { margin: 0 0 12px; padding: 4px 0 4px 14px; border-left: 3px solid var(--accent); color: var(--ink-2); font-style: italic; }
.editor-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.editor-row .spacer { flex: 1; }
.hint { font-size: 12px; color: var(--muted); }
.dirty { color: var(--amber); font-size: 12px; }

.checks { border-radius: 6px; border: 1px solid var(--line); background: #fcfcfa; }
.checks-h { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; font-size: 13px; font-weight: 600; }
.checks ul { list-style: none; margin: 0; padding: 0 12px 10px; display: grid; gap: 6px; }
.checks li { font-size: 13px; padding-left: 10px; border-left: 3px solid var(--line-2); }
.checks li.high { border-color: var(--red); }
.checks li.medium { border-color: var(--amber); }
.checks li.low { border-color: var(--line-2); }
.checks .frag { font-family: var(--mono); font-size: 12px; background: var(--soft); padding: 0 4px; border-radius: 3px; }
.checks .ok { color: var(--green); }
.notes { font-size: 13px; padding: 8px 12px; border-top: 1px solid var(--line); color: var(--ink-2); }

.regen { border: 1px dashed var(--line-2); border-radius: 6px; padding: 10px; background: #fff; display: grid; gap: 8px; }
.regen label.check { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink-2); }

.send-bar {
  position: sticky; bottom: 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 10px 14px; border-top: 1px solid var(--line); background: #fff; border-radius: 0 0 var(--radius) var(--radius);
}
.menu { position: relative; }
.menu-list {
  position: absolute; bottom: 38px; left: 0; z-index: 5; min-width: 230px; background: #fff;
  border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 4px;
}
.menu-list button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 5px; cursor: pointer; }
.menu-list button:hover { background: var(--soft); }

.write-cta { text-align: center; padding: 30px 20px; }
.write-cta p { color: var(--muted); margin: 0 0 14px; }
.write-cta .textarea { max-width: 520px; margin: 0 auto 12px; display: block; }

/* ---------- tables (sources) ---------- */
.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fbfaf8; }
.table td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13px; }
.table tr:last-child td { border-bottom: 0; }
.table tr.off td { opacity: .5; }
.table .input, .table .select { height: 30px; padding: 3px 8px; font-size: 13px; }
.table .err { color: var(--red); font-size: 12px; max-width: 220px; }
.mono { font-family: var(--mono); font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.form-row { display: grid; grid-template-columns: 2fr 2fr 1fr 1fr auto; gap: 8px; align-items: end; margin-bottom: 18px; }

/* ---------- prompts ---------- */
.ptabs { display: flex; gap: 6px; margin-bottom: 14px; }

.vlist { display: grid; gap: 2px; }
.vrow { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 7px 8px; border-radius: 6px; font-size: 12px; }
.vrow:hover { background: var(--soft); }
.vrow.active { background: var(--green-soft); }
.vrow .vnote { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }

/* ---------- settings ---------- */
.settings { display: grid; gap: 14px; max-width: 640px; }
.setting { display: grid; grid-template-columns: 1fr 140px; gap: 16px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.setting p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.stat b { display: block; font: 700 20px/1.2 var(--serif); }
.stat span { font-size: 12px; color: var(--muted); }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 50;
  display: flex; gap: 12px; align-items: center;
  background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  font-size: 13px; max-width: 90vw;
}
.toast.error { background: var(--red); }
.toast button { background: #fff; color: var(--ink); border: 0; border-radius: 5px; padding: 4px 10px; cursor: pointer; font-weight: 600; }

/* ---------- source chain & citations ---------- */
.chain { font-size: 12.5px; margin-top: 3px; color: var(--muted); line-height: 1.35; }
.chain-origin { color: var(--ink-2); font-weight: 600; }
.chain-origin.official { color: var(--blue); }
.chain-rest { color: var(--muted); }
.origin { padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fbfaf8; }
.origin-name { font-weight: 700; font-size: 14px; margin-top: 2px; }
.tier-primary { background: var(--blue); color: #fff; }
.role { font-size: 11px; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line-2); color: var(--ink-2); }
.role-origin { border-color: var(--blue); color: var(--blue); }
.role-adds { border-color: var(--green); color: var(--green); }
.cites { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 5px; font-size: 12px; }
.cite { padding: 1px 7px; border-radius: 999px; background: var(--soft); color: var(--ink-2); }
.cite small { color: var(--muted); }
.cite.to-primary { background: var(--blue-soft); color: var(--blue); }
.cite.ext { background: var(--amber-soft); color: var(--amber); }
.adds { font-size: 12.5px; color: var(--green); margin-top: 4px; }

/* ---------- editor: command bar, title counter, suggestions ---------- */
.cmd { display: grid; gap: 6px; padding: 10px; border-radius: 8px; background: #f7f6f2; border: 1px solid var(--line); }
.cmd-row { display: flex; gap: 6px; align-items: center; }
.cmd-row .input, .cmd-row .select { flex: 1; }
.quick { display: flex; flex-wrap: wrap; gap: 5px; }
.qchip { font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line-2); background: #fff; cursor: pointer; }
.qchip:hover { border-color: var(--ink-2); }
.qchip.loading { opacity: .6; pointer-events: none; }
.menu-list.menu-down { bottom: auto; top: 32px; right: 0; left: auto; }
.title-wrap { position: relative; }
.title-wrap .title-input { padding-right: 64px; }
.title-count { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.title-count.over { color: var(--red); font-weight: 700; }
.suggest { display: grid; gap: 6px; }
.suggest-card { display: grid; gap: 8px; padding: 10px 12px; border-radius: 8px; background: var(--green-soft); border: 1px solid #cbe6d6; }
.suggest-label { color: var(--green); font-weight: 600; }
.suggest-rule { font-weight: 600; }
.count.badge:not(:empty) { background: var(--green); color: #fff; border-radius: 999px; padding: 0 6px; font-size: 11px; }

/* ---------- publish modal ---------- */
.btn-lg { height: 40px; padding: 0 18px; font-size: 15px; }
.publish { display: grid; gap: 14px; }
.publish-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.more-formats summary { cursor: pointer; color: var(--ink-2); font-size: 13px; }
.publish-preview { max-height: 55vh; overflow-y: auto; }

/* ---------- prompt editor ---------- */
.page-wide { max-width: 1500px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.page-head .sub { max-width: 760px; }
.prompt-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr) 330px; gap: 16px; align-items: start; }
.prompt-side { display: grid; gap: 12px; position: sticky; top: 0; }
.prompt-main { display: grid; gap: 10px; }
.prompt-text { min-height: 62vh; font: 13px/1.6 var(--mono); }
.side-h { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 4px; }
.outline { display: grid; gap: 1px; max-height: 40vh; overflow-y: auto; }
.outline-item { text-align: left; border: 0; background: none; padding: 4px 6px; border-radius: 5px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.outline-item:hover { background: var(--soft); color: var(--ink); }
.outline-item.lvl-3 { padding-left: 16px; font-size: 12px; }
.rules { display: grid; gap: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.rule-row { display: flex; gap: 6px; align-items: flex-start; font-size: 12.5px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
.rule-row span { flex: 1; }
.x { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 2px; }
.x:hover { color: var(--red); }
.test-box { display: grid; gap: 6px; padding: 10px; border: 1px dashed var(--line-2); border-radius: 8px; background: #fff; }
.test-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.test-col { display: grid; gap: 6px; align-content: start; }
.test-col .preview { min-height: 0; max-height: 60vh; overflow-y: auto; font-size: 14.5px; }

/* ---------- modal & diff ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(20, 19, 15, .45); display: grid; place-items: center; padding: 20px; }
.modal { background: #fff; border-radius: 10px; width: min(640px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: min(1100px, 100%); }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-h h2 { margin: 0; font: 700 17px/1.3 var(--serif); }
.modal-b { padding: 16px; overflow-y: auto; }
.diff { font: 12.5px/1.55 var(--mono); border: 1px solid var(--line); border-radius: 6px; max-height: 60vh; overflow: auto; }
.d-line { white-space: pre-wrap; padding: 0 10px; }
.d-add { background: #e6f4ea; color: #145a32; }
.d-del { background: #fbe9e7; color: #8a1c13; text-decoration: line-through; text-decoration-color: rgba(138,28,19,.35); }
.d-ctx { color: var(--muted); }
.d-skip { padding: 4px 10px; color: var(--muted); background: #fbfaf8; font-style: italic; }

@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
  .prompt-grid { grid-template-columns: 1fr; }
  .prompt-side { position: static; }
  .test-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .split { grid-template-columns: 1fr; }
  .split.has-detail .list-pane { display: none; }
  .split:not(.has-detail) .detail-pane { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .cycle-text { display: none; }
}

/* ---------- учимся у dp.ru ---------- */
.learn { margin-bottom: 24px; }
.learn .table { margin-top: 4px; }
.examples summary { cursor: pointer; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.examples a { display: block; font-size: 12px; padding: 3px 0; max-width: 360px; }
.section-h { font: 700 16px/1.3 var(--serif); margin: 8px 0 10px; }

/* ---------- chat ---------- */
.chat-layout { display: grid; grid-template-columns: 260px 1fr; height: 100%; }
.chat-side { border-right: 1px solid var(--line); background: var(--panel); padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.chat-list { overflow-y: auto; display: grid; gap: 2px; align-content: start; }
.chat-item { position: relative; padding: 8px 26px 8px 10px; border-radius: 6px; cursor: pointer; }
.chat-item:hover { background: var(--soft); }
.chat-item.active { background: var(--blue-soft); }
.chat-item-title { font-size: 13px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.chat-item .x { position: absolute; right: 6px; top: 8px; visibility: hidden; }
.chat-item:hover .x { visibility: visible; }
.chat-main { display: flex; flex-direction: column; min-height: 0; }
.chat-feed { flex: 1; overflow-y: auto; padding: 20px max(20px, calc((100% - 860px) / 2)); display: flex; flex-direction: column; gap: 10px; }
.chat-composer { display: flex; gap: 8px; align-items: flex-end; padding: 12px max(20px, calc((100% - 860px) / 2)) 16px; border-top: 1px solid var(--line); background: var(--panel); }
.chat-input { resize: none; min-height: 42px; max-height: 220px; }
.chat-empty { margin: auto; text-align: center; max-width: 620px; display: grid; gap: 10px; justify-items: center; }
.chat-empty h2 { font: 700 20px/1.3 var(--serif); margin: 0; }
.chat-empty .quick { justify-content: center; }
.msg { display: flex; }
.msg-user { justify-content: flex-end; }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: 12px; line-height: 1.5; white-space: pre-wrap; }
.msg-user .bubble { background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.msg-assistant .bubble { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; white-space: normal; max-width: 100%; }
.bubble.error { background: var(--red-soft); border-color: #f2c9c4; color: #8a1c13; }
.bubble.md p { margin: 0 0 8px; } .bubble.md p:last-child { margin-bottom: 0; }
.bubble.md ul, .bubble.md ol { margin: 4px 0 8px; padding-left: 20px; } .bubble.md li { margin-bottom: 4px; }
.bubble.md h4 { margin: 10px 0 6px; font-size: 14px; }
.chat-step { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; padding-left: 4px; }
.step-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: none; }
.chat-step.pending .step-dot { background: var(--amber); animation: pulse 1s infinite; }
.chat-thinking { font-size: 12.5px; color: var(--muted); font-style: italic; padding-left: 4px; }
.art-card { border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 12px; display: grid; gap: 10px; }
.art-head { display: flex; justify-content: space-between; align-items: center; }
.art-card .preview { min-height: 0; border: 0; padding: 0; font-size: 15px; }
.art-card .preview h1 { font-size: 20px; }
.art-card details summary { cursor: pointer; font-size: 13px; font-weight: 600; }
@media (max-width: 760px) { .chat-layout { grid-template-columns: 1fr; } .chat-side { display: none; } .bubble { max-width: 92%; } }

/* ---------- обновления источников ---------- */
.flag.upd { background: #fff3d6; color: #8a5a00; }
.upd-banner { border: 1px solid #f0d58c; background: #fffaf0; border-radius: 8px; padding: 10px 12px; display: grid; gap: 8px; }
.upd-h { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.change { display: grid; gap: 2px; font-size: 12.5px; }
.change .d-line { border-radius: 4px; padding: 2px 8px; font-family: inherit; }
.item-changes { margin-top: 5px; font-size: 12.5px; }
.item-changes summary { cursor: pointer; color: var(--ink-2); }
.item-changes .change { margin-top: 6px; }

/* ---------- статья во всю ширину ---------- */
.split.focus { grid-template-columns: minmax(0, 1fr); }
.split.focus .list-pane { display: none; }
.head-actions { flex-wrap: nowrap; }
.side-col { position: sticky; top: 12px; max-height: calc(100vh - 52px - 24px); overflow-y: auto; display: grid; gap: 12px; align-content: start; }
.side-col .side-hide { justify-self: end; }
.side-col.collapsed { overflow: visible; }
.rail { width: 44px; min-height: 220px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); cursor: pointer;
  writing-mode: vertical-rl; transform: rotate(180deg); font-size: 13px; color: var(--ink-2); padding: 12px 0; }
.rail:hover { background: var(--soft); }
.edit-pane { display: grid; gap: 10px; align-content: start; }
.work { display: grid; gap: 16px; }
.work.mode-split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.work.mode-split .preview { position: sticky; top: 12px; max-height: calc(100vh - 52px - 120px); overflow-y: auto; }
.work.mode-edit .edit-pane, .work.mode-preview .preview { max-width: 980px; width: 100%; justify-self: center; }
.preview { font-size: 17px; }
.editor .send-bar { position: sticky; bottom: 0; z-index: 3; box-shadow: 0 -6px 16px rgba(0,0,0,.04); }
@media (max-width: 1250px) { .work.mode-split { grid-template-columns: 1fr; } .work.mode-split .preview { position: static; max-height: none; } }
.suggest-fold { border: 1px solid #cbe6d6; background: var(--green-soft); border-radius: 8px; padding: 7px 12px; }
.suggest-fold summary { cursor: pointer; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest-fold[open] summary { margin-bottom: 8px; }
.suggest-fold .suggest-card { background: #fff; }
