/* English Room — графит + кобальт. Шрифты: Onest (интерфейс), JetBrains Mono (разметка). */

/* ---------- Темы ---------- */
:root {
  color-scheme: light;
  --bg: #F6F6F3;
  --surface: #FFFFFF;
  --surface-2: #F0F0EC;
  --surface-3: #E9E9E3;
  --border: #E3E3DE;
  --border-strong: #CFCFC8;
  --text: #16181B;
  --muted: #62666E;
  --faint: #A4A7AD;
  --ink: #16181B;
  --ink-hover: #2D3036;
  --on-ink: #FFFFFF;
  --accent: #2450D4;
  --accent-hover: #1B3FAE;
  --accent-soft: #E8EEFC;
  --ok: #17803D;
  --ok-soft: #E3F4E8;
  --bad: #C2362B;
  --bad-soft: #FBE8E6;
  --warn: #8A5A00;
  --warn-soft: #FDF3DC;
  --code-bg: #FCFCFA;
  --shadow: 0 1px 2px rgb(22 24 27 / .04);
  --shadow-lg: 0 16px 48px rgb(22 24 27 / .16);
  --font: Onest, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111214;
  --surface: #18191C;
  --surface-2: #202226;
  --surface-3: #282A2F;
  --border: #2C2E33;
  --border-strong: #3B3E44;
  --text: #ECEDEE;
  --muted: #9A9EA6;
  --faint: #6B6F77;
  --ink: #ECEDEE;
  --ink-hover: #FFFFFF;
  --on-ink: #111214;
  --accent: #7A9BFF;
  --accent-hover: #A3BAFF;
  --accent-soft: #1D2742;
  --ok: #4CC27A;
  --ok-soft: #15291D;
  --bad: #F2766B;
  --bad-soft: #33191A;
  --warn: #F0C060;
  --warn-soft: #2E2511;
  --code-bg: #141518;
  --shadow: none;
  --shadow-lg: 0 16px 48px rgb(0 0 0 / .55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111214;
    --surface: #18191C;
    --surface-2: #202226;
    --surface-3: #282A2F;
    --border: #2C2E33;
    --border-strong: #3B3E44;
    --text: #ECEDEE;
    --muted: #9A9EA6;
    --faint: #6B6F77;
    --ink: #ECEDEE;
    --ink-hover: #FFFFFF;
    --on-ink: #111214;
    --accent: #7A9BFF;
    --accent-hover: #A3BAFF;
    --accent-soft: #1D2742;
    --ok: #4CC27A;
    --ok-soft: #15291D;
    --bad: #F2766B;
    --bad-soft: #33191A;
    --warn: #F0C060;
    --warn-soft: #2E2511;
    --code-bg: #141518;
    --shadow: none;
    --shadow-lg: 0 16px 48px rgb(0 0 0 / .55);
  }
}

