/* Bookolot — веб-интерфейс.
   Палитра из brand/build_brand.py: navy / paper / amber.
   Инлайновых стилей нет намеренно: CSP запрещает 'unsafe-inline'. */

@font-face {
  font-family: "Bookolot Read";
  src: url("read.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Bookolot Read";
  src: url("read-bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --paper: #F3EBDD;
  --surface: #FBF6EC;
  --ink: #0F2A45;
  --muted: #5E7187;
  --rule: #DCD2C0;
  --accent: #B07714;
  --accent-soft: #F6E7C6;
  --mark: #F2D79A;
  --sel: rgba(176, 119, 20, .22);
  --ok: #2F6B45;
  --bad: #A2402F;
  --warn: #8C4A1E;
  --warn-soft: #F4DFD2;
  --fig-bg: #FFFFFF;
  --f-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --f-mono: ui-monospace, SFMono-Regular, Menlo, "Cascadia Mono", monospace;
  --f-read: "Bookolot Read", Charter, Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0F2A45;
    --surface: #16344F;
    --ink: #F3EBDD;
    --muted: #9FB2C6;
    --rule: #2A4A69;
    --accent: #E3A63B;
    --accent-soft: #24405C;
    --mark: #6B5220;
    --sel: rgba(227, 166, 59, .3);
    --ok: #86BD9A;
    --bad: #E49383;
    --warn: #E9A98C;
    --warn-soft: #40291F;
    --fig-bg: #F4F1EA;
  }
}
:root[data-theme="dark"] {
  --paper: #0F2A45; --surface: #16344F; --ink: #F3EBDD; --muted: #9FB2C6;
  --rule: #2A4A69; --accent: #E3A63B; --accent-soft: #24405C; --mark: #6B5220;
  --sel: rgba(227, 166, 59, .3); --ok: #86BD9A; --bad: #E49383;
  --warn: #E9A98C; --warn-soft: #40291F; --fig-bg: #F4F1EA;
}

/* ---------- кегль слоёв ---------- */
/* Классы на <body>: размер задаётся ступенями, потому что inline-стили
   запрещены CSP. rs-* — оригинал (raw), ms-* — транслитерация. */
:root { --raw-size: 15.5px; --mod-size: 12.5px; }
.rs-1 { --raw-size: 13px; }
.rs-2 { --raw-size: 14.5px; }
.rs-3 { --raw-size: 16px; }
.rs-4 { --raw-size: 18.5px; }
.rs-5 { --raw-size: 21px; }
.ms-1 { --mod-size: 11px; }
.ms-2 { --mod-size: 12.5px; }
.ms-3 { --mod-size: 14px; }
.ms-4 { --mod-size: 16px; }
.ms-5 { --mod-size: 18px; }

* { box-sizing: border-box; }
/* Атрибут hidden слабее любого класса с display: без этого правила
   скрытый блок остаётся на экране. */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 var(--f-body);
}
a { color: inherit; text-decoration-color: var(--muted); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ---------- шапка ---------- */
header.top {
  display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center;
  max-width: 1120px; margin: 0 auto;
  padding-inline: 16px; padding-block: 16px 10px;
  border-bottom: 1px solid var(--rule);
}
/* Как в фирменном лок-апе (brand/build_brand.py): знак слева, название и
   слоган столбиком, вся группа выровнена по центру знака. */
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-words { display: grid; gap: 2px; }
/* Знак нарисован в двух вариантах: тёмный на бумаге и бумажный на тёмном.
   Переключаем показ, а не цвет: внутри SVG заливка фиксированная. */
.brand .glyph { align-self: center; }
.glyph-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .glyph-light { display: none; }
  :root:not([data-theme="light"]) .glyph-dark { display: inline; }
}
:root[data-theme="dark"] .glyph-light { display: none; }
:root[data-theme="dark"] .glyph-dark { display: inline; }
.brand-name { font: 700 26px/1.05 var(--f-read); letter-spacing: .005em; }
.brand-tag { font: italic 13px/1 var(--f-read); color: var(--muted); letter-spacing: .01em; }
.mainnav { display: flex; gap: 16px; margin-left: 16px; font-size: 14px; align-self: center; }
.mainnav a { text-decoration: none; color: var(--muted); }
.mainnav a:hover { color: var(--ink); text-decoration: underline; }
.langs { margin-left: auto; display: flex; gap: 8px; font: 500 12px var(--f-mono); }
.langs a { padding: 3px 7px; border: 1px solid transparent; border-radius: 5px; color: var(--muted); text-decoration: none; }
.langs a[aria-current="true"] { border-color: var(--rule); background: var(--surface); color: var(--ink); }

