/* ==========================================================================
   Студия уроков: редактор-страница.
   Внутри .lse-page используются классы страницы ученика (lesson-grid, tile,
   q-card, rule-card…), здесь — только слой редактирования поверх них.
   ========================================================================== */
/* старые стили студии задают тёмный текст жёстко — берём цвета из темы */
.ls-wrap.lse { --ls-ink: var(--text); --ls-line: var(--border); color: var(--text); }
.lse { --lse-accent: #e83e73; --lse-accent-soft: rgba(232, 62, 115, .08); --lse-edit: rgba(232, 62, 115, .35); }
.lse .ls-main { background: var(--bg); }
.lse .ls-tree { background: var(--bg-2); }
.lse .ls-course.open { background: var(--surface); }
.lse .ls-topbar { background: color-mix(in srgb, var(--bg) 92%, transparent); }
.lse .ls-tree-body .ls-course-txt b, .lse .ls-lesson-txt b { font-size: 12.5px; }
.lse .ls-course-txt small, .lse .ls-lesson-txt small { font-size: 11px; }
.lse .ls-grip { display: grid; place-items: center; width: 22px; height: 30px; padding: 0; letter-spacing: 0; opacity: 0; transition: opacity .15s; }
.lse .ls-grip svg { width: 14px; height: 14px; }
.lse .ls-lesson:hover .ls-grip, .lse .ls-grip:focus-visible { opacity: 1; }
.lse .ls-lesson.drag-over { box-shadow: inset 0 2px 0 var(--lse-accent); }
.lse .ls-lesson.dragging { opacity: .4; }

/* ---------- полноэкранный режим ---------- */
.ls-wrap.lse-full { position: fixed; inset: 0; z-index: 900; border-radius: 0; min-height: 100dvh; max-height: 100dvh; }
.lse-full .ls-main { max-height: 100dvh; }

/* ---------- верхняя панель ---------- */
.lse-top { min-height: 72px; flex-wrap: wrap; }
.lse-top-fields { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
.lse-dur { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.lse-dur svg { width: 15px; height: 15px; }
.lse-dur input { width: 58px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-weight: 800; text-align: center; }
.lse-dur input:focus { outline: 2px solid var(--lse-edit); outline-offset: 1px; }
.lse-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12.5px; font-weight: 700; color: var(--muted); user-select: none; }
.lse-switch input { position: absolute; opacity: 0; pointer-events: none; }
.lse-switch i { position: relative; width: 34px; height: 20px; border-radius: 20px; background: var(--surface-3); transition: background .2s; }
.lse-switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .2s var(--ease); }
.lse-switch input:checked + i { background: #d8942c; }
.lse-switch input:checked + i::after { transform: translateX(14px); }
.lse-switch input:checked ~ span { color: #b07419; }
.lse-switch input:focus-visible + i { outline: 2px solid var(--lse-edit); outline-offset: 2px; }
.lse-status { display: inline-flex; align-items: center; gap: 6px; max-width: 340px; min-height: 30px; padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; color: var(--muted); background: transparent; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lse-status svg { width: 14px; height: 14px; flex: none; }
.lse-status.saved { color: #218364; }
.lse-status.dirty { color: #b5791d; }
.lse-status.saving { color: #526fc4; }
.lse-status.problem { color: var(--bad); background: var(--bad-bg); cursor: pointer; white-space: normal; }
.lse-status.problem:hover { text-decoration: underline; }
.lse .lse-icon-only { width: 37px; padding: 0; }
.lse-more { position: relative; }
.lse-more > summary { list-style: none; cursor: pointer; }
.lse-more > summary::-webkit-details-marker { display: none; }
.lse-more-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; display: grid; gap: 2px; min-width: 230px; padding: 6px; border: 1px solid var(--border); border-radius: 14px; background: var(--solid); box-shadow: var(--shadow), 0 10px 30px rgba(0, 0, 0, .12); }
.lse-more-menu button { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 9px; font-size: 13px; font-weight: 700; text-align: left; }
.lse-more-menu button:hover { background: var(--surface-2); }
.lse-more-menu button svg { width: 16px; height: 16px; }
.lse-more-menu .danger { color: var(--bad); }
.lse-more-menu .muted { padding: 8px 10px; }

/* ---------- холст страницы ---------- */
.lse-stage { padding: 26px clamp(16px, 3vw, 36px) 80px; }
.lse-page { max-width: 1180px; margin: 0 auto; }
.lse .lesson-aside { top: 96px; }
.lse-static { opacity: .5; pointer-events: none; user-select: none; }
.lse .lesson-nav.lse-static .btn { font-size: 14px; }

/* редактируемые поля выглядят как текст страницы, а при наведении — как поля */
:where(.lse-page) :where(input:not([type=checkbox]):not([type=radio]):not([type=file]), textarea, select) { font: inherit; color: inherit; }
.lse-title, .lse-p, .lse-h3, .lse-small, .lse-qtext, .lse-inline, .lse-callout input, .lse-callout textarea, .lse-tc-title, .lse-tc-time, .lse-explain textarea, .lse-tasks textarea {
  display: block; width: 100%; padding: 4px 8px; margin-left: -8px; border: 1px solid transparent; border-radius: 10px;
  background: transparent; resize: none; outline: none; transition: background .15s, border-color .15s; box-sizing: content-box;
}
.lse-title:hover, .lse-p:hover, .lse-h3:hover, .lse-small:hover, .lse-qtext:hover, .lse-inline:hover, .lse-callout input:hover, .lse-callout textarea:hover, .lse-tc-title:hover, .lse-tc-time:hover, .lse-tasks textarea:hover { background: var(--surface-2); }
.lse-title:focus, .lse-p:focus, .lse-h3:focus, .lse-small:focus, .lse-qtext:focus, .lse-inline:focus, .lse-callout input:focus, .lse-callout textarea:focus, .lse-tc-title:focus, .lse-tc-time:focus, .lse-explain textarea:focus, .lse-tasks textarea:focus { background: var(--surface); border-color: var(--lse-edit); box-shadow: 0 0 0 3px var(--lse-accent-soft); }
.lse-callout input:focus, .lse-callout textarea:focus { background: rgba(255, 255, 255, .45); color: var(--on-lime, #12140a); }
.lse-page ::placeholder { color: var(--faint); opacity: 1; }
.lse-head-main { flex: 1; min-width: 260px; }
.lse-title { width: calc(100% - 16px); margin-top: 10px; font-family: var(--font-d); font-weight: 700; font-size: clamp(24px, 3vw, 36px); line-height: 1.15; letter-spacing: -.02em; overflow: hidden; }

/* ---------- лента блоков ---------- */
.lse-flow { position: relative; margin: 6px 0 0; }
.lse-block { position: relative; margin: 0; padding: 4px 0; border-radius: 22px; transition: box-shadow .18s; }
.lse-block::before { content: ""; position: absolute; inset: -6px -10px; border: 1.5px dashed transparent; border-radius: 24px; pointer-events: none; transition: border-color .18s; }
.lse-block:hover::before { border-color: var(--border-2); }
.lse-block:focus-within::before { border-color: var(--lse-edit); }
.lse-block.lse-dragging { opacity: .35; }
.lse-body > * { margin: 0; }
.lse-body .lesson-text, .lse-body .lesson-image, .lse-body .lesson-formula { margin: 0; }
.lse-bar { position: absolute; top: -22px; left: 6px; z-index: 6; display: flex; align-items: center; gap: 2px; padding: 3px 4px; border: 1px solid var(--border); border-radius: 11px; background: var(--solid); box-shadow: 0 6px 18px -6px rgba(0, 0, 0, .18); font-size: 12px; font-weight: 800; color: var(--muted); opacity: 0; transform: translateY(4px); pointer-events: none; transition: opacity .15s, transform .15s; }
.lse-block:hover > .lse-bar, .lse-block:focus-within > .lse-bar { opacity: 1; transform: none; pointer-events: auto; }
.lse-bar svg { width: 15px; height: 15px; }
.lse-bar-name { display: inline-flex; align-items: center; gap: 5px; padding: 0 8px 0 2px; }
.lse-bar-acts, .lse-q-acts { display: inline-flex; align-items: center; gap: 1px; }
.lse-bar button, .lse-q-acts button, .lse-ic-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: var(--muted); cursor: pointer; }
.lse-bar button:hover:not(:disabled), .lse-q-acts button:hover:not(:disabled), .lse-ic-btn:hover { background: var(--surface-2); color: var(--text); }
.lse-bar button.danger:hover, .lse-q-acts button.danger:hover { color: var(--bad); background: var(--bad-bg); }
.lse-bar button:disabled, .lse-q-acts button:disabled { opacity: .3; cursor: default; }
.lse-q-acts svg, .lse-ic-btn svg { width: 16px; height: 16px; }
.lse-grip { display: inline-grid; place-items: center; width: 26px; height: 28px; border-radius: 8px; cursor: grab; color: var(--faint); }
.lse-grip:hover { background: var(--surface-2); color: var(--text); }
.lse-grip:active { cursor: grabbing; }
@media (hover: none) { .lse-bar { opacity: 1; transform: none; pointer-events: auto; position: static; display: inline-flex; margin-bottom: 6px; max-width: 100%; overflow-x: auto; scrollbar-width: none; } .lse-bar::-webkit-scrollbar { display: none; } }

/* кнопка «+» между блоками */
.lse-ins { position: relative; display: flex; justify-content: center; align-items: center; height: 22px; margin: 2px 0; }
.lse-ins::before { content: ""; position: absolute; left: 10%; right: 10%; top: 50%; border-top: 2px solid transparent; transition: border-color .15s; }
.lse-ins:hover::before, .lse-ins.open::before { border-color: var(--lse-edit); }
.lse-ins.drop::before { border-color: var(--lse-accent); border-top-width: 3px; left: 0; right: 0; }
.lse-ins-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border); background: var(--solid); color: var(--muted); opacity: 0; transition: opacity .15s, transform .15s, background .15s; }
.lse-ins-btn svg { width: 15px; height: 15px; }
.lse-ins:hover .lse-ins-btn, .lse-ins.open .lse-ins-btn, .lse-ins-btn:focus-visible { opacity: 1; }
.lse-ins-btn:hover, .lse-ins.open .lse-ins-btn { color: #fff; background: var(--lse-accent); border-color: var(--lse-accent); }
.lse-ins.last { height: auto; margin: 14px 0 0; }
.lse-ins.last::before { display: none; }
.lse-ins.last .lse-ins-btn { width: 100%; height: 54px; border-radius: 18px; border: 1.5px dashed var(--border-2); background: transparent; opacity: 1; font-size: 14px; font-weight: 800; }
.lse-ins.last .lse-ins-btn:hover, .lse-ins.last.open .lse-ins-btn { color: var(--lse-accent); background: var(--lse-accent-soft); border-color: var(--lse-edit); }
.lse-menu { position: absolute; top: calc(100% + 6px); left: 50%; z-index: 40; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; width: min(480px, calc(100vw - 40px)); padding: 8px; transform: translateX(-50%); border: 1px solid var(--border); border-radius: 18px; background: var(--solid); box-shadow: 0 24px 50px -16px rgba(0, 0, 0, .3); animation: lseMenu .16s var(--ease); }
@keyframes lseMenu { from { opacity: 0; transform: translate(-50%, -4px); } }
.lse-menu button { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; text-align: left; }
.lse-menu button:hover:not(:disabled) { background: var(--surface-2); }
.lse-menu button:disabled { opacity: .45; cursor: default; }
.lse-menu b { display: block; font-size: 13.5px; }
.lse-menu small { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.lse-menu-ic { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 10px; background: var(--lse-accent-soft); color: var(--lse-accent); }
.lse-menu-ic svg { width: 17px; height: 17px; }
.lse-empty { display: flex; gap: 14px; align-items: center; padding: 20px; border-radius: 20px; background: var(--surface-2); color: var(--muted); }
.lse-empty svg { width: 26px; height: 26px; color: var(--lse-accent); flex: none; }
.lse-empty b { display: block; color: var(--text); }

/* ---------- содержимое блоков ---------- */
.lse-h3 { width: calc(100% - 16px); font-family: var(--font-d); font-weight: 700; font-size: 20px; letter-spacing: -.02em; margin-bottom: 4px; }
/* заголовок текстового блока появляется, только когда блок редактируют или он заполнен */
.lse-b-text .lse-h3:placeholder-shown { display: none; }
.lse-b-text:focus-within .lse-h3:placeholder-shown { display: block; }
.lse-p { width: calc(100% - 16px); font-size: 16px; line-height: 1.65; min-height: 1.65em; overflow: hidden; }
.lse-callout { transform: none; }
.lse-callout-title { width: calc(100% - 16px); font-weight: 700; font-size: 13px; opacity: .8; }
.lse-callout textarea { width: calc(100% - 16px); font-family: var(--font-d); font-size: 18px; font-weight: 700; color: inherit; overflow: hidden; }
.lse-callout ::placeholder { color: inherit; opacity: .45; }
.lse-formula { display: grid; gap: 8px; }
.lse-small { width: calc(100% - 16px); font-size: 13px; font-weight: 700; color: var(--muted); }
.lse-katex { min-height: 54px; display: grid; place-items: center; overflow-x: auto; }
.lse-katex.bad .lse-ph { color: var(--bad); }
.lse-ph { color: var(--faint); font-size: 14px; }
.lse-code { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); font-family: ui-monospace, "Cascadia Code", Consolas, monospace !important; font-size: 14px !important; resize: none; overflow: hidden; outline: none; box-sizing: border-box; }
.lse-code:focus { border-color: var(--lse-edit); box-shadow: 0 0 0 3px var(--lse-accent-soft); background: var(--surface); }
.lse-hint { display: block; margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }
.lse-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.lse-row .input { flex: 1; min-width: 220px; }
.lse-row .btn, .lse-hwmeta .btn { cursor: pointer; }
.lse-drop { display: grid; justify-items: center; gap: 6px; padding: 34px 20px; border: 2px dashed var(--border-2); border-radius: 22px; color: var(--muted); text-align: center; cursor: pointer; transition: border-color .15s, background .15s, color .15s; }
.lse-drop:hover { border-color: var(--lse-edit); background: var(--lse-accent-soft); color: var(--lse-accent); }
.lse-drop svg { width: 30px; height: 30px; }
.lse-drop b { color: var(--text); font-size: 15px; }
.lse-drop span { font-size: 13px; }
.lse-drop-video { aspect-ratio: 16 / 7; align-content: center; }
.lse-player-wrap { position: relative; }
.lse-player { pointer-events: none; }
.lse-video-cta { position: absolute; left: 50%; bottom: 76px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; width: min(440px, calc(100% - 32px)); padding: 12px 16px; border-radius: 16px; background: rgba(255, 255, 255, .94); color: #0f172a; box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .45); cursor: pointer; transition: transform .15s var(--ease); }
.lse-video-cta:hover { transform: translateX(-50%) translateY(-2px); }
.lse-video-cta > svg { width: 26px; height: 26px; flex: none; color: var(--lse-accent); }
.lse-video-cta b { display: block; font-size: 14px; }
.lse-video-cta small { display: block; font-size: 12px; color: #475569; line-height: 1.35; }
.lse-busy { opacity: .6; pointer-events: none; cursor: progress; }
.lse-file-ic { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 12px; background: var(--surface-3); color: var(--muted); }
.lse-file-ic svg { width: 18px; height: 18px; }
.lse .file-row .f-body { flex: 1; min-width: 0; }
.lse-inline { width: calc(100% - 16px); font-weight: 700; }
.lse-x { display: inline-grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 9px; color: var(--faint); }
.lse-x:hover { color: var(--bad); background: var(--bad-bg); }
.lse-x svg { width: 15px; height: 15px; }
.lse-add { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 7px 12px; border-radius: 10px; color: var(--lse-accent); font-size: 13.5px; font-weight: 800; cursor: pointer; }
.lse-add:hover { background: var(--lse-accent-soft); }
.lse-add svg { width: 15px; height: 15px; }
.lse-flash { animation: lseFlash 1.4s var(--ease); }
@keyframes lseFlash { 0%, 40% { box-shadow: 0 0 0 4px rgba(244, 63, 94, .45); } 100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0); } }

/* ---------- вопросы ---------- */
.lse-qs { display: grid; gap: 14px; }
.lse-q { animation: none; display: grid; gap: 10px; }
.lse-q .q-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0; }
.lse-q .lse-q-acts { margin-left: auto; }
.lse-qtype { padding: 6px 28px 6px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-size: 13px !important; font-weight: 700 !important; cursor: pointer; }
.lse-pts { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.lse-pts input { width: 46px; padding: 5px 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); text-align: center; font-weight: 800 !important; }
.lse-pts input[readonly] { background: var(--surface-2); color: var(--muted); }
.lse-qtext { width: calc(100% - 16px); margin-bottom: 0; overflow: hidden; }
.lse-qimg { position: relative; justify-self: start; }
.lse-qimg img { display: block; max-width: 100%; max-height: 260px; border-radius: 14px; }
.lse-qimg .lse-x { position: absolute; top: 6px; right: 6px; background: var(--solid); }
.lse-opts { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.lse-opts .opt { cursor: default; padding: 8px 8px 8px 10px; gap: 8px; }
.lse-opts .opt:hover { transform: none; }
.lse-opts .opt input { position: static; opacity: 1; pointer-events: auto; flex: 1; min-width: 0; padding: 6px 4px; border: 0; background: transparent; outline: none; font-weight: 600; }
.lse-correct { display: grid; place-items: center; flex: none; width: 24px; height: 24px; border: 2px solid var(--border-2); border-radius: 50%; color: #fff; transition: color .15s, background-color .15s, border-color .15s, box-shadow .15s, transform .15s, opacity .15s, width .15s, filter .15s; }
.lse-opt.multi .lse-correct { border-radius: 7px; }
.lse-correct:hover { border-color: var(--green); }
.lse-correct svg { width: 14px; height: 14px; }
.lse-opt.is-correct .lse-correct { background: var(--green); border-color: var(--green); }
.lse-opt .lse-x { opacity: 0; }
.lse-opt:hover .lse-x, .lse-opt:focus-within .lse-x { opacity: 1; }
.lse-short { max-width: none; align-items: flex-start; }
.lse-short label { padding-top: 10px; }
.lse-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.lse-chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px 2px 2px 10px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface); }
.lse-chip:focus-within { border-color: var(--lse-edit); }
.lse-chip input { width: 150px; padding: 7px 0; border: 0; outline: none; background: transparent; font-family: "Courier New", monospace !important; font-weight: 700 !important; letter-spacing: .06em; }
.lse-chips .lse-add { margin: 0; }
.lse-match { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.lse-col > b, .lse-crit > b { display: block; margin-bottom: 8px; font-size: 12.5px; color: var(--muted); }
.lse-mrow { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.lse-mrow > input { flex: 1; min-width: 0; padding: 8px 10px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface); outline: none; }
.lse-mrow > input:focus { border-color: var(--lse-edit); }
.lse-mrow select { padding: 7px 6px; border: 1.5px solid var(--border); border-radius: 10px; background: var(--surface-2); font-weight: 800 !important; cursor: pointer; }
.lse-order .q-order-item { padding: 4px 6px 4px 12px; }
.lse-order .q-order-item input { flex: 1; min-width: 0; padding: 7px 4px; border: 0; outline: none; background: transparent; font-weight: 600; }
.lse-long-ph { display: grid; place-items: center; min-height: 80px; padding: 14px; border: 1.5px dashed var(--border-2); border-radius: 14px; color: var(--faint); font-size: 14px; }
.lse-crit .lse-pts input { width: 46px; }
.lse-explain summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; font-weight: 700; color: var(--muted); list-style: none; }
.lse-explain summary::-webkit-details-marker { display: none; }
.lse-explain summary svg { width: 15px; height: 15px; }
.lse-explain[open] summary { color: var(--text); margin-bottom: 6px; }
.lse-explain textarea { width: calc(100% - 16px); margin-left: 0; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); overflow: hidden; }
/* вопрос и разбор — не textarea, а текст с визуальными формулами (как в блоках) */
.q-text.lse-plain, .lse-explain-text.lse-plain {
  display: block; width: calc(100% - 16px); margin: 0 0 2px; padding: 8px; min-height: 42px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  font: inherit; font-weight: 500; line-height: 1.5; white-space: normal; overflow: visible; outline: none;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.q-text.lse-plain { padding: 4px 8px; margin-left: -8px; border-color: transparent; background: transparent; }
.q-text.lse-plain:hover, .lse-explain-text.lse-plain:hover { background: var(--surface-2); }
.q-text.lse-plain:focus, .lse-explain-text.lse-plain:focus { background: var(--surface); border-color: var(--lse-edit); box-shadow: 0 0 0 3px var(--lse-accent-soft); }
.lse-plain:empty::before { content: attr(data-placeholder); color: var(--faint); pointer-events: none; }
/* в полях-вопросах перенос строки = <br>: вокруг выключной формулы он даёт лишнюю пустую строку */
.lse-plain br:has(+ .lse-mathx[data-disp]) { display: none; }
.lse-plain .lse-mathx[data-disp] + br { display: none; }
.lse-plain .lse-mathx[data-disp] { margin: 4px 0; }
.lse-qadd { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 12px; border: 1.5px dashed var(--border-2); border-radius: 18px; }
.lse-qadd > span { margin-right: 4px; font-size: 13px; font-weight: 800; color: var(--muted); }
.lse-qadd button { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: 13px; font-weight: 700; }
.lse-qadd button:hover { border-color: var(--lse-edit); color: var(--lse-accent); background: var(--lse-accent-soft); }
.lse-qadd svg { width: 14px; height: 14px; }

/* ---------- домашка ---------- */
.lse-seg { align-self: center; }
.lse-hwfile .lse-p { margin-bottom: 6px; }
.lse-tasks { margin: 8px 0 0; padding-left: 22px; display: grid; gap: 6px; }
.lse-tasks li { padding-left: 4px; }
.lse-tasks li::marker { font-weight: 800; color: var(--muted); }
.lse-tasks li > * { vertical-align: top; }
.lse-tasks textarea { display: inline-block; width: calc(100% - 64px); overflow: hidden; }
.lse-tasks .lse-task { display: inline-block; width: calc(100% - 64px); min-height: 1.6em; padding: 2px 6px; border-radius: 8px; outline: none; }
.lse-tasks .lse-task:hover { background: var(--surface-2); }
.lse-tasks .lse-task:focus { background: var(--surface); box-shadow: 0 0 0 3px var(--lse-accent-soft); }
.lse-hwmeta { justify-content: space-between; }
.lse-hw-note { flex: 1; min-width: 220px; text-align: right; color: var(--muted); font-size: 12px; font-weight: 600; line-height: 1.4; }
.lse-att { flex: 1; min-width: 240px; }
.lse-att > svg { width: 18px; height: 18px; color: var(--muted); }

/* ---------- таймкоды ---------- */
.lse-chapters h3 { margin-bottom: 10px; }
.lse-tc { gap: 6px; padding: 4px 6px; cursor: default; }
.lse-tc-time { flex: none; width: 66px; padding: 4px 6px; margin: 0; border-radius: 8px; background: var(--surface-3); font-family: var(--font-d) !important; font-size: 12px !important; text-align: center; box-sizing: border-box; }
.lse-tc-title { flex: 1; min-width: 0; margin: 0; font-weight: 600; font-size: 14px; box-sizing: border-box; }
.lse-tc .lse-x { opacity: 0; }
.lse-tc:hover .lse-x, .lse-tc:focus-within .lse-x { opacity: 1; }

@media (max-width: 760px) {
  .lse-match { grid-template-columns: 1fr; }
  .lse-menu { grid-template-columns: 1fr; }
  .lse-top { align-items: flex-start; }
  .lse-hw-note { text-align: left; }
}

/* ===== Свободный холст страницы ===== */
.lse-hintbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; padding: 9px 14px; border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: 12.5px; }
.lse-hintbar svg { width: 14px; height: 14px; }
.lse-hintbar b { color: var(--text); font-weight: 700; }
.lse-hintbar span { opacity: .5; }
.lse-canvas { margin-top: 36px; min-height: 600px; }
.lse-canvas.lse-busy-canvas { user-select: none; }
.lse-canvas::after { content: ""; position: absolute; inset: -12px -12px -40px; z-index: -1; border-radius: 22px; pointer-events: none;
  background-image: radial-gradient(circle, var(--border-2) 1px, transparent 1.2px); background-size: calc(100% / 59) 16px; opacity: .55; }
.lse-canvas > .lse-block { position: absolute; padding: 0; margin: 0; transition: box-shadow .15s; }
.lse-canvas.lc-stack > .lse-block { position: relative; }
.lse-canvas > .lse-block:hover, .lse-canvas > .lse-block.is-sel, .lse-canvas > .lse-block:focus-within { z-index: 4; }
.lse-canvas > .lse-block.is-sel::before { border-style: solid; border-color: var(--lse-accent); }
.lse-canvas > .lse-block.is-sel > .lse-bar { opacity: 1; transform: none; pointer-events: auto; }
.lse-canvas > .lse-block.lse-moving, .lse-canvas > .lse-block.lse-resizing { z-index: 10; box-shadow: 0 24px 50px -20px rgba(0, 0, 0, .35); }
.lse-canvas > .lse-block.lse-moving { opacity: .92; cursor: grabbing; }
.lse-bar { top: -32px; left: 0; }
.lse-body { min-height: inherit; }
.lse-body > .tile, .lse-body > .hw-section, .lse-body > .rule-card { min-height: inherit; box-sizing: border-box; }
.lse-b-teacher .lse-body { display: flex; align-items: center; min-height: 48px; }
.lse-title-block .lse-title { margin-top: 10px; }
.lse-static-in { pointer-events: none; }
/* ручки размера */
.lse-rs { position: absolute; z-index: 5; opacity: 0; transition: opacity .15s; }
.lse-block:hover > .lse-rs, .lse-block.is-sel > .lse-rs { opacity: 1; }
.lse-rs-e { top: 20%; bottom: 20%; right: -12px; width: 10px; cursor: ew-resize; }
.lse-rs-e::after { content: ""; position: absolute; top: 50%; left: 3px; width: 4px; height: 36px; margin-top: -18px; border-radius: 4px; background: var(--lse-accent); }
.lse-rs-s { left: 25%; right: 25%; bottom: -12px; height: 10px; cursor: ns-resize; }
.lse-rs-s::after { content: ""; position: absolute; left: 50%; top: 3px; width: 36px; height: 4px; margin-left: -18px; border-radius: 4px; background: var(--lse-accent); }
.lse-rs-se { right: -12px; bottom: -12px; width: 18px; height: 18px; cursor: nwse-resize; }
.lse-rs-se::after { content: ""; position: absolute; inset: 3px; border-radius: 5px; background: var(--solid); border: 2px solid var(--lse-accent); }
/* направляющие привязки */
.lse-guide { position: absolute; z-index: 20; pointer-events: none; background: var(--lse-accent); }
.lse-guide-v { top: -30px; bottom: -30px; width: 1px; }
.lse-guide-h { left: -30px; right: -30px; height: 1px; }
/* меню добавления блока */
.lse-ctx { --lse-accent: #e83e73; --lse-accent-soft: rgba(232, 62, 115, .08); color: var(--text); font-family: var(--font); position: fixed; z-index: 1000; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; width: 460px; max-width: calc(100vw - 16px); padding: 8px; border: 1px solid var(--border); border-radius: 18px; background: var(--solid); box-shadow: 0 24px 50px -16px rgba(0, 0, 0, .35); animation: lseCtx .14s var(--ease); }
@keyframes lseCtx { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.lse-ctx-head { grid-column: 1 / -1; padding: 4px 8px 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.lse-ctx button { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; text-align: left; }
.lse-ctx button:hover:not(:disabled) { background: var(--surface-2); }
.lse-ctx button:disabled { opacity: .4; cursor: default; }
.lse-ctx b { display: block; font-size: 13.5px; }
.lse-ctx small { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.3; }

/* ===== Фон блока и пункты ===== */
.lse-swatches { display: inline-flex; align-items: center; gap: 3px; padding: 0 6px; margin: 0 2px; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
.lse-bar .lse-sw { width: 18px; height: 18px; padding: 0; border-radius: 6px; border: 1px solid var(--border-2) !important; box-shadow: none; transform: none; }
.lse-bar .lse-sw.lc-bg-none { background: repeating-linear-gradient(45deg, var(--surface) 0 3px, var(--surface-3) 3px 6px) !important; }
.lse-bar .lse-sw.on { outline: 2px solid var(--lse-accent); outline-offset: 1px; }
.lse-bar .lse-sw:hover { transform: scale(1.12); background-color: inherit; }
.lse-bar-txt { display: inline-flex !important; align-items: center; gap: 5px; width: auto !important; padding: 0 8px; font-size: 12px; font-weight: 800; }
.lse-bar-txt.on { color: var(--lse-accent) !important; background: var(--lse-accent-soft) !important; }
.lse-points { display: grid; gap: 2px; }
.lse-point { margin: 0 !important; align-items: flex-start; }
.lse-point > b { margin-top: 6px; }
.lse-point textarea { flex: 1; min-width: 0; padding: 4px 8px; border: 1px solid transparent; border-radius: 10px; background: transparent; resize: none; outline: none; line-height: 1.5; overflow: hidden; }
.lse-point textarea:hover { background: var(--surface-2); }
.lse-point textarea:focus { background: var(--surface); border-color: var(--lse-edit); }
.lse-point .lse-x { opacity: 0; }
.lse-point:hover .lse-x, .lse-point:focus-within .lse-x { opacity: 1; }
.lc-bg .lse-h3, .lc-bg .lse-p, .lc-bg .lse-small, .lc-bg .lse-callout-title { color: inherit; }
.lc-bg-lime ::placeholder { color: inherit; opacity: .45; }
.lse-formula.lc-bg .lse-code { background: rgba(255, 255, 255, .55); color: #12140a; }

/* ===== Редактируемые надписи и подсказки ===== */
.lse-label { outline: none; border-radius: 6px; cursor: text; transition: background .15s, box-shadow .15s; min-width: 1ch; }
.lse-label:hover { background: var(--surface-2); box-shadow: 0 0 0 3px var(--surface-2); }
.lse-label:focus { background: var(--surface); box-shadow: 0 0 0 2px var(--lse-edit); }
.lse-label:empty { display: inline-block; min-width: 40px; }
.lse-label:empty::before { content: attr(data-placeholder); opacity: .35; text-decoration: line-through; }
.lse-label:empty:focus::before { text-decoration: none; }
.pill .lse-label:hover, .pill .lse-label:focus { box-shadow: none; }
h2 > .lse-label, h2.lse-label { display: inline-block; }
.lse-ava.lse-label { width: 36px; height: 36px; font-size: 14px; background: #ff7a00 !important; color: #fff; display: grid; place-items: center; overflow: hidden; white-space: nowrap; }
.lse-sub { margin: 4px 0 12px; }
.lse-tag { display: inline-block; margin-top: 8px; padding: 3px 8px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 11.5px; font-weight: 700; }
.lse-help { position: relative; display: inline-grid; place-items: center; flex: none; width: 18px; height: 18px; margin-left: 4px; border-radius: 50%; background: var(--surface-3); color: var(--muted); font-size: 11px; font-weight: 800; cursor: help; }
.lse-help:hover, .lse-help:focus { background: var(--lse-accent); color: #fff; outline: none; }
.lse-help::after { content: attr(data-tip); position: absolute; left: 50%; top: calc(100% + 8px); z-index: 50; width: max-content; max-width: 280px; padding: 9px 11px; border-radius: 10px; background: #18202c; color: #fff; font-size: 12px; font-weight: 600; line-height: 1.4; text-align: left; white-space: normal; transform: translateX(-50%); opacity: 0; pointer-events: none; transition: opacity .15s; }
.lse-help:hover::after, .lse-help:focus::after { opacity: 1; }

/* ===== Текст с форматированием ===== */
.lse-rich { display: block; min-height: 1.6em; padding: 4px 8px; margin-left: -8px; border: 1px solid transparent; border-radius: 10px; outline: none; line-height: 1.65; overflow-wrap: anywhere; cursor: text; transition: background .15s, border-color .15s; }
.lse-rich:hover { background: var(--surface-2); }
.lse-rich:focus { background: var(--surface); border-color: var(--lse-edit); box-shadow: 0 0 0 3px var(--lse-accent-soft); }
.lse-rich:empty::before { content: attr(data-placeholder); color: var(--faint); pointer-events: none; }
.lse-rich a { color: var(--pink); text-decoration: underline; }
.lse-rich ul, .lse-rich ol { margin: .3em 0; padding-left: 1.4em; }
.lesson-text > .lse-rich { font-size: 16px; }
.lse-callout .lse-rich { font-family: var(--font-d); font-size: 18px; font-weight: 700; color: inherit; }
.lse-callout .lse-rich:focus { background: rgba(255, 255, 255, .45); color: var(--on-lime, #12140a); }
.lc-bg-lime .lse-rich:empty::before { color: inherit; opacity: .45; }
.lse-point .lse-rich { flex: 1; min-width: 0; margin-left: 0; line-height: 1.5; }
.lse-fmt { position: fixed; z-index: 1001; display: flex; align-items: center; gap: 2px; padding: 5px; border-radius: 12px; background: #18202c; color: #fff; box-shadow: 0 16px 36px -12px rgba(0, 0, 0, .5); font-family: var(--font); }
.lse-fmt[hidden] { display: none; }
.lse-fmt button { display: grid; place-items: center; min-width: 30px; height: 30px; padding: 0 6px; border-radius: 8px; color: #fff; font-size: 14px; }
.lse-fmt button:hover { background: rgba(255, 255, 255, .14); }
.lse-fmt button[hidden] { display: none; }
.lse-fmt-sep { width: 1px; height: 20px; margin: 0 4px; background: rgba(255, 255, 255, .2); }
.lse-fmt-group { display: inline-flex; gap: 2px; }
.lse-fmt .lse-fmt-c, .lse-fmt .lse-fmt-m { min-width: 20px; width: 20px; height: 20px; padding: 0; border-radius: 50%; }
.lse-fmt .lse-fmt-c { background: var(--c); border: 2px solid rgba(255, 255, 255, .7); }
.lse-fmt .lse-fmt-m { background: var(--c); border: 2px solid rgba(255, 255, 255, .25); border-radius: 5px; }
.lse-fmt .lse-fmt-m[style*="transparent"] { background: repeating-linear-gradient(45deg, transparent 0 3px, rgba(255, 255, 255, .4) 3px 5px); }
/* меню ПКМ: действия с блоками */
.lse-ctx-acts { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.lse-ctx-acts button { display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: 13px; font-weight: 700; }
.lse-ctx-acts button svg { width: 16px; height: 16px; flex: none; }
.lse-ctx-acts button.danger { color: var(--bad); }
.lse-ctx kbd { margin-left: auto; padding: 1px 5px; border-radius: 5px; background: var(--surface-2); color: var(--muted); font: 600 10.5px/1.4 var(--font); }
.lse-hist { display: inline-flex; gap: 4px; }
.lse .btn:disabled { opacity: .4; cursor: default; }

/* ===== Раунд правок: рамка блоков, размер текста, формулы ===== */
.lse-canvas > .lse-block::before { border-color: color-mix(in srgb, var(--border-2) 75%, transparent); }
.lse-canvas > .lse-block:hover::before { border-color: var(--faint); }
.lse-bar .lse-sw.lc-bg-frame { background: var(--solid) !important; border: 2px solid var(--muted) !important; }
.lse-fs { height: 26px; padding: 0 22px 0 8px; margin: 0 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font: 700 12px var(--font); color: var(--text); cursor: pointer; }
.lesson-text > .lse-rich, .lse-point .lse-rich { font-size: calc(16px * var(--fs, 1)); }
.lse-callout .lse-rich { font-size: calc(18px * var(--fs, 1)); }
.lse-h3 { font-size: calc(20px * var(--fs, 1)); }
.lse-fmt small { font-size: 11px; } .lse-fmt big { font-size: 17px; }
.lse-mathprev { margin: 6px 0 2px; padding: 8px 12px; border-radius: 10px; border: 1px dashed var(--border-2); background: var(--surface); color: var(--text); font-family: var(--font); font-size: 15px; font-weight: 500; line-height: 1.6; }
.lse-mathprev > small { display: block; margin-bottom: 2px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.lse-point { flex-wrap: wrap; }
.lse-point .lse-mathprev { flex-basis: 100%; margin-left: 32px; }

/* ===== Заголовки с оформлением, ∑ и ссылки на формулы ===== */
.lse-rich.lse-h3 { font-family: var(--font-d); font-weight: 700; font-size: calc(20px * var(--fs, 1)); letter-spacing: -.02em; line-height: 1.25; margin-bottom: 4px; }
.lse-b-text:not(:hover):not(:focus-within):not(.is-sel) .lse-rich.lse-h3:empty { display: none; }
.lse-rich.lse-callout-title { font-family: var(--font); font-size: 13px; font-weight: 700; opacity: .8; min-height: 1.3em; line-height: 1.3; }
.lse-rich.lse-small { font-family: var(--font); font-size: 13px; font-weight: 700; color: var(--muted); min-height: 1.3em; line-height: 1.3; }
.lse-label[data-rich] { display: inline; padding: 0; margin: 0; border: 0; line-height: inherit; min-height: 0; }
.lse-label[data-rich]:empty { display: inline-block; }
.lse-formula { position: relative; }
.lse-formula .lc-fnum { top: 22px; transform: none; }
.lse-rich a[href^="#f-"] { color: var(--pink); font-weight: 700; text-decoration: none; border-bottom: 1.5px dashed currentColor; }
.lse-math-btn { font-family: Georgia, serif; font-size: 16px; font-weight: 700; }
.lse-fmt { flex-wrap: wrap; max-width: min(720px, calc(100vw - 16px)); }
.lse-fmt-menu { position: absolute; top: calc(100% + 6px); right: 0; display: grid; gap: 2px; min-width: 260px; max-height: 260px; overflow: auto; padding: 6px; border-radius: 12px; background: #18202c; box-shadow: 0 16px 36px -12px rgba(0, 0, 0, .5); }
.lse-fmt-menu[hidden] { display: none; }
.lse-fmt-menu b { padding: 4px 8px; font-size: 11px; opacity: .7; text-transform: uppercase; letter-spacing: .04em; }
.lse-fmt-menu button { display: flex !important; justify-content: flex-start !important; gap: 10px; width: 100%; height: auto !important; padding: 7px 8px !important; text-align: left; }
.lse-fmt-menu button i { font-style: normal; font-weight: 800; color: #ff7aa8; }
.lse-fmt-menu button span { font-family: ui-monospace, Consolas, monospace; font-size: 12px; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lse-fmt-empty { display: block; padding: 8px; font-size: 12.5px; opacity: .8; max-width: 260px; }

/* открытие урока: дата и «после урока» */
.lse-open { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 4px 6px 4px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 700; color: var(--muted); }
.lse-open svg { width: 14px; height: 14px; }
.lse-open input, .lse-open select { height: 28px; padding: 0 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 12.5px; font-weight: 600; max-width: 230px; }
.ls-lesson-flags .fg.sched { color: #b45309; }
.lse-open-prev, .lse-open-num { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; cursor: pointer; }
.lse-open-num input { width: 52px; }


/* меньше движения — по настройке системы */
@media (prefers-reduced-motion: reduce) {
  .lse-block, .lse-ctx, .lse-menu, .ls-lesson, .lse-bar { transition: none !important; animation: none !important; }
}

.lse-open-hint { font-weight: 800; color: var(--text); white-space: nowrap; }
.lse-open-hint:empty { display: none; }

.lse-durfield { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px 4px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 700; color: var(--muted); }
.lse-durfield svg { width: 14px; height: 14px; }
.lse-durfield input { width: 56px; height: 28px; padding: 0 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 12.5px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }

/* панель блока: компактный выбор размера текста (стилизованный список) */
.lse-bar .ps-btn.lse-fs { flex: none; width: auto; height: 26px; min-height: 26px; padding: 0 24px 0 8px !important; font: 700 12px var(--font); white-space: nowrap; border-radius: 8px; }
.lse-bar .ps-btn.lse-fs .ps-val { flex: none; overflow: visible; }
.lse-bar .ps-btn.lse-fs .ps-chev { right: 6px; width: 13px; height: 13px; }
/* панель висит над блоком: «мостик» до блока и приоритет наведённого блока над выделенным —
   иначе по пути к панели курсор задевает блок выше, тот поднимается поверх и перехватывает клики.
   Выделенный блок всегда выше наведённого: его панель не закроет соседний блок */
.lse-bar::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 12px; }
.lse-canvas > .lse-block:hover { z-index: 7; }
.lse-canvas > .lse-block.is-sel, .lse-canvas > .lse-block:focus-within { z-index: 8; }
.lse-web-switch input:checked + i { background: #e11d6a; }

/* соответствие и последовательность: подсказка, пары, шаги */
.lse-qhint { display: flex; align-items: flex-start; gap: 8px; margin: 2px 0 12px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, #ff3d81 7%, var(--surface-2)); color: var(--text); font-size: 13px; line-height: 1.45; }
.lse-qhint svg { flex: none; width: 16px; height: 16px; margin-top: 1px; color: #e11d6a; }
.lse-pairs { display: grid; gap: 8px; }
.lse-pairs-head, .lse-pair { display: grid; grid-template-columns: 30px minmax(0, 1fr) 22px minmax(0, 1fr) 28px; align-items: center; gap: 8px; }
.lse-pairs-head b { font-size: 12px; color: var(--muted); }
.lse-pair > input, .lse-pair-r > input, .lse-step > input { width: 100%; min-width: 0; padding: 9px 11px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface); outline: none; font: inherit; font-size: 14px; }
.lse-pair > input:focus, .lse-pair-r > input:focus, .lse-step > input:focus { border-color: var(--lse-edit, #ff3d81); }
.lse-pair-arrow { display: grid; place-items: center; color: #e11d6a; }
.lse-pair-arrow svg { width: 18px; height: 18px; }
.lse-pair-r { position: relative; display: flex; align-items: center; min-width: 0; }
.lse-pair-r > input { padding-right: 52px; }
.lse-pair-pick, .lse-pair-r .ps-btn { position: absolute !important; right: 4px; top: 50%; transform: translateY(-50%); width: 44px !important; min-height: 0 !important; height: 30px; padding: 0 18px 0 8px !important; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); font: 800 12px var(--font); cursor: pointer; }
.lse-pair-r .ps-btn .ps-chev { right: 3px; width: 12px; height: 12px; }
.lse-pair-note { grid-column: 4 / 6; display: flex; align-items: center; gap: 4px; margin-top: -4px; color: var(--muted); font-size: 11.5px; }
.lse-pair-note svg { width: 12px; height: 12px; }
.lse-extras { display: grid; gap: 4px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.lse-extras > b { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.lse-extras > b small { font-weight: 500; }
.lse-steps { list-style: none; display: grid; gap: 8px; margin: 0; padding: 0; }
.lse-step { display: flex; align-items: center; gap: 8px; }
.lse-step > input { flex: 1; }
.lse-step-acts { display: flex; align-items: center; gap: 2px; flex: none; }
.lse-step-acts button:not(.lse-x) { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); cursor: pointer; }
.lse-step-acts button:disabled { opacity: .3; cursor: default; }
.lse-step-acts button svg { width: 15px; height: 15px; }
@media (max-width: 700px) { .lse-pairs-head { display: none; } .lse-pair { grid-template-columns: 30px minmax(0, 1fr) 28px; } .lse-pair-arrow { display: none; } .lse-pair-r { grid-column: 2 / 3; } .lse-pair-note { grid-column: 2 / 4; } }
.lse-katex { overflow-y: hidden; padding: .4em 0 .4em; }

/* ===== Живая формула (MathLive) и плавающая палитра Σ (formula-pad.js) ===== */
.lse-fw { position: relative; }
.lse-fw .lse-mathf { display: none; }
.lse-fw.ml:not(.code) .lse-mathf { display: block; }
.lse-fw.ml:not(.code) .lse-code { display: none; }
.lse-mathf {
  width: 100%; min-height: 58px; box-sizing: border-box; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text); font-size: 22px; outline: none;
  --caret-color: var(--ls-accent, #e83e73);
  --selection-background-color: color-mix(in srgb, var(--ls-accent, #e83e73) 22%, transparent);
  --contains-highlight-background-color: color-mix(in srgb, var(--ls-accent, #e83e73) 7%, transparent);
}
.lse-mathf:focus, .lse-mathf:focus-within { border-color: var(--lse-edit, var(--ls-accent, #e83e73)); box-shadow: 0 0 0 3px var(--lse-accent-soft, rgba(232, 62, 115, .14)); }
/* встроенные кнопки MathLive (клавиатура и меню) в блоке не нужны */
.lse-mathf::part(virtual-keyboard-toggle), .lse-mathf::part(menu-toggle) { display: none; }
/* в визуальном режиме KaTeX-превью дублирует формулу — показываем его только в режиме кода */
.lse-formula:has(.lse-fw.ml:not(.code)) .lse-katex { display: none; }
.lse-formula.lc-bg .lse-mathf { background: rgba(255, 255, 255, .78); color: #14160c; }

/* кнопка Σ слева: висит поверх редактора, её можно таскать вверх-вниз */
.fpad-fab {
  position: fixed; left: 72px; z-index: 940; width: 46px; height: 46px; padding: 0;
  display: grid; place-items: center; touch-action: none;
  border: 1px solid var(--ls-line, var(--border)); border-radius: 50%;
  background: var(--solid, var(--surface)); color: var(--text);
  font: 800 20px/1 Georgia, "Times New Roman", serif; cursor: grab;
  box-shadow: 0 10px 28px -10px rgba(0, 0, 0, .45);
  transition: background .15s, color .15s, border-color .15s, transform .15s;
}
.fpad-fab:hover { transform: translateY(-1px); border-color: var(--ls-accent, #e83e73); color: var(--ls-accent, #e83e73); }
/* палитра формул не должна висеть поверх диалога генерации и предпросмотра */
body:has(.lse-gen) .fpad-fab,
body:has(.lse-gen) .fpad-panel { display: none; }
.fpad-fab.on { background: var(--ls-accent, #e83e73); border-color: var(--ls-accent, #e83e73); color: #fff; cursor: grabbing; }
.fpad-fab:focus-visible { outline: 3px solid color-mix(in srgb, var(--ls-accent, #e83e73) 35%, transparent); outline-offset: 2px; }

.fpad-panel {
  position: fixed; z-index: 945; width: 330px; max-width: calc(100vw - 20px);
  max-height: min(78vh, 660px); display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--ls-line, var(--border)); border-radius: 16px;
  background: var(--solid, var(--surface)); box-shadow: 0 28px 70px -24px rgba(0, 0, 0, .55);
}
.fpad-head { display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 12px; cursor: grab; touch-action: none; background: var(--bg-2, var(--surface-2)); border-bottom: 1px solid var(--ls-line, var(--border)); }
.fpad-head:active { cursor: grabbing; }
.fpad-head b { font-size: 13px; letter-spacing: .01em; }
.fpad-grip { color: var(--muted); font-size: 14px; line-height: 1; }
.fpad-x { margin-left: auto; width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 15px; cursor: pointer; }
.fpad-x:hover { background: var(--surface); color: var(--text); }

.fpad-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 8px 8px 6px; }
.fpad-tab { min-width: 0; height: 36px; padding: 0 4px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 9px; background: var(--bg-2, var(--surface-2)); color: var(--muted); cursor: pointer; }
.fpad-tab:hover { border-color: var(--ls-accent, #e83e73); color: var(--text); }
.fpad-tab.on { background: var(--solid, #fff); border-color: var(--ls-accent, #e83e73); color: var(--ls-accent, #e83e73); box-shadow: 0 2px 10px -6px rgba(0, 0, 0, .5); }
.fpad-tab .katex { font-size: 14px; }

.fpad-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px 8px 8px; display: flex; flex-direction: column; gap: 6px; }
.fpad-body::-webkit-scrollbar { width: 8px; }
.fpad-body::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 35%, transparent); border-radius: 8px; }
.fpad-group { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 6px; background: var(--bg-2, var(--surface-2)); border-radius: 11px; }
.fpad-b { min-width: 0; height: 42px; padding: 0 4px; display: grid; place-items: center; overflow: hidden; border: 1px solid transparent; border-radius: 8px; background: var(--solid, #fff); color: var(--text); cursor: pointer; transition: border-color .12s, background .12s; }
.fpad-b:hover { border-color: var(--ls-accent, #e83e73); background: color-mix(in srgb, var(--ls-accent, #e83e73) 8%, var(--solid, #fff)); }
.fpad-b:active { transform: translateY(1px); }
.fpad-b .katex { font-size: 17px; }
.fpad-txt { font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }

.fpad-foot { padding: 6px 12px 8px; border-top: 1px solid var(--ls-line, var(--border)); font-size: 11.5px; color: var(--muted); background: var(--bg-2, var(--surface-2)); }
.fpad-foot.warn { color: var(--warn, #b26a00); }

/* формула прямо в тексте: выглядит формулой, а не ЛаТеХ-строкой */
.lse-mathx {
  display: inline-block; max-width: 100%; margin: 0; padding: 0 1px;
  border-radius: 7px; vertical-align: baseline; cursor: pointer;
  transition: background .12s, box-shadow .12s;
}
.lse-mathx:hover { background: color-mix(in srgb, var(--ls-accent, #e83e73) 10%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--ls-accent, #e83e73) 32%, transparent); }
.lse-mathx[data-disp] { display: block; text-align: center; margin: 8px 0; padding: 6px 4px; overflow-x: auto; overflow-y: hidden; }
.lse-mathx .katex { white-space: normal; font-size: 1.08em; }
/* формула, которую опасно рисовать (глубокая вложенность) — показываем плашкой */
.lse-mathx.bad { padding: 1px 8px; background: #fff1f4; color: #b3123f; font-size: .86em; }

/* живая формула в тексте: пустые слоты, в которые сразу пишем */
.lse-mathlive {
  display: inline-block; vertical-align: baseline; max-width: 100%;
  min-width: 64px; margin: 0 2px; padding: 0 2px;
  border: 0; border-radius: 8px; outline: none;
  background: color-mix(in srgb, var(--ls-accent, #e83e73) 7%, transparent);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ls-accent, #e83e73) 40%, transparent);
  font-size: 1.05em; line-height: 1.15;
  --caret-color: var(--ls-accent, #e83e73);
  --selection-background-color: color-mix(in srgb, var(--ls-accent, #e83e73) 22%, transparent);
  --contains-highlight-background-color: color-mix(in srgb, var(--ls-accent, #e83e73) 8%, transparent);
}
.lse-mathlive:focus, .lse-mathlive:focus-within {
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--ls-accent, #e83e73);
}
.lse-mathlive[data-disp] { display: block; margin: 8px auto; min-width: 0; text-align: center; }
.lse-mathlive::part(virtual-keyboard-toggle), .lse-mathlive::part(menu-toggle) { display: none; }

/* мини-редактор формулы, вставленной в текст */
.fpad-edit {
  position: fixed; z-index: 950; width: min(348px, calc(100vw - 16px));
  display: flex; flex-direction: column; gap: 8px; padding: 8px;
  border: 1px solid var(--ls-line, var(--border)); border-radius: 14px;
  background: var(--solid, var(--surface)); box-shadow: 0 26px 64px -22px rgba(0, 0, 0, .55);
}
.fpad-edit-head { display: flex; align-items: center; gap: 8px; padding: 2px 2px 2px 6px; }
.fpad-edit-head b { font-size: 13px; }
.fpad-edit-head .fpad-x { margin-left: auto; }
.fpad-edit-mf {
  width: 100%; min-height: 54px; box-sizing: border-box; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
  font-size: 22px; outline: none;
  --caret-color: var(--ls-accent, #e83e73);
  --selection-background-color: color-mix(in srgb, var(--ls-accent, #e83e73) 22%, transparent);
  --contains-highlight-background-color: color-mix(in srgb, var(--ls-accent, #e83e73) 7%, transparent);
}
.fpad-edit-mf::part(virtual-keyboard-toggle), .fpad-edit-mf::part(menu-toggle) { display: none; }
.fpad-edit-in {
  width: 100%; box-sizing: border-box; padding: 9px 10px; resize: vertical;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
  font: 500 14px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; outline: none;
}
.fpad-edit-foot { display: flex; align-items: center; gap: 8px; padding: 0 2px 2px; font-size: 11.5px; color: var(--muted); }
.fpad-edit-foot > span { flex: 1 1 auto; min-width: 0; }
.fpad-del, .fpad-ok {
  flex: none; height: 32px; padding: 0 12px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 700 12.5px var(--font);
}
.fpad-del { color: #c0284f; }
.fpad-ok { border-color: var(--ls-accent, #e83e73); background: var(--ls-accent, #e83e73); color: #fff; }
.fpad-del:hover { border-color: #c0284f; }
.fpad-ok:hover { filter: brightness(1.05); }

/* столбик: высокие кнопки в палитре и редактор строк */
.fpad-b.tall { height: 96px; }
.fpad-b.tall .katex { font-size: 15px; }
.fpad-col-prev {
  display: grid; place-items: center; min-height: 62px; margin: 2px 2px 0; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface, #fff);
  overflow-x: auto; overflow-y: hidden;
}
.fpad-col-prev .katex { font-size: 21px; }
.fpad-col-rows { display: flex; flex-direction: column; gap: 2px; max-height: 268px; overflow-y: auto; padding: 2px; }
.fpad-col-row { display: flex; align-items: center; gap: 6px; }
.fpad-col-in {
  flex: 1 1 auto; min-width: 0; height: 36px; padding: 0 10px; box-sizing: border-box;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text);
  font: 600 15px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; outline: none;
}
.fpad-col-in:focus { border-color: var(--ls-accent, #e83e73); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ls-accent, #e83e73) 16%, transparent); }
.fpad-col-del {
  flex: none; width: 28px; height: 28px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted);
  font-size: 13px; line-height: 1;
}
.fpad-col-del:hover { border-color: var(--border); color: #c0284f; }
.fpad-col-line {
  flex: none; width: 100%; height: 12px; padding: 0; border: 0; background: transparent; cursor: pointer;
  display: grid; place-items: center;
}
.fpad-col-line::before { content: ""; display: block; width: 100%; height: 2px; border-radius: 2px; background: var(--text); opacity: .85; }
.fpad-col-line[aria-pressed="false"]::before { height: 0; border-top: 1px dashed var(--border); opacity: .9; }
.fpad-col-line[aria-pressed="true"]::before { opacity: .9; background: var(--ls-accent, #e83e73); }
.fpad-col-line:hover::before { opacity: 1; }
.fpad-col-add {
  flex: none; height: 30px; padding: 0 10px; border-radius: 8px; cursor: pointer;
  border: 1px dashed var(--border); background: transparent; color: var(--text); font: 600 12px var(--font);
}
.fpad-col-add:hover { border-color: var(--ls-accent, #e83e73); color: var(--ls-accent, #e83e73); }

@media (pointer: coarse) {
  .fpad-tab { height: 42px; }
  .fpad-b { height: 46px; }
  .fpad-b .katex { font-size: 16px; }
  .fpad-fab { width: 50px; height: 50px; }
}
@media (max-width: 620px) {
  .fpad-fab { left: 6px; }
  .fpad-panel { width: min(330px, calc(100vw - 16px)); max-height: min(72vh, 560px); }
}

/* ---------- Модули курса в дереве ---------- */
.ls-mod { position: relative; margin: 4px 0 4px 2px; border: 1px solid var(--border); border-radius: 11px; overflow: hidden; background: var(--surface); }
.ls-mod-head { position: relative; display: flex; align-items: center; gap: 2px; padding: 2px 4px 2px 4px; background: var(--surface-2); }
.ls-mod-grip { display: grid; place-items: center; width: 16px; height: 26px; flex: none; color: #b5beca; cursor: grab; opacity: 0; transition: opacity .15s ease; }
.ls-mod-grip:active { cursor: grabbing; }
.ls-mod-grip svg { width: 12px; height: 12px; }
.ls-mod-head:hover .ls-mod-grip { opacity: 1; }
.ls-mod.mod-dragging { opacity: .45; }
.ls-mod::before, .ls-mod::after { content: ""; position: absolute; left: 0; right: 0; height: 3px; z-index: 6; pointer-events: none; background: var(--ls-accent); opacity: 0; }
.ls-mod::before { top: 0; }
.ls-mod::after { bottom: 0; }
.ls-mod.mod-drop-before::before, .ls-mod.mod-drop-after::after { opacity: 1; }
.ls-mod-head.drag-over, .ls-mod-body.drag-over, .ls-loose.drag-over { outline: 2px dashed var(--ls-accent); outline-offset: -2px; }
.ls-mod-toggle { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; padding: 7px 4px; text-align: left; font-size: 11.5px; font-weight: 800; border-radius: 7px; }
.ls-mod-toggle:hover { background: color-mix(in srgb, var(--ls-accent) 8%, transparent); }
.ls-mod-name { flex: 1; min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; white-space: normal; line-height: 1.25; }
.ls-mod-n { color: var(--muted); font-size: 10px; font-weight: 800; background: var(--surface); border: 1px solid var(--ls-line); border-radius: 99px; padding: 1px 6px; margin-right: 2px; transition: opacity .15s ease; }
.ls-mod-btn { position: absolute; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 24px; height: 22px; border-radius: 7px; color: var(--muted); opacity: 0; pointer-events: none; background: var(--surface-2); transition: opacity .15s ease, color .15s ease, background .15s ease; }
.ls-mod-btn[data-act="rename-mod"] { right: 28px; }
.ls-mod-btn[data-act="delete-mod"] { right: 4px; }
.ls-mod-head:hover .ls-mod-btn, .ls-mod-btn:focus-visible { opacity: 1; pointer-events: auto; }
.ls-mod-head:hover .ls-mod-n { opacity: 0; }
.ls-mod-btn svg { width: 13px; height: 13px; }
.ls-mod-btn:hover { background: var(--surface); color: var(--text); }
.ls-mod-btn.del:hover { color: #dc2626; }
.ls-mod-body { display: none; padding: 2px 4px 4px; }
.ls-mod.open .ls-mod-body { display: block; }
.ls-mod.open .ls-mod-toggle .ls-chev { transform: rotate(180deg); }
.ls-mod-empty { padding: 12px 8px; color: var(--muted); font-size: 11px; text-align: center; border: 1px dashed var(--ls-line); border-radius: 8px; margin: 3px; }
.ls-loose { position: relative; margin: 4px 0 4px 2px; border: 1px dashed var(--ls-line); border-radius: 11px; background: transparent; overflow: hidden; }
.ls-loose-head { display: flex; align-items: center; gap: 2px; padding: 2px 4px; }
.ls-loose-grip { flex: none; opacity: .5; }
.ls-loose-head:hover .ls-loose-grip { opacity: 1; }
.ls-loose.mod-dragging { opacity: .45; }
.ls-loose::before, .ls-loose::after { content: ""; position: absolute; left: 0; right: 0; height: 3px; z-index: 6; pointer-events: none; background: var(--ls-accent); opacity: 0; }
.ls-loose::before { top: 0; }
.ls-loose::after { bottom: 0; }
.ls-loose.mod-drop-before::before, .ls-loose.mod-drop-after::after { opacity: 1; }
.ls-loose-toggle { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; padding: 4px 4px 4px 2px; text-align: left; font-size: 11.5px; font-weight: 800; color: var(--muted); border-radius: 7px; }
.ls-loose-toggle:hover { background: color-mix(in srgb, var(--ls-accent) 8%, transparent); }
.ls-loose-name { flex: 1; min-width: 0; }
.ls-loose-toggle .ls-mod-n { margin-right: 2px; }
.ls-loose-body { display: none; padding: 0 4px 4px; }
.ls-loose.open .ls-loose-body { display: block; }
.ls-loose.open .ls-loose-toggle .ls-chev { transform: rotate(180deg); }
.ls-add-mod { color: var(--muted); }
.ls-add-mod svg { width: 13px; height: 13px; }
.lse-modfield { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px 4px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 700; color: var(--muted); }
.lse-modfield svg { width: 14px; height: 14px; }
.lse-modfield select { height: 28px; max-width: 190px; padding: 0 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 12.5px; font-weight: 700; }
.lse-modfield select:focus { outline: 2px solid var(--lse-edit); outline-offset: 1px; }

/* ---------- AI-генератор заданий ---------- */
.lse-gen-top {
  color: var(--lse-accent);
  border-color: color-mix(in srgb, var(--lse-accent) 32%, var(--border));
  background: var(--lse-accent-soft);
}
.lse-gen-top:hover { background: color-mix(in srgb, var(--lse-accent) 15%, transparent); }
.lse-hw-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.lse-gen-btn {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  color: var(--lse-accent); border-color: color-mix(in srgb, var(--lse-accent) 28%, var(--border));
  background: var(--lse-accent-soft);
}
.lse-gen-btn:hover { background: color-mix(in srgb, var(--lse-accent) 14%, transparent); }
.lse-gen-btn .ic, .lse-gen-top .ic { width: 15px; height: 15px; }

.lse-gen {
  --gen-accent: #e83e73;
  --gen-ok: #16a34a;
  display: grid; gap: 15px; color: var(--text);
}
.lse-gen h2 { display: flex; align-items: center; gap: 9px; margin: 0; padding-right: 44px; }
.lse-gen h2 .ic { width: 22px; height: 22px; color: var(--gen-accent); flex: none; }
.lse-gen > p { margin: -4px 0 0; max-width: 72ch; font-size: 13px; line-height: 1.5; }
.lse-gen-kind {
  display: inline-flex; gap: 4px; padding: 4px; width: fit-content; max-width: 100%;
  border: 1px solid var(--border); border-radius: 13px; background: var(--surface-2);
}
.lse-gen-kind button {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px;
  border: 0; border-radius: 9px; background: transparent; color: var(--muted);
  font: 700 12.5px/1.2 var(--font); cursor: pointer; white-space: nowrap;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.lse-gen-kind button .ic { width: 15px; height: 15px; }
.lse-gen-kind button:hover:not(:disabled):not(.is-on) { color: var(--text); }
.lse-gen-kind button.is-on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(15, 23, 42, .1); }
.lse-gen-kind button:disabled { opacity: .55; cursor: default; }
.lse-gen-source { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.lse-gen-source label {
  position: relative; display: flex; align-items: flex-start; gap: 9px; min-width: 0;
  padding: 11px 12px; border: 1.5px solid var(--border); border-radius: 14px;
  background: var(--surface); cursor: pointer; transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.lse-gen-source label:hover { border-color: color-mix(in srgb, var(--gen-accent) 45%, var(--border)); }
.lse-gen-source label:has(input:checked) {
  border-color: var(--gen-accent);
  background: color-mix(in srgb, var(--gen-accent) 7%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gen-accent) 14%, transparent);
}
.lse-gen-source input { flex: none; margin: 2px 0 0; accent-color: var(--gen-accent); }
.lse-gen-source b { display: block; font-size: 13px; line-height: 1.3; }
.lse-gen-source small { display: block; margin-top: 3px; color: var(--muted); font-size: 11.5px; line-height: 1.35; }
.lse-gen-source label.is-disabled { opacity: .55; cursor: not-allowed; }
.lse-gen-source label.is-disabled:hover { border-color: var(--border); }

.lse-gen-prompt textarea { min-height: 108px; resize: vertical; line-height: 1.5; }
.lse-gen-tip { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: -6px; }
.lse-gen-tip .btn { flex: none; }
.lse-gen-counts { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.lse-gen-counts label {
  display: grid; gap: 5px; padding: 8px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2);
}
.lse-gen-counts span { min-height: 26px; color: var(--muted); font-size: 10.5px; font-weight: 800; line-height: 1.2; }
.lse-gen-counts input {
  width: 100%; height: 36px; padding: 0 4px; box-sizing: border-box; text-align: center;
  color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  font: 800 16px/1 var(--font); outline: none;
}
.lse-gen-counts input:focus { border-color: var(--gen-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gen-accent) 14%, transparent); }

.lse-gen-status {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 11px 14px;
  border-radius: 12px; background: var(--surface-2); font-size: 13px; line-height: 1.45;
}
.lse-gen-status[hidden] { display: none; }
.lse-gen-status.bad { color: var(--bad, #b91c1c); background: var(--bad-bg, #fef2f2); }
.lse-gen-status .btn { margin-left: auto; }
.lse-gen-spinner {
  flex: none; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--gen-accent) 24%, transparent);
  border-top-color: var(--gen-accent);
  animation: lseGenSpin .8s linear infinite;
}
@keyframes lseGenSpin { to { transform: rotate(360deg); } }

.lse-gen-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.lse-gen-buttons { display: flex; gap: 8px; flex: none; }
.lse-gen-buttons .btn { white-space: nowrap; }

.lse-gen-preview { gap: 12px; }
.lse-gen-intro { padding: 11px 14px; border-left: 3px solid var(--gen-accent); border-radius: 0 10px 10px 0; background: var(--surface-2); font-size: 13px; line-height: 1.5; }
.lse-gen-warn { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: #fff7ed; color: #9a3412; font-size: 12.5px; line-height: 1.4; }
.lse-gen-warn .ic { width: 16px; height: 16px; flex: none; }
.lse-gen-fig {
  margin-top: 10px; padding: 8px; border: 1px solid var(--border); border-radius: 12px;
  background: #fff; overflow: hidden;
}
.lse-gen-fig img { display: block; width: 100%; height: auto; border-radius: 8px; }
.lse-gen-figcap {
  display: flex; align-items: center; gap: 5px; margin-bottom: 7px;
  color: var(--muted); font-size: 11px; font-weight: 700;
}
.lse-gen-figcap .ic { width: 13px; height: 13px; flex: none; }
.lse-gen-figwarn {
  display: flex; align-items: flex-start; gap: 8px; margin-top: 9px; padding: 8px 11px;
  border: 1px solid color-mix(in srgb, #d97706 30%, var(--border)); border-radius: 10px;
  background: color-mix(in srgb, #f59e0b 8%, transparent); color: #92400e;
  font-size: 12px; line-height: 1.45;
}
.lse-gen-figwarn .ic { flex: none; width: 15px; height: 15px; margin-top: 1px; }
.lse-gen-figwarn b { font-weight: 800; }
.lse-gen-preview-list { display: grid; gap: 10px; max-height: 46vh; overflow: auto; padding: 2px 4px 2px 2px; overscroll-behavior: contain; }
.lse-gen-q { padding: 13px 15px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.lse-gen-q header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.lse-gen-q .q-num {
  display: grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 8px;
  background: var(--gen-accent); color: #fff; font-size: 12px; font-weight: 800;
}
.lse-gen-pts { margin-left: auto; color: var(--muted); font-size: 11.5px; font-weight: 800; }
.lse-gen-qtext { font-size: 13.5px; font-weight: 600; line-height: 1.55; overflow-wrap: anywhere; }
.lse-gen-opts { display: grid; gap: 6px; margin-top: 10px; }
.lse-gen-opts > div {
  display: flex; align-items: flex-start; gap: 8px; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: 10px; font-size: 12.5px; line-height: 1.45;
}
.lse-gen-opts > div > span:first-child {
  display: grid; place-items: center; flex: none; width: 20px; height: 20px; border-radius: 6px;
  background: var(--surface-2); color: var(--muted); font-size: 10.5px; font-weight: 800;
}
.lse-gen-opts > div.is-ok { border-color: color-mix(in srgb, var(--gen-ok) 35%, var(--border)); background: color-mix(in srgb, var(--gen-ok) 7%, transparent); }
.lse-gen-opts > div.is-ok > span:first-child { background: var(--gen-ok); color: #fff; }
.lse-gen-opts .ic { flex: none; width: 14px; height: 14px; margin-left: auto; color: var(--gen-ok); }
.lse-gen-answer { margin-top: 10px; padding: 8px 11px; border-radius: 10px; background: color-mix(in srgb, var(--gen-ok) 8%, transparent); font-size: 12.5px; }
.lse-gen-answer b { color: var(--gen-ok); }
.lse-gen-pairs { display: grid; gap: 5px; margin-top: 10px; }
.lse-gen-pairs > div { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 9px; background: var(--surface-2); font-size: 12.5px; }
.lse-gen-pairs .ic { flex: none; width: 14px; height: 14px; color: var(--muted); }
.lse-gen-pairs b { margin-left: auto; color: var(--gen-ok); text-align: right; }
.lse-gen-order { margin: 10px 0 0; padding-left: 24px; font-size: 12.5px; line-height: 1.5; }
.lse-gen-crit { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.lse-gen-crit span { padding: 5px 9px; border-radius: 99px; background: var(--surface-2); font-size: 11.5px; font-weight: 700; }
.lse-gen-explain { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 9px; }
.lse-gen-explain summary { display: flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 700; list-style: none; }
.lse-gen-explain summary::-webkit-details-marker { display: none; }
.lse-gen-explain summary .ic { width: 14px; height: 14px; color: var(--gen-accent); }
.lse-gen-explain > div { margin-top: 7px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }

.lse-gen-insert { display: grid; gap: 9px; padding-top: 12px; border-top: 1px solid var(--border); }
.lse-gen-insert .field { max-width: 460px; }
.lse-gen-mode { display: flex; align-items: center; gap: 8px; font-size: 12.5px; cursor: pointer; }
.lse-gen-mode input { accent-color: var(--gen-accent); }

@media (max-width: 860px) {
  .lse-gen-source { grid-template-columns: 1fr 1fr; }
  .lse-gen-counts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .lse-gen-source { grid-template-columns: 1fr; }
  .lse-gen-kind { width: 100%; }
  .lse-gen-kind button { flex: 1 1 0; justify-content: center; }
  .lse-gen-preview-list { max-height: none; }
  .lse-gen-actions, .lse-gen-buttons { width: 100%; }
  .lse-gen-buttons .btn { flex: 1; }
  .lse-hw-tools { width: 100%; justify-content: space-between; }
  .lse-gen-status .btn { margin-left: 0; width: 100%; }
}
@media (max-width: 400px) {
  .lse-gen-counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Выделение уроков и меню ПКМ в дереве ---------- */
.lse .ls-lesson.multi { background: color-mix(in srgb, var(--ls-accent) 13%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ls-accent) 55%, transparent); }
.lse .ls-lesson.multi .ls-lesson-btn:hover { background: transparent; }
.lse .ls-lesson.multi .ls-num { color: var(--ls-accent); border-color: color-mix(in srgb, var(--ls-accent) 45%, transparent); background: var(--solid, #fff); }
.lse .ls-lesson.multi .ls-lesson-txt b { color: var(--ls-accent); }
.ls-treectx {
  --ls-accent: #e83e73;
  position: fixed; z-index: 1200; display: flex; flex-direction: column; gap: 2px;
  min-width: 218px; max-width: min(300px, calc(100vw - 16px)); max-height: min(70vh, 460px); overflow: auto;
  padding: 6px; border: 1px solid var(--border); border-radius: 13px;
  background: var(--solid); color: var(--text); font-family: var(--font);
  box-shadow: 0 18px 42px -14px rgba(0, 0, 0, .38);
}
.ls-treectx-head { padding: 4px 10px 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.ls-treectx-sub { margin: 4px 0 1px; padding: 5px 10px 2px; border-top: 1px solid var(--border); color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.ls-treectx button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border-radius: 8px; color: var(--text); text-align: left; font: 600 12.5px/1.25 var(--font); }
.ls-treectx button:hover { background: var(--surface-2); }
.ls-treectx button svg { width: 15px; height: 15px; flex: none; opacity: .8; }
.ls-treectx button.danger { color: #dc2626; }
.ls-treectx button span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ответы и критерии для проверки (ученик их не видит) */
.lse-hwkey { margin-top: 12px; padding: 12px 14px; border-radius: 16px; background: var(--surface-2); }
.lse-hwkey > summary { cursor: pointer; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lse-hwkey > summary small { font-weight: 600; color: var(--muted); }
.lse-hwkey-f { display: grid; gap: 6px; margin-top: 12px; }
.lse-hwkey-f > span { font-size: 13px; font-weight: 700; color: var(--muted); }
.lse-hwkey-f .lse-p { min-height: 64px; padding: 10px 12px; border-radius: 12px; background: var(--surface); }

/* генератор: сложность, перепроверка, действия с заданием */
.lse-gen-level { display: grid; grid-template-columns: 1fr 160px; gap: 12px; margin-top: 12px; }
.lse-gen-level label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.lse-gen-chk { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.lse-gen-chk .ic { width: 14px; height: 14px; }
.lse-gen-chk.is-ok { background: var(--ok-bg, #dcfce7); color: var(--ok, #15803d); }
.lse-gen-chk.is-bad { background: var(--bad-bg, #fee2e2); color: var(--bad, #b91c1c); }
.lse-gen-q.is-mismatch { box-shadow: inset 0 0 0 2px var(--bad, #dc2626); }
.lse-gen-q.is-busy { opacity: .5; pointer-events: none; }
.lse-gen-qtext[contenteditable], .lse-gen-explain [contenteditable] { border-radius: 8px; outline: none; }
.lse-gen-qtext[contenteditable]:focus, .lse-gen-explain [contenteditable]:focus { box-shadow: 0 0 0 2px var(--border-2); }
.lse-gen-qacts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.lse-gen-ok { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--ok-bg, #dcfce7); color: var(--ok, #15803d); font-weight: 600; }
.lse-gen-warn.is-bad { background: var(--bad-bg, #fee2e2); color: var(--bad, #b91c1c); }
@media (max-width: 600px) { .lse-gen-level { grid-template-columns: 1fr; } }

/* черновик урока по видео */
.lse-vd-part { margin-top: 16px; padding: 14px; border-radius: 16px; background: var(--surface-2); }
.lse-vd-pick { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.lse-vd-pick small { color: var(--muted); }
.lse-vd-ch, .lse-vd-list { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 6px; }
.lse-vd-ch { list-style: none; padding: 0; }
.lse-vd-ch li { display: grid; grid-template-columns: 64px 1fr; gap: 10px; }
.lse-vd-ch li > span:first-child { font-weight: 800; font-variant-numeric: tabular-nums; }
.lse-vd-sum { margin-top: 10px; line-height: 1.5; }
.lse-vd [contenteditable]:focus { outline: 2px solid var(--border-2); border-radius: 6px; }

/* прогресс загрузки большого видео */
.lse-upbar { position: fixed; left: 50%; bottom: 20px; z-index: 1000; transform: translateX(-50%); width: min(440px, calc(100vw - 32px)); padding: 12px 16px 16px; border-radius: 16px; background: var(--text); color: var(--bg); box-shadow: 0 10px 30px rgba(0, 0, 0, .25); display: grid; gap: 4px; overflow: hidden; }
.lse-upbar b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lse-upbar span { font-size: 13px; opacity: .8; font-variant-numeric: tabular-nums; }
.lse-upbar i { position: absolute; left: 0; bottom: 0; height: 4px; background: #D4FF3A; transition: width .3s; }
.lse-vd-sum { max-height: 340px; overflow: auto; padding: 12px 14px; border-radius: 12px; background: var(--surface); }
