/* ============ ІнфоДошка — стилі ============ */
:root {
  --bg: #e9edf3;
  --panel: #ffffff;
  --panel-2: #f5f7fa;
  --ink: #1d2433;
  --muted: #6b7486;
  --line: #dde2ea;
  --accent: #2f6fed;
  --accent-ink: #ffffff;
  --accent-soft: #e5edfd;
  --ok: #1f9d55;
  --ok-soft: #e3f6ea;
  --bad: #d64545;
  --bad-soft: #fde8e8;
  --warn: #c98a00;
  --warn-soft: #fff4d6;
  --radius: 10px;
  --shadow: 0 6px 24px rgba(20, 30, 50, .14), 0 1px 3px rgba(20, 30, 50, .08);
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "Courier New", monospace;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --top-h: 52px;
  --tool-w: 58px;
  --dock-w: 78px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
  display: grid;
  grid-template-columns: var(--tool-w) 1fr var(--dock-w);
  grid-template-rows: var(--top-h) 1fr;
  grid-template-areas: "top top top" "tools stage dock";
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg.i { width: 20px; height: 20px; display: block; flex: none; }

/* ---------- Верхня панель ---------- */
.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 14px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 20;
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; }
.brand-logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 14px; font-weight: 700;
}
.brand-name { font-size: 16px; letter-spacing: .2px; }
.lesson { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 120px; }
.lesson select, .pages select {
  height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); padding: 0 8px;
}
#lessonTopic {
  flex: 1; min-width: 80px; height: 34px;
  border: 1px solid transparent; border-radius: 8px; padding: 0 10px;
  font-size: 15px; font-weight: 600; background: transparent;
}
#lessonTopic:hover { border-color: var(--line); }
#lessonTopic:focus { outline: none; border-color: var(--accent); background: #fff; }
.lesson-date { color: var(--muted); white-space: nowrap; font-size: 13px; }
.pages, .file { display: flex; align-items: center; gap: 4px; }
.sep { width: 1px; height: 24px; background: var(--line); margin: 0 6px; }
.page-label {
  min-width: 64px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2);
  font-weight: 600; font-variant-numeric: tabular-nums;
}
.ibtn {
  width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent;
  display: grid; place-items: center; color: var(--ink);
}
.ibtn:hover { background: var(--panel-2); }
.ibtn:active { background: var(--accent-soft); }