.wrap { max-width: var(--page, 1120px); margin: 0 auto; padding-inline: 16px; padding-block: 22px 60px; display: grid; gap: 26px; }
.foot {
  max-width: 1120px; margin: 0 auto; padding-inline: 16px; padding-block: 18px 40px;
  border-top: 1px solid var(--rule); color: var(--muted); font-size: 13px;
}
.foot p { margin: 4px 0; }

/* ---------- поиск ---------- */
.searchbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.searchbar input[type="search"] {
  flex: 1 1 320px; min-width: 0; font: 17px/1.4 var(--f-read);
  padding: 11px 14px; border: 1px solid var(--rule); border-radius: 8px;
  background: var(--surface); color: var(--ink);
}
.searchbar button {
  font: 600 14px var(--f-body); padding: 11px 18px; border-radius: 8px;
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper); cursor: pointer;
}
.modes { display: flex; gap: 6px; }
.chipbtn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font: 500 13px var(--f-body); padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--rule); color: var(--muted); background: var(--surface);
}
.chipbtn input { position: absolute; opacity: 0; width: 0; height: 0; }
.chipbtn:has(input:checked) { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chipbtn:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.filters { flex: 1 1 100%; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); }
.filters > summary { cursor: pointer; padding: 9px 13px; font: 500 13px var(--f-body); color: var(--muted); }
.filters fieldset { border: 0; border-top: 1px solid var(--rule); margin: 0; padding: 12px 13px; }
.filters legend { font: 500 11.5px var(--f-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.filters .years { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.filters .years input { width: 6.5em; font: 14px var(--f-mono); padding: 5px 7px; border: 1px solid var(--rule); border-radius: 6px; background: var(--paper); color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.num { font: 500 12px var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- пустая главная ---------- */
.intro h1 { font: 700 clamp(25px, 3.6vw, 34px)/1.18 var(--f-read); margin: 0 0 10px; text-wrap: balance; }
.lede { max-width: 62ch; color: var(--muted); margin: 0 0 12px; }
.examples { color: var(--muted); }

/* ---------- выбор написаний ---------- */
.forms h2, .mentions h2, .counts h2, .passages h2 { font: 700 19px/1.3 var(--f-body); margin: 0 0 8px; }
.hint { color: var(--muted); font-size: 13px; max-width: 70ch; margin: 0 0 12px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; margin: 0 0 12px; font-size: 12.5px; color: var(--muted); }
.presets a { padding: 3px 10px; border: 1px solid var(--rule); border-radius: 999px; text-decoration: none; }
.presets a[aria-current="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.formgroup { border: 0; margin: 0 0 14px; padding: 0; }
.formgroup legend { font: 500 11.5px var(--f-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.chip {
  display: inline-flex; align-items: baseline; gap: 7px; cursor: pointer;
  padding: 6px 11px; border-radius: 8px; border: 1px solid var(--rule); background: var(--surface);
}
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip .form { font: 400 17px/1.3 var(--f-read); }
.chip .badge { font: 500 10.5px var(--f-mono); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.chip-similar .badge { color: var(--warn); }

/* ---------- конкорданс ---------- */
.results { display: grid; gap: 20px; }
.mentions { display: grid; gap: 14px; }
.mention {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 9px;
  padding: 14px 16px; display: grid; gap: 9px; min-width: 0;
}
.mention .lines { display: grid; gap: 3px; min-width: 0; }
.mention .ctx { margin: 0; font: 400 15px/1.45 var(--f-read); color: var(--muted); overflow-wrap: anywhere; }
.mention .raw { margin: 0; font: 400 calc(var(--raw-size) + 3px)/1.5 var(--f-read); overflow-wrap: anywhere; }
.mention .modern { margin: 2px 0 0; font: 400 calc(var(--mod-size) + 1px)/1.45 var(--f-body); color: var(--muted); overflow-wrap: anywhere; }
.layer { font: 500 10px var(--f-mono); text-transform: uppercase; letter-spacing: .06em; margin-right: 7px; opacity: .75; }
mark { background: var(--mark); color: inherit; padding: 0 1px; border-radius: 2px; }
mark.part { background: linear-gradient(90deg, var(--mark), transparent); }
.meta { margin: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 12.5px; color: var(--muted); }
.cite { font: 500 12px var(--f-mono); color: var(--accent); }
.meta .book { max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta .year { font-variant-numeric: tabular-nums; }
.tag { font-size: 11.5px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--rule); }
.conf { font: 500 12px var(--f-mono); font-variant-numeric: tabular-nums; }
.conf.low { color: var(--warn); background: var(--warn-soft); padding: 2px 7px; border-radius: 999px; }
.review-machine-generated { color: var(--warn); }
.fig { margin: 0; background: var(--fig-bg); border: 1px solid var(--rule); border-radius: 7px; padding: 6px; overflow: hidden; }
.fig img { display: block; width: 100%; height: auto; }
.fig figcaption { font: 500 11.5px var(--f-mono); color: #4a4a4a; padding-top: 4px; }
.more { margin: 0; }
.more a { font: 500 14px var(--f-body); display: inline-block; padding: 9px 16px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); text-decoration: none; }
.empty, .loading { color: var(--muted); padding: 14px 0; margin: 0; }

/* ---------- распределение ---------- */
.counts { background: var(--surface); border: 1px solid var(--rule); border-radius: 9px; padding: 14px 16px; }
.counts .groups { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.counts .groups a { font-size: 12.5px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--rule); text-decoration: none; color: var(--muted); }
.counts .groups a[aria-current="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.counts .total { margin: 0 0 10px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.bars li { display: grid; grid-template-columns: minmax(5em, 9em) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bars .k { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .v { font: 500 12px var(--f-mono); font-variant-numeric: tabular-nums; }
.bars progress { width: 100%; height: 11px; appearance: none; border: 0; background: var(--rule); border-radius: 3px; }
.bars progress::-webkit-progress-bar { background: var(--rule); border-radius: 3px; }
.bars progress::-webkit-progress-value { background: var(--accent); border-radius: 3px; }
.bars progress::-moz-progress-bar { background: var(--accent); border-radius: 3px; }

/* ---------- фрагменты и страница фрагмента ---------- */
.passage-hit { background: var(--surface); border: 1px solid var(--rule); border-radius: 9px; padding: 13px 15px; margin-bottom: 12px; }
.snippet { margin: 0 0 7px; font: 400 16px/1.55 var(--f-read); overflow-wrap: anywhere; }
.mode-note { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.passage h1 { font: 700 23px/1.25 var(--f-body); margin: 0 0 8px; }
.passage h1 code { font: 500 17px var(--f-mono); color: var(--accent); }
.bookline { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin: 0 0 14px; font-size: 13.5px; }
.muted { color: var(--muted); }
.figs { display: grid; gap: 10px; margin-bottom: 16px; }
.passage-lines { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 7px; }
.passage-lines li { display: grid; grid-template-columns: 4.5em minmax(0, 1fr) 3.4em; gap: 0 12px; padding: 4px 9px; border-radius: 7px; }
.passage-lines li.target { background: var(--accent-soft); }
.passage-lines .ln { grid-column: 1; grid-row: 1 / -1; align-self: baseline; font: 500 11px/1.5 var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.passage-lines .raw { grid-column: 2; font: 400 calc(var(--raw-size) + 1px)/1.4 var(--f-read); overflow-wrap: anywhere; }
.passage-lines .modern { grid-column: 2; font-size: var(--mod-size); line-height: 1.3; color: var(--muted); }
.passage-lines .conf { grid-column: 3; grid-row: 1 / -1; align-self: baseline; font: 500 10.5px/1.5 var(--f-mono); text-align: right; font-variant-numeric: tabular-nums; }
.prov { border-top: 1px solid var(--rule); padding-top: 14px; }
.prov h2 { font: 700 16px var(--f-body); margin: 0 0 8px; }
.prov-steps { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 13px; }
.prov-steps dt { font: 500 12px var(--f-mono); color: var(--muted); }
.prov-steps dd { margin: 0; }
.prov pre { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: 7px; padding: 12px; font: 12px/1.5 var(--f-mono); }

/* ---------- книга и ошибки ---------- */
.eyebrow { font: 500 11px var(--f-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 4px; }
.bookline .read { margin-right: 4px; }
.bookcard h1 { font: 700 24px/1.25 var(--f-read); margin: 0 0 8px; text-wrap: balance; }
.props { display: grid; grid-template-columns: auto 1fr; gap: 5px 16px; margin: 0 0 20px; font-size: 14px; }
.props dt { font: 500 12px var(--f-mono); color: var(--muted); }
.props dd { margin: 0; overflow-wrap: anywhere; }
.weak { list-style: none; padding: 0; display: grid; gap: 5px; font-size: 13.5px; }
.errorbox h1 { font: 700 24px var(--f-body); margin: 0 0 8px; }

.htmx-request .loading { opacity: 1; }
@media (max-width: 720px) {
  .bars li { grid-template-columns: minmax(4em, 7em) 1fr auto; }
  .passage-lines li { grid-template-columns: 3.4em minmax(0, 1fr) 3.2em; }
  .searchbar button { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- читалка ---------- */
/* Скан и текст рядом: чем шире экран, тем крупнее оба. */
body:has(.reader) { --page: 2200px; }  /* читалка занимает экран целиком */
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12.5px; color: var(--muted); }
.crumbs a { text-decoration: none; }
.crumbs a::after { content: " ›"; color: var(--rule); }
.crumbs a:last-child::after { content: ""; }
.readhead h1 { font: 700 21px/1.2 var(--f-body); margin: 6px 0 6px; }
.pagenav { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.pagenav a, .pagenav .off, .pagenav .pos {
  font: 500 13px var(--f-body); padding: 7px 13px; border-radius: 7px;
  border: 1px solid var(--rule); background: var(--surface); text-decoration: none;
}
.pagenav .off { opacity: .4; }
.pagenav .pos { border-color: var(--ink); background: var(--ink); color: var(--paper); font-variant-numeric: tabular-nums; }
.reader { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.reader-scan { position: sticky; top: 12px; display: grid; gap: 8px; }
.scanwrap { position: relative; line-height: 0; margin: 0; }
.scanwrap img { display: block; width: 100%; height: auto; }

/* Рамки строк поверх скана. Координаты — атрибуты SVG, а не inline-стили:
   CSP запрещает style="", а viewBox делает их независимыми от масштаба. */
.boxes { position: absolute; inset: 6px; width: calc(100% - 12px); height: calc(100% - 12px); }
.bx { fill: transparent; stroke-width: 3; cursor: pointer; pointer-events: all; }
.bx.g-hi { stroke: var(--ok); }
.bx.g-mid { stroke: var(--warn); }
.bx.g-lo { stroke: var(--bad); stroke-width: 5; }
.bx.g-unknown { stroke: var(--muted); }
.bx:hover, .bx.act { fill: var(--sel); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; font: 500 11.5px var(--f-mono); color: var(--muted); }
.legend span::before {
  content: ""; display: inline-block; width: 10px; height: 10px;
  margin-right: 6px; vertical-align: -1px; border: 2px solid currentColor;
}
.legend .g-hi { color: var(--ok); }
.legend .g-mid { color: var(--warn); }
.legend .g-lo { color: var(--bad); }
.legend .full { margin-left: auto; color: var(--muted); }
.scanfail { margin: 0; padding: 12px 14px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }

.textprefs { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 0 0 8px; font: 500 11px var(--f-mono); color: var(--muted); }
.textprefs .grp { display: inline-flex; align-items: center; gap: 4px; }
.textprefs a, .textprefs .off {
  display: inline-block; min-width: 22px; text-align: center;
  padding: 1px 6px; border: 1px solid var(--rule); border-radius: 5px;
  text-decoration: none; color: inherit;
}
.textprefs .off { opacity: .35; }
.textprefs .lvl { font-variant-numeric: tabular-nums; }
.layers { display: flex; flex-wrap: wrap; gap: 7px; align-items: baseline; margin: 0 0 8px; font: 500 11.5px var(--f-mono); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.layers a { padding: 2px 9px; border: 1px solid var(--rule); border-radius: 999px; text-decoration: none; text-transform: none; letter-spacing: 0; }
.layers a[aria-current="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.read-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
/* Номер слева, уверенность справа — оба узкими колонками, а не своими
   рядами: иначе одна строка книги занимает на экране три. */
.read-lines li {
  display: grid; grid-template-columns: 2.2em minmax(0, 1fr) 3.2em;
  gap: 0 9px; padding: 3px 8px; border-radius: 6px;
  border-left: 3px solid transparent; cursor: default;
}
.read-lines li.g-hi { border-left-color: var(--ok); }
.read-lines li.g-mid { border-left-color: var(--warn); }
.read-lines li.g-lo { border-left-color: var(--bad); }
.read-lines li:hover { background: var(--surface); }
.read-lines li.act { background: var(--sel); }
.read-lines .ln {
  grid-column: 1; grid-row: 1 / -1; align-self: baseline;
  font: 500 10.5px/1.5 var(--f-mono); color: var(--muted);
  text-decoration: none; text-align: right; font-variant-numeric: tabular-nums;
}
.read-lines .raw { grid-column: 2; font: 400 var(--raw-size)/1.35 var(--f-read); overflow-wrap: anywhere; }
.read-lines .modern { grid-column: 2; font-size: var(--mod-size); line-height: 1.3; color: var(--muted); overflow-wrap: anywhere; }
.read-lines .conf {
  grid-column: 3; grid-row: 1 / -1; align-self: baseline;
  font: 500 10.5px/1.5 var(--f-mono); color: var(--muted);
  text-align: right; font-variant-numeric: tabular-nums;
}
.read-lines .conf.low { padding: 0 4px; }

/* ---------- каталог ---------- */
.catalogbar .reset { font-size: 13px; color: var(--muted); }
.catalog h1 { font: 700 23px/1.2 var(--f-body); margin: 0 0 4px; }
.catalog .range { color: var(--muted); font: 500 12px var(--f-mono); margin: 0 0 12px; }
.booklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.bookrow {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 9px;
  padding: 13px 15px; display: grid; gap: 6px;
}
.bookrow .title { font: 600 16.5px/1.35 var(--f-read); text-decoration: none; text-wrap: pretty; }
.bookrow .actions { margin: 0; }
.actions .read {
  display: inline-block; font: 500 13px var(--f-body); padding: 7px 14px;
  border-radius: 7px; border: 1px solid var(--ink); background: var(--ink);
  color: var(--paper); text-decoration: none;
}
.tag.rights { border-style: dashed; }

@media (max-width: 960px) {
  .reader { grid-template-columns: minmax(0, 1fr); }
  .reader-scan { position: static; }
  .read-lines li { grid-template-columns: 2.2em minmax(0, 1fr) 3.2em; }
  .mainnav { margin-left: 0; }
}

/* Строка, ради которой пришли из поиска: её видно сразу, без вглядывания.
   Подсветка самих слов — <mark> внутри строки, это разные вещи. */
.read-lines li.focus { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.boxes .bx.focus { stroke-width: 4px; }

/* Кнопки скачивания на карточке книги: у каждой сказано, что это за слой —
   иначе читатель не отличит канон от машинной транслитерации. */
.downloads { list-style: none; padding: 0; display: grid; gap: 10px; }
.downloads li { display: grid; grid-template-columns: auto auto 1fr; gap: 4px 10px; align-items: baseline; }
.downloads a { font-weight: 600; }
.downloads .size { color: var(--muted); font-variant-numeric: tabular-nums; }
.downloads .note { grid-column: 1 / -1; color: var(--muted); font-size: .92em; }

/* ---------- чат поверх фонда (/ask) ---------- */
.ask-note { color: var(--muted); font-size: 13px; max-width: 78ch; margin: -12px 0 0; }
/* Ответ моделью — один блок, источники под ним списком: канонический текст
   должен быть виден без прокрутки за пределы ответа. */
.answer h2 { font: 700 19px/1.3 var(--f-body); margin: 0 0 8px; }
.answer h3 { font: 500 11.5px var(--f-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 10px; }
.answer-text {
  font: 400 17px/1.6 var(--f-read); max-width: 72ch; margin: 0 0 8px;
  background: var(--surface); border: 1px solid var(--rule); border-left: 3px solid var(--accent);
  border-radius: 9px; padding: 14px 16px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.answer-text .ref { font: 500 12px var(--f-mono); color: var(--accent); text-decoration: none; vertical-align: super; }
.answer-text .ref:hover { text-decoration: underline; }
.answer-warn { color: var(--muted); font-size: 12.5px; max-width: 72ch; margin: 0; }
/* Числа, которых во фрагментах нет: не прячем и не правим, а показываем. */
.answer-flag {
  font: 500 13px/1.5 var(--f-body); max-width: 72ch; margin: 0 0 6px;
  padding: 8px 12px; border: 1px solid var(--accent); border-radius: 7px;
  background: var(--accent-soft); color: var(--ink);
}
.sources { list-style: none; margin: 0; padding: 0; counter-reset: src; }
.sources li {
  position: relative; counter-increment: src; background: var(--surface);
  border: 1px solid var(--rule); border-radius: 9px; padding: 13px 15px 13px 42px; margin-bottom: 10px;
}
.sources li::before {
  content: "[" counter(src) "]"; position: absolute; left: 12px; top: 13px;
  font: 500 12px var(--f-mono); color: var(--accent);
}
.sources li:target { border-color: var(--accent); background: var(--accent-soft); }
/* Индикатор ожидания свой: htmx-config отключает его встроенные стили. */
.htmx-indicator { display: none; font-size: 13px; color: var(--muted); }
.htmx-request .htmx-indicator, .htmx-indicator.htmx-request { display: inline; }
