/*
  «Lince» — чистый лист и чернила. Единственный яркий элемент — цвет текущего курса (--accent):
  точка у названия, полоса контекста, кнопка отправки, главная кнопка. Всё остальное — оттенки чернил.
*/
:root {
  --paper: #ffffff;
  --ink: #1a1f2b;
  --graphite: #646b7a;
  --hairline: #e6e8ec;
  --mist: #f3f4f6;
  --mist-2: #e9ebef;
  --warn: #a35f00;
  --bad: #c0392b;
  --accent: #1a1f2b;
  --on-accent: #ffffff;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --radius: 14px;
  color-scheme: light;
}
:root[data-course="espanol"]    { --accent: #c4410c; }
:root[data-course="english"]    { --accent: #1d5fe0; }
:root[data-course="tensors"]    { --accent: #6741d9; }
:root[data-course="mba"]        { --accent: #9a5b06; }
:root[data-course="causal"]     { --accent: #0b6e80; }
:root[data-course="gametheory"] { --accent: #b8235a; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121418; --ink: #e8eaf0; --graphite: #969dab; --hairline: #262a32; --mist: #1b1e24; --mist-2: #252931;
    --warn: #e0a640; --bad: #ef6f62; --accent: #e8eaf0; --on-accent: #121418;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    color-scheme: dark;
  }
  :root:not([data-theme="light"])[data-course="espanol"]    { --accent: #ff8a50; }
  :root:not([data-theme="light"])[data-course="english"]    { --accent: #6b97ff; }
  :root:not([data-theme="light"])[data-course="tensors"]    { --accent: #a28bff; }
  :root:not([data-theme="light"])[data-course="mba"]        { --accent: #e8a23a; }
  :root:not([data-theme="light"])[data-course="causal"]     { --accent: #3bc9db; }
  :root:not([data-theme="light"])[data-course="gametheory"] { --accent: #f27aa6; }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 16px/1.55 "Golos Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
}
button, select, input, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
/* иконки: только внутри кнопок и выбора курса, графики не затрагиваются */
button svg, .course-pick svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
button svg circle { fill: currentColor; stroke: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.muted { color: var(--graphite); }
.error { color: var(--bad); margin: 0; font-size: 14px; }


/* кнопки */
.primary {
  border: 0; border-radius: 999px; padding: 12px 22px; background: var(--accent); color: var(--on-accent);
  font-weight: 600; font-size: 15px; cursor: pointer;
}
.primary:active { transform: scale(.98); }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: none; border-radius: 12px;
  color: var(--ink); cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--mist); }
.icon-btn:disabled { opacity: .35; }
.link-btn { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 13px; padding: 4px 2px; cursor: pointer; }
.pill { border: 1px solid var(--hairline); background: none; border-radius: 999px; padding: 7px 14px; font-size: 14px; cursor: pointer; }
.pill:hover { background: var(--mist); }
.pill:disabled { opacity: .5; }

/* вход */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 340px; display: grid; gap: 14px; }
.login-logo { width: 64px; height: 64px; border-radius: 15px; margin-bottom: 6px; }
.login-card h1 { margin: 0 0 4px; font-size: 40px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.05; }
.login-card p { margin: 0 0 10px; color: var(--graphite); font-size: 15px; }
.login-card input { padding: 13px 16px; border: 0; border-radius: var(--radius); background: var(--mist); font-size: 16px; }

/* каркас */
.app { height: 100%; display: flex; flex-direction: column; max-width: var(--chat-w, 760px); margin: 0 auto; position: relative; }
.top {
  display: flex; align-items: center; gap: 4px; min-height: 56px;
  padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
}
.top-title { flex: 1; font-size: 17px; font-weight: 600; padding-left: 4px; }
.top-actions { display: flex; gap: 2px; margin-left: auto; }
.course-pick { position: relative; display: flex; align-items: center; gap: 8px; min-width: 0; flex: 0 1 auto; padding-left: 6px; cursor: pointer; }
.course-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; transition: background .25s; }
.course-pick select {
  appearance: none; -webkit-appearance: none; border: 0; background: none; padding: 6px 22px 6px 0; margin: 0;
  font-size: 18px; font-weight: 600; letter-spacing: -0.01em; min-width: 0; max-width: 100%;
  text-overflow: ellipsis; white-space: nowrap; overflow: hidden; cursor: pointer;
}
.course-pick .chev { position: absolute; right: 0; width: 18px; height: 18px; color: var(--graphite); pointer-events: none; }
.course-pick select:focus-visible { outline: none; }
.course-pick:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.course-pick select:disabled { opacity: .6; }

/* контекст: тонкая полоса цвета курса и цифры под ней */
.ctx { padding: 0 max(16px, env(safe-area-inset-left)) 8px; font-size: 12.5px; color: var(--graphite); font-variant-numeric: tabular-nums; }
.ctx-bar { height: 2px; background: var(--hairline); border-radius: 2px; overflow: hidden; }
.ctx-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .4s, background .25s; }
.ctx[data-level="warn"] .ctx-bar span { background: var(--warn); }
.ctx[data-level="bad"] .ctx-bar span { background: var(--bad); }
.ctx-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; min-height: 20px; }
.ctx-row > span { display: flex; flex-wrap: wrap; column-gap: 14px; }
.ctx-row b { font-weight: 500; color: var(--ink); }
.ctx-hint { margin-top: 4px; color: var(--warn); }
.ctx[data-level="bad"] .ctx-hint { color: var(--bad); }

/* лента */
.log { flex: 1; overflow-y: auto; padding: 12px max(16px, env(safe-area-inset-right)) 16px max(16px, env(safe-area-inset-left)); -webkit-overflow-scrolling: touch; }
.msg { overflow-wrap: anywhere; }
.msg.assistant { margin: 0 0 6px; font-size: 16.5px; }
.msg.assistant > :first-child { margin-top: 0; }
.msg.assistant > :last-child { margin-bottom: 0; }
.msg.assistant p { margin: 0 0 .75em; }
.msg.assistant h1, .msg.assistant h2, .msg.assistant h3 { font-size: 1.1em; font-weight: 600; margin: 1.1em 0 .4em; letter-spacing: -0.01em; }
.msg.assistant ul, .msg.assistant ol { padding-left: 1.25em; margin: .4em 0 .75em; }
.msg.assistant li { margin: .2em 0; }
.msg.assistant strong { font-weight: 600; }
.msg.assistant table { border-collapse: collapse; margin: .6em 0 1em; display: block; overflow-x: auto; max-width: 100%; font-size: .94em; overflow-wrap: normal; word-break: normal; hyphens: auto; }
.msg.assistant th, .msg.assistant td { border-bottom: 1px solid var(--hairline); padding: 6px 14px 6px 0; text-align: left; }
.msg.assistant th { font-weight: 600; }
.msg.assistant code { background: var(--mist); padding: 1px 5px; border-radius: 6px; font-size: .9em; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.msg.assistant pre { background: var(--mist); padding: 12px 14px; border-radius: 12px; overflow-x: auto; }
.msg.assistant pre code { background: none; padding: 0; }
.msg.assistant blockquote { margin: .6em 0; padding: 2px 0 2px 14px; border-left: 2px solid var(--accent); }
.msg.assistant hr { border: 0; border-top: 1px solid var(--hairline); margin: 1em 0; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }

.user-wrap { display: flex; flex-direction: column; align-items: flex-end; margin: 22px 0 18px; }
.msg.user {
  width: fit-content; max-width: 85%; background: var(--mist); padding: 10px 15px; border-radius: 20px;
  white-space: pre-wrap; font-size: 16px;
}
.msg-act { border: 0; background: none; color: var(--graphite); font-size: 13px; padding: 6px 4px 0; cursor: pointer; }
.msg-act:hover { color: var(--ink); }
.msg-actions { margin: 2px 0 8px; }

.tool { display: flex; align-items: baseline; gap: 8px; font-size: 13px; color: var(--graphite); margin: 0 0 8px; }
.tool::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--mist-2); flex: none; transform: translateY(-2px); }
.tool.write::before { background: var(--accent); }
.tool.write { color: var(--ink); }
.tool.error { color: var(--bad); }
.tool.error::before { background: var(--bad); }

.audio { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; max-width: 100%; }
.audio button {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; cursor: pointer; flex: none;
}
.audio button svg { width: 16px; height: 16px; }
.audio button svg path { fill: currentColor; stroke: none; }
.audio .a-text { font-size: 15.5px; }
.audio .a-hidden { color: var(--graphite); }
.audio .a-meta { font-size: 12.5px; color: var(--graphite); }

.stats { display: flex; flex-wrap: wrap; column-gap: 12px; font-size: 12px; color: var(--graphite); margin: 8px 0 4px; font-variant-numeric: tabular-nums; }
.marker { text-align: center; font-size: 13px; color: var(--graphite); margin: 22px 0; }
.marker details { text-align: left; margin-top: 8px; background: var(--mist); border-radius: var(--radius); padding: 10px 14px; white-space: pre-wrap; color: var(--ink); }
.marker summary { cursor: pointer; color: var(--graphite); }
.err { color: var(--bad); font-size: 14px; margin: 6px 0 14px; padding-left: 12px; border-left: 2px solid var(--bad); }
.thinking { color: var(--graphite); font-size: 15px; }
.thinking::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* пустой чат — единственный «громкий» момент: крупное название курса */
.empty { margin: 14vh 0 0; max-width: 34rem; }
.empty h2 { margin: 0 0 14px; font-size: clamp(34px, 9vw, 52px); font-weight: 600; letter-spacing: -0.035em; line-height: 1.02; }
.empty h2::after { content: ""; display: block; width: 44px; height: 3px; border-radius: 3px; background: var(--accent); margin-top: 18px; }
.empty p { margin: 0 0 22px; color: var(--graphite); font-size: 16px; }
.empty p b { color: var(--ink); font-weight: 500; }

/* ввод */
.composer { padding: 6px max(12px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.field { display: flex; align-items: flex-end; gap: 6px; background: var(--mist); border-radius: 26px; padding: 5px 5px 5px 18px; }
.field:focus-within { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.field textarea {
  flex: 1; resize: none; border: 0; background: none; outline: none; max-height: 40vh;
  padding: 9px 0; font-size: 16px; line-height: 1.45;
}
.field textarea::placeholder { color: var(--graphite); }
.send {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; cursor: pointer; flex: none; transition: background .25s, opacity .2s;
}
.send svg { width: 20px; height: 20px; stroke-width: 2.2; }
.send:disabled { opacity: .3; }
.edit-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--graphite);
  padding: 6px max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
}

/* боковая панель */
.drawer { position: fixed; inset: 0; background: rgba(10, 12, 18, .32); z-index: 10; }
.drawer-panel {
  position: absolute; inset: 0 auto 0 0; width: min(340px, 86vw); background: var(--paper); overflow-y: auto;
  padding: calc(8px + env(safe-area-inset-top)) 12px 16px max(12px, env(safe-area-inset-left));
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 8px 8px; font-size: 17px; }
.chat-item {
  display: block; width: 100%; text-align: left; border: 0; background: none; border-radius: 12px;
  padding: 10px 10px 10px 14px; margin: 0 0 2px; cursor: pointer; position: relative;
}
.chat-item:hover { background: var(--mist); }
.chat-item.active { background: var(--mist); }
.chat-item.active::before { content: ""; position: absolute; left: 4px; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--accent); }
.chat-item .t { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .m { display: flex; column-gap: 10px; font-size: 12.5px; color: var(--graphite); font-variant-numeric: tabular-nums; }

/* диалоги: на телефоне — лист снизу */
.dlg { border: 1px solid var(--hairline); padding: 0; width: min(460px, 92vw); border-radius: 20px; background: var(--paper); color: var(--ink); box-shadow: 0 24px 60px rgba(10, 12, 18, .28); }
.dlg::backdrop { background: rgba(8, 10, 14, .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
@media (max-width: 600px) {
  .dlg { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 22px 22px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
.dlg form { padding: 22px 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.dlg h3 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.dlg p { margin: 0; color: var(--graphite); font-size: 14.5px; }
.dlg label { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; font-size: 13.5px; color: var(--graphite); min-width: 0; }
.dlg select, .dlg input {
  width: 100%; min-width: 0; text-overflow: ellipsis; padding: 11px 12px; border: 0; border-radius: 12px; background: var(--mist);
  font-size: 16px; color: var(--ink);
}
.dlg .row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.dlg .row button { padding: 10px 16px; border-radius: 999px; border: 0; background: var(--mist); cursor: pointer; font-weight: 500; }
.dlg .row button.primary { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.dlg .row button.danger { color: var(--bad); background: none; padding-left: 0; }
.dlg .left { justify-content: flex-start; border-top: 1px solid var(--hairline); padding-top: 12px; }

/* статистика: цифры, тонкие линии, без россыпи карточек */
.stats-body { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
.st-sec { padding: 8px 0 26px; border-bottom: 1px solid var(--hairline); margin-bottom: 18px; }
.st-sec:last-child { border-bottom: 0; }
.st-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.st-sec h2 { font-size: 26px; font-weight: 600; letter-spacing: -0.025em; margin: 0; }
.st-sec h4 { font-size: 15px; font-weight: 600; margin: 26px 0 8px; }
.note { font-size: 13px; color: var(--graphite); margin: 6px 0 0; max-width: 64ch; }
.small { font-size: 14px; }

.figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; margin: 18px 0 8px; }
@media (min-width: 640px) { .figures { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.fig-value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.fig-label { font-size: 13px; color: var(--graphite); margin-top: 4px; }
.fig-sub { font-size: 12.5px; color: var(--graphite); font-variant-numeric: tabular-nums; }

.course-row { padding: 16px 0; border-bottom: 1px solid var(--hairline); }
.course-row:last-child { border-bottom: 0; }
.course-row .cr-head { display: flex; align-items: baseline; gap: 10px; }
.course-row .cr-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; transform: translateY(-1px); }
.course-row h3 { margin: 0; font-size: 17px; font-weight: 600; flex: 1; }
.course-row .cr-status { font-size: 13px; color: var(--graphite); }
.course-row .cr-level { font-size: 15px; margin: 4px 0 2px 19px; }
.course-row .cr-meta { font-size: 13px; color: var(--graphite); margin-left: 19px; }
.course-row .cr-next { font-size: 14.5px; margin: 8px 0 0 19px; }
.course-row details { margin: 8px 0 0 19px; }
.course-row summary { font-size: 13px; color: var(--graphite); cursor: pointer; }
.course-row .sub-label { font-size: 13px; color: var(--graphite); margin: 12px 0 4px; }
.course-row ul { margin: 0; padding-left: 1.15em; font-size: 14.5px; }
.course-row p { margin: 0; font-size: 14.5px; }
.course-row .summary { margin-top: 12px; color: var(--graphite); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips span { font-size: 13px; background: var(--mist); padding: 3px 10px; border-radius: 999px; }

.block { margin: 18px 0 0; }
.block-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.hero { font-size: 34px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.meter { height: 6px; background: var(--mist-2); border-radius: 6px; overflow: hidden; margin: 12px 0 6px; }
.meter span { display: block; height: 100%; background: var(--ink); border-radius: 6px; }
.meter[data-level="warn"] span { background: var(--warn); }
.meter[data-level="bad"] span { background: var(--bad); }
.lines p { margin: 3px 0; font-size: 14.5px; font-variant-numeric: tabular-nums; }

.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--hairline); stroke-width: 1; }
.chart .axis { fill: var(--graphite); font-size: 11.5px; font-family: inherit; }
.chart .bar { fill: var(--ink); transition: opacity .15s; }
.chart .bar.hover { opacity: .6; }
.chart .hit { fill: transparent; outline: none; }
.chart .line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart .dot { stroke: var(--paper); stroke-width: 2; }
.chart .dot.hover { stroke: var(--ink); }
.seg { display: inline-flex; background: var(--mist); border-radius: 999px; padding: 3px; margin: 0 0 10px; }
.seg button { border: 0; background: none; border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; color: var(--graphite); }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); font-weight: 500; box-shadow: 0 1px 2px rgba(10, 12, 18, .12); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; margin: 8px 0 0; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 2px; border-radius: 2px; display: inline-block; }
.tip {
  position: fixed; z-index: 30; pointer-events: none; background: var(--ink); color: var(--paper);
  padding: 6px 10px; border-radius: 10px; font-size: 13px; white-space: nowrap;
}
.tip b { font-weight: 600; }

.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 9px 8px; border-bottom: 1px solid var(--hairline); text-align: right; white-space: nowrap; vertical-align: top; }
.tbl th:first-child, .tbl td:first-child { text-align: left; padding-left: 0; white-space: normal; }
.tbl th:last-child, .tbl td:last-child { padding-right: 0; }
.tbl th { color: var(--graphite); font-weight: 400; font-size: 12.5px; }
.tbl td small, .tbl th small { display: block; color: var(--graphite); font-size: 12px; }
.tbl tr:last-child td { border-bottom: 0; }
details.more { margin-top: 6px; }
details.more summary { font-size: 13px; color: var(--graphite); cursor: pointer; }

/* цвета курсов для меток в статистике */
.cr-dot[data-c="espanol"] { background: #c4410c; } .cr-dot[data-c="english"] { background: #1d5fe0; }
.cr-dot[data-c="tensors"] { background: #6741d9; } .cr-dot[data-c="mba"] { background: #9a5b06; }
.cr-dot[data-c="causal"] { background: #0b6e80; } .cr-dot[data-c="gametheory"] { background: #b8235a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cr-dot[data-c="espanol"] { background: #ff8a50; } :root:not([data-theme="light"]) .cr-dot[data-c="english"] { background: #6b97ff; }
  :root:not([data-theme="light"]) .cr-dot[data-c="tensors"] { background: #a28bff; } :root:not([data-theme="light"]) .cr-dot[data-c="mba"] { background: #e8a23a; }
  :root:not([data-theme="light"]) .cr-dot[data-c="causal"] { background: #3bc9db; } :root:not([data-theme="light"]) .cr-dot[data-c="gametheory"] { background: #f27aa6; }
}

/* таблицы в ответах: широкая таблица листается вбок, тени у краёв подсказывают, что есть продолжение */
:root { --shade: rgba(10, 12, 18, .16); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --shade: rgba(0, 0, 0, .75); } }
.table-scroll {
  overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; margin: .6em 0 1em; max-width: 100%;
  background:
    linear-gradient(to right, var(--paper) 40%, transparent) left center / 28px 100% no-repeat local,
    linear-gradient(to left, var(--paper) 40%, transparent) right center / 28px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--shade), transparent) left center / 12px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--shade), transparent) right center / 12px 100% no-repeat scroll;
}
.msg.assistant .table-scroll table { display: table; margin: 0; width: max-content; min-width: 100%; max-width: none; overflow: visible; }
.msg.assistant .table-scroll th, .msg.assistant .table-scroll td {
  min-width: 5.5em; max-width: 17em; white-space: normal; overflow-wrap: normal; word-break: normal; hyphens: manual; vertical-align: top;
}

/* ширина чата на десктопе: ручки по краям колонки */
.resize-handle { display: none; }
@media (hover: hover) and (pointer: fine) and (min-width: 900px) {
  .resize-handle { display: block; position: absolute; top: 0; bottom: 0; width: 14px; cursor: col-resize; z-index: 5; touch-action: none; }
  .resize-handle.left { left: -20px; }
  .resize-handle.right { right: -20px; }
  .resize-handle::after {
    content: ""; position: absolute; top: 50%; left: 6px; width: 2px; height: 44px; margin-top: -22px; border-radius: 2px;
    background: var(--hairline); opacity: 0; transition: opacity .15s, background .15s, height .15s, margin-top .15s;
  }
  .app:hover .resize-handle::after { opacity: 1; }
  .resize-handle:hover::after, .resize-handle:focus-visible::after, body.resizing .resize-handle::after {
    opacity: 1; background: var(--accent); height: 88px; margin-top: -44px;
  }
  .resize-handle:focus-visible { outline: none; }
}
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none; }

/* телефон: страница закреплена, прокручивается только лента; высота — по видимой области (клавиатура на iOS её уменьшает) */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { position: fixed; inset: 0; width: 100%; }
.app { height: var(--app-h, 100dvh); transform: translateY(var(--app-top, 0px)); }
.log { min-height: 0; overscroll-behavior: contain; }
.login { height: var(--app-h, 100dvh); overflow-y: auto; }

/* тёмная тема, выбранная в настройках (повторяет системную тёмную) */
  :root[data-theme="dark"] {
    --paper: #121418; --ink: #e8eaf0; --graphite: #969dab; --hairline: #262a32; --mist: #1b1e24; --mist-2: #252931;
    --warn: #e0a640; --bad: #ef6f62; --accent: #e8eaf0; --on-accent: #121418;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    color-scheme: dark;
  }
  :root[data-theme="dark"][data-course="espanol"]    { --accent: #ff8a50; }
  :root[data-theme="dark"][data-course="english"]    { --accent: #6b97ff; }
  :root[data-theme="dark"][data-course="tensors"]    { --accent: #a28bff; }
  :root[data-theme="dark"][data-course="mba"]        { --accent: #e8a23a; }
  :root[data-theme="dark"][data-course="causal"]     { --accent: #3bc9db; }
  :root[data-theme="dark"][data-course="gametheory"] { --accent: #f27aa6; }
  :root[data-theme="dark"] .cr-dot[data-c="espanol"] { background: #ff8a50; } :root[data-theme="dark"] .cr-dot[data-c="english"] { background: #6b97ff; }
  :root[data-theme="dark"] .cr-dot[data-c="tensors"] { background: #a28bff; } :root[data-theme="dark"] .cr-dot[data-c="mba"] { background: #e8a23a; }
  :root[data-theme="dark"] .cr-dot[data-c="causal"] { background: #3bc9db; } :root[data-theme="dark"] .cr-dot[data-c="gametheory"] { background: #f27aa6; }
 :root[data-theme="dark"] { --shade: rgba(0, 0, 0, .75); } 

/* выбор из нескольких действий: столбиком на всю ширину, главное сверху */
.dlg .row.stack { flex-direction: column; align-items: stretch; gap: 8px; margin-top: 6px; }
.dlg .row.stack button { width: 100%; padding: 12px 16px; font-size: 15px; }
.dlg .row button.ghost { background: none; color: var(--graphite); padding-top: 8px; padding-bottom: 8px; }
.dlg .row button.ghost:hover { color: var(--ink); }

/* ---------- движение: только в ответ на действие или чтобы показать состояние ---------- */
:root { --ease-out: cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }

/* новые сообщения во время занятия */
.enter-user { animation: rise .26s var(--ease-out) both; transform-origin: right bottom; }
.enter-fade { animation: fade-in .22s ease-out both; }

/* ожидание ответа: блик по надписи и кольцо на кнопке отправки */
.thinking {
  color: transparent; background: linear-gradient(90deg, var(--graphite) 0%, var(--graphite) 35%, var(--ink) 50%, var(--graphite) 65%, var(--graphite) 100%);
  background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; animation: shimmer 1.8s linear infinite;
}
.thinking::after { content: none; animation: none; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -150% 0; } }
.send { position: relative; transition: background .25s, transform .12s; }
.send:active:not(:disabled) { transform: scale(.92); }
.send:disabled { opacity: .3; }
.send.busy { opacity: 1; }
.send.busy svg { opacity: 0; }
.send.busy::after {
  content: ""; position: absolute; inset: 11px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.field { transition: box-shadow .2s; }

/* цвет курса перетекает при переключении */
.primary, .audio button, .link-btn, .chat-item.active::before, .resize-handle::after { transition: background-color .25s, color .25s, transform .12s; }

/* окна: появляются и уходят; на телефоне — лист снизу */
.dlg[open] { animation: dlg-in .22s var(--ease-out); }
.dlg[open]::backdrop { animation: fade-in .22s ease-out; }
.dlg.closing { animation: dlg-out .16s ease-in forwards; }
.dlg.closing::backdrop { animation: fade-out .16s ease-in forwards; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes dlg-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }
@media (max-width: 600px) {
  .dlg[open] { animation: sheet-in .3s var(--ease-out); }
  .dlg.closing { animation: sheet-out .18s ease-in forwards; }
  @keyframes sheet-in { from { transform: translateY(100%); } }
  @keyframes sheet-out { to { transform: translateY(100%); } }
}

/* список чатов выезжает слева */
.drawer.anim-in { animation: fade-in .2s ease-out; }
.drawer.anim-in .drawer-panel { animation: slide-in .26s var(--ease-out); }
.drawer.closing { animation: fade-out .18s ease-in forwards; }
.drawer.closing .drawer-panel { animation: slide-out .18s ease-in forwards; }
@keyframes slide-in { from { transform: translateX(-100%); } }
@keyframes slide-out { to { transform: translateX(-100%); } }

/* переход «чат ↔ статистика» */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .28s; animation-timing-function: var(--ease-out); }
:root[data-vt="forward"]::view-transition-old(root) { animation-name: vt-out-left; }
:root[data-vt="forward"]::view-transition-new(root) { animation-name: vt-in-right; }
:root[data-vt="back"]::view-transition-old(root) { animation-name: vt-out-right; }
:root[data-vt="back"]::view-transition-new(root) { animation-name: vt-in-left; }
@keyframes vt-out-left { to { opacity: 0; transform: translateX(-8%); } }
@keyframes vt-in-right { from { opacity: 0; transform: translateX(8%); } }
@keyframes vt-out-right { to { opacity: 0; transform: translateX(8%); } }
@keyframes vt-in-left { from { opacity: 0; transform: translateX(-8%); } }

/* пустой экран курса — единственный «торжественный» момент */
.empty > * { animation: rise .55s var(--ease-out) both; }
.empty > p { animation-delay: .12s; }
.empty > .primary { animation-delay: .22s; }
.empty h2::after { transform-origin: left center; animation: draw .7s var(--ease-out) .18s both; }
@keyframes draw { from { transform: scaleX(0); } }

/* подтверждение: память записана, звук играет */
.tool.write.enter-fade::before { animation: pulse 1.1s ease-out .1s 2; }
.audio button.playing { animation: pulse 1.4s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 100% { box-shadow: 0 0 0 9px transparent; } }

/* графики вырастают от оси при открытии статистики */
.chart svg.grow .bar { transform-box: fill-box; transform-origin: bottom; animation: grow-y .5s var(--ease-out) both; }
.chart svg.grow .dot, .chart svg.grow .line { animation: fade-in .45s ease-out .1s both; }
@keyframes grow-y { from { transform: scaleY(0); } }

/* «Уменьшить движение» в системе: без анимаций */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, .dlg::backdrop { transition: none !important; animation: none !important; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; }
}

/* ---------- карта курса ---------- */
.empty-actions { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.map-link { border: 0; background: none; padding: 8px 0; font-size: 15px; color: var(--ink); cursor: pointer; border-bottom: 1px solid var(--hairline); }
.map-link:hover { border-bottom-color: var(--accent); }
.map-body { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
.map-hero { padding: 18px 0 8px; }
.map-course { display: flex; align-items: center; gap: 9px; font-size: 15px; color: var(--graphite); font-weight: 500; }
.map-percent { display: flex; align-items: baseline; margin-top: 6px; line-height: 1; }
.map-percent .num { font-size: clamp(72px, 22vw, 112px); font-weight: 600; letter-spacing: -0.05em; font-variant-numeric: tabular-nums; }
.map-percent .pct { font-size: clamp(28px, 7vw, 40px); font-weight: 500; color: var(--accent); margin-left: 4px; }
.map-percent-label { font-size: 15px; color: var(--graphite); margin-top: 8px; }
.map-bar { height: 6px; background: var(--mist-2); border-radius: 6px; overflow: hidden; margin: 16px 0 0; }
.map-bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 6px; transition: width 1s var(--ease-out, ease-out); }
.map-goal { font-size: 16px; margin: 16px 0 0; max-width: 60ch; }
.map-goal b { font-weight: 600; }
.map-updating { margin-top: 10px; }
.map-now { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; padding: 24px 0; border-bottom: 1px solid var(--hairline); }
@media (min-width: 640px) { .map-now { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.now-label { font-size: 13px; color: var(--graphite); margin-bottom: 4px; }
.now-block p { margin: 0; font-size: 16px; font-weight: 500; }
.now-sub { font-size: 13px; color: var(--graphite); margin-top: 4px; }
.map-activity { display: flex; align-items: center; gap: 20px; padding: 22px 0; border-bottom: 1px solid var(--hairline); }
.heat { display: flex; gap: 4px; flex: none; }
.heat-col { display: grid; gap: 4px; }
.heat i { display: block; width: 12px; height: 12px; border-radius: 3px; background: var(--mist-2); }
.heat i.on { background: var(--accent); }
.heat i.future { background: transparent; }
.heat i.today { box-shadow: 0 0 0 1.5px var(--ink); }
.heat-num { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.heat-sub { font-size: 13px; color: var(--graphite); }

/* извилистая горизонтальная дорога */
.road-wrap { position: relative; margin: 6px 0 4px; }
.road-scroll {
  overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; scrollbar-width: none;
  margin: 0 -16px; padding: 0 16px; cursor: grab;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
          mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
}
.road-scroll::-webkit-scrollbar { display: none; }
.road-scroll.dragging { cursor: grabbing; user-select: none; }
.road-canvas { position: relative; }
.road-svg { position: absolute; inset: 0; overflow: visible; }
.road-base, .road-progress { fill: none; stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
.road-base { stroke: var(--mist-2); }
.road-progress { stroke: var(--accent); }
.road-sep { stroke: var(--hairline); stroke-width: 1; stroke-dasharray: 3 5; }
.road-node .rn-done { fill: var(--accent); stroke: var(--paper); stroke-width: 3; }
.road-node .rn-check { fill: none; stroke: var(--on-accent); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.road-node .rn-current { fill: var(--paper); stroke: var(--accent); stroke-width: 3.5; }
.road-node .rn-dot { fill: var(--accent); }
.road-node .rn-up { fill: var(--paper); stroke: var(--mist-2); stroke-width: 3; }
.road-node .rn-finish { fill: var(--ink); stroke: var(--paper); stroke-width: 3; }
.road-node .rn-flag { fill: none; stroke: var(--paper); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.road-node .rn-pulse { fill: var(--accent); opacity: 0; transform-box: fill-box; transform-origin: center; animation: ring-pulse 1.9s ease-out infinite; }
@keyframes ring-pulse { from { opacity: .45; transform: scale(1); } to { opacity: 0; transform: scale(2.3); } }
.road-label { position: absolute; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.road-label.up { justify-content: flex-end; }
.road-label .rl-title {
  font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.road-label .rl-note {
  font-size: 12px; line-height: 1.3; color: var(--graphite); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.road-label.upcoming .rl-title { color: var(--graphite); }
.road-label.current .rl-title, .road-label.finish .rl-title { font-weight: 600; }
.road-label .here { margin-top: 4px; }
.road-stage {
  position: absolute; top: 4px; font-size: 12.5px; font-weight: 600; color: var(--graphite); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; padding-left: 8px; border-left: 2px solid var(--hairline);
}
.road-arrows { display: none; }
@media (hover: hover) and (pointer: fine) {
  .road-arrows { display: flex; justify-content: space-between; position: absolute; left: -6px; right: -6px; top: 50%; transform: translateY(-50%); pointer-events: none; }
  .road-arrow {
    pointer-events: auto; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--hairline); background: var(--paper);
    display: grid; place-items: center; cursor: pointer; color: var(--ink); opacity: 0; transition: opacity .2s;
  }
  .road-wrap:hover .road-arrow { opacity: 1; }
  .road-arrow svg { width: 18px; height: 18px; }
}
@media (prefers-reduced-motion: reduce) { .road-node .rn-pulse { animation: none; opacity: 0; } }

.map-wins { padding: 22px 0 6px; border-top: 1px solid var(--hairline); margin-top: 8px; }
.map-wins h3 { margin: 0 0 10px; font-size: 17px; font-weight: 600; }
.map-wins ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.map-wins li { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.win-ic { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.win-ic svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.map-motivation { font-size: 17px; line-height: 1.5; margin: 22px 0 10px; padding-left: 14px; border-left: 2px solid var(--accent); max-width: 60ch; }
.map-loading { margin: 18vh 0 0; font-size: 17px; }
@media (prefers-reduced-motion: reduce) { .map-bar span { transition: none !important; } }
.here { display: inline-block; font-size: 12px; font-weight: 600; color: var(--on-accent); background: var(--accent); padding: 2px 9px; border-radius: 999px; }

/* строка контекста и цены: «всегда» / «когда контекст большой» / «никогда» (настройка на устройстве) */
:root[data-ctxbar="never"] .ctx, :root[data-ctxbar="auto"] .ctx[data-level="ok"] { display: none; }

/* запас под последним ответом, чтобы ход можно было держать у верхнего края */
.turn-spacer { pointer-events: none; }

/* ---------- минимальная шапка и боковое меню ---------- */
.course-title {
  display: flex; align-items: center; gap: 9px; min-width: 0; border: 0; background: none; cursor: pointer;
  padding: 6px 10px 6px 6px; border-radius: 12px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink);
}
.course-title:hover { background: var(--mist); }
.course-title #courseName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-panel { display: flex; flex-direction: column; gap: 4px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.drawer-head .brand { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.course-list { display: grid; gap: 2px; margin: 4px 0 10px; }
.cl-item {
  display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; border-radius: 12px;
  padding: 10px 12px; font-size: 15.5px; text-align: left; cursor: pointer; color: var(--ink);
}
.cl-item:hover { background: var(--mist); }
.cl-item.active { background: var(--mist); font-weight: 600; }
.cl-item .cr-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.cl-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-pct { font-size: 13px; color: var(--graphite); font-weight: 400; font-variant-numeric: tabular-nums; }
.cl-item:disabled, .chat-item:disabled { opacity: .45; cursor: default; }
.drawer-actions { display: grid; gap: 2px; padding: 10px 0; border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); }
.drawer-act {
  display: flex; align-items: center; gap: 14px; width: 100%; border: 0; background: none; border-radius: 12px;
  padding: 10px 12px; font-size: 15.5px; text-align: left; cursor: pointer; color: var(--ink);
}
.drawer-act:hover { background: var(--mist); }
.drawer-act svg { color: var(--graphite); }
#newBtn svg { color: var(--accent); }
.drawer-act:disabled { opacity: .4; cursor: default; }
.drawer-sub { font-size: 13px; color: var(--graphite); padding: 14px 12px 4px; }
.drawer-empty { padding: 0 12px; font-size: 14px; }
/* свайп: панель идёт за пальцем, затемнение — по степени открытия */
.drawer.dragging, .drawer.dragging .drawer-panel, .drawer.settling, .drawer.settling .drawer-panel { animation: none !important; }
.drawer.dragging, .drawer.settling { background: rgba(8, 10, 14, calc(.32 * var(--p, 0))); }
.drawer.settling .drawer-panel { transition: transform .22s cubic-bezier(.2, .8, .2, 1); }
.drawer.settling { transition: background-color .22s; }

/* телефон: плотнее по вертикали; в PWA без двойного отступа сверху и с меньшим запасом над полоской «Домой» */
@media (max-width: 600px) {
  .top { min-height: 48px; }
  .log { padding-top: 6px; padding-bottom: 10px; }
  .ctx { padding-bottom: 6px; }
  .ctx-row { margin-top: 4px; }
  .composer { padding-top: 4px; padding-bottom: max(8px, calc(env(safe-area-inset-bottom) - 12px)); }
  .user-wrap { margin: 16px 0 14px; }
  .stats-body, .map-body { padding-bottom: max(16px, calc(env(safe-area-inset-bottom) - 8px)); }
}
:root[data-notop] .top { padding-top: 0; }
:root[data-notop] .drawer-panel { padding-top: 8px; }
:root[data-standalone] .login { padding-top: 12px; padding-bottom: 12px; }

/* метаинформация под ответом: одна строка, листается вбок */
.stats {
  flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; white-space: nowrap; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain; padding-right: 16px;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
          mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
}
.stats::-webkit-scrollbar { display: none; }
.stats span { flex: none; }

/* ---------- прогресс по дням ---------- */
.pheat { display: grid; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.pheat::-webkit-scrollbar { display: none; }
.pheat-months, .pheat-grid { display: grid; grid-template-columns: repeat(16, 14px); gap: 4px; }
.pheat-months span { font-size: 11px; color: var(--graphite); white-space: nowrap; overflow: visible; height: 14px; }
.pheat-col { display: grid; gap: 4px; }
.pheat i { display: block; width: 14px; height: 14px; border-radius: 4px; background: var(--mist-2); }
.pheat i[data-l="1"] { background: color-mix(in srgb, var(--ink) 28%, var(--mist-2)); }
.pheat i[data-l="2"] { background: color-mix(in srgb, var(--ink) 50%, var(--mist-2)); }
.pheat i[data-l="3"] { background: color-mix(in srgb, var(--ink) 72%, var(--mist-2)); }
.pheat i[data-l="4"] { background: var(--ink); }
.pheat i.future { background: transparent; }
.pheat i.today { box-shadow: 0 0 0 1.5px var(--paper), 0 0 0 3px var(--ink); }
.pheat-legend { display: flex; align-items: center; gap: 4px; margin-top: 6px; font-size: 12px; color: var(--graphite); }
.pheat-legend i { width: 11px; height: 11px; border-radius: 3px; }
.pheat-legend span:first-child { margin-right: 4px; } .pheat-legend span:last-child { margin-left: 4px; }
.pfeed { padding: 22px 0 6px; }
.pfeed h3 { margin: 0 0 6px; font-size: 20px; font-weight: 600; letter-spacing: -0.015em; }
.pday { padding: 14px 0; border-bottom: 1px solid var(--hairline); }
.pday:last-child { border-bottom: 0; }
.pday-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.pday-head h4 { margin: 0; font-size: 16px; font-weight: 600; }
.pday-meta { font-size: 13px; color: var(--graphite); white-space: nowrap; }
.pcourse { padding: 6px 0 4px; }
.pcourse-title { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 500; }
.pcourse-title .cr-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.pcourse ul { margin: 4px 0 0 18px; padding-left: 1.1em; font-size: 14px; color: var(--ink); }
.pcourse li { margin: 2px 0; }
.pcourse-meta { font-size: 12.5px; color: var(--graphite); margin: 3px 0 0 18px; }

/* ---------- шпаргалки ---------- */
.cheats-hero { padding: 16px 0 6px; }
.cheats-hero h2 { margin: 8px 0 14px; font-size: 30px; font-weight: 600; letter-spacing: -0.025em; line-height: 1.1; }
.cheats-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.cheats-search { flex: 1; min-width: 200px; border: 0; background: var(--mist); border-radius: 999px; padding: 10px 16px; font-size: 16px; color: var(--ink); }
.cheats-search:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.cheats-group { padding: 14px 0 4px; }
.cheats-stage { font-size: 13px; font-weight: 600; color: var(--graphite); padding: 0 0 6px; }
.cheat-item {
  display: grid; gap: 2px; width: 100%; text-align: left; border: 0; background: none; cursor: pointer; color: var(--ink);
  padding: 12px 0; border-bottom: 1px solid var(--hairline);
}
.cheat-item:hover .ci-title { color: var(--accent); }
.ci-title { font-size: 16px; font-weight: 600; transition: color .15s; }
.ci-sum { font-size: 14px; color: var(--graphite); }
.ci-date { font-size: 12px; color: var(--graphite); }
.cheat-head { padding: 12px 0 4px; }
.cheat-back { padding-left: 0; }
.cheat-head h2 { margin: 8px 0 4px; font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
.cheat-meta { font-size: 13px; color: var(--graphite); }
.cheat-body { margin-top: 14px; }
.cheat-body h2 { font-size: 17px; margin-top: 1.4em; padding-top: 1em; border-top: 1px solid var(--hairline); }
.cheat-body h2:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.cheat-body details { border: 1px solid var(--hairline); border-radius: 12px; padding: 10px 14px; margin: 8px 0; }
.cheat-body details[open] { background: var(--mist); }
.cheat-body summary { cursor: pointer; font-weight: 500; }
.cheat-body details > :not(summary) { margin-top: 8px; }
.rl-cheat { margin-top: 4px; border: 0; background: none; padding: 0; font-size: 12px; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40;
  display: flex; align-items: center; gap: 14px; max-width: min(92vw, 560px); padding: 11px 16px; border-radius: 14px;
  background: var(--ink); color: var(--paper); font-size: 14px; box-shadow: 0 10px 30px rgba(10, 12, 18, .25); animation: rise .25s var(--ease-out);
}
.toast .link-btn { color: var(--paper); text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
.cheat-body details .answer > :first-child { margin-top: 8px; } .cheat-body details .answer > :last-child { margin-bottom: 0; }

/* меню: только вертикальная прокрутка, длинные строки переносятся */
.drawer-panel { overflow-x: hidden; overscroll-behavior: contain; }
.chat-item { overflow: hidden; }
.chat-item .m { flex-wrap: wrap; }
.course-list, .drawer-actions { grid-template-columns: minmax(0, 1fr); }
.cl-item, .drawer-act, .chat-item { min-width: 0; }

/* кнопка «вниз» над полем ввода */
.composer { position: relative; }
.to-bottom {
  position: absolute; left: 50%; bottom: calc(100% + 10px); z-index: 6; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--hairline); background: var(--paper); color: var(--ink); display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 6px 18px rgba(10, 12, 18, .16); opacity: 0; pointer-events: none;
  transform: translate(-50%, 8px) scale(.9); transition: opacity .18s ease-out, transform .18s ease-out;
}
.to-bottom.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0) scale(1); }
.to-bottom svg { width: 20px; height: 20px; }
.to-bottom:active { transform: translate(-50%, 0) scale(.92); }
