/* «Учебный ассистент» — оформление «Фазовый портрет» (design/design-philosophy.md):
   тёмная тема — тушь, светлая — бумага; индиго — главный акцент, янтарь — подсказки и «сейчас здесь».
   Тема выбирается кнопкой в нижней строке панели (theme.js), по умолчанию — как в системе. */

:root {
  --bg: #0b0e14;
  --bg-soft: #0f131b;
  --bg-card: #141923;
  --bg-raised: #1b2130;
  --bg-input: #0e1219;
  --bg-glass: rgba(11, 14, 20, .82);
  --line: #212839;
  --line-strong: #303a52;
  --text: #e8ebf3;
  --text-2: #c4cad8;
  --muted: #8a93a6;
  --accent: #8b9cff;
  --accent-soft: rgba(139, 156, 255, .12);
  --accent-line: rgba(139, 156, 255, .38);
  --primary: #6672f2;
  --primary-hi: #7d88f7;
  --on-primary: #fff;
  --spark: #f2b25c;
  --spark-soft: rgba(242, 178, 92, .1);
  --spark-line: rgba(242, 178, 92, .34);
  --ok: #4fd18b;
  --ok-soft: rgba(79, 209, 139, .09);
  --ok-line: rgba(79, 209, 139, .32);
  --warn: #f2b25c;
  --warn-soft: rgba(242, 178, 92, .09);
  --warn-line: rgba(242, 178, 92, .32);
  --bad: #f47b7b;
  --bad-soft: rgba(244, 123, 123, .09);
  --bad-line: rgba(244, 123, 123, .32);
  --hard: #c9a6ff;
  --formula: #c9d4ff;
  --track: #222a3a;
  --scroll: #2b3346;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .18);
  --shadow-pop: 0 24px 70px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .3);
  --radius: 18px;
  --radius-sm: 12px;
  --font: "Golos Text", "Inter", "Segoe UI Variable Text", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Mono", "JetBrains Mono", "SF Mono", Consolas, monospace;
  color-scheme: dark;
}

/* Светлая тема — «бумага старой монографии». Включается явно или по настройке системы. */
:root[data-theme="light"] {
  --bg: #f5f2ea;
  --bg-soft: #efebe1;
  --bg-card: #fffdf8;
  --bg-raised: #f1ece1;
  --bg-input: #fbf9f4;
  --bg-glass: rgba(245, 242, 234, .84);
  --line: #e3ddcf;
  --line-strong: #d1c8b4;
  --text: #191b22;
  --text-2: #33374a;
  --muted: #6c6f7b;
  --accent: #4453d6;
  --accent-soft: rgba(68, 83, 214, .08);
  --accent-line: rgba(68, 83, 214, .32);
  --primary: #4453d6;
  --primary-hi: #5462e0;
  --spark: #c7741a;
  --spark-soft: rgba(199, 116, 26, .08);
  --spark-line: rgba(199, 116, 26, .32);
  --ok: #1f8f52;
  --ok-soft: rgba(31, 143, 82, .07);
  --ok-line: rgba(31, 143, 82, .3);
  --warn: #b76d0e;
  --warn-soft: rgba(199, 116, 26, .08);
  --warn-line: rgba(199, 116, 26, .32);
  --bad: #cc3f3f;
  --bad-soft: rgba(204, 63, 63, .06);
  --bad-line: rgba(204, 63, 63, .3);
  --hard: #7c4bc9;
  --formula: #2f3a8f;
  --track: #e7e1d3;
  --scroll: #cfc6b2;
  --shadow: 0 1px 2px rgba(60, 50, 30, .06), 0 8px 24px rgba(60, 50, 30, .06);
  --shadow-pop: 0 24px 60px rgba(40, 32, 18, .18), 0 2px 8px rgba(40, 32, 18, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f2ea; --bg-soft: #efebe1; --bg-card: #fffdf8; --bg-raised: #f1ece1; --bg-input: #fbf9f4;
    --bg-glass: rgba(245, 242, 234, .84); --line: #e3ddcf; --line-strong: #d1c8b4;
    --text: #191b22; --text-2: #33374a; --muted: #6c6f7b;
    --accent: #4453d6; --accent-soft: rgba(68, 83, 214, .08); --accent-line: rgba(68, 83, 214, .32);
    --primary: #4453d6; --primary-hi: #5462e0;
    --spark: #c7741a; --spark-soft: rgba(199, 116, 26, .08); --spark-line: rgba(199, 116, 26, .32);
    --ok: #1f8f52; --ok-soft: rgba(31, 143, 82, .07); --ok-line: rgba(31, 143, 82, .3);
    --warn: #b76d0e; --warn-soft: rgba(199, 116, 26, .08); --warn-line: rgba(199, 116, 26, .32);
    --bad: #cc3f3f; --bad-soft: rgba(204, 63, 63, .06); --bad-line: rgba(204, 63, 63, .3);
    --hard: #7c4bc9; --formula: #2f3a8f; --track: #e7e1d3; --scroll: #cfc6b2;
    --shadow: 0 1px 2px rgba(60, 50, 30, .06), 0 8px 24px rgba(60, 50, 30, .06);
    --shadow-pop: 0 24px 60px rgba(40, 32, 18, .18), 0 2px 8px rgba(40, 32, 18, .08);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

/* Полосы прокрутки в цвет темы, а не системные. */
html { scrollbar-color: var(--scroll) var(--bg); }
.sidebar, .chapters, .ask-log, .scan-wrap, textarea { scrollbar-color: var(--scroll) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--line-strong); }
::-webkit-scrollbar-corner { background: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15.5px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}
::selection { background: var(--accent-line); }
:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }
button, input, select, textarea { font-family: inherit; }
[hidden] { display: none !important; }

