/* Леммиум. Нейтральная графитовая гамма, один акцент (чернильный синий), сетка 4px. */
:root {
  --bg: #F4F4F2; --surface: #FFFFFF; --sunken: #ECECE9;
  --line: rgba(24, 24, 27, .10); --line-strong: rgba(24, 24, 27, .20);
  --text: #18181B; --text-2: #52525B; --text-3: #6B6B73;
  --accent: #2740B8; --accent-ink: #1E3293; --accent-weak: #E8EBF9; --on-accent: #FFFFFF;
  --ok: #1C6A43; --ok-weak: #E2F0E8; --warn: #8F4400; --warn-weak: #FAEBD9;
  --ui: 'Golos Text', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141415; --surface: #1C1C1E; --sunken: #242427;
    --line: rgba(255, 255, 255, .09); --line-strong: rgba(255, 255, 255, .20);
    --text: #EDEDEE; --text-2: #B4B4BB; --text-3: #92929A;
    --accent: #94A6F6; --accent-ink: #B5C1FA; --accent-weak: #232A4A; --on-accent: #141415;
    --ok: #7FCFA4; --ok-weak: #17301F; --warn: #F0B070; --warn-weak: #3A2A14;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 24px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.5 var(--ui); }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; }
.link { color: var(--accent-ink); font-weight: 500; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Каркас */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 20px 12px 16px; display: flex; flex-direction: column; gap: 20px; border-right: 1px solid var(--line); }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 0 8px; }
.brand { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.side-toggle { display: none; width: 44px; height: 44px; border: 0; background: none; border-radius: 10px; align-items: center; justify-content: center; cursor: pointer; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 8px; border-radius: 8px; color: var(--text-2); font-weight: 500; transition: background-color .15s var(--ease), color .15s var(--ease); }
.nav-item:hover { background: var(--sunken); color: var(--text); }
.nav-item[aria-current] { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.nav-item[aria-current] .icon { color: var(--accent); }
.access { margin-top: auto; padding: 12px; border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; gap: 8px; }
.access-line { font-size: 13px; color: var(--text-2); }
.access-name { font-weight: 500; }
.lock { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.lock .icon { width: 24px; height: 24px; color: var(--text-3); }
.lock p { margin-top: 0; }
.lock .btn { margin-top: 8px; }
.empty-card .btn { margin-top: 16px; }
.pay-code { font: 500 20px var(--mono); color: var(--accent); letter-spacing: .04em; }
.admin-note { margin-top: 12px; }
.paid-toggle[data-paid="1"] { border-color: var(--ok); color: var(--ok); }
.main { padding: 32px 40px 64px; max-width: 1160px; width: 100%; }
.main-wide { max-width: 1480px; }
/* Появление страницы: только сдвиг, без прозрачности, чтобы текст был виден даже если анимация не доиграла */
.main > * { animation: settle .28s var(--ease) backwards; }
.main > *:nth-child(2) { animation-delay: .04s; }
.main > *:nth-child(3) { animation-delay: .08s; }
.main > *:nth-child(n+4) { animation-delay: .12s; }
@keyframes settle { from { transform: translateY(8px); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* Кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid transparent; font-weight: 500; font-size: 14px; cursor: pointer; transition: background-color .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease); }
.btn { white-space: nowrap; }
.btn:active { transform: scale(.98); }
.btn-accent { background: var(--accent); color: var(--on-accent); }
.btn-accent:hover { background: var(--accent-ink); }
.btn-quiet { background: var(--surface); border-color: var(--line-strong); }
.btn-quiet:hover { background: var(--sunken); }
.btn[disabled] { opacity: .55; cursor: default; }

/* Шапка страницы */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 32px; margin-bottom: 24px; }
h1 { font-size: 28px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.lead { margin-top: 4px; color: var(--text-2); }
.search { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; flex: 0 1 340px; min-width: 220px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; color: var(--text-3); transition: border-color .15s var(--ease); }
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none; color: var(--text); }
.search input::placeholder, textarea::placeholder { color: var(--text-3); }

.block { margin-top: 32px; }
.block-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; margin-bottom: 12px; }
h2 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.block > h2 { margin-bottom: 12px; }

/* Продолжить */
.resume { display: flex; align-items: center; gap: 20px; padding: 20px 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; transition: border-color .15s var(--ease); }
a.resume:hover { border-color: var(--line-strong); }
.resume-num { font: 500 28px/1 var(--mono); color: var(--accent); min-width: 72px; font-variant-numeric: tabular-nums; }
.resume-body { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.resume-kicker { font-size: 13px; color: var(--text-2); }
.resume-title { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.resume-go { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; color: var(--accent-ink); white-space: nowrap; }
a.resume:hover .resume-go .icon { transform: translateX(2px); }
.resume-go .icon { transition: transform .15s var(--ease); }

/* Карта курса */
.subjects { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.subjects-1 { grid-template-columns: 1fr; }
.subject { padding: 16px 20px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.subject-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.subject-name { font-weight: 600; }
.subject-name:hover { color: var(--accent-ink); }
.subject-meta { font: 400 12px var(--mono); color: var(--text-3); }
.map { display: flex; flex-wrap: wrap; gap: 6px; }
.cell { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; height: 32px; padding: 0 6px; border-radius: 8px; border: 1px solid transparent; font: 500 12px var(--mono); font-variant-numeric: tabular-nums; transition: transform .12s var(--ease), border-color .15s var(--ease); }
a.cell:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.cell-none { background: var(--sunken); color: var(--text-3); }
.cell-opened { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
.cell-ok { background: var(--ok-weak); color: var(--ok); }
.cell-no { background: var(--warn-weak); color: var(--warn); }
.cell-missing { border: 1px dashed var(--line-strong); color: var(--text-3); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--text-3); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .cell { min-width: 12px; width: 12px; height: 12px; padding: 0; border-radius: 4px; }

/* Списки лекций */
.rows { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 16px; padding: 12px 20px; border-top: 1px solid var(--line); transition: background-color .15s var(--ease); }
.row:first-child { border-top: 0; }
.row:hover { background: var(--sunken); }
.row-off { color: var(--text-3); }
.row-num { flex: none; width: 56px; font: 500 13px var(--mono); color: var(--accent); font-variant-numeric: tabular-nums; }
.row-off .row-num { color: var(--text-3); }
.row-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.row-title { font-weight: 500; }
.row-meta, .row-snippet { font-size: 13px; color: var(--text-3); }
.row-snippet { color: var(--text-2); }
.row-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 6px; background: var(--sunken); color: var(--text-2); font-size: 12px; font-weight: 500; white-space: nowrap; }
.chip .icon { width: 14px; height: 14px; }
.chip-ok { background: var(--ok-weak); color: var(--ok); }
.chip-warn { background: var(--warn-weak); color: var(--warn); }

.tabs { display: flex; gap: 4px; overflow: auto hidden; box-shadow: inset 0 -1px 0 var(--line); margin-bottom: 4px; }
.tabs a { padding: 8px 12px; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; transition: color .15s var(--ease), border-color .15s var(--ease); }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current] { color: var(--text); border-color: var(--accent); }

/* Страница конспекта */
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--text-3); margin-bottom: 16px; }
.crumbs a:hover { color: var(--text); }
.reader { display: grid; grid-template-columns: minmax(0, 760px) minmax(320px, 400px); gap: 32px; align-items: start; }
.note { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px 40px 28px; min-width: 0; }
.note-head { display: flex; gap: 20px; align-items: baseline; padding-bottom: 20px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.note-num { flex: none; font: 500 22px/1.3 var(--mono); color: var(--accent); min-width: 64px; font-variant-numeric: tabular-nums; }
.note-meta { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; color: var(--text-3); }
.fixes, .report { border: 1px solid var(--line); border-radius: 10px; padding: 0 16px; margin-bottom: 16px; }
.fixes summary, .report summary { cursor: pointer; padding: 10px 0; font-weight: 500; font-size: 14px; color: var(--text-2); }
.fixes[open], .report[open] { padding-bottom: 14px; }
.fixes .prose { font-size: 14px; }
.trial .note-head { border-bottom: 0; padding-bottom: 0; margin-bottom: 12px; }
.trial-about { padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 16px; font-size: 14px; color: var(--text-2); display: flex; flex-direction: column; gap: 4px; }
.task { padding-top: 28px; margin-top: 28px; border-top: 1px solid var(--line); scroll-margin-top: 24px; }
.task > h2 { font-size: 20px; margin-bottom: 12px; }
.solution { margin-top: 16px; border: 1px solid var(--line); border-radius: 12px; padding: 0 20px; background: var(--sunken); }
.solution summary { cursor: pointer; padding: 12px 0; font-weight: 500; color: var(--accent-ink); }
.solution[open] { padding-bottom: 16px; }
.solution[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.solution .formula, .solution .table-wrap, .solution th { background: var(--surface); }
.prose td:empty::after { content: '\00a0'; }
.materials { margin-bottom: 16px; }
.materials h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; margin-bottom: 8px; }
.files { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; }
.files li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 16px; min-height: 44px; border-top: 1px solid var(--line); }
.files li:first-child { border-top: 0; }
.file { display: inline-flex; align-items: center; gap: 10px; min-width: 0; color: var(--accent-ink); font-weight: 500; }
.file:hover .file-name { text-decoration: underline; text-underline-offset: 3px; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { flex: none; font: 400 12px var(--mono); color: var(--text-3); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 8px; }
.photo { display: block; aspect-ratio: 4 / 3; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--sunken); }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.prose img { max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); }
.toc { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; background: var(--sunken); border-radius: 10px; margin-bottom: 24px; font-size: 14px; }
.toc-title { font-size: 12px; color: var(--text-3); margin-bottom: 4px; }
.toc a { color: var(--text-2); padding: 2px 0; }
.toc a:hover, .toc a.is-here { color: var(--accent-ink); }
.prose { font-size: 16px; line-height: 1.65; overflow-wrap: break-word; }
.prose section { scroll-margin-top: 24px; }
.prose h2 { font-size: 20px; margin: 32px 0 12px; }
.prose section:first-child h2 { margin-top: 0; }
.prose h3 { font-size: 16px; font-weight: 600; margin: 20px 0 8px; }
.prose p { margin: 0 0 12px; }
.prose ul, .prose ol { margin: 0 0 12px; padding-left: 24px; }
.prose li { margin: 4px 0; }
.prose b, .prose strong { font-weight: 600; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
.prose blockquote { margin: 0 0 12px; padding: 4px 0 4px 16px; border-left: 2px solid var(--line-strong); color: var(--text-2); }
.prose code { font: 400 14px var(--mono); background: var(--sunken); padding: 1px 4px; border-radius: 4px; }
.formula { margin: 16px 0; padding: 16px; background: var(--sunken); border-radius: 12px; overflow-x: auto; }
.formula .katex-display { margin: 0; }
.katex { font-size: 1.06em; }
.table-wrap { overflow-x: auto; margin: 0 0 16px; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px 12px; text-align: left; vertical-align: top; border-top: 1px solid var(--line); }
tr:first-child th, tr:first-child td { border-top: 0; }
th { font-weight: 600; background: var(--sunken); }
.note-foot { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 16px; }
.mark { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.mark-q { font-weight: 600; }
.mark-hint { font-size: 13px; color: var(--text-2); }
.seg { position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 2px; background: var(--sunken); border-radius: 10px; }
.seg button { position: relative; height: 36px; padding: 0 20px; border: 0; background: none; border-radius: 8px; font-weight: 500; color: var(--text-2); cursor: pointer; transition: color .2s var(--ease); }
.seg-pill { position: absolute; top: 2px; bottom: 2px; left: 2px; width: calc(50% - 2px); border-radius: 8px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-strong); opacity: 0; transition: transform .22s var(--ease), opacity .15s var(--ease); }
.mark[data-mark="ok"] .seg-pill { opacity: 1; }
.mark[data-mark="no"] .seg-pill { opacity: 1; transform: translateX(100%); }
.mark[data-mark="ok"] [data-value="ok"] { color: var(--ok); }
.mark[data-mark="no"] [data-value="no"] { color: var(--warn); }
.report-form { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
textarea { width: 100%; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; resize: none; outline: none; transition: border-color .15s var(--ease); }
textarea:focus { border-color: var(--accent); }
.report-done { font-size: 13px; color: var(--ok); }
.empty { color: var(--text-2); }

/* Чат */
.reader-side { position: sticky; top: 24px; height: calc(100vh - 48px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.reader-side-head { padding: 16px 20px 12px; border-bottom: 1px solid var(--line); }
.reader-side-head p { margin-top: 2px; font-size: 13px; color: var(--text-3); }
.chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-page { height: calc(100vh - 220px); min-height: 360px; margin-top: 16px; display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.chat-log:empty::before { content: 'Задай вопрос, и я найду ответ в конспектах'; color: var(--text-3); font-size: 14px; margin: auto; text-align: center; }
.msg { max-width: 100%; animation: rise .22s var(--ease) both; }
.msg-user { align-self: flex-end; max-width: 85%; padding: 8px 12px; background: var(--sunken); border-radius: 12px 12px 4px 12px; }
.msg-bot .prose { font-size: 15px; line-height: 1.55; }
.msg-bot .prose > * { animation: rise .3s var(--ease) both; }
.msg-bot .prose > *:nth-child(2) { animation-delay: .08s; }
.msg-bot .prose > *:nth-child(3) { animation-delay: .16s; }
.msg-bot .prose > *:nth-child(n+4) { animation-delay: .24s; }
.msg-bot .prose h2 { font-size: 16px; margin: 12px 0 8px; }
.chat-stub { font-size: 13px; color: var(--text-3); }
.sources { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.source { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; transition: border-color .15s var(--ease); }
.source:hover { border-color: var(--line-strong); }
.source-kicker { color: var(--text-3); }
.source-title { color: var(--accent-ink); font-weight: 500; }
.msg-actions { display: flex; gap: 8px; margin-top: 8px; }
.msg-actions .btn { height: 32px; font-size: 13px; }
.msg-actions .is-picked { border-color: var(--accent); color: var(--accent-ink); }
.handoff { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.handoff-hint { font-size: 13px; color: var(--text-3); }
.handoff .msg-actions { flex-wrap: wrap; }
.dots { display: inline-flex; gap: 4px; padding: 8px 0; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: blink 1s var(--ease) infinite; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 100% { opacity: .25; } 40% { opacity: 1; } }
.chat-form { padding: 12px 16px 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.chat-label { font-size: 12px; color: var(--text-3); }
.chat-row { display: flex; align-items: flex-end; gap: 8px; }
.chat-row textarea { min-height: 40px; max-height: 140px; }
.chat-send { width: 40px; height: 40px; padding: 0; flex: none; }
.chat-error { font-size: 13px; color: var(--warn); }

/* Прочее */
.empty-card { padding: 28px 32px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; max-width: 640px; }
.empty-card p { margin-top: 8px; color: var(--text-2); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 16px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.stat-label, .stat-note { font-size: 13px; color: var(--text-3); }
.stat-value { font-size: 32px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.data td a { font-weight: 500; }
.data td a:hover { color: var(--accent-ink); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.td-meta { display: block; font-size: 12px; color: var(--text-3); }
.data { background: var(--surface); }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 24px; }
.feed { list-style: none; margin: 0; padding: 4px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.feed li { padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.feed li:first-child { border-top: 0; }
.progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; background: var(--accent); transform-origin: 0 50%; transform: scaleX(var(--read, 0)); z-index: 5; }

@media (max-width: 1180px) {
  .reader { grid-template-columns: minmax(0, 1fr); }
  .reader-side { position: static; height: 520px; }
}
@media (max-width: 860px) {
  .shell { display: block; }
  .side { position: static; height: auto; padding: 8px 12px; gap: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-toggle { display: inline-flex; }
  .side-nav, .access { display: none; }
  .side.is-open .side-nav, .side.is-open .access { display: flex; }
  .nav-item { height: 44px; }
  .main { padding: 20px 16px 48px; }
  h1 { font-size: 24px; }
  .note { padding: 20px 16px; }
  .note-head { flex-direction: column; gap: 4px; }
  .row { flex-wrap: wrap; gap: 8px 12px; padding: 12px 16px; }
  .row-num { width: 44px; }
  .row-chips { justify-content: flex-start; width: 100%; padding-left: 56px; }
  .resume { flex-wrap: wrap; gap: 12px; padding: 16px; }
  .resume-num { min-width: 0; font-size: 22px; }
  .chat-page { height: calc(100vh - 260px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}
