/* Уголовные дела — отдельный сайт.

   Тот же язык, что у панели: почти чёрный фон, текст и волосяные линии,
   один акцент (лаванда). Своё здесь — устройство страницы: реестр как
   таблица без коробок, редактор в три колонки (оглавление, документ,
   ИИ-помощник) и лист документа, набранный антиквой, как бумага. */

:root {
  --bg: #08090c;
  --bg-float: #111217;
  --surface: rgba(255, 255, 255, .03);
  --surface-2: rgba(255, 255, 255, .05);
  --surface-3: rgba(255, 255, 255, .08);
  --field: rgba(255, 255, 255, .025);
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .11);
  --line-3: rgba(255, 255, 255, .18);

  --text: #e9eaee;
  --text-2: #9b9ea9;
  --text-3: #676a75;

  --acc: #aaa3ff;
  --acc-strong: #bdb7ff;
  --acc-ink: #121025;
  --acc-soft: rgba(170, 163, 255, .1);
  --acc-line: rgba(170, 163, 255, .38);

  --ok: #56c596;
  --bad: #ec6a6f;
  --bad-soft: rgba(236, 106, 111, .1);
  --wait: #d9b15f;
  --blue: #7fb0ff;

  --r-sm: 6px;
  --r: 8px;
  --r-lg: 12px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --serif: "PT Serif", Georgia, "Times New Roman", serif;
  --shadow: 0 16px 40px -16px rgba(0, 0, 0, .85);
  --top-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
html { background: var(--bg); color-scheme: dark; }
body { min-height: 100dvh; background: var(--bg); color: var(--text); font: 14px/1.55 var(--font); letter-spacing: -.003em; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
[hidden] { display: none !important; }
a { color: var(--acc); text-decoration: none; }
a:hover { color: var(--acc-strong); }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.02em; }
p { margin: 0; }
.spacer { flex: 1; }

/* Цвет статуса — одна переменная на все места, где он виден. */
.s-open { --c: var(--acc); }
.s-inv { --c: var(--wait); }
.s-court { --c: var(--blue); }
.s-closed { --c: var(--text-3); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes breathe { 50% { opacity: .35; } }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ================= Элементы ================= */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 32px; padding: 0 12px;
  border-radius: var(--r); white-space: nowrap; cursor: pointer; text-decoration: none;
  font-size: 13px; font-weight: 500; line-height: 1.1; color: var(--text);
  background: transparent; border: 1px solid var(--line-2); transition: background .15s, border-color .15s, color .15s, opacity .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-3); color: #fff; }