/* ---------- Ліва панель інструментів ---------- */
.toolbar {
  grid-area: tools;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto; overflow-x: hidden;
  padding: 6px 0;
  z-index: 15;
  scrollbar-width: thin;
}
.tgroup {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; border-bottom: 1px solid var(--line);
}
.tgroup:last-child { border-bottom: 0; }
.tgroup-label { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; text-align: center; line-height: 1.1; padding: 0 2px 2px; }
.tool {
  width: 42px; height: 38px; border: 0; border-radius: 8px; background: transparent;
  display: grid; place-items: center; color: var(--ink);
}
.tool.small { height: 32px; }
.tool:hover { background: var(--panel-2); }
.tool.active { background: var(--accent); color: var(--accent-ink); }
.swatches { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.swatch {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line); padding: 0;
}
.swatch.active { box-shadow: 0 0 0 2px var(--accent); }
.color-custom {
  margin-top: 4px; width: 40px; height: 22px; border-radius: 6px; overflow: hidden;
  border: 1px solid var(--line); cursor: pointer; display: block;
}
.color-custom input { width: 150%; height: 150%; margin: -25%; border: 0; padding: 0; cursor: pointer; }
.vrange { writing-mode: vertical-lr; direction: rtl; width: 22px; height: 90px; accent-color: var(--accent); }
.small-val { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Сцена з дошкою ---------- */
.stage { grid-area: stage; position: relative; overflow: hidden; background: #fff; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.stage[data-cursor="pen"] #board, .stage[data-cursor="highlighter"] #board,
.stage[data-cursor="line"] #board, .stage[data-cursor="arrow"] #board,
.stage[data-cursor="rect"] #board, .stage[data-cursor="ellipse"] #board,
.stage[data-cursor^="fc-"] #board { cursor: crosshair; }
.stage[data-cursor="text"] #board { cursor: text; }
.stage[data-cursor="hand"] #board { cursor: grab; }
.stage[data-cursor="panning"] #board { cursor: grabbing; }
.stage[data-cursor="eraser"] #board { cursor: cell; }
.stage[data-cursor="laser"] #board { cursor: none; }
.stage[data-cursor="select"] #board { cursor: default; }
.zoom-ctrl {
  position: absolute; right: 10px; bottom: 10px; z-index: 6; display: flex; align-items: center;
  background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 2px 8px rgba(20,30,50,.12); overflow: hidden;
}
.zoom-ctrl button { border: 0; background: transparent; height: 34px; min-width: 34px; font-size: 18px; font-weight: 600; display: grid; place-items: center; color: var(--ink); }
.zoom-ctrl button:hover { background: var(--panel-2); }
.zoom-ctrl #zoomBadge { font-size: 12.5px; min-width: 52px; color: var(--muted); font-variant-numeric: tabular-nums; }
.zoom-ctrl svg.i { width: 17px; height: 17px; }
.subject-select { font-weight: 600; color: var(--accent); }
.dock-apps { display: contents; }
.fn-row { display: flex; align-items: center; gap: 6px; }
.fn-row .swatch-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.plot-host { flex: 1; min-height: 220px; position: relative; background: #fff; border-top: 1px solid var(--line); touch-action: none; }
.plot-host canvas { position: absolute; inset: 0; }
.kbd-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.kbd-grid button { height: 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); font-size: 15px; }
.kbd-grid button:hover { background: var(--accent-soft); }
.kbd-grid button.op { background: var(--panel-2); font-weight: 600; }
.kbd-grid button.eq { background: var(--accent); color: #fff; border-color: var(--accent); }
.calc-screen { font-family: var(--mono); font-size: 22px; text-align: right; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe; min-height: 64px; word-break: break-all; }
.calc-screen .res { color: var(--accent); font-weight: 700; font-size: 26px; }
.formula { font-family: "Cambria Math", "Times New Roman", serif; font-size: 20px; font-style: italic; }
.sol { font-family: "Cambria Math", "Times New Roman", serif; font-size: 18px; line-height: 1.7; }
.var-grid { display: grid; grid-template-columns: auto 1fr auto; gap: 6px 8px; align-items: center; }
.var-grid input.unknown { background: var(--warn-soft); font-weight: 700; }
.pt-grid { display: grid; grid-template-columns: repeat(18, minmax(34px, 1fr)); gap: 2px; }
.pt-el { border: 1px solid rgba(0,0,0,.12); border-radius: 4px; padding: 2px 1px; text-align: center; cursor: pointer; line-height: 1.05; min-height: 42px; display: flex; flex-direction: column; justify-content: center; }
.pt-el b { font-size: 15px; }
.pt-el small { font-size: 9px; opacity: .75; }
.pt-el:hover, .pt-el.sel { outline: 2px solid var(--ink); z-index: 1; }
.pt-el.dim { opacity: .25; }
.sol-table td { font-weight: 700; min-width: 30px; }
.sol-R { background: #dff5e6; color: #18733d; }
.sol-M { background: #fff1c9; color: #8a6200; }
.sol-N { background: #fde2e2; color: #a52a2a; }
.sol-X { background: #eceff3; color: #6b7486; }
.punnett td, .punnett th { min-width: 56px; font-family: var(--mono); font-size: 16px; }
.codon { display: inline-flex; flex-direction: column; align-items: center; margin: 2px; padding: 3px 5px; border-radius: 6px; background: var(--panel-2); font-family: var(--mono); }
.codon small { font-family: var(--sans); font-size: 11px; color: var(--accent); font-weight: 700; }
.leaflet-container { font: inherit; }
.text-editor {
  position: absolute; z-index: 5; margin: 0; padding: 0;
  border: 1px dashed var(--accent); background: rgba(255,255,255,.6);
  outline: none; resize: none; overflow: hidden; line-height: 1.25; white-space: pre;
  min-width: 40px;
}
.text-editor.on-dark { background: rgba(0,0,0,.25); }
.text-editor.centered { text-align: center; white-space: pre-wrap; }

/* Шторка */
.curtain {
  position: absolute; left: 0; right: 0; top: 0; height: 60%;
  background: repeating-linear-gradient(90deg, #3a4a68 0 26px, #33425e 26px 52px);
  z-index: 6; box-shadow: 0 6px 18px rgba(0,0,0,.25);
}
.curtain-handle {
  position: absolute; left: 50%; bottom: -16px; transform: translateX(-50%);
  background: #2a3650; color: #fff; padding: 6px 16px; border-radius: 0 0 10px 10px;
  font-size: 13px; cursor: ns-resize; user-select: none; touch-action: none; white-space: nowrap;
}

/* ---------- Правий док ---------- */
.dock {
  grid-area: dock; background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0;
  overflow-y: auto; z-index: 15; scrollbar-width: thin;
}
.dock-label { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px; }
.dock-sep { width: 40px; height: 1px; background: var(--line); margin: 6px 0; flex: none; }
.app {
  width: 66px; flex: none; border: 0; background: transparent; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 2px;
  font-size: 11.5px; color: var(--ink);
}
.app i { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--panel-2); }
.app:hover i { background: var(--accent-soft); color: var(--accent); }
.app.open i { background: var(--accent); color: #fff; }

/* ---------- Плаваючі вікна ---------- */
#windows { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
.win {
  position: absolute; pointer-events: auto;
  background: var(--panel); border-radius: 12px; box-shadow: var(--shadow);
  border: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
  resize: both; min-width: 300px; min-height: 180px;
  max-width: 100%; max-height: 100%;
}
.win.maximized { left: 8px !important; top: 8px !important; width: calc(100% - 16px) !important; height: calc(100% - 16px) !important; resize: none; }
.win.minimized { height: auto !important; min-height: 0; resize: none; }
.win.minimized .win-body { display: none; }
.win-head {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px;
  background: var(--panel-2); border-bottom: 1px solid var(--line);
  cursor: move; user-select: none; touch-action: none; flex: none;
}
.win-head .title { font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-head .ibtn { width: 28px; height: 28px; }
.win-head .ibtn svg.i { width: 16px; height: 16px; }
.win-body { flex: 1; overflow: auto; min-height: 0; display: flex; flex-direction: column; }

/* Вкладки */
.tabs { display: flex; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--line); flex: none; flex-wrap: wrap; background: var(--panel); }
.tab {
  border: 0; background: transparent; padding: 7px 12px; border-radius: 8px 8px 0 0;
  color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-pane { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }

/* Загальні елементи у вікнах */
.pad { padding: 12px 14px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.btn {
  height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap;
}
.btn:hover { background: var(--panel-2); }
.btn svg.i { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.field, select.field, textarea.field {
  height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: #fff; min-width: 0;
}
textarea.field { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.4; }
.field:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field.mono, .mono { font-family: var(--mono); }
label.lbl { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--panel); }
.card h4 { margin: 0 0 8px; font-size: 14px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; }
.pill-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill-bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { border: 1px solid var(--line); background: var(--panel-2); border-radius: 6px; padding: 3px 8px; font-family: var(--mono); font-size: 13px; }
.chip:hover { background: var(--accent-soft); border-color: var(--accent); }

table.tbl { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { border: 1px solid var(--line); padding: 5px 10px; text-align: center; }
.tbl th { background: var(--panel-2); font-weight: 600; }
.tbl td.one { background: var(--ok-soft); color: var(--ok); font-weight: 700; }
.tbl td.zero { color: var(--muted); }
.tbl tr.hl td { background: var(--warn-soft); }

/* ---------- Редактор коду ---------- */
.code-wrap { display: grid; grid-template-columns: 1fr 1fr; flex: 1; min-height: 0; }
.code-wrap.stack { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
.code-left, .code-right { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.code-left { border-right: 1px solid var(--line); }
.code-bar { display: flex; gap: 6px; align-items: center; padding: 8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; flex: none; }
.editor-host { flex: 1; min-height: 0; position: relative; }
.editor-host .CodeMirror, .editor-host textarea.plain {
  position: absolute; inset: 0; height: 100%; width: 100%;
  font-family: var(--mono); font-size: 16px;
}
.editor-host textarea.plain { border: 0; padding: 10px; resize: none; outline: none; tab-size: 4; }
.CodeMirror { line-height: 1.5; }
.CodeMirror-gutters { background: var(--panel-2); border-right: 1px solid var(--line); }
.console {
  flex: 1; min-height: 60px; margin: 0; padding: 10px 12px; overflow: auto;
  background: #141a26; color: #d8e1f0; font-family: var(--mono); font-size: 15px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
.console .err { color: #ff8a8a; }
.console .info { color: #8fb3ff; }
.console .tip { color: #ffd479; }
.console input {
  background: transparent; border: 0; border-bottom: 1px solid #8fb3ff; color: #fff; font-family: var(--mono);
  font-size: 15px; outline: none; min-width: 120px;
}
.turtle-host { flex: none; background: #fff; border-bottom: 1px solid var(--line); display: grid; place-items: center; overflow: auto; }
.turtle-host:empty { display: none; }
.turtle-host canvas { max-width: 100%; }
iframe.preview { flex: 1; border: 0; background: #fff; width: 100%; min-height: 0; }

/* ---------- Робот ---------- */
.robot-wrap { display: grid; grid-template-columns: 300px 1fr; flex: 1; min-height: 0; }
.robot-side { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-height: 0; }
.robot-side textarea { flex: 1; min-height: 120px; border: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 10px; font-family: var(--mono); font-size: 16px; line-height: 1.5; resize: none; outline: none; white-space: pre; overflow: auto; }
.robot-field { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.robot-field .canvas-host { flex: 1; min-height: 0; position: relative; }
.robot-field canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.robot-status { padding: 8px 12px; border-top: 1px solid var(--line); font-weight: 600; min-height: 38px; }
.robot-status.ok { background: var(--ok-soft); color: var(--ok); }
.robot-status.bad { background: var(--bad-soft); color: var(--bad); }
.cmd-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 8px; }
.cmd-btns .btn { justify-content: center; padding: 0 4px; font-size: 13px; }

/* ---------- Числа ---------- */
.steps { font-family: var(--mono); font-size: 16px; line-height: 1.6; }
.div-table { border-collapse: collapse; font-family: var(--mono); font-size: 17px; }
.div-table td { padding: 2px 12px; border-bottom: 1px solid var(--line); text-align: right; }
.div-table td.rem { color: var(--bad); font-weight: 700; border-left: 2px solid var(--line); }
.result-big { font-family: var(--mono); font-size: 26px; font-weight: 700; color: var(--accent); word-break: break-all; }
.result-big sub { font-size: 14px; color: var(--muted); }
.col-arith { font-family: var(--mono); font-size: 22px; line-height: 1.35; border-collapse: collapse; }
.col-arith td { width: 1.25em; text-align: center; padding: 0; }
.col-arith tr.carry td { font-size: 13px; color: var(--bad); height: 16px; }
.col-arith tr.res td { border-top: 2px solid var(--ink); font-weight: 700; color: var(--accent); }
.col-arith tr.line td { border-top: 2px solid var(--ink); }
.bits { display: flex; gap: 3px; flex-wrap: wrap; }
.bit { width: 30px; height: 38px; border-radius: 6px; border: 1px solid var(--line); display: grid; place-items: center; font-family: var(--mono); font-size: 18px; font-weight: 700; cursor: pointer; user-select: none; background: #fff; }
.bit.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.bit-w { font-size: 10px; color: var(--muted); text-align: center; font-family: var(--mono); }

/* ---------- Алгоритми ---------- */
.viz { flex: 1; min-height: 160px; position: relative; }
.viz canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; background: var(--c); }
.algo-desc { font-size: 13px; line-height: 1.5; color: var(--ink); background: var(--panel-2); border-radius: 8px; padding: 8px 10px; }
.search-cells { display: flex; flex-wrap: wrap; gap: 4px; }
.scell { min-width: 44px; height: 48px; border: 2px solid var(--line); border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: var(--mono); font-size: 17px; font-weight: 700; position: relative; background: #fff; transition: all .2s; }
.scell small { font-size: 10px; color: var(--muted); font-weight: 400; }
.scell.out { opacity: .3; }
.scell.cur { border-color: var(--warn); background: var(--warn-soft); transform: translateY(-4px); }
.scell.found { border-color: var(--ok); background: var(--ok-soft); }
.scell.seen { background: var(--panel-2); }

/* ---------- Логіка ---------- */
.gate-wrap { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.switch { width: 58px; height: 34px; border-radius: 99px; border: 0; background: #cdd3dc; position: relative; transition: .2s; font-weight: 700; color: #fff; }
.switch::after { content: ""; position: absolute; left: 4px; top: 4px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: .2s; }
.switch.on { background: var(--ok); }
.switch.on::after { left: 28px; }
.lamp { width: 54px; height: 54px; border-radius: 50%; background: #d7dce4; border: 3px solid #b9c0cb; display: grid; place-items: center; font-weight: 800; font-size: 20px; color: #fff; transition: .2s; }
.lamp.on { background: #ffd23f; border-color: #e0a800; color: #7a5a00; box-shadow: 0 0 24px #ffd23f; }

/* ---------- Таймер / учні / вікторина ---------- */
.timer-display { font-family: var(--mono); font-size: clamp(48px, 12vw, 120px); font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; line-height: 1.1; padding: 10px 0; }
.timer-display.done { color: var(--bad); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.progress { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .3s linear; }
.picked { font-size: clamp(28px, 6vw, 56px); font-weight: 800; text-align: center; padding: 18px 8px; min-height: 100px; display: grid; place-items: center; }
.picked.spin { color: var(--muted); }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.groups .card ol { margin: 0; padding-left: 20px; line-height: 1.6; }
.quiz-q { font-size: clamp(20px, 3vw, 30px); font-weight: 700; line-height: 1.3; }
.quiz-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quiz-opt { border: 2px solid var(--line); border-radius: 12px; padding: 14px 16px; text-align: left; background: #fff; font-size: clamp(15px, 2vw, 20px); display: flex; gap: 10px; align-items: center; }
.quiz-opt b { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--panel-2); flex: none; }
.quiz-opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.quiz-opt.correct b { background: var(--ok); color: #fff; }
.quiz-opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.quiz-edit-item { border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: grid; gap: 6px; }
.qr-out { display: grid; place-items: center; padding: 10px; background: #fff; min-height: 120px; }

/* ---------- Довідник ---------- */
.ref-list { display: grid; grid-template-columns: 200px 1fr; flex: 1; min-height: 0; }
.ref-nav { border-right: 1px solid var(--line); overflow-y: auto; padding: 6px; }
.ref-nav button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; }
.ref-nav button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.ref-body { overflow-y: auto; padding: 14px 18px; line-height: 1.55; }
.ref-body h3 { margin: 0 0 10px; }
.ref-body pre { background: var(--panel-2); border-radius: 8px; padding: 10px 12px; font-family: var(--mono); font-size: 14px; overflow-x: auto; }
.ref-body code { font-family: var(--mono); background: var(--panel-2); padding: 0 4px; border-radius: 4px; }
.ref-body table { border-collapse: collapse; margin: 8px 0; }
.ref-body td, .ref-body th { border: 1px solid var(--line); padding: 4px 10px; }
.ref-body th { background: var(--panel-2); }

/* ---------- Довідка, тост ---------- */
.kbd { font-family: var(--mono); font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; }
.help-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #1d2433; color: #fff; padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: .25s; z-index: 100; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.page-menu {
  position: fixed; z-index: 50; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  padding: 6px; min-width: 220px; max-height: 60vh; overflow-y: auto;
}
.page-menu .pm-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.page-menu .pm-item:hover { background: var(--panel-2); }
.page-menu .pm-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.page-menu .pm-item span { flex: 1; }
.page-menu .pm-item .ibtn { width: 26px; height: 26px; }

/* ---------- Онлайн-урок ---------- */
.student-only { display: none !important; }
body.student .student-only { display: revert !important; }
body.student .teacher-only { display: none !important; }
body.student { grid-template-columns: var(--tool-w) 1fr 0; }
body.student .page-label { cursor: default; min-width: 90px; }
.student-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.toolbar.locked .tgroup { opacity: .35; pointer-events: none; }
.live-btn {
  height: 34px; border: 1px solid var(--line); border-radius: 99px; background: var(--panel-2);
  display: inline-flex; align-items: center; gap: 6px; padding: 0 12px 0 9px; font-weight: 600; white-space: nowrap;
}
.live-btn svg.i { width: 18px; height: 18px; }
.live-btn:hover { background: var(--accent-soft); color: var(--accent); }
.live-btn.on { background: #e8f8ee; border-color: #8fd8ac; color: var(--ok); font-variant-numeric: tabular-nums; }
.live-btn.on svg.i { animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.live-code { font-family: var(--mono); font-size: 40px; font-weight: 800; letter-spacing: 3px; color: var(--accent); line-height: 1.1; }
.student-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }
.student-row .name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #c3cad5; flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.switch.sm { width: 44px; height: 26px; flex: none; }
.switch.sm::after { width: 18px; height: 18px; }
.switch.sm.on::after { left: 22px; }
.student-bar {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%); z-index: 7;
  padding: 7px 16px; border-radius: 99px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow);
  background: #fff; color: var(--ink); max-width: calc(100% - 24px); text-align: center; pointer-events: none;
}
.student-bar:empty { display: none !important; }
.student-bar.draw { background: var(--ok); color: #fff; }
.student-bar.view { background: #fff; color: var(--ink); }
.student-bar.connecting { background: var(--warn-soft); color: #7a5a00; }
.student-bar.lost, .student-bar.ended { background: var(--bad); color: #fff; }
.student-help {
  position: absolute; left: 50%; top: 58px; transform: translateX(-50%); z-index: 7;
  width: min(520px, calc(100% - 24px)); background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--bad);
  border-radius: 10px; box-shadow: var(--shadow); padding: 10px 12px; font-size: 14px; line-height: 1.45;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
}
.student-help > div, .join-err { white-space: pre-line; }
.author-mark { width: 6px; height: 22px; border-radius: 3px; flex: none; }
.student-row.active { border-color: #8fd8ac; background: #f2fbf5; }
.student-row.offline { background: var(--panel-2); }
.student-row.offline .name, .student-row.offline .author-mark { opacity: .55; }
.off-note { display: block; font-size: 11.5px; font-weight: 400; color: var(--bad); opacity: 1; }
.name-pill {
  border: 0; border-radius: 99px; color: #fff; font-weight: 600; font-size: 12.5px; padding: 2px 9px;
  white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; flex: none;
}
.name-pill:hover { filter: brightness(1.15); }
.activity-chip {
  position: absolute; left: 70px; bottom: 10px; z-index: 7; display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: 99px; padding: 4px 6px 4px 12px;
  box-shadow: var(--shadow); font-size: 13px; font-weight: 600; max-width: calc(100% - 90px);
}
.sel-bar {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%); z-index: 8;
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px 8px 6px 12px; box-shadow: var(--shadow);
  max-width: calc(100% - 24px); font-size: 14px;
}
.live-log { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; margin-top: 8px; font-size: 13px; }
.log-row { display: flex; gap: 8px; align-items: center; }
.log-row > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.join-overlay, .code-overlay {
  position: fixed; inset: 0; z-index: 80; background: rgba(20, 28, 45, .55); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 16px; overflow-y: auto;
}
.join-box {
  background: var(--panel); border-radius: 16px; box-shadow: var(--shadow); padding: 24px;
  width: min(400px, 100%); display: flex; flex-direction: column; gap: 10px;
}
.join-box h2 { margin: 4px 0 6px; text-align: center; font-size: 22px; }
.join-err { color: var(--bad); font-weight: 600; min-height: 20px; font-size: 13.5px; }
.code-overlay { background: rgba(255, 255, 255, .97); color: var(--ink); text-align: center; gap: 6px; align-content: center; cursor: pointer; }
.co-title { font-size: clamp(24px, 4vw, 44px); font-weight: 800; }
.co-code { font-family: var(--mono); font-size: clamp(56px, 12vw, 150px); font-weight: 800; letter-spacing: 6px; color: var(--accent); line-height: 1; }
.co-url { font-family: var(--mono); font-size: clamp(14px, 2vw, 22px); color: var(--muted); word-break: break-all; }

/* ---------- Адаптивність ---------- */
@media (max-width: 1100px) {
  .brand-name, .lesson-date { display: none; }
}
@media (max-width: 820px) {
  :root { --dock-w: 0px; }
  body { grid-template-rows: auto 1fr auto; grid-template-areas: "top top top" "tools stage stage" "dock dock dock"; }
  .topbar { flex-wrap: wrap; padding: 6px 8px; gap: 6px; }
  .lesson { order: 5; flex-basis: 100%; }
  .dock { flex-direction: row; overflow-x: auto; overflow-y: hidden; border-left: 0; border-top: 1px solid var(--line); padding: 4px; }
  .dock-label, .dock-sep { display: none; }
  .code-wrap, .robot-wrap, .ref-list { grid-template-columns: 1fr; }
  .quiz-opts { grid-template-columns: 1fr; }
  .win { min-width: 260px; }
}
