/* Сервис вычитки словарей — единственный лист стилей.
 *
 * Вид — в духе платформы Sowa: тёплый светлый фон, белые карточки со
 * скруглением, шалфейно-зелёный акцент, чёрные основные кнопки. Всё на
 * токенах (:root), разовых значений в правилах нет.
 *
 * Строки списков и дерева — ОДНОЙ высоты при любых данных: слоты счётчиков
 * фиксированной ширины, длинный текст режется эллипсисом, полное значение
 * остаётся в `title` (ПРАВИЛО 9 платформы).
 */

:root {
    --bg:          #f6f4ee;
    --surface:     #ffffff;
    --surface-2:   #fbfaf6;
    --ink:         #1c1d1a;
    --ink-2:       #4a4d47;
    --muted:       #7b7f77;
    --line:        #e4e0d5;
    --line-2:      #cfcabb;

    --sage:        #5c7a6f;
    --sage-deep:   #2f5d54;
    --sage-pale:   #e4ece8;

    --green:       #1f8a4c;
    --green-pale:  #e8f5ec;
    --red:         #b03a3a;
    --red-pale:    #fbeceb;
    --amber-pale:  #fdf3dc;

    /* Щиты категорий (комплект history-shields-v1) */
    --cat-off:     #8c9087;
    --cat-line:    #268856;
    --cat-halo:    #42dc89;
    --lamp:        24px;
    --lamp-gap:    6px;

    --r-sm:  8px;
    --r:     14px;
    --r-lg:  18px;
    --gap:   16px;
    --pad:   20px;

    --font-head: "Manrope", "Segoe UI", system-ui, sans-serif;
    --font-text: "Inter", "Segoe UI", system-ui, sans-serif;

    /* Слоты счётчиков в строках дерева и списков — константы раскладки:
     * данные не двигают соседей. */
    --slot-count: 76px;
    --slot-new:   62px;
    --slot-meta: 120px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.5 var(--font-text);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .h1, .h2, .h3 { font-family: var(--font-head); margin: 0 0 12px; }
.h1 { font-size: 26px; line-height: 1.2; }
.h2 { font-size: 18px; }
.h3 { font-size: 15px; color: var(--ink-2); }
p { margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 13px; }
.link { color: var(--sage-deep); }
.code {
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: var(--r-sm); padding: 10px 12px; overflow: auto;
    font-size: 13px; white-space: pre-wrap;
}

/* ── Шапка ───────────────────────────────────────────────────────────── */
.top {
    display: flex; align-items: center; gap: var(--gap);
    padding: 10px 24px; background: var(--surface);
    border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.top__brand {
    font-family: var(--font-head); font-weight: 700; font-size: 16px;
    color: var(--ink); text-decoration: none;
}
.top__nav { display: flex; gap: 14px; margin-left: auto; }
.top__nav a, .top__user { color: var(--ink-2); text-decoration: none; font-size: 14px; }
.top__nav a:hover { color: var(--sage-deep); text-decoration: underline; }
.top__user { color: var(--muted); }

.switch { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; overflow: hidden; }
.switch__item {
    padding: 5px 14px; font-size: 14px; color: var(--ink-2);
    text-decoration: none; background: var(--surface);
}
.switch__item--on { background: var(--sage-deep); color: #fff; }

/* ── Каркас страницы ─────────────────────────────────────────────────── */
.page { max-width: 1240px; margin: 0 auto; padding: 24px 16px 60px; }
.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: var(--gap); align-items: start; }
.review { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--gap); align-items: start; }
@media (max-width: 900px) {
    .cols, .review { grid-template-columns: minmax(0, 1fr); }
}

.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r); padding: var(--pad); margin-bottom: var(--gap);
}
.card--note { background: var(--sage-pale); border-color: var(--sage); }