.btn:active { opacity: .8; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn svg { flex: none; }
.btn-sm { min-height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-lg { min-height: 42px; padding: 0 18px; font-size: 14px; border-radius: 10px; }
.btn-primary { background: var(--acc); border-color: transparent; color: var(--acc-ink); font-weight: 600; }
.btn-primary:hover { background: var(--acc-strong); border-color: transparent; color: var(--acc-ink); }
.btn-ghost { border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: transparent; border-color: transparent; color: var(--text); }

.icon-btn { display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: var(--r); color: var(--text-3); transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

kbd { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 5px; font: 10.5px/1 var(--mono); color: var(--text-3); border: 1px solid var(--line-2); }

input[type="text"], input[type="search"], textarea, select {
  height: 36px; padding: 0 12px; border-radius: var(--r); outline: none; font-size: 13.5px; color: var(--text);
  background: var(--field); border: 1px solid var(--line-2); transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 12px; line-height: 1.6; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:hover, textarea:hover, select:hover { border-color: var(--line-3); }
input:focus, textarea:focus, select:focus { border-color: var(--acc-line); box-shadow: 0 0 0 3px var(--acc-soft); }
select { cursor: pointer; }
select option { background: var(--bg-float); color: var(--text); }

.seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 9px; border: 1px solid var(--line); }
.seg button { padding: 4px 11px; border: 0; border-radius: 7px; cursor: pointer; background: transparent; font-size: 12.5px; font-weight: 500; color: var(--text-3); transition: background .15s, color .15s; }
.seg button:hover { color: var(--text); }
.seg button.is-active { color: var(--text); background: var(--surface-3); }

/* ================= Вход ================= */

.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card { max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; animation: rise .6s var(--ease); }
.gate-mark { color: var(--acc); }
.gate h1 { font-size: 30px; letter-spacing: -.04em; }
.gate p { margin-bottom: 8px; line-height: 1.6; color: var(--text-2); }

/* ================= Верхняя строка ================= */

.top {
  position: sticky; top: 0; z-index: 30; height: var(--top-h); padding: 0 28px;
  display: flex; align-items: center; gap: 14px;
  background: rgba(8, 9, 12, .84); -webkit-backdrop-filter: saturate(160%) blur(14px); backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; flex: none; font-size: 14px; font-weight: 600; color: var(--text); }
.brand:hover { color: #fff; }
.brand svg { color: var(--acc); }
.crumbs { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 13.5px; color: var(--text-2); }
.crumbs i { font-style: normal; color: var(--text-4, #4d5059); }
.crumbs span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; animation: fadeIn .3s var(--ease); }
.top-link { flex: none; padding: 6px 10px; border-radius: var(--r); font-size: 13px; color: var(--text-2); transition: background .15s, color .15s; }
.top-link:hover { color: var(--text); background: var(--surface-2); }
.top-link span { color: var(--text-3); }
.who { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: var(--text-3); }

.page.enter { animation: rise .45s var(--ease); }

/* ================= Реестр ================= */

.page-list { max-width: 1080px; margin: 0 auto; padding: 0 28px 96px; }

.hero { position: relative; min-height: 300px; display: flex; align-items: flex-end; padding: 36px 0 34px; }
.hero-copy { position: relative; z-index: 1; max-width: 520px; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.eyebrow { font: 500 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--acc); }
.hero h1 { font-size: clamp(34px, 4.2vw, 50px); line-height: 1.02; letter-spacing: -.045em; }
.lead { max-width: 440px; font-size: 15px; line-height: 1.65; color: var(--text-2); }
.hero-actions { margin-top: 8px; }
.hero-scene {
  position: absolute; right: -28px; top: 0; width: min(50%, 520px); height: 100%; pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, #000 78%, transparent);
  mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, #000 78%, transparent);
}
.no-webgl .hero-scene { display: none; }

/* Счётчики — они же фильтр по статусу. */
.stats { display: flex; flex-wrap: wrap; gap: 6px 0; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.stat { position: relative; min-width: 104px; padding: 4px 28px 0 0; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; border: 0; cursor: pointer; text-align: left; background: none; transition: opacity .25s var(--ease); }
.stat-v { font-size: 26px; font-weight: 500; line-height: 1.1; letter-spacing: -.04em; color: var(--text); }
.stat-k { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-3); transition: color .15s; }
.stat[class*="s-"] .stat-k::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--c); }
.stat:hover .stat-k { color: var(--text-2); }
.stat::after { content: ""; position: absolute; left: 0; bottom: -19px; width: 0; height: 1px; background: var(--acc); transition: width .35s var(--ease); }
.stat.is-on::after { width: calc(100% - 28px); }
.stats.is-filtered .stat:not(.is-on) { opacity: .45; }
.stats.is-filtered .stat:not(.is-on):hover { opacity: .8; }

.toolbar { position: sticky; top: var(--top-h); z-index: 5; display: flex; gap: 8px; padding: 14px 0; background: var(--bg); }
.search { position: relative; flex: 1; display: flex; align-items: center; }
.search svg { position: absolute; left: 12px; color: var(--text-3); pointer-events: none; }
.search input { width: 100%; height: 38px; padding-left: 34px; padding-right: 40px; }
.search kbd { position: absolute; right: 10px; pointer-events: none; }
.search input:focus ~ kbd { opacity: 0; }

.list { display: flex; flex-direction: column; }
.row {
  display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; align-items: center; gap: 18px;
  padding: 16px 4px; border-bottom: 1px solid var(--line); color: var(--text);
  animation: rise .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 35ms);
  transition: padding .25s var(--ease), background .25s;
}
.row:hover { padding-left: 12px; color: var(--text); background: linear-gradient(90deg, var(--surface), transparent 70%); }
.row-num { font: 500 12.5px/1 var(--mono); color: var(--text-3); transition: color .2s; }
.row:hover .row-num { color: var(--acc); }
.row-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.row-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 600; letter-spacing: -.012em; }
.row-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: var(--text-3); }
.row-side { display: flex; align-items: center; gap: 20px; }
.pill { display: inline-flex; align-items: center; gap: 7px; min-width: 104px; white-space: nowrap; font-size: 12.5px; color: var(--text-2); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c, var(--acc)); }
.meter { width: 44px; height: 2px; overflow: hidden; border-radius: 2px; background: var(--line-2); }
.meter i { display: block; width: calc(var(--p, 0) * 100%); height: 100%; background: var(--text-2); transition: width .6s var(--ease); }
.row time { width: 62px; text-align: right; font: 12px/1 var(--mono); color: var(--text-3); }

.empty { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 64px 20px; text-align: center; color: var(--text-3); animation: fadeIn .4s var(--ease); }
.skel { height: 64px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, transparent, var(--surface-2), transparent) 0 0 / 200% 100%; animation: shimmer 1.6s linear infinite; }

/* ================= Новое дело ================= */

.page-new { max-width: 760px; margin: 0 auto; padding: 28px 28px 96px; }
.back { display: inline-block; margin-bottom: 30px; font-size: 13px; color: var(--text-3); transition: color .15s, transform .25s var(--ease); }
.back:hover { color: var(--text); transform: translateX(-3px); }
.page-head h1 { font-size: clamp(26px, 3vw, 34px); line-height: 1.1; letter-spacing: -.035em; }
.page-head p { margin-top: 10px; color: var(--text-2); }

