:root {
  --bg: #f5f6f8;
  --desk: #eceef2;
  --board-bg: #ffffff;
  --grid-line: #e8edf4;
  --grid-dot: #c9d2de;
  --panel: #ffffff;
  --border: #e6e8ec;
  --border-strong: #d6d9df;
  --text: #1e1e24;
  --muted: #6b7180;
  --hover: #f2f3f6;
  --accent: #4f6bed;
  --accent-hover: #3f5ae0;
  --accent-soft: #eef1fe;
  --danger: #e03131;
  --danger-soft: #fdecec;
  --ok: #2fb344;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .18);
  --radius: 12px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
#app, .page { height: 100%; }
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.w100 { width: 100%; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  cursor: pointer; font-weight: 550; white-space: nowrap; transition: background .12s, border-color .12s, color .12s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--hover); }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-soft:hover { background: #e2e7fd; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c92a2a; }
.btn-panel { background: var(--panel); border-color: var(--border); box-shadow: var(--shadow); height: 40px; }
.btn-panel:hover { background: var(--hover); }
.btn-panel.active { background: var(--accent-soft); color: var(--accent); border-color: #cdd6fb; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px;
  border: 0; background: transparent; cursor: pointer; color: #474c59; transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn.active { background: var(--accent-soft); color: var(--accent); }
.icon-btn.sm { width: 26px; height: 26px; border-radius: 7px; }
.icon-btn.xs { width: 24px; height: 24px; border-radius: 6px; }
.ic { display: block; flex: none; }

.input {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 10px;
  font: inherit; color: var(--text); background: #fff; outline: none; transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 107, 237, .15); }
.field-label { display: block; font-size: 12.5px; font-weight: 600; color: #4a4f5c; margin: 14px 0 6px; }
.field-label:first-child { margin-top: 0; }

.avatar {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: color-mix(in srgb, var(--a) 14%, white); color: var(--a); font-weight: 700; font-size: 12px;
}
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(47, 179, 68, .18); flex: none; }

/* ---------- Главный экран ---------- */
.dash { max-width: 1180px; margin: 0 auto; padding: 20px 28px 60px; }
.dash-head { display: flex; align-items: center; justify-content: space-between; height: 52px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: #fff; }
.dash-sub { margin: 28px 0 22px; }
.dash-sub h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: -.01em; }
.dash-sub p { margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .15s, border-color .15s; }
.card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.card-preview { display: block; height: 160px; border-bottom: 1px solid var(--border); position: relative; background: var(--board-bg); }
.preview-host { position: absolute; inset: 0; }
.card-body { padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.card-title { display: flex; align-items: center; gap: 10px; }
.card-name { min-width: 0; flex: 1; }
.card-name .name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-actions { display: flex; align-items: center; gap: 4px; }
.card-actions .btn { flex: 1; height: 36px; }
.online-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #237a33; background: #e9f7ec; padding: 3px 9px 3px 8px; border-radius: 99px; font-weight: 600; }
.card-add { border-style: dashed; border-width: 1.5px; align-items: center; justify-content: center; gap: 10px; min-height: 250px; cursor: pointer; color: var(--muted); font-weight: 600; background: transparent; }
.card-add:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); box-shadow: none; }
.card-add .plus { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--hover); }
.card-add:hover .plus { background: #fff; }
.empty { grid-column: 1 / -1; text-align: center; padding: 70px 20px; background: var(--panel); border: 1px dashed var(--border-strong); border-radius: 16px; }
.empty-art { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); margin-bottom: 10px; }
.empty h3 { margin: 6px 0; font-size: 18px; }
.empty p { max-width: 420px; margin: 0 auto 18px; }

/* ---------- Вход ---------- */
.login { height: 100%; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.login-card .brand { margin-bottom: 22px; }
.login-card .btn { margin-top: 16px; }
.login-err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 6px; }
.center-msg { height: 100%; display: grid; place-content: center; text-align: center; padding: 20px; }

/* ---------- Экран доски ---------- */
.app { display: flex; height: 100%; overflow: hidden; }
.stage { position: relative; flex: 1; min-width: 0; height: 100%; overflow: hidden; }
.board-host { position: absolute; inset: 0; }
.float { position: absolute; z-index: 10; display: flex; align-items: center; gap: 8px; pointer-events: none; }
.float > * { pointer-events: auto; }
.top-left { top: 12px; left: 12px; }
.bottom-center { bottom: 12px; left: 50%; transform: translateX(-50%); flex-direction: column-reverse; gap: 8px; }
.top-right { top: 12px; right: 12px; }
.bottom-left { bottom: 12px; left: 12px; }
.bottom-right { bottom: 12px; right: 12px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel.group { display: flex; align-items: center; padding: 3px; gap: 2px; }
.stage { container-type: inline-size; container-name: stage; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  font-weight: 550; white-space: nowrap; max-width: 320px;
}
.title-chip { max-width: 280px; }
.is-student .title-chip .t-name, .is-student .title-chip .t-sep { display: none; }
.title-chip .t-name { overflow: hidden; text-overflow: ellipsis; }
.title-chip .t-sep, .title-chip .t-page { color: var(--muted); font-weight: 500; }
.title-chip .t-page { overflow: hidden; text-overflow: ellipsis; }
.status-chip { background: #fff7e6; border-color: #ffe0a3; color: #8a5a00; }
.presence .pdot { width: 8px; height: 8px; border-radius: 50%; background: #c3c7cf; }
.presence.on .pdot { background: var(--ok); box-shadow: 0 0 0 3px rgba(47, 179, 68, .18); }
.presence { color: var(--muted); }
.presence.on { color: var(--text); }
.zoom-label { border: 0; background: transparent; min-width: 52px; height: 36px; border-radius: 8px; cursor: pointer; font-size: 13px; font-variant-numeric: tabular-nums; color: #474c59; }
.zoom-label:hover { background: var(--hover); }
.bg-group .icon-btn.active { background: var(--accent-soft); color: var(--accent); }

/* Инструменты */
.toolbar { display: flex; align-items: center; padding: 4px; gap: 2px; }
.tool {
  position: relative; display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 9px;
  background: transparent; color: #3f4450; cursor: pointer; transition: background .12s, color .12s;
}
.tool:hover { background: var(--hover); color: var(--text); }
.tool.active { background: var(--accent-soft); color: var(--accent); }
.tb-sep { width: 1px; height: 22px; background: var(--border); margin: 0 5px; flex: none; }
.view-note { display: inline-flex; align-items: center; gap: 6px; padding: 0 10px 0 4px; color: var(--muted); font-weight: 550; white-space: nowrap; }
[data-tip]::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%) translateY(-2px);
  background: #22252c; color: #fff; font-size: 12px; font-weight: 500; padding: 5px 9px; border-radius: 7px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .12s, transform .12s; z-index: 50;
}
[data-tip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); transition-delay: .35s; }

.stylebar { display: flex; flex-direction: column; align-items: stretch; padding: 6px 8px; gap: 6px; }
.ctx-row { display: flex; align-items: center; gap: 4px; justify-content: center; flex-wrap: wrap; row-gap: 6px; }
.stylebar { max-width: calc(100vw - 24px); }
.ctx-shapes { gap: 2px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.shape-btn { display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: #3f4450; cursor: pointer; }
.shape-btn:hover { background: var(--hover); }
.shape-btn.active { background: var(--accent-soft); color: var(--accent); }
.pal-wrap { display: flex; align-items: center; gap: 6px; }
.pal { display: grid; grid-template-columns: repeat(10, 20px); gap: 3px; }
.swatch { width: 20px; height: 20px; border-radius: 5px; border: 0; padding: 0; cursor: pointer; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14); transition: transform .08s; }
.swatch:hover { transform: scale(1.15); }
.swatch.active { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14), 0 0 0 2px #fff, 0 0 0 3.5px var(--accent); }
.swatch.none { background: #fff linear-gradient(to top right, transparent calc(50% - 1px), #e03131 calc(50% - 1px), #e03131 calc(50% + 1px), transparent calc(50% + 1px)); width: 24px; height: 24px; }
.swatch-custom { width: 26px; height: 26px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; background: conic-gradient(#ed1c24, #fff200, #22b14c, #00a2e8, #3f48cc, #a349a4, #ed1c24); display: grid; place-items: center; }
.swatch-custom span { display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: #fff; color: #3f4450; font-weight: 700; font-size: 14px; line-height: 1; }
.swatch-custom:hover { transform: scale(1.08); }
.wells { display: flex; flex-direction: column; gap: 3px; }
.well { display: flex; align-items: center; gap: 7px; height: 24px; padding: 0 8px 0 4px; border: 0; border-radius: 7px; background: transparent; cursor: pointer; font-size: 12.5px; font-weight: 550; color: #474c59; white-space: nowrap; }
.well:hover { background: var(--hover); }
.well.active { background: var(--accent-soft); color: var(--accent); }
.well-sw { width: 16px; height: 16px; border-radius: 4px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .2); }
.well-sw.none { background: #fff linear-gradient(to top right, transparent calc(50% - 1px), #e03131 calc(50% - 1px), #e03131 calc(50% + 1px), transparent calc(50% + 1px)); }
.color-input { position: fixed; left: 50%; bottom: 150px; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }
.size { width: 32px; height: 30px; border-radius: 8px; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; color: #3f4450; }
.size:hover { background: var(--hover); }
.size.active { background: var(--accent-soft); color: var(--accent); }
.size-dot { display: block; border-radius: 50%; background: currentColor; }
.size-t { font-weight: 700; line-height: 1; }

/* Доступ ученика */
.seg { display: flex; align-items: center; gap: 2px; padding: 3px; height: 40px; }
.seg-label { padding: 0 6px 0 9px; color: var(--muted); font-weight: 550; white-space: nowrap; }
.seg button { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-weight: 550; color: #474c59; white-space: nowrap; }
.seg button:hover { background: var(--hover); }
.seg button.active { background: var(--accent-soft); color: var(--accent); }
.seg-mini { display: flex; gap: 2px; padding: 1px; background: var(--hover); border-radius: 9px; }
.seg-mini button { height: 28px; padding: 0 11px; border: 0; border-radius: 7px; background: transparent; cursor: pointer; font-weight: 550; font-size: 13px; color: #474c59; }
.seg-mini button.active { background: #fff; color: var(--accent); box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }
.size-ring { display: block; border-radius: 50%; border: 1.8px solid currentColor; }

/* Переключатель */
.switch { display: inline-flex; align-items: center; gap: 10px; height: 40px; padding: 0 14px 0 10px; cursor: pointer; user-select: none; font-weight: 550; }
.switch input { display: none; }
.switch .sw { position: relative; width: 34px; height: 20px; border-radius: 99px; background: #cfd3da; transition: background .15s; flex: none; }
.switch .sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .15s; }
.switch input:checked + .sw { background: var(--accent); }
.switch input:checked + .sw::after { transform: translateX(14px); }

.hint {
  position: absolute; top: 64px; left: 50%; transform: translate(-50%, -8px); z-index: 9; pointer-events: none;
  background: rgba(34, 37, 44, .88); color: #fff; font-size: 12.5px; padding: 7px 12px; border-radius: 9px;
  opacity: 0; transition: opacity .2s, transform .2s; white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis;
}
.hint.show { opacity: 1; transform: translate(-50%, 0); }
.drop-overlay { position: absolute; inset: 10px; z-index: 30; border: 2px dashed var(--accent); border-radius: 16px; background: rgba(238, 241, 254, .7); display: none; place-items: center; pointer-events: none; }
.drop-overlay > div { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--accent); font-weight: 600; }
.stage.dragging .drop-overlay { display: grid; }

/* ---------- Боковая панель ---------- */
.sidebar { width: 252px; flex: none; background: #fbfbfc; border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; transition: margin-left .2s; z-index: 20; }
.sb-closed .sidebar { margin-left: -252px; }
.panel-btn { display: none; background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow); width: 40px; height: 40px; border-radius: var(--radius); }
.sb-closed .panel-btn { display: inline-grid; }
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 8px 12px; }
.sb-home { display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px 6px 4px; border-radius: 8px; font-weight: 600; color: #3f4450; }
.sb-home:hover { background: var(--hover); }
.sb-section { padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; min-height: 0; }
.sb-grow { flex: 1; overflow: auto; border-top: 1px solid var(--border); padding-top: 10px; }
.sb-title { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 4px 6px 6px; }
.sb-students { display: flex; flex-direction: column; gap: 2px; max-height: 36vh; overflow: auto; }
.sb-student { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 0; background: transparent; border-radius: 9px; cursor: pointer; text-align: left; width: 100%; }
.sb-student:hover { background: var(--hover); }
.sb-student.active { background: var(--accent-soft); }
.sb-student.active .st-name { color: var(--accent); font-weight: 650; }
.sb-student .avatar { width: 26px; height: 26px; font-size: 11px; }
.st-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-add { display: flex; align-items: center; gap: 10px; padding: 7px 8px 7px 12px; border: 0; background: transparent; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 550; }
.sb-add:hover { background: var(--hover); color: var(--accent); }
.sb-pages { display: flex; flex-direction: column; gap: 2px; }
.sb-page { display: flex; align-items: center; gap: 10px; padding: 0 6px 0 8px; height: 36px; border-radius: 9px; cursor: pointer; user-select: none; }
.sb-page:hover { background: var(--hover); }
.sb-page.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pg-num { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: #eceef2; font-size: 11.5px; font-weight: 700; color: #5b606c; flex: none; }
.sb-page.active .pg-num { background: var(--accent); color: #fff; }
.pg-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-page { gap: 6px; }
.sb-page .pg-num { margin-right: 4px; }
.pg-act { opacity: 0; flex: none; }
.sb-page:hover .pg-act, .sb-page.active .pg-act { opacity: 1; }
.sb-page.active .pg-act { color: var(--accent); }
.sb-page.editing .pg-act { display: none; }
.pg-act.danger:hover { color: #d33; }
.inline-edit { flex: 1; min-width: 0; height: 28px; padding: 0 8px; border: 1.5px solid var(--accent); border-radius: 7px; font: inherit; font-weight: 600; color: var(--text, #1b1b1f); background: #fff; outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.title-chip .inline-edit { flex: none; width: 170px; height: 26px; font-weight: 500; }
.is-tutor .title-chip .t-page { cursor: text; border-radius: 6px; padding: 2px 4px; margin: -2px -4px; }
.is-tutor .title-chip .t-page:hover { background: var(--hover); color: var(--text, #1b1b1f); }
.sb-foot { padding: 10px; border-top: 1px solid var(--border); }

/* ---------- Холст ---------- */
.wb { position: absolute; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; outline: none; cursor: crosshair; }
.wb-bg { position: absolute; inset: 0; }
.wb-media { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; pointer-events: none; }
.wb-ink, .wb-ui { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.wb-text { position: absolute; white-space: pre; line-height: 1.25; font-family: var(--font); font-weight: 450; }
.wb-formula { position: absolute; white-space: nowrap; line-height: 1.2; padding: 2px 4px; }
.wb-formula .katex-display { margin: 0; }
.wb-formula .katex { font-size: 1em; }
.wb-measure { position: absolute; left: -99999px; top: 0; visibility: hidden; white-space: nowrap; line-height: 1.2; padding: 2px 4px; }
.wb-measure .katex-display { margin: 0; }
.wb-measure .katex { font-size: 1em; }
.wb-img { position: absolute; display: block; user-select: none; -webkit-user-drag: none; border-radius: 2px; }
.wb-livecanvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.snap-mark { fill: rgba(79, 107, 237, .15); stroke: var(--accent); stroke-width: 2; }
.poly-start { fill: #fff; stroke: var(--accent); stroke-width: 2; }
.poly-start.hot { fill: var(--accent); }
.wb-textedit {
  position: absolute; z-index: 5; margin: 0; padding: 0; border: 0; outline: 1.5px dashed var(--accent); outline-offset: 4px;
  background: transparent; resize: none; overflow: hidden; white-space: pre; line-height: 1.25; font-family: var(--font); font-weight: 450;
}
.wb[data-tool="select"] { cursor: default; }
.wb[data-tool="hand"], .board-host.space .wb { cursor: grab; }
.wb.panning { cursor: grabbing !important; }
.wb[data-tool="text"] { cursor: text; }
.wb[data-tool="pen"] { cursor: var(--pen-cursor, crosshair); }
.wb[data-tool="marker"] { cursor: var(--marker-cursor, crosshair); }
.wb[data-tool="eraser"] { cursor: none; }
.wb[data-tool="laser"] { cursor: crosshair; }
.sel-box { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 4; }
.sel-item { fill: none; stroke: var(--accent); stroke-width: 1; opacity: .6; }
.sel-handle { fill: #fff; stroke: var(--accent); stroke-width: 2; }
.marquee { fill: rgba(79, 107, 237, .08); stroke: var(--accent); stroke-width: 1; }
.eraser-cursor { fill: rgba(255, 255, 255, .6); stroke: #474c59; stroke-width: 1.5; }
.remote-view { fill: none; stroke: #e8590c; stroke-width: 1.5; stroke-dasharray: 8 5; rx: 6; }
.remote-view-label { fill: #e8590c; font: 600 12px var(--font); }
.laser-core { fill: none; stroke: #ff2d2d; stroke-linecap: round; stroke-linejoin: round; }
.laser-glow { fill: none; stroke: rgba(255, 45, 45, .25); stroke-linecap: round; stroke-linejoin: round; }
.wb-cursors { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.wb-cursor { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 6px; transition: transform .08s linear, opacity .4s; will-change: transform; }
.wb-cursor .dot { width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.wb-cursor .lbl { font-size: 11.5px; font-weight: 600; color: #fff; padding: 2px 7px; border-radius: 6px; margin-top: -6px; }
.wb-cursor.is-tutor .dot, .wb-cursor.is-tutor .lbl { background: #4f6bed; }
.wb-cursor.is-student .dot, .wb-cursor.is-student .lbl { background: #e8590c; }
.wb-cursor.idle { opacity: .35; }
.wb-selbar {
  position: absolute; z-index: 6; display: none; align-items: center; gap: 2px; padding: 3px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
}
.wb-selbar button { display: inline-flex; align-items: center; gap: 6px; height: 32px; min-width: 32px; justify-content: center; padding: 0 8px; border: 0; border-radius: 7px; background: transparent; cursor: pointer; color: #3f4450; font-weight: 550; font-size: 13px; }
.wb-selbar button:hover { background: var(--hover); }
.wb-selbar button.danger:hover { background: var(--danger-soft); color: var(--danger); }
.wb-preview { cursor: pointer; }

/* ---------- Окна ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 100; background: rgba(20, 22, 28, .35); display: grid; place-items: center; padding: 16px; opacity: 0; transition: opacity .15s; }
.modal-wrap.show { opacity: 1; }
.modal { width: 100%; max-width: 440px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); transform: translateY(8px) scale(.98); transition: transform .15s; }
.modal-wrap.show .modal { transform: none; }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 4px 22px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 12px 22px 8px; overflow: auto; }
.modal-body p { margin: 0 0 10px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px 18px; }
.copy-row { display: flex; gap: 8px; }
.copy-row .input { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

/* Формулы */
.fx { display: grid; grid-template-columns: 330px 1fr; gap: 20px; }
.fx-main { min-width: 0; }
.fx-palette { max-height: 460px; overflow: auto; padding-right: 6px; }
.fx-group { margin-bottom: 12px; }
.fx-group-name { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.fx-btns { display: flex; flex-wrap: wrap; gap: 4px; }
.fx-btn, .fx-recent-btn { min-width: 44px; height: 40px; padding: 0 8px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; display: grid; place-items: center; font-size: 13px; }
.fx-btn:hover, .fx-recent-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.fx-btn .katex-display, .fx-recent-btn .katex-display { margin: 0; }
.fx-recent-btn { height: auto; min-height: 40px; padding: 4px 10px; max-width: 100%; overflow: hidden; }
.fx-input { font-family: ui-monospace, Consolas, "Cascadia Mono", monospace; font-size: 14px; }
.fx-preview-wrap { margin-top: 12px; border: 1px solid var(--border); border-radius: 12px; background: #fbfbfd; min-height: 120px; display: grid; place-items: center; padding: 14px; overflow: auto; }
.fx-preview { font-size: 26px; }
.fx-preview .katex-display { margin: 0; }
.fx-recent { margin-top: 14px; }
.fx-recent-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 120px; overflow: auto; }
.fx-tip { margin-top: 12px; font-size: 12.5px; }

/* Уведомления */
#toast {
  position: fixed; left: 50%; top: 106px; transform: translate(-50%, -10px); z-index: 200;
  background: #22252c; color: #fff; padding: 9px 16px; border-radius: 10px; font-weight: 500; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); text-align: center; box-shadow: var(--shadow-lg);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); }

/* Фигуры — выпадающая панель */
.readonly [data-act="undo"], .readonly [data-act="redo"] { display: none; }
.readonly .bottom-left .group:first-child { display: none; }

/* Узкая область доски */
@container stage (max-width: 1080px) {
  .bottom-left { bottom: 70px; }
  .btn-panel span, .switch .sw-label, .seg-label { display: none; }
  .btn-panel { width: 40px; padding: 0; }
}
@container stage (max-width: 820px) {
  .seg button span { display: none; }
  .presence .ptext { display: none; }
  .bg-group { display: none; }
}

/* ---------- Узкие экраны (телефон ученика) ---------- */
@media (max-width: 720px) {
  .toolbar { max-width: calc(100vw - 24px); overflow-x: auto; }
  .bottom-left { top: 64px; bottom: auto; }
  .bottom-left .group:last-child .icon-btn[data-act="zoom-out"], .bottom-left .group:last-child .icon-btn[data-act="zoom-in"] { display: none; }
  .presence .ptext { display: none; }
  .presence { padding: 0 14px; }
  .title-chip { max-width: 55vw; }
  .hint { display: none; }
  .wells { flex-direction: row; }
  .ctx-shapes .shape-btn { width: 30px; height: 30px; }
  .fx { grid-template-columns: 1fr; }
  .fx-main { min-width: 0; }
.fx-palette { max-height: 220px; order: 2; }
  .dash { padding: 12px 16px 40px; }
  .sidebar { position: absolute; inset: 0 auto 0 0; box-shadow: var(--shadow-lg); }
  [data-tip]::after { display: none; }
}

button:focus:not(:focus-visible) { outline: none; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Лист и участки фона */
.wb-paper { position: absolute; left: 0; top: 0; transform-origin: 0 0; background: var(--board-bg); border-radius: 3px; box-shadow: 0 0 0 1px rgba(16, 24, 40, .06), 0 2px 10px rgba(16, 24, 40, .07); pointer-events: none; }
.wb-zones { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.zone-bg { fill: #fff; }
.zone-lines { fill: none; stroke: #d7e0ec; stroke-width: 1; vector-effect: non-scaling-stroke; shape-rendering: crispEdges; }
.zone-dots { fill: none; stroke: #a9b6c8; stroke-width: 2.6; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.zone-border { fill: none; stroke: #c3cedc; stroke-width: 1; vector-effect: non-scaling-stroke; }
.wb-extend {
  position: absolute; z-index: 4; display: none; align-items: center; gap: 6px;
  height: 32px; padding: 0 14px 0 10px; border: 1px dashed #b8c1ce; border-radius: 99px; background: rgba(255, 255, 255, .85);
  color: #5b6272; font: 550 13px var(--font); cursor: pointer; white-space: nowrap;
}
.wb-extend:hover { border-color: var(--accent); color: var(--accent); background: #fff; }
.wb-preview .wb-extend { display: none !important; }
.seg-mini button { display: inline-flex; align-items: center; gap: 6px; }

/* Скачивание листа */
.export-wrap { position: relative; }
.btn-square { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--panel); box-shadow: var(--shadow); color: #474c59; cursor: pointer; }
.btn-square:hover { background: var(--hover); color: var(--text); }
.export-menu { position: absolute; top: calc(100% + 8px); left: 0; display: flex; flex-direction: column; padding: 4px; min-width: 200px; z-index: 30; }
.export-menu.hidden { display: none; }
.export-menu button { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-size: 13.5px; color: #3f4450; text-align: left; white-space: nowrap; }
.export-menu button:hover { background: var(--hover); color: var(--text); }
.export-menu b { font-weight: 650; }

/* Панель над инструментами не сжимается до половины ширины доски */
.float.bottom-center { width: max-content; max-width: calc(100% - 24px); }
.stylebar .size { width: 28px; }

/* ---------- Удобство для пера: крупнее цели ---------- */
.pal { grid-template-columns: repeat(10, 24px); gap: 4px; }
.swatch { width: 24px; height: 24px; border-radius: 6px; }
.swatch.none { width: 28px; height: 28px; }
.swatch-custom { width: 30px; height: 30px; }
.swatch-custom span { width: 18px; height: 18px; }
.stylebar .size { width: 34px; height: 34px; }
.shape-btn { width: 36px; height: 36px; }
.well { height: 28px; font-size: 13px; }
.well-sw { width: 18px; height: 18px; }
.seg-mini button { height: 32px; padding: 0 13px; }
.wb.temp-erase { cursor: none !important; }
.toggle-btn { height: 34px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; cursor: pointer; font-weight: 550; font-size: 13px; color: #474c59; white-space: nowrap; }
.toggle-btn:hover { background: var(--hover); }
.toggle-btn.active { background: var(--accent-soft); border-color: #c5d0fb; color: var(--accent); }
.act-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 9px; background: #fff; cursor: pointer; font-weight: 600; font-size: 13.5px; color: #3f4450; white-space: nowrap; }
.act-btn:hover { background: var(--hover); }
.act-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.act-btn.primary:hover { background: var(--accent-hover); }
.ctx-note { color: var(--muted); font-size: 13px; font-weight: 550; padding: 0 4px; }
.ctx-actions { padding-top: 6px; border-top: 1px solid var(--border); }

/* ---------- Координатная плоскость ---------- */
.origin-handle { fill: #fff; stroke: var(--accent); stroke-width: 3; }
.fn-list { flex-direction: column; align-items: stretch; gap: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--border); max-height: 40vh; overflow: auto; }
.fn-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fn-color { width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--c); cursor: pointer; flex: none; box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(0, 0, 0, .12); }
.fn-formula { min-height: 36px; padding: 2px 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; cursor: pointer; font-size: 17px; }
.fn-formula:hover { border-color: var(--border-strong); background: #fafbfc; }
.fn-formula .katex-display { margin: 0; }
.pslider { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; color: #474c59; min-width: 150px; }
.pslider-name b { font-weight: 700; color: var(--text); }
.pslider input[type=range] { width: 150px; height: 26px; accent-color: var(--accent); cursor: pointer; }
.pslider input[type=range]::-webkit-slider-thumb { width: 22px; height: 22px; }
.scale-ctl { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: #474c59; white-space: nowrap; }
.scale-ctl b { min-width: 28px; text-align: center; color: var(--text); }
.scale-ctl .icon-btn.sm { width: 32px; height: 32px; border: 1px solid var(--border); background: #fff; }
.gd-input-row { display: flex; align-items: center; gap: 10px; }
.gd-y { font: italic 20px 'Cambria Math', 'Times New Roman', serif; color: #3f4450; white-space: nowrap; flex: none; }
.gd-input { font-size: 18px; height: 46px; font-family: ui-monospace, Consolas, monospace; }
.gd-preview { margin: 12px 0 16px; min-height: 64px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 12px; background: #fbfbfd; font-size: 22px; padding: 8px; overflow: auto; }
.gd-preview .katex-display { margin: 0; }
.gd-err { color: var(--danger); font-size: 14px; }
.gd-templates { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.gd-tpl { min-height: 52px; border: 1px solid var(--border); border-radius: 10px; background: #fff; cursor: pointer; font-size: 15px; padding: 4px; }
.gd-tpl:hover { border-color: var(--accent); background: var(--accent-soft); }
.gd-tpl .katex-display { margin: 0; }
.gd-help { font-size: 12.5px; line-height: 1.6; }
.gd-help code { background: #f1f3f5; border-radius: 4px; padding: 1px 4px; font-size: 12px; }
@media (max-width: 720px) { .gd-templates { grid-template-columns: repeat(2, 1fr); } }

/* Курсоры, заметные на любом фоне (серая заливка, картинки) */
.wb { cursor: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20width%3D%2724%27%20height%3D%2724%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cg%20stroke-linecap%3D%27round%27%3E%3Cpath%20d%3D%27M12%202v7M12%2015v7M2%2012h7M15%2012h7%27%20stroke%3D%27%23fff%27%20stroke-width%3D%274%27/%3E%3Cpath%20d%3D%27M12%202v7M12%2015v7M2%2012h7M15%2012h7%27%20stroke%3D%27%23111%27%20stroke-width%3D%271.6%27/%3E%3Ccircle%20cx%3D%2712%27%20cy%3D%2712%27%20r%3D%271.6%27%20fill%3D%27%23111%27%20stroke%3D%27%23fff%27%20stroke-width%3D%271.2%27/%3E%3C/g%3E%3C/svg%3E") 12 12, crosshair; }
.wb[data-tool="text"] { cursor: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20width%3D%2724%27%20height%3D%2724%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cg%20stroke-linecap%3D%27round%27%3E%3Cpath%20d%3D%27M9%203h6M9%2021h6M12%203v18%27%20stroke%3D%27%23fff%27%20stroke-width%3D%274%27/%3E%3Cpath%20d%3D%27M9%203h6M9%2021h6M12%203v18%27%20stroke%3D%27%23111%27%20stroke-width%3D%271.6%27/%3E%3C/g%3E%3C/svg%3E") 12 12, text; }
.wb[data-tool="laser"] { cursor: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20width%3D%2724%27%20height%3D%2724%27%20viewBox%3D%270%200%2024%2024%27%3E%3Cg%20stroke-linecap%3D%27round%27%3E%3Cpath%20d%3D%27M12%202v7M12%2015v7M2%2012h7M15%2012h7%27%20stroke%3D%27%23fff%27%20stroke-width%3D%274%27/%3E%3Cpath%20d%3D%27M12%202v7M12%2015v7M2%2012h7M15%2012h7%27%20stroke%3D%27%23111%27%20stroke-width%3D%271.6%27/%3E%3Ccircle%20cx%3D%2712%27%20cy%3D%2712%27%20r%3D%271.6%27%20fill%3D%27%23111%27%20stroke%3D%27%23fff%27%20stroke-width%3D%271.2%27/%3E%3C/g%3E%3C/svg%3E") 12 12, crosshair; }
.sel-label { fill: none; stroke: var(--accent); stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; }
.pslider-name { display: flex; align-items: center; gap: 5px; }
.pval { width: 58px; height: 24px; padding: 0 6px; border: 1px solid var(--line, #dfe2e8); border-radius: 6px; font: inherit; font-weight: 700; color: var(--text); background: #fff; text-align: center; outline: none; }
.pval:hover { border-color: #b9c0cc; }
.pval:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pval.bad { border-color: #e03131; box-shadow: 0 0 0 3px #ffe3e3; }
/* Полосы прокрутки листа */
.wb-scroll { position: absolute; z-index: 9; border-radius: 8px; touch-action: none; cursor: default; transition: background .15s; }
.wb-scroll.hidden { display: none; }
.wb-scroll.v { top: 64px; bottom: 18px; right: 3px; width: 14px; }
.wb-scroll.h { left: 12px; right: 34px; bottom: 2px; height: 12px; }
.wb-scroll:hover, .wb-scroll.dragging { background: rgba(30, 35, 50, .06); }
.wb-thumb { position: absolute; border-radius: 8px; background: rgba(60, 66, 82, .32); transition: background .15s, width .15s, height .15s, left .15s, top .15s; }
.wb-scroll.v .wb-thumb { left: 4px; width: 6px; top: 0; }
.wb-scroll.h .wb-thumb { top: 3px; height: 6px; left: 0; }
.wb-scroll.v:hover .wb-thumb, .wb-scroll.v.dragging .wb-thumb { left: 2px; width: 10px; }
.wb-scroll.h:hover .wb-thumb, .wb-scroll.h.dragging .wb-thumb { top: 1px; height: 10px; }
.wb-scroll:hover .wb-thumb { background: rgba(60, 66, 82, .5); }
.wb-scroll.dragging .wb-thumb { background: var(--accent); }
/* Вид линии и прозрачность */
.look-dash button { padding: 0 8px; color: var(--text); }
.look-dash button svg { display: block; }
.op-ctl { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #474c59; }
.op-range { width: 110px; height: 26px; accent-color: var(--accent); cursor: pointer; }
.op-range::-webkit-slider-thumb { width: 22px; height: 22px; }
.op-val { min-width: 34px; text-align: right; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.op-ic { color: #5b606c; flex: none; }
/* Поворот */
.rot-stem { stroke: var(--accent); stroke-width: 1.5; }
.rot-handle circle { fill: #fff; stroke: var(--accent); stroke-width: 1.8; filter: drop-shadow(0 1px 1.5px rgba(16, 24, 40, .2)); }
.rot-handle .rot-ic { fill: none; stroke: var(--accent); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rot-label { font: 600 12px Inter, Segoe UI, system-ui, sans-serif; fill: #fff; paint-order: stroke; stroke: var(--accent); stroke-width: 7px; stroke-linejoin: round; }
/* Страницы ученика */
.pages-wrap { position: relative; }
.page-pick { cursor: pointer; gap: 6px; border: 0; font: inherit; }
.page-pick .t-page { color: var(--text); font-weight: 600; }
.page-pick:hover { background: #fff; box-shadow: 0 0 0 1px var(--accent) inset, var(--shadow, 0 1px 3px rgba(16,24,40,.1)); }
.pages-menu { position: absolute; top: calc(100% + 8px); left: 0; display: flex; flex-direction: column; padding: 6px; min-width: 240px; max-width: min(340px, calc(100vw - 24px)); max-height: 60vh; overflow: auto; z-index: 30; }
.pages-menu.hidden { display: none; }
.pm-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 6px 10px 4px; }
.pm-item { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 10px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; font-size: 14px; color: var(--text); text-align: left; }
.pm-item:hover { background: var(--hover); }
.pm-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pm-item.active .pg-num { background: var(--accent); color: #fff; }
.pm-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-badge { flex: none; font-size: 11px; font-weight: 650; color: #2b8a3e; background: #ebfbee; border-radius: 6px; padding: 2px 6px; }
.pg-student { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #2fb344; box-shadow: 0 0 0 2px #fff; }
.presence.on.away .pdot { background: #f59f00; box-shadow: 0 0 0 3px rgba(245, 159, 0, .2); }
/* Кабинет: материалы и резервная копия */
.dash-section { margin-top: 44px; }
.sec-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.sec-head h2 { font-size: 20px; margin: 0 0 4px; letter-spacing: -.01em; }
.sec-head p { margin: 0; max-width: 720px; }
.mat-drop { display: flex; align-items: center; justify-content: center; gap: 10px; height: 64px; border: 1.5px dashed #c9cfd9; border-radius: 12px; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s, color .15s; margin-bottom: 10px; }
.mat-drop:hover, .mat-drop.over { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.mat-progress { position: relative; height: 30px; border-radius: 8px; background: var(--hover); overflow: hidden; margin-bottom: 10px; }
.mat-progress.hidden { display: none; }
.mat-bar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent-soft); transition: width .15s; }
.mat-ptext { position: relative; display: block; line-height: 30px; padding: 0 12px; font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mat-list { display: flex; flex-direction: column; gap: 6px; }
.mat-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.mat-ext { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 9px; background: color-mix(in srgb, var(--c) 12%, white); color: var(--c); font-size: 11px; font-weight: 800; letter-spacing: .02em; }
.mat-info { flex: 1; min-width: 0; }
.mat-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mat-empty { margin: 4px 2px; }
.backup-box { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 16px 18px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; }
.backup-state { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.bk-dot { width: 10px; height: 10px; border-radius: 50%; background: #c3c7cf; }
.backup-state.ok .bk-dot { background: var(--ok, #2fb344); }
.backup-state.warn .bk-dot { background: #f59f00; }
.backup-state.warn { color: #b35c00; }
.backup-actions { display: flex; gap: 10px; flex-wrap: wrap; }
@media (max-width: 640px) { .sec-head { flex-direction: column; align-items: stretch; } }
.zcell-val { min-width: 38px; text-align: center; font-variant-numeric: tabular-nums; }