.banner { padding: 10px 14px; border-radius: var(--r-sm); margin-bottom: var(--gap); }
.banner--warn { background: var(--amber-pale); border: 1px solid #e3c37a; }

.flash { list-style: none; margin: 0 0 var(--gap); padding: 0; display: grid; gap: 8px; }
.flash__item { padding: 10px 14px; border-radius: var(--r-sm); background: var(--sage-pale); border: 1px solid var(--sage); }
.flash__item--error { background: var(--red-pale); border-color: var(--red); }

/* ── Плитки сводки ───────────────────────────────────────────────────── */
.tiles { display: flex; flex-wrap: wrap; gap: var(--gap); margin-bottom: var(--gap); }
.tile {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
    padding: 14px 18px; min-width: 150px; flex: 1 1 150px;
}
.tile--accent { background: var(--sage-pale); border-color: var(--sage); }
.tile__num { display: block; font-family: var(--font-head); font-size: 26px; font-weight: 700; }
.tile__of { font-size: 16px; color: var(--muted); font-weight: 600; }
.tile__cap { display: block; font-size: 12px; color: var(--muted); }

/* ── Кнопки и поля ───────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font: 600 14px/1 var(--font-text); padding: 10px 18px; border-radius: 999px;
    border: 1px solid transparent; background: var(--ink); color: #fff;
    cursor: pointer; text-decoration: none;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--ink); }
.btn--ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line-2); }
.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--wide { width: 100%; }
.btn--accept { background: var(--green); border-color: var(--green); font-size: 15px; letter-spacing: .03em; }
.btn--reject { background: var(--red); border-color: var(--red); font-size: 15px; letter-spacing: .03em; }
.btn:focus-visible, .fld:focus-visible, .input:focus-visible, summary:focus-visible {
    outline: 2px solid var(--sage-deep); outline-offset: 2px;
}

.field { display: block; margin-bottom: 12px; }
.field__label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.input {
    width: 100%; padding: 10px 12px; font: 15px var(--font-text);
    border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface);
}
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }

.auth { max-width: 380px; margin: 60px auto; }
.auth__title { font-size: 24px; text-align: center; }
.auth__sub { text-align: center; color: var(--muted); font-size: 13px; }
.auth__error { background: var(--red-pale); border: 1px solid var(--red); border-radius: var(--r-sm); padding: 8px 10px; }

/* ── Дерево разделов ─────────────────────────────────────────────────── */
.tree { list-style: none; margin: 0; padding: 0; }
.tree--sub { padding-left: 18px; border-left: 1px solid var(--line); margin-left: 6px; }
.tree__d > summary {
    cursor: pointer;
    /* Свой маркер (▸/▾ у названия) вместо треугольника браузера: он должен
     * стоять в слоте названия, а не перед всей строкой. */
    display: block;
    list-style: none;
}
.tree__d > summary::-webkit-details-marker { display: none; }
.tree__d > summary::marker { content: ""; }

.row {
    display: flex; align-items: center; gap: 8px;
    height: 30px; padding: 0 6px; border-radius: var(--r-sm);
    font-size: 14px; white-space: nowrap;
}
.row:hover { background: var(--surface-2); }
.row--era { font-family: var(--font-head); font-weight: 700; }
.row--period { font-weight: 600; color: var(--ink-2); }
.row--topic { color: var(--ink-2); }
.row--locked { background: var(--red-pale); color: var(--red); }
.row__title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.row__count { flex: 0 0 var(--slot-count); text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.row__new {
    flex: 0 0 var(--slot-new); text-align: center; font-size: 12px;
    color: var(--sage-deep); background: var(--sage-pale); border-radius: 999px;
    line-height: 20px; font-variant-numeric: tabular-nums;
}
.row__lock { flex: 0 0 auto; font-size: 12px; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.row__box { flex: 0 0 auto; width: 15px; height: 15px; accent-color: var(--sage-deep); }
.tree__d > summary .row__title::before { content: "▸ "; color: var(--line-2); }
.tree__d[open] > summary .row__title::before { content: "▾ "; }

.sticky-actions {
    display: flex; align-items: center; gap: 12px;
    padding-top: 14px; margin-top: 10px; border-top: 1px solid var(--line);
    position: sticky; bottom: 0; background: var(--surface);
}

/* ── Списки (сессии, пользователи, темы) ─────────────────────────────── */
.list { list-style: none; margin: 0; padding: 0; }
.list__row {
    display: flex; align-items: center; gap: 12px; height: 34px;
    border-bottom: 1px solid var(--line); font-size: 14px; white-space: nowrap;
}
.list__row:last-child { border-bottom: 0; }
.list__main { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--ink); text-decoration: none; }
a.list__main:hover { color: var(--sage-deep); text-decoration: underline; }
.list__meta {
    flex: 0 0 var(--slot-meta); color: var(--muted); font-size: 13px;
    overflow: hidden; text-overflow: ellipsis; text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ── Карточка задания ────────────────────────────────────────────────── */
.task__where { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.task__where span { overflow: hidden; text-overflow: ellipsis; max-width: 340px; white-space: nowrap; }

.task__cats {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 10px 14px; margin-bottom: 14px;
    background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
}
.task__meta { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.badge {
    font-size: 12px; color: var(--ink-2); background: var(--surface);
    border: 1px solid var(--line-2); border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.badge--muted { color: var(--muted); }

.lamps { display: inline-flex; align-items: center; gap: var(--lamp-gap); flex: none; }
.lamp { width: var(--lamp); height: var(--lamp); display: grid; place-items: center; flex: none; }
.lamp__ic {
    width: var(--lamp); height: var(--lamp);
    --history-line: var(--cat-off); --history-halo: var(--cat-off); --history-glow: 0;
}
.lamp__ic[data-state="positive"] {
    --history-line: var(--cat-line); --history-halo: var(--cat-halo); --history-glow: .8;
}
.cat-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.task__title { font-family: var(--font-head); font-weight: 600; }
.task__question {
    background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
    padding: 16px 18px; margin-bottom: 16px; font-size: 16px; line-height: 1.55;
}
.task__images { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.shot { margin: 0; max-width: 100%; }
.shot img { max-width: 420px; max-height: 420px; border-radius: var(--r-sm); border: 1px solid var(--line); }
.shot__cap { font-size: 12px; color: var(--muted); }
.task__content { margin-bottom: 16px; }
.task__expl { font-size: 14px; color: var(--ink-2); background: var(--sage-pale); border-radius: var(--r-sm); padding: 10px 12px; }
.task__expl-cap { color: var(--sage-deep); font-weight: 600; }
.task__src { font-size: 12px; color: var(--muted); }

.task__decide {
    display: flex; align-items: center; justify-content: space-between; gap: var(--gap);
    flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 16px; margin-top: 8px;
}
.task__buttons { display: flex; gap: 12px; }
.task__buttons .btn { min-width: 160px; }

/* ── Содержимое задания по видам ─────────────────────────────────────── */
.opts { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.opt { display: flex; align-items: flex-start; gap: 10px; padding: 6px 10px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); }
.opt--right { background: var(--green-pale); border-color: var(--green); }
.opt__mark { flex: 0 0 22px; text-align: center; color: var(--muted); font-weight: 600; }
.opt--right .opt__mark { color: var(--green); }
.opt__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--green-pale); border: 1px solid var(--green); border-radius: 999px; padding: 4px 12px; font-size: 14px; }
.chip--muted { background: var(--surface-2); border-color: var(--line-2); color: var(--ink-2); }

.match__head, .match__row { display: grid; grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr); align-items: center; gap: 8px; }
.match__head { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.match__rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.match__row { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 10px; }
.match__cell { min-width: 0; }
.match__cell--right { color: var(--ink); background: var(--green-pale); border-radius: var(--r-sm); padding: 2px 8px; }
.match__arrow { text-align: center; color: var(--muted); }
.match__extra-cap { font-size: 12px; color: var(--muted); margin: 12px 0 6px; }

.groups { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.group { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; }
.group__name { font-size: 14px; margin-bottom: 8px; }

.seq__vector { font-size: 13px; color: var(--muted); }
.seq__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.seq__item { display: flex; align-items: flex-start; gap: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 10px; }
.seq__num { flex: 0 0 22px; text-align: center; font-weight: 700; color: var(--sage-deep); }

.vars__text { font-size: 16px; line-height: 1.8; }
.vars__slot { background: var(--green-pale); border-bottom: 2px solid var(--green); border-radius: 4px; padding: 1px 4px; }
.vars__alt { color: var(--muted); font-size: 13px; }
.vars__alt::before { content: " / "; }

/* ── Редактируемый текст ─────────────────────────────────────────────── */
.fld {
    font: inherit; color: inherit; text-align: left; background: none;
    border: 0; border-bottom: 1px dashed var(--line-2); padding: 0 1px;
    margin: 0; cursor: text; white-space: pre-wrap; display: inline;
}
.fld:hover { background: var(--amber-pale); }
.fld--changed { background: var(--amber-pale); border-bottom-color: #c99a2e; }
.fld--changed::after { content: " ✎"; color: #b1832a; font-size: .8em; }
.fld[hidden] { display: none; }

.ed { display: block; margin: 6px 0; }
.ed__area { display: block; }
.ed__area {
    width: 100%; font: 15px/1.5 var(--font-text); padding: 8px 10px;
    border: 1px solid var(--sage); border-radius: var(--r-sm); background: var(--surface);
}
.ed__bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.ed__was { font-size: 12px; color: var(--muted); max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed__err { font-size: 13px; color: var(--red); }

/* ── Боковая колонка вычитки ─────────────────────────────────────────── */
.side { position: sticky; top: 16px; }
.side__box { max-height: 60vh; overflow: auto; }
.side__sum { font-size: 13px; color: var(--sage-deep); font-weight: 600; }
.side__hint { margin-top: 8px; }

/* Текущие сессии на дашборде: карточка на сессию, подписи у значений */
.live { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.live__item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.live__who { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live__facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 8px 0 0; }
.live__facts dt { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.live__facts dd { margin: 2px 0 0; font-variant-numeric: tabular-nums; }