.form { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 16px; margin-top: 34px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > span, .field > label { font-size: 12.5px; color: var(--text-2); }
.num-kinds { display: flex; gap: 4px; }
.num-kinds button { flex: 1; height: 26px; border: 1px solid var(--line-2); border-radius: var(--r-sm); cursor: pointer; background: none; font: 500 11.5px/1 var(--mono); color: var(--text-3); transition: color .15s, border-color .15s, background .15s; }
.num-kinds button:hover { color: var(--text); border-color: var(--line-3); }
.num-kinds button.is-on { color: var(--acc-ink); background: var(--acc); border-color: transparent; }
.field b { font-weight: 500; color: var(--acc); }
.field input, .field select, .field textarea { width: 100%; }
.field.is-bad input, .field.is-bad textarea { border-color: rgba(236, 106, 111, .55); box-shadow: 0 0 0 3px var(--bad-soft); }
.wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; padding-top: 8px; }

/* ================= Редактор дела ================= */

/* Слева — рабочая область с листом документа, справа — ИИ-помощник
   на всю высоту. Каждая колонка прокручивается сама. */
.page-case { display: grid; grid-template-columns: minmax(0, 1fr) 400px; height: calc(100dvh - var(--top-h)); }
body[data-page="case"] { overflow: hidden; }

.ws { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ws-bar {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  width: 100%; max-width: 760px; margin: 0 auto; padding: 16px 20px 12px;
}
.ws-bar-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ws-title { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.ws-bar-side { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.ws-bar-side select { height: 32px; padding: 0 8px; font-size: 12.5px; color: var(--c, var(--text)); }
.btn-light { background: #f1f2f5; border-color: transparent; color: #16171b; font-weight: 600; }
.btn-light:hover { background: #fff; border-color: transparent; color: #16171b; }

.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; }
.tools button {
  display: inline-grid; place-items: center; min-width: 26px; height: 24px; padding: 0 6px;
  border: 1px solid var(--line); border-radius: 5px; cursor: pointer; background: var(--surface);
  font-size: 11.5px; line-height: 1; color: var(--text-2); transition: background .12s, color .12s, border-color .12s;
}
.tools button:hover { color: var(--text); background: var(--surface-3); border-color: var(--line-2); }
.tools-sep { width: 1px; height: 14px; margin: 0 3px; background: var(--line-2); }
.tools button.is-on { color: var(--acc-ink); background: var(--acc); border-color: transparent; }
.tools { transition: opacity .25s; }
.tools:not(.is-active) button:not([data-cmd="image"]) { opacity: .55; }

.save-state { display: inline-flex; align-items: center; gap: 7px; font: 11.5px/1 var(--mono); color: var(--text-3); white-space: nowrap; }
.save-state:not(:empty)::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.save-state.is-busy::before { background: var(--wait); animation: breathe 1s ease-in-out infinite; }
.save-state.is-bad { color: var(--bad); }
.save-state.is-bad::before { background: var(--bad); }

.ws-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 20px 80px; border-top: 1px solid var(--line); }
.ws-scroll > * { width: 100%; max-width: 720px; margin-left: auto; margin-right: auto; }

.note {
  display: flex; gap: 14px; margin-top: 18px; margin-bottom: 14px; padding: 14px 16px;
  border-radius: var(--r-lg); border: 1px solid var(--line-2); background: var(--surface); color: var(--text-2);
}
.note > svg { flex: none; margin-top: 1px; color: var(--text); }
.note-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 12.5px; line-height: 1.5; }
.note-text b { font-size: 13px; font-weight: 600; color: var(--text); }
.facts { margin-top: 4px; }
.facts summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; color: var(--acc); }
.facts summary::-webkit-details-marker { display: none; }
.facts summary::before { content: "›"; display: inline-block; transition: transform .25s var(--ease); }
.facts[open] summary::before { transform: rotate(90deg); }
.facts p { max-height: 200px; margin-top: 6px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; color: var(--text-2); animation: fadeIn .3s var(--ease); }

/* Лист документа — светлый, как бумага. */
.paper {
  --ink: #1d1f24; --ink-2: #4a4e57; --ink-3: #868b95; --rule: #d3d6dd; --cell: #e8eaef; --cell-2: #dfe2e8;
  padding: 26px 14px 30px; border-radius: 6px; background: #f3f4f7; color: var(--ink);
  box-shadow: 0 30px 80px -40px #000, 0 0 0 1px rgba(255, 255, 255, .06);
  font: 13.5px/1.55 var(--font); animation: rise .45s var(--ease);
}
/* Шапка: колонки по краям равной ширины, поэтому герб стоит точно по
   центру листа, а подписи углов выровнены по его нижнему краю. */
.paper-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 16px; padding: 4px 4px 12px; }
.paper-corner { display: flex; flex-direction: column; gap: 6px; padding-bottom: 4px; font-size: 11px; line-height: 1.2; color: var(--ink); }
.paper-corner small { font-size: 11px; font-weight: 500; }
.paper-corner span { font-size: 11px; color: var(--ink-2); }
.paper-corner.r { align-items: flex-end; text-align: right; }
.paper-seal { display: block; justify-self: center; color: #2a2c31; }
.paper-rule { height: 4px; margin: 0 4px; border-top: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); }
.paper-dept { padding: 22px 0 16px; text-align: center; }
.paper-dept h2 { font-size: 16px; font-weight: 400; letter-spacing: .03em; }
.paper-dept p { margin-top: 2px; font-size: 13px; color: var(--ink-2); }
.paper-addr { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 22px; font-size: 12px; line-height: 1.45; color: var(--ink-2); }
.paper-addr .r { text-align: right; }