.app { display: grid; grid-template-columns: 320px 1fr; min-height: 100vh; }

/* ── Левая панель ── */
.sidebar {
  border-right: 1px solid var(--line);
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}
.side-head { padding: 18px 16px 8px; }
.side-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.side-head h1 { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; flex: none; box-shadow: 0 0 0 1px var(--line); }
.icon-btn {
  flex: none; width: 32px; height: 32px; display: grid; place-items: center;
  font: inherit; font-size: 18px; line-height: 1; cursor: pointer;
  background: transparent; color: var(--muted); border: 1px solid transparent; border-radius: 10px;
  transition: background .15s, color .15s;
}
.icon-btn:hover { color: var(--text); background: var(--bg-raised); }

/* Скрытая левая панель: контент на всю ширину, в углу — кнопка возврата. */
.sidebar-show {
  display: none; position: fixed; top: 14px; left: 14px; z-index: 5;
  width: 42px; height: 42px; place-items: center; cursor: pointer;
  font: inherit; font-size: 18px; color: var(--text);
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 13px;
  box-shadow: var(--shadow);
}
.sidebar-show:hover { background: var(--bg-raised); }
body.no-sidebar .app { grid-template-columns: 1fr; }
body.no-sidebar .sidebar { display: none; }
body.no-sidebar .sidebar-show { display: grid; }
body.no-sidebar .main { margin: 0 auto; padding-left: 72px; padding-right: 72px; max-width: 1180px; }
.main.reading, body.no-sidebar .main.reading { max-width: none; width: 100%; min-width: 0; }
/* «По ширине» на широком мониторе не растягивает скан больше, чем удобно читать. */
.main.reading .scan-frame:not(.zoomed) { max-width: 1240px; }
.muted { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }

/* Полка: «Учебники / Задачники» — сегментированный переключатель. */
.book-kind { display: flex; gap: 2px; padding: 3px; margin-bottom: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.book-kind[hidden] { display: none; }
.book-kind button {
  flex: 1; padding: 6px 8px; border: 0; border-radius: 9px; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s;
}
.book-kind button:hover { color: var(--text); }
.book-kind button.on { background: var(--bg-card); color: var(--text); box-shadow: var(--shadow), 0 0 0 1px var(--line); }
.book-label { display: block; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin-bottom: 6px; }

.book-select, .filter {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  transition: border-color .15s;
}
.book-select:hover, .filter:hover { border-color: var(--line-strong); }
.book-select:focus, .filter:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.filter { margin: 8px 0 10px; width: calc(100% - 32px); margin-left: 16px; }
#book-title { line-height: 1.45; }

.overall { margin-top: 14px; font-size: 12.5px; color: var(--muted); }
.overall-row { display: flex; justify-content: space-between; gap: 8px; font-variant-numeric: tabular-nums; }

.chapters { overflow-y: auto; padding: 0 10px 20px; }

/* Разделы «Книга / Глоссарий / Формулы». */
.views { display: flex; gap: 4px; margin: 0 2px 10px; padding: 3px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.view-btn {
  flex: 1; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  background: transparent; color: var(--muted); border: 0; border-radius: 9px; padding: 6px 8px;
  transition: background .15s, color .15s;
}
.view-btn:hover { color: var(--text); }
.view-btn.active { color: var(--text); background: var(--bg-card); box-shadow: var(--shadow), 0 0 0 1px var(--line); }

.chapter {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  cursor: pointer;
  display: block;
  margin-bottom: 2px;
  font: inherit;
  position: relative;
  transition: background .15s;
}
.chapter:hover { background: var(--bg-raised); }
.chapter.active { background: var(--accent-soft); border-color: var(--accent-line); }
.chapter.active::before {
  content: ''; position: absolute; left: -10px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.chapter .row1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.chapter .num { color: var(--muted); font: 500 11.5px/1 var(--mono); font-variant-numeric: tabular-nums; }
.chapter .name { font-size: 13.5px; font-weight: 600; line-height: 1.35; }
.chapter .meta { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 5px; font-variant-numeric: tabular-nums; }
.chapter .meta .score { font-weight: 700; }

.side-foot { padding: 10px 16px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* ── Основная колонка ── */
.main { padding: 32px 40px 72px; max-width: 1040px; }
.empty { color: var(--muted); margin-top: 40vh; text-align: center; }

.chapter-head h2 { margin: 0 0 10px; font-size: 27px; line-height: 1.22; font-weight: 700; letter-spacing: -.022em; }
.chapter-head .sub { color: var(--muted); font-size: 13px; display: flex; gap: 10px 14px; flex-wrap: wrap; align-items: center; }
.chapter-head .score { font-weight: 700; font-variant-numeric: tabular-nums; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 11.5px; font-weight: 600; color: var(--muted); background: var(--bg-card); }
.pill.ok { color: var(--ok); border-color: var(--ok-line); background: var(--ok-soft); }

/* Вкладки главы — сегментированный переключатель. */
.tabs {
  display: inline-flex; gap: 2px; margin: 22px 0 20px; padding: 4px; flex-wrap: wrap; max-width: 100%;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 14px;
}
.tab {
  background: transparent; border: none; border-radius: 10px;
  color: var(--muted); padding: 7px 14px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); background: var(--bg-card); box-shadow: var(--shadow), 0 0 0 1px var(--line); }

/* Переключатели (полка, разделы, вкладки) с перетекающей «таблеткой» выбранного пункта — её двигает segments.js.
   Пока скрипт не подключился, выбранный пункт подсвечен сам — как выше. */
.book-kind, .views, .tabs { position: relative; isolation: isolate; }
.book-kind button, .view-btn, .tab { position: relative; z-index: 1; }
.seg-ready > button.on, .seg-ready > button.active { background: transparent; box-shadow: none; }
.seg-pill {
  position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none;
  border-radius: 9px; background: var(--bg-card); box-shadow: var(--shadow), 0 0 0 1px var(--line);
  transition: transform .34s cubic-bezier(.3, 1.15, .4, 1), width .34s cubic-bezier(.3, 1.15, .4, 1), height .34s ease;
}
.tabs > .seg-pill { border-radius: 10px; }
.seg-pill.instant { transition: none; }
@media (prefers-reduced-motion: reduce) { .seg-pill { transition: none; } }

.section-head {
  display: flex; align-items: baseline; gap: 12px;
  margin: 34px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
  scroll-margin-top: 16px;
}
.section-head h3 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.012em; color: var(--text-2); }
.section-head .muted { margin: 0; font-variant-numeric: tabular-nums; }
.section-head .bar.mini { margin-left: auto; align-self: center; }
.section-head .page-link { font-size: 12.5px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 10px; font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tag { font-size: 11px; border-radius: 999px; padding: 2px 9px; border: 1px solid var(--line); color: var(--muted); font-weight: 600; letter-spacing: .01em; }
.tag.hard { color: var(--hard); border-color: color-mix(in srgb, var(--hard) 35%, transparent); }

.text { white-space: pre-wrap; }
.q { margin: 0 0 10px; }
.label { color: var(--muted); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; margin: 14px 0 6px; }

details.hint { margin: 8px 0 4px; }
details.hint summary { cursor: pointer; color: var(--warn); font-size: 13px; font-weight: 600; }
details.hint p { margin: 8px 0 0; color: var(--text); padding: 10px 14px; border-radius: var(--radius-sm); background: var(--warn-soft); border: 1px solid var(--warn-line); }

textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  line-height: 1.55;
  transition: border-color .15s, box-shadow .15s;
}
textarea::placeholder, input::placeholder { color: var(--muted); opacity: .8; }
textarea:hover { border-color: var(--line-strong); }
textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ── Кнопки ── */
.actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
button.btn {
  background: var(--primary); color: var(--on-primary); border: 1px solid transparent; border-radius: 999px;
  padding: 8px 18px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .14) inset, 0 4px 14px color-mix(in srgb, var(--primary) 30%, transparent);
  transition: background .15s, transform .1s, box-shadow .15s;
}
button.btn:hover { background: var(--primary-hi); }
button.btn:active { transform: translateY(1px); }
button.btn:disabled { opacity: .5; cursor: default; transform: none; }
button.ghost, button.btn.ghost {
  background: var(--bg-card); border: 1px solid var(--line); color: var(--text-2); box-shadow: none;
}
button.ghost:hover, button.btn.ghost:hover { background: var(--bg-raised); border-color: var(--line-strong); color: var(--text); }
.spacer { flex: 1; }

button.link {
  background: none; border: none; padding: 0 4px; font: inherit; font-size: 12.5px; font-weight: 500; color: var(--accent); cursor: pointer;
  text-underline-offset: 3px;
}
button.link:hover { text-decoration: underline; }

/* ── Вердикт проверки ── */
.verdict { margin-top: 14px; border-radius: 14px; padding: 12px 16px; font-size: 13.5px; border: 1px solid var(--line); background: var(--bg-soft); }
.verdict.ok { border-color: var(--ok-line); background: var(--ok-soft); }
.verdict.warn { border-color: var(--warn-line); background: var(--warn-soft); }
.verdict.bad { border-color: var(--bad-line); background: var(--bad-soft); }
.verdict .head { font-weight: 700; margin-bottom: 6px; display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.verdict.ok .head { color: var(--ok); }
.verdict.warn .head { color: var(--warn); }
.verdict.bad .head { color: var(--bad); }
.verdict ul { margin: 6px 0 0 18px; padding: 0; }
.verdict li { margin: 3px 0; }

/* ── Формулы (KaTeX) ── */
.math .katex { font-size: 1.08em; white-space: nowrap; }
/* KaTeX помечает \text{мВт/лм} классом .text — без этого на него действует наш .text (pre-wrap) и единицы рвутся на строки. */
.katex { overflow-wrap: normal; word-break: normal; }
.katex .text { white-space: nowrap; }
.math-block { overflow-x: auto; overflow-y: hidden; padding: 4px 0; white-space: normal; }
.math-block .katex-display { margin: 2px 0; }

/* ── Задача из задачника: поиск, подсказки-плашки, ответ и решение ── */
.problem-num { font-variant-numeric: tabular-nums; }
.problem-search { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; }
.problem-search[hidden], .search-opener[hidden], .to-top[hidden] { display: none; }
.search-opener { margin: 0 0 12px; padding: 6px 14px; font-size: 13px; }
/* Кнопка «наверх» в правом нижнем углу. */
.to-top {
  position: fixed; right: 24px; bottom: 24px; z-index: 19; width: 46px; height: 46px;
  display: grid; place-items: center; font: inherit; font-size: 20px; font-weight: 600; cursor: pointer;
  color: var(--text); background: var(--bg-card); border: 1px solid var(--line); border-radius: 50%;
  box-shadow: var(--shadow-pop);
}
.to-top:hover { border-color: var(--accent-line); color: var(--accent); }
.problem-search-input {
  width: 280px; max-width: 100%; padding: 8px 16px; font: inherit; font-size: 14px;
  background: var(--bg-input); color: var(--text); border: 1px solid var(--line); border-radius: 999px;
}
.problem-search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
/* В главе задачника сотни карточек: браузер раскладывает и рисует только те, что рядом с экраном
   (иначе открытие главы на телефоне занимало десятки секунд). auto — запомненная высота уже показанной карточки. */
.card.task { scroll-margin-top: 16px; content-visibility: auto; contain-intrinsic-size: auto 460px; }
.card.task.flash { animation: task-flash 1.6s ease-out; }
@keyframes task-flash { from { box-shadow: 0 0 0 3px var(--accent); } to { box-shadow: 0 0 0 3px transparent; } }
.card.task .answer { font-size: 15px; }
.hints { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 0; }
.hint-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.hint-btn { margin-top: 8px; }
.hint-btn[hidden] { display: none; }
.plaque { border-radius: 14px; padding: 11px 15px; border: 1px solid var(--line); background: var(--bg-soft); }
.plaque-head { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; margin-bottom: 5px; }
.plaque.hint-plaque { border-color: var(--warn-line); background: var(--warn-soft); }
.plaque.hint-plaque .plaque-head { color: var(--warn); }
.plaque.answer-plaque { border-color: var(--ok-line); background: var(--ok-soft); }
.plaque.answer-plaque .plaque-head { color: var(--ok); }
.plaque.solution-plaque { border-color: var(--accent-line); background: var(--accent-soft); }
.plaque.solution-plaque .plaque-head { color: var(--accent); }
.solution { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }

.reference { margin-top: 14px; border: 1px solid var(--accent-line); border-radius: 14px; background: var(--accent-soft); padding: 11px 15px; }
.reference p { margin: 0; }

/* ── Таблицы ── */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; vertical-align: top; padding: 10px 10px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }
th { color: var(--muted); font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; }
.table-wrap { overflow-x: auto; }
td.term { font-weight: 700; min-width: 140px; }
td.muted-cell { color: var(--muted); }
td.formula { font-family: var(--mono); color: var(--formula); white-space: normal; min-width: 220px; font-size: 13.5px; line-height: 1.5; }
td.ref { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.search {
  width: 100%; margin: 18px 0 16px; padding: 11px 18px; font: inherit; font-size: 14px;
  background: var(--bg-input); color: var(--text); border: 1px solid var(--line); border-radius: 999px;
}
.search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Поиск по терминам и формулам всех книг. */
.found-scope { display: flex; gap: 6px; margin: -6px 0 14px; }
.scope-chip {
  font: inherit; font-size: 12.5px; padding: 5px 12px; cursor: pointer;
  background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 999px;
}
.scope-chip:hover { color: var(--text); }
.scope-chip.on { color: var(--text); background: var(--bg-card); border-color: var(--accent); }
.found-book { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 4px; }
.found td.ref .link { margin-right: 6px; white-space: nowrap; }
.found-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.found-title { font-weight: 700; }
.hits { display: flex; flex-direction: column; }
.hit {
  display: flex; gap: 12px; align-items: baseline; width: 100%; text-align: left; cursor: pointer;
  font: inherit; font-size: 13.5px; line-height: 1.5; color: var(--text);
  background: transparent; border: 0; border-top: 1px solid var(--line); padding: 9px 4px;
}
.hit:first-child { border-top: 0; }
.hit:hover { background: var(--accent-soft); }
.hit-page { flex: none; width: 84px; display: flex; flex-direction: column; font-size: 12.5px; color: var(--muted); }
.hit-page b { color: var(--accent); font-weight: 700; }
.hit-text { min-width: 0; overflow-wrap: anywhere; color: var(--muted); }
.hit-text mark { background: var(--accent-soft); color: var(--text); font-weight: 700; border-radius: 3px; padding: 0 2px; }
.hits-more { margin-top: 6px; }
.hits-more[hidden] { display: none; }
@media (max-width: 600px) { .hit { gap: 8px; } .hit-page { width: 58px; } }
/* Колонки одной ширины во всех группах книг (на телефоне строки таблиц и так идут столбиком — см. mobile.css). */
@media (min-width: 861px) {
  .found table { table-layout: fixed; }
  .found td.term { width: 30%; min-width: 0; }
  .found td.formula { width: 46%; min-width: 0; overflow-x: auto; }
  .found td.ref { width: 96px; white-space: normal; }
  /* У глоссария есть строка заголовков — при fixed-раскладке ширины берутся из неё. */
  .found table.glossary th:first-child { width: 28%; }
  .found table.glossary th:last-child { width: 118px; }
}
.find-term { display: inline-block; margin-top: 2px; font-size: 12.5px; white-space: nowrap; }
tr.flash > td { animation: row-flash 1.8s ease-out; }
@keyframes row-flash { from { background: var(--accent-soft); } to { background: transparent; } }

.clist { margin: 6px 0 0; padding-left: 20px; }
.clist li { margin: 6px 0; }
.status-line { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.error { color: var(--bad); font-size: 13px; margin-top: 8px; }

/* ── Шкала баллов: 0 — красный, середина — жёлтый, максимум — зелёный ── */
.bar {
  height: 6px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
  margin-top: 8px;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background-image: linear-gradient(90deg, #ef5a4f 0%, #f39a3d 30%, #e9c94a 55%, #8ed063 78%, #3ccf86 100%);
  background-repeat: no-repeat;
  transition: width .4s cubic-bezier(.2, .8, .2, 1);
}
.bar.compact { height: 4px; margin-top: 7px; }
.bar.big { height: 8px; margin-top: 16px; }
.bar.mini { height: 4px; margin-top: 0; width: 64px; flex: none; }

/* ── Оглавление параграфов ── */
.toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.toc-item {
  display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--text-2);
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 12px; padding: 7px 11px; font-size: 12.5px; font-weight: 600;
  transition: border-color .15s, color .15s;
}
.toc-item:hover { color: var(--accent); border-color: var(--accent-line); }

/* ── Карточка задания ── */
.card.task.done.ok { border-color: var(--ok-line); }
.card.task.done.warn { border-color: var(--warn-line); }
.card.task.done.bad { border-color: var(--bad-line); }
.self-grade { display: none; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.self-grade.visible { display: flex; }
.chip {
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; border-radius: 999px; padding: 5px 12px;
  background: var(--bg-card); border: 1px solid var(--line); color: var(--text-2);
  transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { background: var(--bg-raised); color: var(--text); }
.chip.ok:hover { color: var(--ok); border-color: var(--ok-line); background: var(--ok-soft); }
.chip.warn:hover { color: var(--warn); border-color: var(--warn-line); background: var(--warn-soft); }
.chip.bad:hover { color: var(--bad); border-color: var(--bad-line); background: var(--bad-soft); }
.chip:disabled { opacity: .45; cursor: default; }

/* ── Читалка сканов ── */
.reader-bar {
  position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 12px 0; margin-bottom: 14px; background: var(--bg-glass); border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.reader-bar .btn, .reader-bar .ghost { padding: 7px 13px; }
.reader-bar input[type="number"] {
  width: 76px; padding: 7px 10px; font: 500 14px var(--mono); text-align: center;
  background: var(--bg-input); color: var(--text); border: 1px solid var(--line); border-radius: 999px;
}
.reader-bar select {
  max-width: 300px; padding: 7px 12px; font: inherit; font-size: 13.5px;
  background: var(--bg-input); color: var(--text); border: 1px solid var(--line); border-radius: 999px;
}
.reader-bar input[type="number"]:focus, .reader-bar select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
/* Без стрелочек-счётчика: страницы листаются кнопками ‹ › и клавишами. */
.reader-bar input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
.reader-bar input[type="number"]::-webkit-inner-spin-button,
.reader-bar input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.reader-bar .where { color: var(--muted); font: 12.5px var(--mono); }
/* Без justify-content: center — иначе левый край увеличенного скана уходит за прокрутку. */
.scan-wrap { display: flex; overflow-x: auto; padding-bottom: 6px; }
.scan-wrap.pannable { cursor: grab; }
.scan-wrap.dragging { cursor: grabbing; user-select: none; }
.scan {
  display: block; background: #fff; border-radius: 8px; box-shadow: var(--shadow-pop);
  max-width: 100%; height: auto;
}
.zoom { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: var(--bg-card); }
.zoom button {
  border: 0; background: none; color: var(--text); font: inherit; font-size: 14px; cursor: pointer;
  padding: 6px 10px; border-radius: 999px;
}
.zoom button:hover { background: var(--bg-raised); }
.zoom .zoom-step { font-size: 17px; line-height: 1; width: 34px; padding: 6px 0; }
.zoom .zoom-label { min-width: 54px; font: 12.5px var(--mono); font-variant-numeric: tabular-nums; }
.zoom .zoom-fit { font-size: 13px; color: var(--muted); border-left: 1px solid var(--line); border-radius: 0 999px 999px 0; }
.zoom .zoom-fit.on { color: var(--accent); }
/* Тёмная страница — перекрашенная копия (darkScan в app.js). Пока она готовится, белый оригинал не показываем:
   на его месте тёмная подложка. Не вышло перекрасить — запасной вариант, CSS-фильтр. */
.scan.dark:not(.inverted):not(.invert-failed) { visibility: hidden; }
.scan-frame:has(> .scan.dark) { background: #141414; border-radius: 8px; }
.scan-frame:has(> .scan.dark:not(.inverted):not(.invert-failed)) { min-height: 70vh; }
.scan.dark.invert-failed { filter: invert(.92) hue-rotate(180deg); }
.scan-hint { color: var(--muted); font-size: 12.5px; text-align: center; margin: 12px 0 0; }
button.page-link { padding: 0 2px; font-size: inherit; color: var(--accent); }

/* ── Вопросы по странице ── */
.scan-frame { position: relative; display: inline-block; max-width: 100%; line-height: 0; margin: 0 auto; flex: none; }
.scan-frame:not(.zoomed), .scan-frame:not(.zoomed) .scan { width: 100%; }
.scan-frame.zoomed { max-width: none; }
.scan-frame.zoomed .scan { max-width: none; }
.scan-frame.selecting { cursor: crosshair; touch-action: none; user-select: none; }
.scan-frame.selecting .scan { outline: 2px dashed var(--accent); outline-offset: 3px; }
/* ── Пометки: маркер и фломастер поверх страницы ── */
/* multiply — как настоящий маркер: чёрный текст остаётся чёрным. На тёмной странице — screen: светлый текст остаётся светлым. */
.notes-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; mix-blend-mode: multiply; }
.notes-layer path.hl { stroke-opacity: .5; }
.notes-layer.hidden g.saved { display: none; }
.scan.dark ~ .notes-layer { mix-blend-mode: screen; }
.scan.dark ~ .notes-layer path.hl { stroke-opacity: .42; }
.scan-frame.drawing .notes-layer { pointer-events: auto; touch-action: none; cursor: crosshair; }
.scan-frame.drawing[data-tool="erase"] .notes-layer { cursor: cell; }
.draw-toggle.on, button.ghost.draw-toggle.on { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }

.draw-bar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 40;
  display: flex; align-items: center; gap: 4px; padding: 6px 8px; margin: 0;
  border-radius: 999px; box-shadow: var(--shadow-pop); max-width: calc(100vw - 24px); overflow-x: auto;
  animation: draw-in .14s ease-out;
}
@keyframes draw-in { from { opacity: 0; translate: 0 10px; } }
.draw-group { display: flex; align-items: center; gap: 2px; padding-right: 6px; margin-right: 2px; border-right: 1px solid var(--line); flex: none; }
.draw-bar button {
  border: 0; background: none; color: var(--text); font: inherit; cursor: pointer; flex: none;
}
.draw-bar button:disabled { opacity: .35; cursor: default; }
.draw-tool { padding: 6px 12px; border-radius: 999px; font-size: 13.5px; font-weight: 500; }
.draw-tool:hover { background: var(--bg-raised); }
.draw-tool.on { background: var(--primary); color: var(--on-primary); }
.draw-colors { gap: 5px; padding-left: 4px; }
.swatch {
  width: 22px; height: 22px; border-radius: 50%; padding: 0;
  background: var(--swatch) !important; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18);
}
.swatch.hl { border-radius: 6px; }
.swatch.on { box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--text); }
.draw-icon { width: 32px; height: 32px; border-radius: 50%; font-size: 16px; display: grid; place-items: center; padding: 0; }
.draw-icon:not(:disabled):hover { background: var(--bg-raised); }
.size-dot { display: block; border-radius: 50%; background: currentColor; }
.size-dot.s0 { width: 5px; height: 5px; }
.size-dot.s1 { width: 9px; height: 9px; }
.size-dot.s2 { width: 14px; height: 14px; }
.draw-status { color: var(--muted); font-size: 12px; min-width: 70px; padding: 0 4px; white-space: nowrap; flex: none; }
.draw-status.bad { color: var(--bad); }

.sel-box {
  position: absolute; border: 2px solid var(--accent); background: var(--accent-soft);
  border-radius: 4px; pointer-events: none;
}
/* Кнопка вызова вопросов: круг с «?», на широком экране — с подписью. */
.ask-fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 20;
  display: inline-flex; align-items: center; gap: 8px; height: 52px; padding: 0 20px 0 8px;
  font: inherit; font-size: 15px; font-weight: 600; color: var(--on-primary); cursor: pointer;
  background: linear-gradient(135deg, var(--primary-hi), var(--primary)); border: none; border-radius: 999px;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--primary) 45%, transparent), 0 1px 0 rgba(255, 255, 255, .18) inset;
  transition: transform .15s ease, box-shadow .15s ease;
}
.ask-fab:hover { transform: translateY(-1px); }
.ask-fab-icon {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%;
  background: rgba(255, 255, 255, .18); font-size: 19px; font-weight: 700;
}
.ask-fab.unread::after, .ask-fab.busy::after {
  content: ''; position: absolute; top: 4px; right: 6px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--ok); border: 2px solid var(--bg);
}
.ask-fab.busy::after { background: var(--spark); animation: pulse 1.2s ease-in-out infinite; }

