/* ==========================================================================
   Студия уроков: редактор-страница.
   Внутри .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; } }

/* кнопка «+» между блоками */
.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: all .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; }
.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-hwmeta { justify-content: space-between; }
.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-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; }