.paper-table { width: 100%; table-layout: fixed; margin-bottom: 26px; border-collapse: separate; border-spacing: 0; overflow: hidden; border: 1px solid var(--rule); border-radius: 5px; }
.paper-table th, .paper-table td { padding: 9px 10px; text-align: center; border-right: 1px solid var(--rule); }
.paper-table th:last-child, .paper-table td:last-child { border-right: 0; }
.paper-table th { font-size: 13px; font-weight: 600; background: var(--cell); border-bottom: 1px solid var(--rule); }
.paper-table td { font-size: 13px; background: var(--cell-2); word-break: break-word; }
.paper-table td.b { font-weight: 600; }
.paper-table th, .paper-table td { vertical-align: middle; }
.paper-table .case-field { display: block; width: 100%; min-width: 0; height: 54px; margin: 0; padding: 6px 3px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: inherit; font: inherit; text-align: center; box-shadow: none; color-scheme: light; }
.paper-table .case-field:hover { border-color: var(--rule); }
.paper-table .case-field:focus { outline: 2px solid #8f87d8; background: #fff; }
.paper-table .case-field:not(:focus) { text-overflow: ellipsis; }

.psec { margin-bottom: 22px; overflow: hidden; border: 1px solid var(--rule); border-radius: 5px; transition: border-color .2s, box-shadow .2s; }
.psec h3 { padding: 8px 12px; text-align: center; font-size: 13px; font-weight: 600; letter-spacing: 0; background: var(--cell); border-bottom: 1px solid var(--rule); }
.psec.is-focus { border-color: #9a93f0; box-shadow: 0 0 0 3px rgba(154, 147, 240, .22); }
.psec.is-written { animation: written 1.8s var(--ease); }
.psec.is-ai-writing { border-color: #9a93f0; box-shadow: 0 0 0 3px rgba(154, 147, 240, .25), 0 10px 40px -12px rgba(110, 100, 230, .45); }
.psec.is-ai-writing h3 { position: relative; overflow: hidden; }
.psec.is-ai-writing h3::after { content: "ИИ пишет"; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); padding: 2px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 600; color: #fff; background: #7d74ef; animation: pulse 1.4s ease-in-out infinite; }
.psec.is-ai-writing h3::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 40%; background: linear-gradient(90deg, transparent, rgba(154, 147, 240, .25), transparent); animation: sweep 1.6s linear infinite; }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.psec.is-ai-writing .psec-body { cursor: progress; }
.ai-caret { display: inline-block; width: 8px; height: 1.05em; margin-left: 1px; vertical-align: -2px; border-radius: 1px; background: #6a61e0; animation: blink 1s steps(2, start) infinite; }
.psec.is-drop { border-color: #9a93f0; box-shadow: 0 0 0 3px rgba(154, 147, 240, .3); }
.psec.is-drop .psec-body { background: #e3e1fb; }
.psec { transition: border-color .25s, box-shadow .35s var(--ease); }
.psec h3 { transition: background .25s; }
.psec:hover:not(.is-focus):not(.is-ai-writing) { border-color: #bfc3cc; }
#paperHead.is-written { animation: written 1.8s var(--ease); border-radius: 6px; }
@keyframes written { 0% { box-shadow: 0 0 0 0 rgba(154, 147, 240, .55); border-color: #9a93f0; } 100% { box-shadow: 0 0 0 10px rgba(154, 147, 240, 0); } }

.psec-body {
  min-height: 40px; padding: 10px 12px; outline: none; background: var(--cell-2); caret-color: #5b52d6;
  white-space: normal; word-break: break-word; color: var(--ink); cursor: text;
}
.psec-body:empty::before { content: attr(data-placeholder); color: var(--ink-3); pointer-events: none; }
.psec-body::selection, .psec-body *::selection { background: rgba(120, 110, 240, .28); color: inherit; }
.psec-body > div { min-height: 1.55em; }
.psec-body h1 { margin: .5em 0 .3em; font-size: 1.45em; line-height: 1.25; letter-spacing: -.01em; }
.psec-body h2 { margin: .5em 0 .3em; font-size: 1.22em; line-height: 1.3; letter-spacing: 0; }
.psec-body h3 { margin: .4em 0 .2em; font-size: 1.06em; letter-spacing: 0; }
.psec-body .bb-center { text-align: center; }
.psec-body blockquote { margin: .5em 0; padding: .1em 0 .1em .9em; border-left: 2px solid #b6bac4; color: var(--ink-2); }
.psec-body ul, .psec-body ol { margin: .3em 0; padding-left: 1.5em; }
.psec-body a { color: #3d5bd9; text-decoration: underline; text-underline-offset: 2px; }
.psec-body img, .bb-img { display: block; max-width: 100%; max-height: 420px; margin: 8px 0; border-radius: 4px; border: 1px solid var(--rule, #cfd2d8); }
.psec-body img { cursor: default; }

/* Низ листа: штамп электронной подписи слева, подписант справа. */
.paper-sign { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-top: 30px; padding: 0 2px; }
.esign {
  flex: none; width: 226px; padding: 14px 16px 12px; border: 1px solid var(--rule); border-radius: 8px;
  font-size: 12px; color: var(--ink); background: rgba(255, 255, 255, .35); transition: opacity .3s;
}
.esign.is-unsigned { opacity: .55; }
.esign-head { display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 600; }
.esign dl { margin: 14px 0 12px; }
.esign dt { font-weight: 600; }
.esign dd { min-height: 1.3em; margin: 2px 0 12px; color: var(--ink-2); word-break: break-all; }
.esign dd:last-child { margin-bottom: 0; }
.esign-hash { font: 11.5px/1.3 var(--mono); letter-spacing: .02em; color: #4b5a78 !important; }
.esign-site { text-align: center; font-weight: 600; }

.signer { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; text-align: right; }
.signer-who { display: flex; align-items: baseline; justify-content: flex-end; flex-wrap: wrap; }
.sig-chip {
  max-width: 260px; padding: 2px 5px; border: 0; border-radius: 3px; outline: none;
  font: 600 14.5px/1.4 var(--font); color: var(--ink); background: var(--cell); text-align: center;
}
.sig-chip::placeholder { color: var(--ink-3); }
input.sig-chip { height: auto; min-width: 5ch; field-sizing: content; transition: box-shadow .15s, background .15s; }
input.sig-chip:hover { background: var(--cell-2); }
input.sig-chip:focus { background: #fff; box-shadow: 0 0 0 2px rgba(154, 147, 240, .5); }
.sig-comma { margin: 0 5px 0 1px; font-weight: 600; color: var(--ink); }
.signer-cap { font-size: 12.5px; color: var(--ink-2); }
.signer-date { margin-top: 16px; font: 600 15px/1.2 var(--font); letter-spacing: .02em; color: var(--ink); }

/* Ссылка на просмотр */
.share { position: relative; }
#shareBtn.is-on svg { color: var(--acc); }
.share-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: 340px; padding: 14px;
  display: flex; flex-direction: column; gap: 10px; border-radius: var(--r-lg);
  background: var(--bg-float); border: 1px solid var(--line-2); box-shadow: var(--shadow); animation: rise .2s var(--ease);
}
.share-pop p { font-size: 12.5px; line-height: 1.5; color: var(--text-2); }
.share-pop input { width: 100%; font: 12px/1 var(--mono); }
.share-actions { display: flex; align-items: center; gap: 6px; }
.share-off:hover { color: var(--bad) !important; }

/* ИИ-помощник */
.assistant { position: relative; display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: linear-gradient(180deg, rgba(170, 163, 255, .035), transparent 38%); transition: background .4s var(--ease); }
.assistant.is-drop { background: linear-gradient(180deg, rgba(170, 163, 255, .12), rgba(170, 163, 255, .04)); box-shadow: inset 0 0 0 2px var(--acc-line); }
.assistant-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px 14px; border-bottom: 1px solid var(--line); }
.assistant-head h2 { font-size: 14px; }
.assistant-sub { display: block; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--text-3); transition: color .2s; }
.assistant.is-busy .assistant-sub { color: var(--acc); }
.assistant-id { min-width: 0; }
.assistant-model { display: block; margin-top: 3px; color: var(--acc); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assistant-head, .skills, .chat-form { flex-shrink: 0; }
.assistant { overflow: hidden; }

/* «Орб» ИИ: три кольца; когда ИИ работает — вращаются и дышат. */
.ai-orb, .intro-orb { position: relative; flex: none; width: 30px; height: 30px; }
.ai-orb i, .intro-orb i { position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid var(--acc); opacity: .55; }
.ai-orb i:nth-child(2), .intro-orb i:nth-child(2) { inset: 5px; opacity: .8; border-color: var(--acc-strong); }
.ai-orb i:nth-child(3), .intro-orb i:nth-child(3) { inset: 11px; border: 0; opacity: 1; background: var(--acc); box-shadow: 0 0 12px var(--acc); }
.assistant.is-busy .ai-orb i:nth-child(1) { border-style: dashed; animation: spin 2.4s linear infinite; }
.assistant.is-busy .ai-orb i:nth-child(2) { border-right-color: transparent; animation: spin 1.1s linear infinite reverse; }
.assistant.is-busy .ai-orb i:nth-child(3) { animation: pulse 1.2s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { transform: scale(.6); opacity: .5; } }

.chat-log { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 16px; padding: 18px 22px; overflow-y: auto; scroll-behavior: smooth; }

/* Пустой чат */
.chat-intro { margin: auto 0; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; animation: rise .5s var(--ease); }
.intro-orb { width: 40px; height: 40px; margin-bottom: 4px; }
.intro-orb i:nth-child(1) { border-style: dashed; animation: spin 9s linear infinite; }
.chat-intro h3 { font-size: 16px; letter-spacing: -.02em; }
.chat-intro p { font-size: 13px; line-height: 1.6; color: var(--text-2); }
.intro-actions { display: flex; flex-direction: column; gap: 6px; width: 100%; margin-top: 6px; }
.intro-actions button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 10px 12px;
  border: 1px solid var(--line-2); border-radius: var(--r-lg); cursor: pointer; text-align: left; background: var(--surface);
  animation: rise .5s var(--ease) both; transition: border-color .2s, background .2s, transform .2s var(--ease);
}
.intro-actions button:nth-child(2) { animation-delay: .06s; }
.intro-actions button:nth-child(3) { animation-delay: .12s; }
.intro-actions button:hover { border-color: var(--acc-line); background: var(--acc-soft); transform: translateX(3px); }
.intro-actions b { font-size: 13px; font-weight: 600; }
.intro-actions span { font-size: 12px; color: var(--text-3); }

/* Сообщения */
.msg { display: flex; flex-direction: column; gap: 8px; animation: rise .35s var(--ease); }
.msg-text { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.6; }
.msg-text:empty { display: none; }
.msg-me { align-self: flex-end; max-width: 88%; padding: 9px 13px; border-radius: 14px 14px 4px 14px; background: var(--acc-soft); }
.msg-ai .msg-text { padding-left: 12px; border-left: 1px solid var(--line-2); color: var(--text); }
.msg-ai.is-live .msg-text { border-left-color: var(--acc-line); }
.msg-text.is-typing:not(:empty)::after { content: ""; display: inline-block; width: 7px; height: 14px; margin-left: 2px; vertical-align: -2px; border-radius: 1px; background: var(--acc); animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
.msg-err .msg-text { color: #f3b9bc; border-left-color: rgba(236, 106, 111, .5); }
.msg-actions { display: flex; flex-wrap: wrap; gap: 4px; padding-left: 12px; transition: opacity .2s; }
.msg-actions button { padding: 4px 9px; border: 1px solid var(--line-2); border-radius: var(--r-sm); cursor: pointer; background: none; font-size: 12px; color: var(--text-2); transition: color .15s, border-color .15s, background .15s; }
.msg-actions button:hover { color: var(--text); border-color: var(--line-3); background: var(--surface-2); }
@media (hover: hover) {
  .msg-actions { opacity: 0; }
  .msg:hover .msg-actions, .msg:focus-within .msg-actions, .msg-ai:last-child .msg-actions { opacity: 1; }
}
.msg-pics { display: flex; flex-wrap: wrap; gap: 6px; }
.msg-me .msg-pics { justify-content: flex-end; }
.msg-pics img { display: block; width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line-2); transition: transform .2s var(--ease); }
.msg-pics a:hover img { transform: scale(1.04); }

/* Этапы работы ИИ */
.ai-steps { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0 0 0 2px; list-style: none; }
.ai-steps li { display: grid; grid-template-columns: 18px 1fr auto; align-items: center; column-gap: 8px; padding: 3px 0; font-size: 12.5px; color: var(--text-2); animation: rise .3s var(--ease); }
.ai-steps .st-ic { position: relative; width: 12px; height: 12px; justify-self: center; border-radius: 50%; }
.ai-steps li.is-run { color: var(--text); }
.ai-steps li.is-run .st-ic { border: 1.5px solid var(--acc); border-right-color: transparent; animation: spin .8s linear infinite; }
.ai-steps li.is-done .st-ic { background: var(--ok); transform: scale(.75); animation: pop .3s var(--ease); }
.ai-steps li.is-done .st-ic::after { content: ""; position: absolute; left: 4px; top: 2px; width: 3px; height: 6px; border: solid #0b1a12; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.ai-steps li.is-fail .st-ic { background: var(--bad); }
.ai-steps .st-text { min-width: 0; }
.ai-steps li.is-run .st-text { background: linear-gradient(90deg, var(--text) 0%, var(--acc-strong) 50%, var(--text) 100%) 0 0 / 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shine 1.8s linear infinite; }
@keyframes shine { to { background-position: -200% 0; } }
@keyframes pop { from { transform: scale(0); } }
.ai-steps .st-time { font: 11px/1 var(--mono); color: var(--text-3); }
.ai-steps .st-detail { grid-column: 2 / -1; font-size: 11.5px; color: var(--text-3); }
.ai-steps .st-detail:empty { display: none; }
.ai-steps.is-collapsed li { padding: 1px 0; }
.ai-steps.is-collapsed .st-detail { display: none; }
.ai-steps.is-collapsed { opacity: .7; }

/* Ход мысли */
.ai-think { border: 1px solid var(--line); border-radius: var(--r-lg); background: rgba(170, 163, 255, .04); animation: rise .35s var(--ease); }
.ai-think summary { display: flex; align-items: center; gap: 8px; padding: 7px 11px; cursor: pointer; list-style: none; font-size: 12px; font-weight: 500; color: var(--text-2); }
.ai-think summary::-webkit-details-marker { display: none; }
.ai-think summary::after { content: "›"; margin-left: auto; transition: transform .25s var(--ease); }
.ai-think[open] summary::after { transform: rotate(90deg); }
.think-ic { width: 8px; height: 8px; border-radius: 50%; background: var(--acc); box-shadow: 0 0 8px var(--acc); }
.is-live .think-ic { animation: pulse 1s ease-in-out infinite; }
.think-body { max-height: 240px; padding: 0 12px 10px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; font-size: 12.5px; line-height: 1.55; color: var(--text-2); }

/* Источники */
.ai-sources { display: flex; flex-direction: column; gap: 5px; }
.src-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.src-k { margin-right: 4px; font: 500 10.5px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.src-chip { padding: 2px 8px; border-radius: 999px; font-size: 11.5px; color: var(--text-2); border: 1px solid var(--line-2); animation: rise .35s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }
.src-practice .src-chip { color: var(--acc-strong); border-color: var(--acc-line); background: var(--acc-soft); }
.src-more { padding: 2px 6px; border: 0; border-radius: 999px; cursor: pointer; background: none; font-size: 11.5px; color: var(--text-3); }
.src-more:hover { color: var(--text); background: var(--surface-2); }
.src-chip.is-extra { display: none; }
.src-row.is-open .src-chip.is-extra { display: inline-block; }

/* Что ИИ пишет в документ */
.ai-writes { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }
.ai-writes:empty { display: none; }
.ai-writes li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--r); font-size: 12.5px; background: var(--surface); border: 1px solid var(--line); animation: rise .3s var(--ease); }
.ai-writes li i { width: 7px; height: 7px; border-radius: 50%; background: var(--wait); }
.ai-writes li.is-run i { animation: pulse 1s ease-in-out infinite; }
.ai-writes li.is-done i { background: var(--ok); }
.ai-writes li span { flex: 1; }
.ai-writes li em { font: normal 11px/1 var(--mono); color: var(--text-3); }

/* Навыки */
.skills { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 22px 0; border-top: 1px solid var(--line); }
.skills-label { align-self: center; color: var(--text-3); font-size: 11px; }
.skills button { padding: 5px 11px; border: 1px solid var(--line-2); border-radius: 999px; cursor: pointer; background: none; font-size: 12px; color: var(--text-2); transition: color .15s, border-color .15s, background .15s, opacity .2s, transform .2s var(--ease); }
.skills button:hover { color: var(--text); border-color: var(--acc-line); background: var(--acc-soft); transform: translateY(-1px); }
.skills .skill-more { border-style: dashed; color: var(--acc); }
.skills .skill-more[aria-expanded="true"] { background: var(--acc-soft); border-style: solid; border-color: var(--acc-line); }
.skills.is-busy button { opacity: .4; pointer-events: none; }
.skills-menu {
  position: absolute; left: 14px; right: 14px; bottom: 150px; z-index: 15; max-height: min(62vh, 520px); overflow-y: auto;
  padding: 10px; border-radius: var(--r-lg); background: var(--bg-float); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  animation: rise .22s var(--ease);
}
.sk-group + .sk-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.sk-group h4 { margin: 2px 6px 6px; font: 500 10.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.sk-item { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; padding: 7px 8px; border: 0; border-radius: var(--r); cursor: pointer; text-align: left; background: none; transition: background .15s; }
.sk-item:hover { background: var(--surface-3); }
.sk-item b { font-size: 13px; font-weight: 500; color: var(--text); }
.sk-item span { font-size: 11.5px; color: var(--text-3); }

/* Поле ввода */
.chat-form { display: flex; flex-direction: column; gap: 8px; padding: 12px 22px 14px; margin-top: auto; background: var(--bg); }
.chat-row { display: flex; align-items: flex-end; gap: 8px; }
.chat-form textarea { flex: 1; min-width: 0; height: 82px; min-height: 82px; max-height: 82px; padding: 9px 12px; resize: none; overflow-y: auto; scrollbar-gutter: stable; line-height: 1.45; field-sizing: fixed; }
.chat-hint { font-size: 11px; color: var(--text-3); }
.chat-send { position: relative; flex: none; width: 38px; height: 38px; min-height: 0; padding: 0; transition: background .2s, transform .2s var(--ease); }
.chat-send:active { transform: scale(.94); }
.chat-send .ic-stop { display: none; }
.chat-send.is-stop { background: var(--bad); color: #fff; }
.chat-send.is-stop:hover { background: #f07c80; color: #fff; }
.chat-send.is-stop .ic-send { display: none; }
.chat-send.is-stop .ic-stop { display: block; }
.chat-send.is-stop::before { content: ""; position: absolute; inset: -4px; border-radius: 12px; border: 1.5px solid rgba(236, 106, 111, .5); border-top-color: transparent; animation: spin 1.2s linear infinite; }
.chat-attach { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line-2); border-radius: var(--r); cursor: pointer; background: none; color: var(--text-3); transition: color .15s, border-color .15s; }
.chat-attach:hover { color: var(--text); border-color: var(--line-3); }
.chat-tray { display: flex; flex-wrap: wrap; gap: 6px; }
.tray-item { position: relative; width: 56px; height: 56px; overflow: hidden; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface-2); animation: rise .25s var(--ease); }
.tray-item img { width: 100%; height: 100%; object-fit: cover; }
.tray-item.is-loading img { opacity: .4; animation: breathe 1s ease-in-out infinite; }
.tray-item button { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border: 0; border-radius: 50%; cursor: pointer; font-size: 13px; line-height: 1; color: #fff; background: rgba(0, 0, 0, .65); }

/* Окошко ссылки */
.link-pop { position: fixed; z-index: 60; width: 290px; padding: 12px; display: flex; flex-direction: column; gap: 8px; border-radius: var(--r-lg); background: var(--bg-float); border: 1px solid var(--line-2); box-shadow: var(--shadow); animation: rise .2s var(--ease); }
.link-pop label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--text-3); }
.link-pop input { width: 100%; height: 32px; font-size: 13px; }
.link-actions { display: flex; gap: 6px; }

/* ================= Тосты ================= */

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { position: relative; max-width: 380px; padding: 10px 14px 10px 28px; pointer-events: auto; border-radius: var(--r-lg); font-size: 13px; background: var(--bg-float); border: 1px solid var(--line-2); box-shadow: var(--shadow); animation: rise .25s var(--ease); }
.toast::before { content: ""; position: absolute; left: 12px; top: 17px; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.toast.err::before { background: var(--bad); }
.toast.leaving { animation: fadeOut .2s var(--ease) forwards; }

/* ================= Адаптив ================= */

/* Узкий экран: редактор становится обычной страницей — панель
   оформления прилипает сверху, помощник уезжает под документ. */
@media (max-width: 1180px) {
  body[data-page="case"] { overflow: visible; }
  .page-case { display: flex; flex-direction: column; height: auto; }
  .ws-scroll { overflow: visible; padding-bottom: 40px; }
  .ws-bar { position: sticky; top: var(--top-h); z-index: 6; max-width: none; background: var(--bg); }
  .assistant { height: 600px; border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 760px) {
  .top { gap: 10px; padding: 0 16px; }
  .brand span, .who { display: none; }
  .page-list, .page-new { padding-left: 16px; padding-right: 16px; }

  .hero { flex-direction: column; align-items: stretch; min-height: 0; padding: 0 0 28px; }
  .hero-scene { position: relative; right: auto; order: -1; width: 100%; height: 190px; }

  .row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .row-side { gap: 14px; }
  .pill { min-width: 0; }
  .row time { width: auto; margin-left: auto; }

  .form { grid-template-columns: 1fr; }

  .ws-bar { flex-direction: column; padding: 12px 16px; }
  .ws-bar-side { justify-content: flex-start; }
  .ws-scroll { padding: 4px 10px 32px; }
  .paper { padding: 18px 8px 22px; }
  .paper-addr { font-size: 11px; }
  .paper-table th, .paper-table td { padding: 7px 5px; font-size: 12px; }
  .paper-table col:nth-child(1) { width: 29% !important; }
  .paper-table col:nth-child(2) { width: 34% !important; }
  .paper-table col:nth-child(3) { width: 37% !important; }
  .paper-sign { flex-direction: column-reverse; align-items: stretch; }
  .esign { width: auto; }
  .share-pop { position: fixed; left: 16px; right: 16px; top: auto; bottom: 16px; width: auto; }
  .assistant { height: 520px; }
  .assistant-head, .chat-log, .skills, .chat-form { padding-left: 16px; padding-right: 16px; }
  .toasts { left: 16px; right: 16px; bottom: 16px; }
  .toast { max-width: none; }
}

/* ================= Просмотр по ссылке ================= */

/* Готовое дело, как на бумаге: строка с названием и статусом над листом,
   ничего больше — ни правки, ни чата, ни кнопок. */
.view-page { overflow: auto; }
.view-bar { border-bottom: 1px solid var(--line); background: var(--bg); }
.view-bar-in { max-width: 700px; margin: 0 auto; padding: 18px 2px 14px; }
.view-title { font-size: 13.5px; font-weight: 600; letter-spacing: -.01em; }
.view-status { margin-top: 4px; font-size: 12px; color: var(--text-3); }
.view-main { padding: 10px 16px 80px; }
.view-main > .paper { max-width: 700px; margin: 0 auto; }

/* Лист просмотра — нейтрально-серый, разделы без заливки, как в образце. */
.paper-static { --cell: #e2e2e2; --cell-2: #e8e8e8; --rule: #cfcfcf; padding: 30px 14px 34px; background: #e8e8e8; border-radius: 5px; }
.paper-static .psec { margin-bottom: 26px; }
.paper-static .psec h3 { background: #e8e8e8; }
.paper-static .psec-body { padding: 12px 12px 10px; background: #e8e8e8; cursor: auto; line-height: 1.5; }
.paper-static .esign { background: transparent; }
.view-empty { max-width: 420px; margin: 18vh auto 0; text-align: center; color: var(--text-2); animation: fadeIn .4s var(--ease); }

@media print {
  .view-bar { display: none; }
  html, body, .view-page { background: #fff !important; }
  .view-main { padding: 0; }
  .paper { box-shadow: none !important; animation: none !important; }
}