/* Всплывающая панель вопросов (на телефоне — выезжает снизу). */
.ask-panel {
  position: fixed; right: 24px; bottom: 24px; z-index: 21; margin: 0;
  width: min(450px, calc(100vw - 48px)); max-height: min(78vh, 760px);
  display: none; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow-pop); border-radius: 22px;
}
.ask-panel.open { display: flex; animation: pop-in .18s cubic-bezier(.2, .8, .2, 1); }
@keyframes pop-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.ask-head { display: flex; align-items: center; gap: 8px; }
.ask-head h3 { margin: 0; }
.ask-close {
  width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer;
  font: inherit; font-size: 20px; line-height: 1; color: var(--muted);
  background: transparent; border: 1px solid transparent; border-radius: 10px;
}
.ask-close:hover { color: var(--text); background: var(--bg-raised); }
.select-banner {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: 12px; padding: 10px 18px;
  background: var(--bg-card); border: 1px solid var(--accent-line); border-radius: 999px;
  box-shadow: var(--shadow-pop); font-size: 14px; white-space: nowrap;
}
.ask-log { flex: 1; min-height: 120px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 4px; }
.ask-empty { margin: 0; line-height: 1.55; }
.q-bubble {
  align-self: flex-end; max-width: 92%; padding: 9px 14px; border-radius: 16px 16px 4px 16px;
  background: var(--accent-soft); border: 1px solid var(--accent-line); font-size: 14px; line-height: 1.5; white-space: pre-wrap;
}
.q-bubble .tag { margin-right: 6px; }
.answer { font-size: 14px; line-height: 1.62; }
.answer p { margin: 0 0 8px; overflow-wrap: anywhere; }
.answer p:last-child { margin-bottom: 0; }
.thinking { margin: 0; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.crop-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crop-row .ghost.active { color: var(--text); border-color: var(--accent); }
.crop-thumb { max-height: 56px; max-width: 140px; border-radius: 8px; background: #fff; border: 1px solid var(--line); }
.ask-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.ask-input {
  width: 100%; resize: vertical; padding: 11px 14px; font: inherit; font-size: 14px;
  background: var(--bg-input); color: var(--text); border: 1px solid var(--line); border-radius: 14px;
}
.ask-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ask-panel .actions { margin-top: 0; }
.ask-note { font-size: 12px; }
.deep-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.deep-toggle input { accent-color: var(--primary); }
@media (pointer: coarse) { .scan-hint { display: none; } }
@media (max-width: 700px) {
  .ask-fab { right: 16px; bottom: 16px; padding: 0 8px; }
  .ask-fab-label { display: none; }
  .ask-panel {
    left: 0; right: 0; bottom: 0; width: auto; max-height: 82vh;
    border-radius: 22px 22px 0 0; border-bottom: none;
  }
  .select-banner { white-space: normal; width: calc(100vw - 32px); bottom: 16px; justify-content: space-between; border-radius: 16px; }
  /* Панель пометок — слева от кнопки «?», прокручивается вбок. */
  .draw-bar {
    left: 10px; right: 72px; bottom: 14px; transform: none; max-width: none; border-radius: 20px;
    flex-wrap: wrap; justify-content: center; row-gap: 4px; overflow: visible;
  }
  .draw-group { border-right: none; padding-right: 0; margin-right: 0; }
  .draw-tool { padding: 6px 10px; }
  .draw-icon { width: 30px; height: 30px; }
  .draw-status { display: none; }
  .draw-status.bad { display: block; width: 100%; text-align: center; white-space: normal; }
}

/* ── Вход: полотно «фазовый портрет» на весь экран и карточка поверх ── */
.login-page { min-height: 100vh; overflow-x: hidden; }
.login-art { position: fixed; inset: 0; width: 100%; height: 100%; color: var(--accent); pointer-events: none; }
.login-art .orbit { fill: none; stroke: currentColor; stroke-width: 1.1; vector-effect: non-scaling-stroke; }
.login-art .separatrix { fill: none; stroke: currentColor; stroke-width: 2; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 6px var(--accent-line)); }
.login-art .axis { stroke: currentColor; stroke-opacity: .16; stroke-width: 1; vector-effect: non-scaling-stroke; }
.login-art .tick { stroke: currentColor; stroke-opacity: .3; stroke-width: 1; vector-effect: non-scaling-stroke; }
.login-art .mark { fill: var(--muted); font: 13px var(--mono); letter-spacing: .06em; }
.login-art .spark { fill: var(--spark); }
.login-art .spark-halo { fill: var(--spark); opacity: .18; }
.login-art .veil { fill: url(#login-veil); }
.login-art stop { stop-color: var(--bg); }
.login { position: relative; min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.login-card {
  width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; padding: 32px 28px 26px; text-align: center;
  background: color-mix(in srgb, var(--bg-card) 86%, transparent); border: 1px solid var(--line); border-radius: 26px;
  box-shadow: var(--shadow-pop); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
.login-card h1 { margin: 4px 0 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.login-card .muted { margin: 0 0 6px; font-size: 13.5px; }
.login-logo { width: 72px; height: 72px; margin: 0 auto 4px; border-radius: 20px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3), 0 0 0 1px var(--line); }
.login-input {
  padding: 12px 18px; font: inherit; font-size: 16px; text-align: center;
  background: var(--bg-input); color: var(--text); border: 1px solid var(--line); border-radius: 999px;
}
.login-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-btn { padding: 12px 18px; font-size: 15px; }
.login-card .status-line { min-height: 1.2em; margin: 0; color: var(--bad); }
.login-tabs { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg-input); }
.login-tabs button {
  flex: 1; padding: 8px 10px; border: none; border-radius: 999px; background: none; color: var(--muted);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.login-tabs button.on { background: var(--bg-raised); color: var(--text); box-shadow: 0 0 0 1px var(--line-strong); }
.login-hint { margin: -2px 0 0; font-size: 12.5px; color: var(--muted); }

/* ── Профиль ── */
.profile { max-width: 640px; margin: 0 auto; padding: 20px 16px 48px; display: flex; flex-direction: column; gap: 14px; }
.profile-head { display: flex; align-items: center; gap: 12px; }
.profile-back, a.link { color: var(--accent); font-size: 13.5px; font-weight: 600; text-decoration: none; }
.profile-back:hover, a.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.profile-title { display: flex; align-items: center; gap: 10px; margin: 12px 0 0; font-size: 24px; letter-spacing: -.02em; overflow-wrap: anywhere; }
.profile-title + .muted { margin: -8px 0 4px; font-size: 13.5px; }
.profile-card { display: flex; flex-direction: column; gap: 12px; }
.profile-card h3 { margin: 0; }
.profile-welcome { border-color: var(--accent-line); background: var(--accent-soft); }
.profile-welcome p { margin: 0; }
.profile-note { margin: 0; font-size: 13.5px; color: var(--text-2); }
.profile-steps { margin: 0; padding-left: 20px; font-size: 13.5px; color: var(--text-2); }
.profile-steps li { margin: 3px 0; }
.profile-steps a { color: var(--accent); overflow-wrap: anywhere; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.field-input {
  width: 100%; box-sizing: border-box; padding: 10px 14px; font: inherit; font-size: 16px;
  background: var(--bg-input); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
}
.field-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.profile-card .actions { margin-top: 0; }
.profile-card .status-line { margin: 0; }
.status-line.bad { color: var(--bad); }
.tag.ok { color: var(--ok); border-color: var(--ok-line); }
.tag.warn { color: var(--warn); border-color: var(--warn-line); }
button.link.danger { color: var(--bad); }

/* Кнопка профиля (левая панель и шапка главной): кружок с буквой имени, имя, подпись. */
.profile-chip {
  display: inline-flex; align-items: center; gap: 10px; min-width: 0; max-width: 100%; box-sizing: border-box;
  padding: 5px 16px 5px 5px; border-radius: 999px; text-decoration: none; color: var(--text);
  background: var(--bg-raised); border: 1px solid var(--line-strong);
  transition: border-color .15s, background .15s;
}
.profile-chip:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.profile-chip:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.profile-avatar {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary); color: var(--on-primary); font-size: 15px; font-weight: 700;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.profile-avatar { overflow: hidden; }
.profile-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.profile-avatar.big { width: 88px; height: 88px; font-size: 34px; box-shadow: 0 0 0 4px var(--accent-soft); }
.profile-avatar.small { display: inline-grid; width: 26px; height: 26px; font-size: 12px; box-shadow: none; vertical-align: middle; margin-right: 8px; }
.avatar-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.avatar-actions { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.avatar-actions .actions { margin-top: 0; }
td.user-cell { white-space: nowrap; }
.profile-chip-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.profile-chip-name { font-size: 14px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-chip-sub { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-chip-sub.warn { color: var(--warn); font-weight: 600; }
.side-profile-slot { padding: 10px 12px 0; border-top: 1px solid var(--line); }
.side-profile-slot + .side-foot { border-top: none; }
.side-profile { display: flex; width: 100%; }

/* Выбор шрифта: всплывает над нижней строкой левой панели. */
.font-menu {
  position: absolute; left: 10px; right: 10px; bottom: 54px; z-index: 30; max-height: min(560px, 72vh); overflow-y: auto;
  padding: 8px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow-pop);
}
.font-menu-head { color: var(--muted); font-size: 12.5px; padding: 4px 10px 6px; }
.font-option {
  display: grid; grid-template-columns: 1fr auto; gap: 0 10px; text-align: left; width: 100%;
  padding: 8px 10px; border: 1px solid transparent; border-radius: var(--radius-sm); background: none; color: var(--text); cursor: pointer;
}
.font-option:hover { background: var(--bg-raised); }
.font-option.on { border-color: var(--accent-line); background: var(--accent-soft); }
.font-option .font-name { font-weight: 700; font-size: 15px; }
.font-option .font-note { color: var(--muted); font-size: 11.5px; align-self: center; text-align: right; }
.font-option .font-sample { grid-column: 1 / -1; color: var(--text-2); font-size: 14px; }

/* ── Узкие экраны: базовая раскладка (шторка, верхняя строка и читалка — в mobile.css) ── */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .main { padding: 18px 16px 50px; }
  body.no-sidebar .main { padding: 18px 16px 90px 64px; }
}