/* ---------- База ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--font); min-height: 100vh; -webkit-font-smoothing: antialiased; }
body.is-dragging { user-select: none; -webkit-user-select: none; cursor: grabbing; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.xs { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.center { justify-content: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: -3px; }

.container { max-width: 1040px; margin: 0 auto; padding: 28px 16px 96px; }
.container.wide { max-width: 1480px; padding-top: 20px; }
.container.narrow { max-width: 720px; }

/* ---------- Шапка ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1040px; margin: 0 auto; padding: 0 16px; height: 60px; display: flex; align-items: center; gap: 24px; }
.topbar-inner.wide { max-width: 1480px; }
.topbar .spacer { flex: 1; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--text); white-space: nowrap; }
.logo:hover { color: var(--text); }
.logo-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--ink); color: var(--on-ink); display: grid; place-items: center; font-size: 12px; font-weight: 700; letter-spacing: -0.02em; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); font-size: 14px; font-weight: 500; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.nav a .icon { width: 16px; height: 16px; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--surface-2); color: var(--text); }
.count-pill { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; display: inline-grid; place-items: center; }
:root[data-theme="dark"] .count-pill { color: #111214; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 500 15px var(--font); cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); font-weight: 600; }
.btn.primary:hover { background: var(--ink-hover); border-color: var(--ink-hover); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.btn.danger-fill { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 600; }
.btn.danger-fill:hover { background: color-mix(in srgb, var(--bad) 85%, #000); border-color: transparent; color: #fff; }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; gap: 6px; }
.btn.sm .icon { width: 16px; height: 16px; }
.btn.lg { height: 52px; padding: 0 24px; font-size: 16px; border-radius: 12px; }
.btn.icon-only { width: 40px; padding: 0; }
.btn.sm.icon-only { width: 32px; }
.btn.block { width: 100%; }

/* ---------- Поля ---------- */
.input, .textarea {
  width: 100%; font: 15px/1.5 var(--font); color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 9px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.textarea { resize: vertical; min-height: 48px; }
.input:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.select { max-width: 340px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.hint { font-size: 13px; color: var(--muted); max-width: 62ch; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }

/* ---------- Карточки и общее ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { flex: 1; min-width: 200px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); font: 500 14px var(--font); padding: 7px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }

.empty { text-align: center; padding: 48px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty p { color: var(--muted); max-width: 460px; text-wrap: pretty; }
.empty .row { margin-top: 8px; }
.empty-ico { width: 52px; height: 52px; border-radius: 14px; background: var(--surface-2); color: var(--text); display: grid; place-items: center; }
.empty-ico .icon { width: 24px; height: 24px; }
.loading { text-align: center; color: var(--muted); padding: 64px 0; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .input { max-width: 280px; }
.toolbar .sort-select { width: auto; max-width: 240px; margin-left: auto; }

/* ---------- Материалы ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.mcard { padding: 18px; display: flex; flex-direction: column; gap: 8px; color: var(--text); transition: border-color .15s; }
.mcard:hover { border-color: var(--border-strong); color: var(--text); }
.mcard h3 { font-size: 17px; overflow-wrap: anywhere; margin-top: 4px; }
.mcard .meta { font-size: 13px; color: var(--muted); }
.mcard .actions { display: flex; gap: 4px; margin-top: auto; padding-top: 10px; }

/* ---------- Редактор ---------- */
.editor-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.title-input { flex: 1; min-width: 220px; font: 700 24px var(--font); letter-spacing: -0.01em; color: var(--text); border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 4px 8px; outline: none; }
.title-input:hover { border-color: var(--border); }
.title-input:focus { border-color: var(--accent); background: var(--surface); }
.save-state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.save-state .icon { width: 15px; height: 15px; color: var(--ok); }
.save-state.error, .save-state.error .icon { color: var(--bad); }
.editor-settings { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
.link-box { display: flex; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 4px 4px 4px 12px; min-width: 0; max-width: 100%; }
.link-box span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 13px var(--mono); color: var(--muted); }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.split-tabs { display: none; margin-bottom: 12px; }
.pane { display: flex; flex-direction: column; overflow: hidden; }
.pane-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
.pane-head .icon { width: 16px; height: 16px; }
.md-status { font-size: 13px; color: var(--muted); margin-left: 4px; }
.md-toolbar { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.tool-row { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.tool-label { flex: none; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.tool-group { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.tool { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: 500 13px var(--font); cursor: pointer; white-space: nowrap; }
.tool .icon { width: 16px; height: 16px; color: var(--muted); }
.tool:hover { border-color: var(--border-strong); background: var(--surface-2); }

.md-scroll { background: var(--code-bg); }
.md-editor { position: relative; }
.md-hl, .md-input {
  margin: 0; padding: 16px 18px; border: 0;
  font: 14px/1.75 var(--mono); letter-spacing: 0; tab-size: 2;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: normal;
}
.md-hl { position: absolute; inset: 0; color: var(--text); pointer-events: none; overflow: hidden; }
.md-input { position: relative; display: block; width: 100%; min-height: 480px; resize: none; overflow: hidden; background: transparent; color: transparent; caret-color: var(--text); outline: none; }
.md-input::placeholder { color: var(--faint); }
.md-input::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); color: transparent; }
.hl-kw { color: var(--accent); font-weight: 600; }
.hl-ok { color: var(--ok); font-weight: 600; }
.hl-dim { color: var(--muted); }
.hl-h { font-weight: 700; }
.hl-ans { background: var(--ok-soft); color: var(--ok); border-radius: 4px; }
.md-warnings { display: flex; flex-direction: column; gap: 6px; padding: 0 12px; }
.md-warnings:not(:empty) { padding: 12px; border-top: 1px solid var(--border); }
.warn-line { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--warn); background: var(--warn-soft); padding: 7px 10px; border-radius: 8px; }
.warn-line .icon { width: 15px; height: 15px; margin-top: 2px; }

.preview-pane { background: var(--surface-2); position: sticky; top: 76px; max-height: calc(100vh - 92px); }
.preview-pane .pane-head { background: var(--surface); }
.preview-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.preview-empty { text-align: center; color: var(--muted); padding: 48px 16px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.preview-empty .icon { width: 28px; height: 28px; }

.cheats { display: flex; flex-direction: column; gap: 8px; }
.cheat { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 14px; align-items: start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.cheat-code { margin: 0; font: 13px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.cheat-text { font-size: 14px; color: var(--muted); }
.gpt-box { padding: 16px; border-radius: 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }

/* ---------- Справка ---------- */
.help { display: flex; flex-direction: column; gap: 16px; }
.help-steps { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.help-step { padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.help-step .step-n { width: 28px; height: 28px; border-radius: 8px; background: var(--ink); color: var(--on-ink); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.help-step p { color: var(--muted); font-size: 14px; }
.help-step code, .help code { font: 13px var(--mono); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.help-section { padding: 20px; display: flex; flex-direction: column; gap: 12px; }

/* ---------- Урок онлайн ---------- */
.live-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
.live-wait { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.live-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.live-tabs:empty { display: none; }
.live-tab { display: inline-flex; align-items: center; gap: 8px; max-width: 260px; height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: 500 14px var(--font); cursor: pointer; }
.live-tab.active { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.live-tab .p-ok, .live-tab .p-bad { font-weight: 700; font-size: 13px; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.online-dot.on { background: var(--ok); }
.online-dot.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.live-progress { margin-bottom: 12px; box-shadow: none; }
.live-view .task { transition: box-shadow .2s; }
.live-view .task.student-here { position: relative; box-shadow: 0 0 0 2px var(--accent); }
.live-view .task.student-here::after { content: attr(data-who); position: absolute; top: -11px; right: 16px; background: var(--accent); color: var(--surface); font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.live-view .options, .live-view .gaps-text, .live-view .bank, .live-view .match-grid, .live-view textarea, .live-view .q-check { pointer-events: none; }

/* ---------- Занятие ---------- */
.active-classes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.active-class { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: var(--text); border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.active-class:hover { color: var(--text); border-color: var(--ok); }
.pick-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
.pick-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: 500 15px var(--font); cursor: pointer; text-align: left; }
.pick-item:hover { border-color: var(--ink); }
.class-head, .class-bar { max-width: 1180px; margin-left: auto; margin-right: auto; }
.class-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.class-title { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; min-width: 0; }
.class-title .badge { gap: 6px; }
.class-material { font: 700 20px var(--font); border: 1px solid transparent; background-color: transparent; padding: 4px 36px 4px 8px; margin-left: -8px; max-width: 520px; cursor: pointer; }
.class-material:hover { border-color: var(--border); }
.class-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 14px; }
.class-student { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.class-page { max-width: 1240px; }
.class-page .class-layout { justify-content: center; }
.class-page .s-head .badge { gap: 6px; }
.class-layout { display: grid; grid-template-columns: minmax(0, 760px) 400px; justify-content: center; gap: 20px; align-items: start; }
.class-main { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.class-tabs { align-self: flex-start; display: none; }
.class-tabs button { display: inline-flex; align-items: center; gap: 6px; }
.class-tabs .icon { width: 16px; height: 16px; }
.class-side { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.class-chat { height: 340px; display: flex; flex-direction: column; overflow: hidden; }
.class-board { display: flex; flex-direction: column; overflow: hidden; }
.class-board-body { padding: 10px; }
.class-board .board-bar .tool span { display: none; }
.class-board .board-bar .tool { width: 32px; padding: 0; justify-content: center; }
.class-board.board-full { position: fixed; inset: 16px; z-index: 120; overflow: auto; }
.class-board.board-full .board-bar .tool { width: auto; padding: 0 9px; }
.class-board.board-full .board-bar .tool span { display: inline; }
.class-board.board-full .board-wrap { width: min(100%, calc((100vh - 150px) * 1.6)); margin: 0 auto; }
.board-backdrop { position: fixed; inset: 0; z-index: 110; background: rgb(10 11 13 / .5); }
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-empty { margin: auto; color: var(--muted); font-size: 14px; }
.msg { max-width: 85%; align-self: flex-start; display: flex; flex-direction: column; gap: 2px; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg-meta { font-size: 11px; color: var(--muted); padding: 0 4px; }
.msg-text { padding: 8px 12px; border-radius: 12px 12px 12px 4px; background: var(--surface-2); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.msg.mine .msg-text { background: var(--ink); color: var(--on-ink); border-radius: 12px 12px 4px 12px; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); align-items: flex-end; }
.chat-input { flex: 1; resize: none; font: 15px/1.4 var(--font); color: var(--text); background: var(--surface-2); border: 1px solid transparent; border-radius: 10px; padding: 9px 12px; outline: none; max-height: 120px; }
.chat-input:focus { border-color: var(--accent); background: var(--surface); }
.board { display: flex; flex-direction: column; gap: 8px; }
.board-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.board-bar .tool.active { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.board-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; padding: 0; }
.swatch.active { box-shadow: 0 0 0 2px var(--accent); }
.board-wrap { position: relative; background: #ffffff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.board-canvas { display: block; width: 100%; touch-action: none; cursor: crosshair; }
.board-wrap[data-tool="text"] .board-canvas { cursor: text; }
.board-wrap[data-tool="eraser"] .board-canvas { cursor: cell; }
.board-text-input { position: absolute; transform: translateY(-4px); min-width: 180px; max-width: 70%; font: 600 16px var(--font); border: 1px dashed #2450d4; border-radius: 6px; background: rgb(255 255 255 / .95); padding: 2px 6px; outline: none; white-space: nowrap; overflow: hidden; }
.board-text-input:empty::before { content: attr(data-placeholder); color: #9a9ea6; font-weight: 500; }

/* ---------- Модалки, тосты ---------- */
.modal-back { position: fixed; inset: 0; background: rgb(10 11 13 / .5); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; animation: fade .15s; }
.modal { width: 100%; max-width: 760px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.modal.sm { max-width: 420px; }
.modal-head { padding: 18px 20px 0; display: flex; align-items: center; gap: 10px; }
.modal-head h2 { flex: 1; }
.modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 0 20px 20px; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; width: calc(100% - 32px); max-width: 480px; pointer-events: none; }
.toast { background: var(--ink); color: var(--on-ink); padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow-lg); animation: pop .2s; pointer-events: auto; }
.toast.error { background: var(--bad); color: #fff; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade { from { opacity: 0; } }
.drop-overlay { position: fixed; inset: 0; z-index: 150; background: color-mix(in srgb, var(--bg) 80%, transparent); display: grid; place-items: center; pointer-events: none; }
.drop-overlay > div { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 36px 48px; border: 2px dashed var(--accent); border-radius: 16px; background: var(--surface); color: var(--text); font-size: 18px; font-weight: 600; }
.drop-overlay .icon { width: 32px; height: 32px; color: var(--accent); }

/* ---------- Вход ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
.login-card { padding: 24px; }
.login-card h1 { font-size: 22px; }
.form-error { color: var(--bad); font-size: 14px; }

/* ---------- Домашки и файлы ---------- */
.usage { padding: 20px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 10px; }
.usage-nums { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.usage-nums b { font-size: 22px; }
.progress { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.progress > div { height: 100%; background: var(--ink); border-radius: 3px; }
.progress.warn > div { background: var(--bad); }
.list { display: flex; flex-direction: column; overflow: hidden; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text); }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--surface-2); color: var(--text); }
.list-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item.unseen .title::after { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-left: 8px; vertical-align: 2px; }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); flex: none; }
.avatar { width: 40px; height: 40px; border-radius: 20px; background: var(--surface-3); color: var(--text); display: grid; place-items: center; font-weight: 700; flex: none; }
.avatar.lg { width: 52px; height: 52px; border-radius: 26px; font-size: 20px; }
.sub-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.score { font-weight: 700; font-size: 14px; padding: 4px 10px; border-radius: 8px; white-space: nowrap; }
.score.big { font-size: 20px; padding: 8px 16px; border-radius: 10px; }
.score.good { background: var(--ok-soft); color: var(--ok); }
.score.mid { background: var(--warn-soft); color: var(--warn); }
.score.low { background: var(--bad-soft); color: var(--bad); }
.score.none { background: var(--surface-2); color: var(--muted); }

/* ---------- Задания (ученик, предпросмотр, отчёт) ---------- */
.tasks { display: flex; flex-direction: column; gap: 12px; }
.task { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.task-num { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; margin-right: 8px; border-radius: 6px; background: var(--ink); color: var(--on-ink); font-size: 12px; font-weight: 700; letter-spacing: 0; vertical-align: 1px; }
.report-label { display: flex; align-items: center; gap: 0; }
.report-label .score { text-transform: none; letter-spacing: 0; font-size: 12px; }
.task-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; white-space: pre-wrap; }
.prose { font-size: 16px; line-height: 1.6; overflow-wrap: anywhere; display: block; }
.prose h3 { font-size: 20px; font-weight: 700; margin: 0 0 10px; }
.prose h4 { font-size: 16px; font-weight: 700; margin: 18px 0 6px; }
.prose h3 + h4 { margin-top: 4px; }
.prose p { margin: 0 0 8px; }
.prose p.label { margin: 14px 0 4px; font-weight: 700; }
.prose ul, .prose ol { margin: 4px 0 10px; padding-left: 22px; }
.prose li { margin: 3px 0; }
.prose li::marker { color: var(--muted); }
.prose > :last-child { margin-bottom: 0; }
.q-text p { margin: 0; }
figure { margin: 0; }
figure img { display: block; border-radius: 8px; margin: 0 auto; max-height: 70vh; object-fit: contain; }
figcaption { font-size: 14px; color: var(--muted); margin-top: 10px; text-align: center; white-space: pre-wrap; }
.missing { flex-direction: row; align-items: center; color: var(--warn); background: var(--warn-soft); border-color: transparent; font-size: 14px; }
.video-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #000; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.audio-embed iframe { width: 100%; height: 80px; border: 0; border-radius: 8px; }
.audio-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }

.player { display: flex; align-items: center; gap: 14px; }
.play-btn { width: 48px; height: 48px; border-radius: 24px; border: 0; background: var(--ink); color: var(--on-ink); display: grid; place-items: center; cursor: pointer; flex: none; }
.play-btn:hover { background: var(--ink-hover); }
.play-btn .icon { width: 18px; height: 18px; }
.player-main { flex: 1; min-width: 0; }
.seek { -webkit-appearance: none; appearance: none; width: 100%; height: 20px; background: transparent; margin: 0; cursor: pointer; --p: 0%; }
.seek::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--accent) var(--p), var(--border) var(--p)); }
.seek::-moz-range-track { height: 4px; border-radius: 2px; background: var(--border); }
.seek::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
.seek::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 7px; background: var(--accent); margin-top: -5px; border: 0; }
.seek::-moz-range-thumb { width: 14px; height: 14px; border-radius: 7px; background: var(--accent); border: 0; }
.audio-time { font: 13px var(--mono); color: var(--muted); white-space: nowrap; }
.speed-btn { border: 1px solid var(--border); background: transparent; color: var(--muted); border-radius: 8px; height: 32px; padding: 0 8px; font: 600 13px var(--mono); cursor: pointer; }

.question + .question { padding-top: 16px; border-top: 1px solid var(--border); }
.question { display: flex; flex-direction: column; gap: 8px; }
.q-text { font-weight: 600; display: flex; gap: 8px; align-items: flex-start; white-space: pre-wrap; font-size: 16px; }
.q-text .n { color: var(--muted); flex: none; }
.q-hint { margin-top: -4px; }
.options { display: flex; flex-direction: column; gap: 8px; }
.option { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--surface); transition: border-color .12s, background .12s; overflow-wrap: anywhere; font-size: 15px; }
.option:hover { border-color: var(--border-strong); }
.option input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); flex: none; }
.option.chosen { border-color: var(--accent); background: var(--accent-soft); }
.option.ok { border-color: var(--ok); background: var(--ok-soft); }
.option.ok input { accent-color: var(--ok); }
.option.bad { border-color: var(--bad); background: var(--bad-soft); }
.option.bad input { accent-color: var(--bad); }
.option.missed { border-color: var(--ok); border-style: dashed; }
.option .tag { margin-left: auto; font-size: 12px; font-weight: 600; flex: none; display: flex; }
.option.ok .tag, .option.missed .tag { color: var(--ok); }
.option.bad .tag { color: var(--bad); }
.locked .option { cursor: default; }

/* вписать слово */
.gaps-text { font-size: 16px; line-height: 2.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.gap { display: inline-block; vertical-align: baseline; font: 600 16px var(--font); color: var(--text); border: 0; border-bottom: 2px solid var(--border-strong); background: var(--surface-2); border-radius: 6px 6px 0 0; padding: 0 8px; min-width: 64px; height: 32px; line-height: 30px; outline: none; text-align: center; margin: 0 2px; }
.gap:focus { border-bottom-color: var(--accent); background: var(--accent-soft); }
.gap.ok { border-bottom-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.gap.bad { border-bottom-color: var(--bad); background: var(--bad-soft); color: var(--bad); text-decoration: line-through; }
.gap-fix { color: var(--ok); font-weight: 600; font-size: 14px; margin: 0 4px; }
.gap-static { display: inline-block; padding: 0 8px; border-radius: 6px; margin: 0 2px; line-height: 28px; font-weight: 600; }
.gap-static.ok { background: var(--ok-soft); color: var(--ok); }
.gap-static.bad { background: var(--bad-soft); color: var(--bad); text-decoration: line-through; }
.gap-static.empty { background: var(--bad-soft); color: var(--bad); font-style: italic; font-weight: 500; }

/* плашки: перетащить и сопоставить */
.bank { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; border-radius: 10px; background: var(--surface-2); min-height: 58px; }
.tile {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 38px; padding: 4px 14px; border: 1.5px solid var(--border-strong); border-bottom-width: 3px; border-radius: 8px;
  background: var(--surface); color: var(--text); font: 600 15px var(--font); cursor: grab;
  touch-action: none; user-select: none; -webkit-user-select: none; transition: transform .1s, border-color .1s, opacity .1s;
}
.tile:hover { border-color: var(--accent); }
.tile:disabled { cursor: default; opacity: .7; }
.tile:disabled:hover { border-color: var(--border-strong); }
.tile.used { display: none; }
.bank:not(:has(.tile:not(.used))) { display: none; }
.tile.selected { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-2px); }
.tile.dragging { opacity: .3; }
.tile.ghost { position: fixed; left: 0; top: 0; z-index: 300; pointer-events: none; cursor: grabbing; box-shadow: var(--shadow-lg); border-color: var(--accent); transform-origin: 0 0; }
.slot {
  display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
  min-width: 72px; min-height: 38px; margin: 0 2px; padding: 0; border: 1.5px dashed var(--border-strong); border-radius: 8px;
  background: var(--surface-2); font: inherit; color: inherit; cursor: pointer; transition: border-color .1s, background .1s;
}
.slot.wide { width: 100%; justify-content: flex-start; margin: 0; }
.slot.filled { border: 0; background: transparent; min-width: 0; }
.slot.wide.filled .tile { width: 100%; justify-content: flex-start; }
.slot .tile.in-slot { border-color: var(--accent); background: var(--accent-soft); }
.slot.target { border-color: var(--accent); background: var(--accent-soft); }
.slot.hover, .slot.selected { border-color: var(--accent); border-style: solid; background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-soft); }
.slot.ok .tile.in-slot { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.slot.bad .tile.in-slot { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); text-decoration: line-through; }
.slot.bad:not(.filled) { border-color: var(--bad); background: var(--bad-soft); }
.gaps-text.drag { line-height: 2.8; }
.match-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 10px; align-items: center; }
.match-left { padding: 9px 12px; border-radius: 8px; background: var(--surface-2); font-weight: 600; overflow-wrap: anywhere; }
.match-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.match-right .slot.wide { flex: 1; width: auto; min-width: 0; }

.progress-pill { display: inline-flex; align-items: center; gap: 12px; padding: 10px 18px; border-radius: 999px; background: var(--ink); color: var(--on-ink); font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); white-space: nowrap; }
.progress-pill .icon { width: 16px; height: 16px; }
.progress-pill.complete { background: var(--ok); color: #fff; }
.pill-bar { width: 120px; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--on-ink) 25%, transparent); overflow: hidden; }
.pill-bar > span { display: block; height: 100%; border-radius: 3px; background: var(--ok); transition: width .3s; }
.progress-pill.complete .pill-bar { display: none; }
.live-view > div:first-child:has(.progress-pill) { margin-bottom: 12px; }
.progress-foot { display: flex; justify-content: center; margin: 24px 0 8px; }
.progress-foot .progress-pill { box-shadow: none; }
/* попытки: кружочки */
.dots { display: inline-flex; flex-direction: column; gap: 3px; vertical-align: middle; margin: 0 6px 0 3px; flex: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--border-strong); background: transparent; display: inline-block; flex: none; }
.dot.ok { background: var(--ok); border-color: var(--ok); }
.dot.bad { background: var(--bad); border-color: var(--bad); }
.dot.inline { vertical-align: -1px; margin: 0 2px; }
.q-text .dots { margin: 2px 0 0 8px; }
.task-foot { display: flex; padding-top: 4px; }
.task-check { min-width: 120px; }
.slot.fixed { cursor: default; }
.slot.revealed .tile.in-slot { border-color: var(--ok); border-style: dashed; background: transparent; color: var(--ok); }
.slot.ok .tile.in-slot { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.match-right .dots { margin-left: 4px; }
.progress-card { width: 100%; padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow-lg); }
.progress-nums { display: flex; align-items: center; gap: 16px; font-size: 14px; font-weight: 600; }
.progress-nums .muted { margin-left: auto; font-weight: 500; }
.progress-nums .p-ok, .progress-nums .p-bad { display: inline-flex; align-items: center; gap: 4px; }
.p-ok { color: var(--ok); }
.p-bad { color: var(--bad); }
.progress-nums .icon { width: 16px; height: 16px; }
.progress-card .progress > div { background: var(--ok); }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.btn.soft:hover { background: color-mix(in srgb, var(--accent-soft) 70%, var(--accent) 12%); color: var(--accent); }
.example-code { margin: 0; padding: 16px 18px; font: 14px/1.75 var(--mono); white-space: pre-wrap; overflow-wrap: break-word; background: var(--code-bg); }
.example-banner { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 14px 16px; border-radius: 12px; background: var(--accent-soft); margin-bottom: 16px; }
.example-banner .icon { color: var(--accent); }
.example-banner > .grow { max-width: 70ch; }
.help-section > p, .gpt-box p, .modal-body > p { max-width: 70ch; }

.open-answer { white-space: pre-wrap; background: var(--surface-2); border-radius: 10px; padding: 12px 14px; overflow-wrap: anywhere; }

/* ---------- Страница ученика ---------- */
.s-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.s-head .badge { margin-bottom: 8px; }
.s-head h1 { overflow-wrap: anywhere; }
.who { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 14px; }
.who .icon { width: 16px; height: 16px; color: var(--muted); }
.name-gate { max-width: 420px; margin: 32px auto; padding: 28px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.name-gate form { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; width: 100%; }
.result-card { padding: 24px; text-align: center; margin-top: 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.result-ico { width: 52px; height: 52px; border-radius: 26px; background: var(--surface-2); color: var(--text); display: grid; place-items: center; }
.result-ico.ok { background: var(--ok-soft); color: var(--ok); }
.result-ico .icon { width: 24px; height: 24px; }
.result-big { font-size: 40px; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; }
.result-big span { font-size: 22px; font-weight: 500; color: var(--muted); }
.result-card .row { margin-top: 8px; }
.bottom-bar { position: sticky; bottom: 0; padding: 16px 0 calc(16px + env(safe-area-inset-bottom)); margin-top: 16px; background: linear-gradient(to top, var(--bg) 70%, transparent); display: flex; gap: 10px; justify-content: center; }
.bottom-bar .btn { min-width: 220px; }
.notice { max-width: 760px; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; background: var(--accent-soft); font-size: 14px; margin-bottom: 14px; }
.notice .icon { color: var(--accent); margin-top: 1px; }

/* ---------- Адаптив ---------- */
@media (max-width: 1000px) {
  .class-layout { grid-template-columns: minmax(0, 1fr); }
  .class-tabs { display: inline-flex; }
  .class-side { position: static; }
  .class-layout[data-tab="tasks"] .class-side { display: none; }
  .class-layout:not([data-tab="tasks"]) .class-tasks { display: none; }
  .class-layout[data-tab="board"] .class-chat { display: none; }
  .class-layout[data-tab="chat"] .class-board { display: none; }
  .class-chat { height: 65vh; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .split-tabs { display: inline-flex; }
  .split.show-md .preview-pane, .split.show-preview .md-pane { display: none; }
  .preview-pane { position: static; max-height: none; }
}
@media (max-width: 640px) {
  h1 { font-size: 22px; }
  .container { padding: 16px 12px 88px; }
  .topbar-inner { gap: 8px; padding: 0 8px 0 12px; height: 56px; }
  .logo-text, .nav a .lbl { display: none; }
  .nav a { padding: 8px 10px; }
  .task { padding: 16px; }
  .card-pad { padding: 16px; }
  .toolbar .input { max-width: none; flex: 1 1 100%; }
  .toolbar .sort-select { max-width: none; margin-left: 0; }
  .md-status { display: none; }
  .title-input { font-size: 20px; min-width: 0; flex-basis: 100%; order: 3; margin-left: 0; }
  .editor-settings { flex-direction: column; align-items: stretch; }
  .cheat { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .bottom-bar .btn { flex: 1; min-width: 0; }
  .modal-back { padding: 12px; }
  .player { gap: 10px; }
  .speed-btn { display: none; }
}
