/* Суфлёр. Палитра — студийное оборудование: алюминий, матово-чёрный корпус монитора,
   красный — только сигнал записи (кнопка, буква фокуса, огонёк камеры). */
:root {
  --canvas: #e4e7eb;
  --panel: #eff1f4;
  --sheet: #ffffff;
  --ink: #15171b;
  --ink-2: #3b4048;
  --muted: #6b727c;
  --line: #d2d7dd;
  --line-soft: #e3e7eb;
  --track: #d6dbe1;
  --chip: #f1f3f6;
  --on: #15171b;
  --knob: #ffffff;
  --tally: #ef3a2d;
  --tally-deep: #cf2a1e;
  --tally-glow: rgba(239, 58, 45, 0.38);
  --focus: #3563ff;
  --metal: #c3c8cf;
  --metal-deep: #aab0b8;
  --bezel: #1b1d21;
  --hl-cmd: rgba(53, 99, 255, 0.15);
  --hl-cue: rgba(222, 160, 20, 0.25);
  --hl-emph: rgba(239, 58, 45, 0.15);
  --hl-sec: rgba(21, 23, 27, 0.07);
  --c-cmd: #3563ff;
  --c-cue: #b57b00;
  --c-emph: #e0352a;
  --shadow-sheet: 0 1px 2px rgba(20, 30, 45, 0.05), 0 16px 40px -18px rgba(20, 30, 45, 0.22);
  --shadow-ctl: 0 1px 2px rgba(20, 30, 45, 0.14), 0 0 0 1px rgba(20, 30, 45, 0.04);
  --r-sheet: 18px;
  --r-card: 14px;
  --r-ctl: 9px;
  --ui: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Unbounded", "Onest", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #111316;
    --panel: #171a1e;
    --sheet: #1c1f24;
    --ink: #eceef1;
    --ink-2: #c7ccd3;
    --muted: #8e96a1;
    --line: #2d3238;
    --line-soft: #24292e;
    --track: #33393f;
    --chip: #23272c;
    --on: #eceef1;
    --knob: #1c1f24;
    --focus: #809dff;
    --metal: #3a3f46;
    --metal-deep: #2c3036;
    --bezel: #08090a;
    --hl-cmd: rgba(128, 157, 255, 0.22);
    --hl-cue: rgba(232, 170, 40, 0.24);
    --hl-emph: rgba(255, 96, 84, 0.22);
    --hl-sec: rgba(255, 255, 255, 0.07);
    --c-cmd: #8aa5ff;
    --c-cue: #e6b44a;
    --c-emph: #ff6b5f;
    --shadow-sheet: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px -18px rgba(0, 0, 0, 0.7);
    --shadow-ctl: 0 1px 2px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--canvas);
  color: var(--ink);
  font: 15px/1.45 var(--ui);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Режимы: в простом прячем настройки «Про», в «Про» — упрощённые дубли */
body[data-mode="simple"] [data-pro],
body[data-mode="pro"] [data-simple] { display: none !important; }

/* ——— Верхняя панель ——— */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 18px;
  padding: 14px 28px;
  background: color-mix(in srgb, var(--canvas) 86%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 11px; }
.wordmark { font: 600 19px/1 var(--display); letter-spacing: -0.02em; }
.tally {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--tally);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tally) 20%, transparent), 0 0 12px var(--tally-glow);
}
.stats { flex: 1; min-width: 0; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats b { color: var(--ink); font-weight: 600; }
.actions { display: flex; align-items: center; gap: 8px; }
/* Переключатель языка: кнопка с глобусом и выпадающее меню */
.lang-menu { position: relative; }
.lang-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 10px 0 11px;
  border: 1px solid transparent; border-radius: 999px;
  background: transparent; color: var(--ink-2);
  font-size: 13.5px; font-weight: 600; letter-spacing: 0.02em;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.lang-trigger:hover, .lang-trigger[aria-expanded="true"] { background: var(--sheet); border-color: var(--line); color: var(--ink); }
.lang-trigger svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.lang-globe { width: 17px; height: 17px; stroke-width: 1.6; opacity: 0.85; }
.lang-chevron { width: 9px; height: 6px; stroke-width: 1.6; opacity: 0.6; transition: transform 0.18s; }
.lang-trigger[aria-expanded="true"] .lang-chevron { transform: rotate(180deg); }
.lang-list {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 20;
  width: 212px; padding: 6px;
  border-radius: var(--r-card);
  background: var(--sheet);
  border: 1px solid var(--line-soft);
  box-shadow: 0 1px 2px rgba(20, 30, 45, 0.06), 0 18px 40px -14px rgba(20, 30, 45, 0.3);
  transform-origin: top right;
  animation: menu-in 0.14s ease-out;
}
.lang-list[hidden] { display: none; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(0.97); } to { opacity: 1; transform: none; } }
.lang-list a {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  height: 42px; padding: 0 36px 0 12px;
  border-radius: 9px;
  color: var(--ink); text-decoration: none;
  outline: none;
}
.lang-list a:hover, .lang-list a:focus-visible { background: var(--chip); }
.lang-list a:focus-visible { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--focus) 55%, transparent); }
.lang-name { font-weight: 500; }
.lang-code { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; }
.lang-list a[aria-checked="true"]::after {
  content: ""; position: absolute; right: 15px; top: 50%;
  width: 9px; height: 5px; margin-top: -4px;
  border-left: 2px solid var(--tally); border-bottom: 2px solid var(--tally);
  transform: rotate(-45deg);
}

.btn {
  display: inline-flex; align-items: center; gap: 9px;
  height: 40px; padding: 0 17px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--sheet);
  font-weight: 500; white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.btn:hover { border-color: var(--muted); }
.btn-rec {
  padding: 0 19px 0 15px;
  border-color: transparent;
  background: var(--tally); color: #fff; font-weight: 600;
  box-shadow: 0 8px 20px -8px var(--tally-glow), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn-rec:hover { background: var(--tally-deep); border-color: transparent; }
/* «Начать чтение»: основная часть запускает, стрелка справа открывает варианты */
.split { position: relative; display: inline-flex; border-radius: 999px; box-shadow: 0 8px 20px -8px var(--tally-glow); }
.split .btn-rec { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18); }
.split-main { border-top-right-radius: 0; border-bottom-right-radius: 0; padding-right: 15px; }
.split-toggle {
  padding: 0 13px 0 11px;
  border-top-left-radius: 0; border-bottom-left-radius: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.3) !important;
}
.split-toggle svg { width: 10px; height: 6px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.18s; }
.split-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.start-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 20;
  min-width: 240px; max-width: 320px; padding: 6px;
  border-radius: var(--r-card);
  background: var(--sheet); color: var(--ink);
  border: 1px solid var(--line-soft);
  box-shadow: 0 1px 2px rgba(20, 30, 45, 0.06), 0 18px 40px -14px rgba(20, 30, 45, 0.3);
  transform-origin: top right;
  animation: menu-in 0.14s ease-out;
}
.start-menu[hidden], .start-menu-sections[hidden] { display: none; }
.start-menu button {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; height: 40px; padding: 0 12px;
  border: 0; border-radius: 9px; background: transparent;
  color: var(--ink); font-size: 14px; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  outline: none;
}
.start-menu button:hover, .start-menu button:focus-visible { background: var(--chip); }
.start-menu button:focus-visible { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--focus) 55%, transparent); }
.start-menu kbd { color: var(--muted); border-color: var(--line); background: var(--chip); font-size: 11.5px; }
.start-menu-sections { margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--line-soft); }
.start-menu-label { padding: 4px 12px 2px; color: var(--muted); font-size: 12.5px; }
.start-menu-sections button { color: var(--ink-2); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.28); }

/* ——— Раскладка ——— */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
  gap: 22px;
  padding: 6px 28px 28px;
  align-items: start;
}
.editor-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* ——— Лист со сценарием ——— */
.sheet {
  display: flex; flex-direction: column;
  min-height: calc(100vh - 150px);
  background: var(--sheet);
  border-radius: var(--r-sheet);
  box-shadow: var(--shadow-sheet);
  overflow: hidden;
}
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 12px;
  border: 1px solid var(--line-soft); border-radius: 999px;
  background: var(--chip); color: var(--ink-2);
  font-size: 13.5px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover { background: var(--sheet); border-color: var(--line); color: var(--ink); }
.glyph { font-weight: 700; letter-spacing: -0.03em; color: var(--c-cmd); }
.glyph-emph { color: var(--c-emph); }
.glyph-cue { color: var(--c-cue); letter-spacing: 0; }
.glyph-sec { color: var(--muted); }
.toolbar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }

/* Редактор: прозрачный textarea поверх слоя с подсветкой разметки */
.editor { position: relative; flex: 1; min-height: 460px; }
.editor-mirror, .editor textarea {
  position: absolute; inset: 0;
  margin: 0; border: 0;
  padding: 30px max(36px, calc((100% - 70ch) / 2)) 56px;
  font: 18.5px/1.8 var(--ui);
  letter-spacing: normal;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  tab-size: 4;
  overflow-y: scroll;
  scrollbar-gutter: stable;
}
.editor-mirror { color: transparent; pointer-events: none; }
.editor textarea { background: transparent; resize: none; outline: none; caret-color: var(--tally); color: var(--ink); }
.editor textarea::placeholder { color: var(--muted); }
.editor-mirror mark { color: transparent; border-radius: 4px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.editor-mirror .m-cmd { background: var(--hl-cmd); }
.editor-mirror .m-cue { background: var(--hl-cue); }
.editor-mirror .m-emph { background: var(--hl-emph); }
.editor-mirror .m-sec { background: var(--hl-sec); }

/* ——— Шпаргалка ——— */
.cheatsheet summary {
  list-style: none;
  display: inline-flex; align-items: center; gap: 9px;
  padding: 6px 4px;
  color: var(--ink-2); font-weight: 500;
  cursor: pointer;
}
.cheatsheet summary::-webkit-details-marker { display: none; }
.cheatsheet summary::before {
  content: ""; width: 7px; height: 7px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg); transition: transform 0.15s;
}
.cheatsheet[open] summary::before { transform: rotate(45deg) translate(-2px, -2px); }
.cheatsheet dl {
  display: grid; grid-template-columns: max-content 1fr; gap: 11px 22px;
  margin: 8px 0 0; padding: 18px 20px;
  background: var(--sheet);
  border-radius: var(--r-card);
  border: 1px solid var(--line-soft);
}
.cheatsheet dt { white-space: nowrap; }
.cheatsheet dd { margin: 0; color: var(--muted); max-width: 70ch; }
code {
  font: 12.5px/1 "JetBrains Mono", ui-monospace, monospace;
  padding: 3px 6px; border-radius: 5px;
  background: var(--hl-cmd); color: var(--ink);
}

/* ——— О Суфлёре ——— */
.about {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 20px 48px;
  margin: 12px 28px 36px; padding: 32px 36px;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
}
.about h2 { margin: 0 0 12px; font: 600 20px/1.3 var(--display); letter-spacing: -0.02em; color: var(--ink); }
.about-intro p { margin: 0; line-height: 1.6; max-width: 60ch; }
.about-faq { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 20px 32px; }
.about-faq dt { font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.about-faq dd { margin: 0; line-height: 1.55; color: var(--muted); }
.about-faq div { min-width: 0; }
.about-meta { grid-column: 1 / -1; margin: 8px 0 0; color: var(--muted); font-size: 13.5px; }
.about-meta a { color: var(--ink-2); text-underline-offset: 3px; }

/* ——— Панель настроек ——— */
.settings-col {
  position: sticky; top: 74px;
  max-height: calc(100vh - 92px);
  overflow-y: auto;
  padding: 18px 18px 22px;
  border-radius: var(--r-sheet);
  background: var(--panel);
  border: 1px solid var(--line-soft);
  display: flex; flex-direction: column;
  scrollbar-width: thin;
}
.group {
  border: 0; margin: 0; padding: 18px 0 2px;
  display: flex; flex-direction: column; gap: 13px;
  border-top: 1px solid var(--line-soft);
  min-width: 0;
}
.monitor + .group { border-top: 0; padding-top: 14px; }
.group + .group { margin-top: 16px; }
.group legend { float: left; width: 100%; padding: 0; margin: 0 0 2px; font-weight: 600; font-size: 13px; color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 12px; }
.row > span { color: var(--ink-2); }
.row output { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }
.row input[type="range"] { grid-column: 1 / -1; }
.hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.link { align-self: flex-start; border: 0; background: none; padding: 2px 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; font-size: 13.5px; }
.link:hover { color: var(--ink); }

/* Ползунок: тонкая дорожка с заливкой до значения (--p ставит app.js) */
input[type="range"] {
  --p: 50%;
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; margin: 0;
  background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(to right, var(--on) 0 var(--p), var(--track) var(--p) 100%);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px; margin-top: -7px; border-radius: 50%;
  background: #fff; border: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22), 0 3px 10px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(0, 0, 0, 0.06);
  transition: transform 0.12s;
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 999px; background: var(--track); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--on); }
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border: 0; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22), 0 3px 10px rgba(0, 0, 0, 0.14);
}
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 40%, transparent), 0 1px 2px rgba(0, 0, 0, 0.22); }

/* Переключатель вместо чекбокса */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; cursor: pointer; color: var(--ink-2); }
.switch input {
  -webkit-appearance: none; appearance: none;
  position: relative; flex: none;
  width: 38px; height: 22px; margin: 0;
  border-radius: 999px; background: var(--track);
  cursor: pointer; transition: background 0.18s;
}
.switch input::before {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s;
}
.switch input:checked { background: var(--on); }
.switch input:checked::before { transform: translateX(16px); background: var(--knob); }

/* Сегменты */
.seg {
  display: inline-flex; gap: 2px; padding: 3px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid var(--line-soft);
}
.seg button {
  height: 28px; padding: 0 12px;
  border: 0; border-radius: 999px;
  background: transparent; color: var(--muted);
  font-size: 13.5px; white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-checked="true"],
.seg button[aria-selected="true"] { background: var(--sheet); color: var(--ink); font-weight: 500; box-shadow: var(--shadow-ctl); }
.mode-switch { background: color-mix(in srgb, var(--ink) 6%, transparent); }

.row select {
  -webkit-appearance: none; appearance: none;
  height: 32px; padding: 0 32px 0 13px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--sheet) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b727c' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;
}
.pauses { grid-template-columns: 1fr repeat(3, auto); }
.pauses > span { white-space: nowrap; }
.pauses label { display: flex; align-items: center; gap: 4px; }
.pauses input {
  width: 54px; height: 30px; padding: 0 6px;
  border: 1px solid var(--line); border-radius: var(--r-ctl);
  background: var(--sheet); text-align: center; font-variant-numeric: tabular-nums;
}
.pauses small { color: var(--c-cmd); font-weight: 700; font-size: 12px; min-width: 18px; }

/* Время выступления */
.duration {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 1px 12px;
  padding: 14px 16px;
  border-radius: var(--r-card);
  background: var(--sheet);
  border: 1px solid var(--line-soft);
}
.duration-label { color: var(--ink-2); font-weight: 500; }
.duration-note { grid-column: 1; grid-row: 2; color: var(--muted); font-size: 12.5px; }
.duration-value { grid-column: 2; grid-row: 1 / span 2; display: flex; align-items: baseline; gap: 5px; }
.duration-value .approx { color: var(--muted); font-size: 18px; }
.duration-value b { font: 500 32px/1 var(--display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }

/* ——— Мини-монитор с камерой ——— */
.monitor { margin: 0; display: flex; flex-direction: column; align-items: center; }
.monitor-body {
  position: relative; width: 100%;
  padding: 13px 8px 9px;
  border-radius: 13px;
  background: var(--bezel);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04) inset, 0 18px 30px -18px rgba(0, 0, 0, 0.55);
}
.cam { position: absolute; top: 4px; left: 50%; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: #3a3f47; box-shadow: 0 0 0 1.5px #25282d; }
.cam-led { position: absolute; top: 5px; left: calc(50% + 9px); width: 3px; height: 3px; border-radius: 50%; background: #2a2d32; transition: background 0.2s, box-shadow 0.2s; }
.monitor.live .cam-led { background: var(--tally); box-shadow: 0 0 6px 1px var(--tally-glow); }
.monitor-screen {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: 3px;
  overflow: hidden;
  isolation: isolate;
  background: var(--bg); color: var(--fg);
}
.monitor-block {
  position: absolute;
  transform: translate(-50%, -50%);
  outline: 1px dashed color-mix(in srgb, var(--fg) 30%, transparent);
  outline-offset: 2px;
  display: flex; justify-content: center;
}
.monitor.live .monitor-block { outline-color: transparent; }
.monitor-word { white-space: pre; line-height: 1.25; }
.monitor-play {
  position: absolute; right: 7px; bottom: 7px;
  height: 24px; padding: 0 10px 0 9px;
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--fg) 18%, transparent);
  background: color-mix(in srgb, var(--fg) 9%, transparent);
  color: color-mix(in srgb, var(--fg) 85%, transparent);
  font-size: 11.5px;
  backdrop-filter: blur(6px);
}
.monitor-play::before { content: ""; border-left: 7px solid currentColor; border-top: 4.5px solid transparent; border-bottom: 4.5px solid transparent; }
.monitor.live .monitor-play::before { border: 0; width: 7px; height: 7px; background: currentColor; border-radius: 1px; }
.monitor-play:hover { background: color-mix(in srgb, var(--fg) 16%, transparent); }
.monitor-stand { position: relative; width: 16%; height: 16px; background: linear-gradient(var(--metal-deep), var(--metal)); clip-path: polygon(22% 0, 78% 0, 90% 100%, 10% 100%); }
.monitor figcaption { position: relative; margin-top: 0; padding-top: 11px; color: var(--muted); font-size: 12.5px; }
.monitor figcaption::before {
  content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 132px; height: 5px; border-radius: 3px;
  background: var(--metal);
}

/* ——— Запись видео ——— */
.rec-body { display: flex; flex-direction: column; gap: 13px; }
body:not([data-record="true"]) .rec-body { display: none; }
/* Дубли с прошлого раза видны, даже если запись сейчас выключена */
body:not([data-record="true"]) #takesOpen:disabled { display: none; }
.cam-preview {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-card);
  overflow: hidden;
  background: #0d0f12;
}
.cam-preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: none; }
.cam-preview.on video { display: block; }
.cam-preview-btn {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  height: 32px; padding: 0 14px;
  border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1); color: #fff;
  font-size: 13px; white-space: nowrap;
}
.cam-preview-btn:hover { background: rgba(255, 255, 255, 0.18); }
.cam-preview.on .cam-preview-btn { left: auto; top: auto; right: 8px; bottom: 18px; transform: none; height: 26px; padding: 0 10px; font-size: 12px; backdrop-filter: blur(6px); }
.mic-meter { position: absolute; left: 10px; right: 10px; bottom: 7px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.2); overflow: hidden; display: none; }
.cam-preview.on .mic-meter { display: block; }
.mic-meter i { display: block; height: 100%; background: #3ddc84; transform-origin: left center; transform: scaleX(0); transition: transform 0.06s linear; }
.cam-info {
  position: absolute; left: 8px; top: 8px;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.55); color: #fff;
  font-size: 11.5px; font-variant-numeric: tabular-nums;
  display: none;
}
.cam-preview.on .cam-info:not(:empty) { display: block; }
.seg button:disabled { opacity: 0.35; cursor: default; }
.seg button:disabled:hover { color: var(--muted); }
.rec-error { margin: 0; color: var(--c-emph); font-size: 13px; line-height: 1.4; }
.row select { max-width: 210px; text-overflow: ellipsis; }
.btn-small { height: 32px; padding: 0 14px; font-size: 13.5px; align-self: flex-start; }
.btn-small:disabled { opacity: 0.5; cursor: default; }
.btn-small:disabled:hover { border-color: var(--line); }

/* Себя за текстом: камера как зеркало, приглушённая цветом темы */
.cam-layer { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: none; }
[data-selfview="true"] > .cam-layer { display: block; }
[data-selfview="true"]::after {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: color-mix(in srgb, var(--bg) 42%, transparent);
}
.monitor-screen[data-selfview="true"] > :not(.cam-layer),
.stage[data-selfview="true"] > :not(.cam-layer) { z-index: 1; }
.stage[data-selfview="true"] .word,
.monitor-screen[data-selfview="true"] .monitor-word { text-shadow: 0 1px 2px color-mix(in srgb, var(--bg) 70%, transparent), 0 0 18px color-mix(in srgb, var(--bg) 55%, transparent); }

/* Список дублей */
.dialog-wide { width: min(760px, calc(100% - 32px)); }
.takes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.take { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: center; padding: 12px; border-radius: var(--r-card); background: var(--chip); }
.take video { width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; background: #000; }
.take-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.take-info b { font-weight: 600; }
.take-info span { color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.take-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.take-actions .btn { text-decoration: none; }
.take-actions .confirm { border-color: var(--c-emph); color: var(--c-emph); }
.takes-empty { color: var(--muted); padding: 8px 0; }

/* ——— Автоматическая разметка ——— */
.auto-link, .inline-link {
  border: 0; background: none; padding: 0;
  color: var(--c-cmd); font-weight: 500;
  text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--c-cmd) 35%, transparent);
  text-underline-offset: 3px;
}
.auto-link { margin-left: auto; font-size: 13.5px; padding: 0 4px; }
.auto-link:hover, .inline-link:hover { text-decoration-color: currentColor; }

.dialog {
  width: min(540px, calc(100% - 32px));
  max-height: calc(100vh - 48px);
  padding: 0; border: 0;
  border-radius: var(--r-sheet);
  background: var(--sheet); color: var(--ink);
  box-shadow: 0 30px 80px -30px rgba(10, 15, 25, 0.5);
}
.dialog::backdrop { background: rgba(15, 18, 24, 0.38); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.dialog[open] { animation: dialog-in 0.18s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.dialog-body { position: relative; padding: 26px 28px 28px; }
.dialog h2 { margin: 0 36px 8px 0; font: 600 20px/1.25 var(--display); letter-spacing: -0.02em; }
.dialog h3 { margin: 24px 0 8px; font-size: 15px; font-weight: 600; }
.dialog p { margin: 0; color: var(--ink-2); line-height: 1.55; }
.dialog-lead { margin-bottom: 18px !important; }
.dialog-steps { margin: 0; display: grid; gap: 4px; }
.dialog-steps dt { font-weight: 500; margin-top: 8px; }
.dialog-steps dd { margin: 0; color: var(--ink-2); line-height: 1.55; }
.dialog .code-block { display: block; margin-top: 6px; padding: 10px 12px; border-radius: var(--r-ctl); background: var(--chip); font-size: 13px; line-height: 1.4; user-select: all; overflow-x: auto; white-space: nowrap; }
.dialog-close {
  position: absolute; top: 18px; right: 18px;
  width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: var(--chip);
}
.dialog-close::before, .dialog-close::after {
  content: ""; position: absolute; top: 50%; left: 50%;
  width: 13px; height: 1.5px; background: var(--ink-2);
}
.dialog-close::before { transform: translate(-50%, -50%) rotate(45deg); }
.dialog-close::after { transform: translate(-50%, -50%) rotate(-45deg); }
.dialog-close:hover { background: var(--line-soft); }
.dialog-tabs { display: flex; margin-bottom: 18px; }
.dialog-tabs button { flex: 1; height: 32px; }
.dialog-panel > p { margin-bottom: 16px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.dialog-actions .btn:disabled { opacity: 0.45; cursor: default; }
.dialog-actions .btn.copied { border-color: var(--c-cmd); color: var(--c-cmd); }
.dialog-actions .btn-dark.copied { background: var(--c-cmd); color: #fff; }
.prompt-preview summary {
  list-style: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--ink-2); font-weight: 500;
}
.prompt-preview summary::-webkit-details-marker { display: none; }
.prompt-preview summary::before {
  content: ""; width: 6px; height: 6px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg); transition: transform 0.15s;
}
.prompt-preview[open] summary::before { transform: rotate(45deg) translate(-2px, -2px); }
.prompt-preview pre {
  margin: 10px 0 0; padding: 14px 16px;
  max-height: 280px; overflow: auto;
  border-radius: var(--r-ctl);
  background: var(--chip); color: var(--ink-2);
  font: 12.5px/1.55 var(--ui);
  white-space: pre-wrap;
}
.btn-dark { background: var(--ink); color: var(--sheet); border-color: transparent; text-decoration: none; font-weight: 600; }
.btn-dark:hover { border-color: transparent; opacity: 0.9; }

/* ——— Сцена чтения ——— */
.stage, .monitor-screen {
  --bg: #000; --fg: #f2f2f2; --pivot: #ff3b30; --emph: #ffc53d; --dim: rgba(255, 255, 255, 0.42); --hud-bg: rgba(26, 28, 32, 0.78); --hud-line: rgba(255, 255, 255, 0.12);
}
[data-theme="light"] { --bg: #fff; --fg: #111418; --pivot: #d92b20; --emph: #1f5be0; --dim: rgba(0, 0, 0, 0.45); --hud-bg: rgba(246, 247, 249, 0.86); --hud-line: rgba(0, 0, 0, 0.1); }
[data-theme="amber"] { --bg: #000; --fg: #ffc940; --pivot: #ffffff; --emph: #ff7a45; --dim: rgba(255, 201, 64, 0.45); }
.stage {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg); color: var(--fg);
  font-family: var(--ui);
  user-select: none;
  overflow: hidden;
}
.stage[data-state="playing"], .stage[data-state="countdown"] { cursor: none; }
.stage-inner { position: absolute; inset: 0; }
.stage[data-flip="true"] .stage-inner { transform: scaleX(-1); }

.block { position: absolute; transform: translate(-50%, -50%); padding: 0 16px; touch-action: none; }
.stage[data-frame="true"] .block,
.stage[data-state="paused"] .block,
.stage[data-state="ended"] .block { outline: 1px dashed var(--dim); outline-offset: 8px; border-radius: 4px; }
.stage[data-state="paused"] .block { cursor: grab; }
.stage.dragging .block { cursor: grabbing; }

.line { position: relative; display: flex; align-items: center; justify-content: center; }
.word { width: 100%; white-space: pre; line-height: 1.2; text-align: center; }
.word.orp { display: grid; grid-template-columns: 1fr auto 1fr; }
.word .pre { text-align: right; }
.word .post { text-align: left; }
.word .pivot { color: var(--pivot); }
.word .emph { color: var(--emph); text-decoration: underline; text-decoration-thickness: 0.05em; text-underline-offset: 0.14em; }
.word .pivot.emph { color: var(--pivot); text-decoration-color: var(--emph); }
.word.countdown { color: var(--pivot); font-variant-numeric: tabular-nums; animation: count-in 0.9s ease-out; }
.word.status { color: var(--dim); font-size: 0.36em !important; letter-spacing: 0.01em; }
@keyframes count-in { from { opacity: 0.2; transform: scale(1.18); } to { opacity: 1; transform: scale(1); } }

.guide { position: absolute; left: 50%; width: 2px; height: 0.2em; background: var(--dim); transform: translateX(-50%); display: none; font-style: normal; border-radius: 1px; }
.guide-top { top: -0.12em; }
.guide-bottom { bottom: -0.12em; }
.stage[data-guides="true"][data-align="orp"] .guide { display: block; }

.cue {
  position: absolute; left: 0; right: 0; bottom: 100%;
  text-align: center;
  color: var(--dim);
  font-size: max(14px, 0.26em);
  font-style: italic;
  padding-bottom: 0.55em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transition: opacity 0.15s;
}
.cue.on { opacity: 1; }
.cue::before { content: "("; } .cue::after { content: ")"; }

.pausebar { position: absolute; left: 30%; right: 30%; top: 100%; height: 3px; margin-top: 0.3em; opacity: 0; }
.pausebar i { display: block; height: 100%; width: 100%; background: var(--dim); border-radius: 2px; transform-origin: center; }
.pausebar.on { opacity: 1; }

.handle { position: absolute; top: 50%; width: 8px; height: 40px; margin-top: -20px; border-radius: 4px; background: var(--dim); display: none; cursor: ew-resize; }
.handle-l { left: -12px; } .handle-r { right: -12px; }
.stage[data-state="paused"] .handle { display: block; }

.stage-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: color-mix(in srgb, var(--dim) 30%, transparent); display: none; }
.stage-progress i { display: block; height: 100%; width: 0; background: var(--pivot); }
.stage[data-progress="true"] .stage-progress,
.stage[data-state="paused"] .stage-progress,
.stage[data-state="ended"] .stage-progress { display: block; }

.toast {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  padding: 8px 15px; border-radius: 999px;
  background: var(--hud-bg); color: var(--fg); border: 1px solid var(--hud-line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  font-size: 14px; font-variant-numeric: tabular-nums;
  opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.toast.on { opacity: 1; }

.rec-badge {
  position: absolute; left: 18px; bottom: 16px;
  display: none; align-items: center; gap: 7px;
  color: var(--dim); font-size: 13px; font-variant-numeric: tabular-nums;
}
.rec-badge i { width: 8px; height: 8px; border-radius: 50%; background: var(--pivot); }
.stage[data-rec="recording"] .rec-badge,
.stage[data-rec="paused"] .rec-badge { display: flex; }
.stage[data-rec="paused"] .rec-badge i { background: var(--dim); }
.stage[data-state="paused"] .rec-badge,
.stage[data-state="ended"] .rec-badge { display: none; }

/* Панель на паузе */
.hud { position: absolute; inset: 0; pointer-events: none; display: none; }
.stage[data-state="paused"] .hud,
.stage[data-state="ended"] .hud { display: block; }
.hud-top { position: absolute; top: 16px; left: 18px; right: 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.hud-top > * { pointer-events: auto; }
.hud-where { color: var(--dim); font-size: 14px; font-variant-numeric: tabular-nums; }
.hud-panel {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%);
  width: min(780px, calc(100% - 32px));
  padding: 18px 20px;
  border-radius: 20px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-line);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.7);
  display: flex; flex-direction: column; gap: 14px;
  pointer-events: auto;
}
.hud-context { margin: 0; font-size: 17px; line-height: 1.55; color: var(--dim); max-height: 4.65em; overflow: hidden; }
.hud-context .cur { color: var(--fg); background: color-mix(in srgb, var(--pivot) 28%, transparent); border-radius: 4px; padding: 0 3px; }
.hud-context:empty { display: none; }
.hud-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.hud-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--hud-line);
  background: color-mix(in srgb, var(--fg) 5%, transparent); color: var(--fg);
  font-size: 14px;
  transition: background 0.15s, border-color 0.15s;
}
.hud-btn:hover { background: color-mix(in srgb, var(--fg) 10%, transparent); border-color: var(--dim); }
.hud-play { background: var(--pivot); border-color: transparent; color: #fff; font-weight: 600; }
.hud-play:hover { background: var(--pivot); border-color: transparent; filter: brightness(0.92); }
.stage[data-theme="amber"] .hud-play { color: #000; }
.hud-keys { margin: 0; color: var(--dim); font-size: 13px; line-height: 2; }
kbd {
  font: 12px/1 var(--ui);
  padding: 3px 6px; border-radius: 5px;
  border: 1px solid var(--hud-line);
  background: color-mix(in srgb, var(--fg) 8%, transparent);
  margin-right: 2px;
}
.hud-play kbd { border-color: rgba(255, 255, 255, 0.35); background: rgba(255, 255, 255, 0.14); }
.hud-sections { display: flex; flex-wrap: wrap; gap: 6px; }
.hud-sections:empty { display: none; }
.hud-sections button {
  height: 28px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--hud-line); background: transparent; color: var(--dim);
  font-size: 13px;
}
.hud-sections button:hover { color: var(--fg); }
.hud-sections button[aria-current="true"] { color: var(--fg); border-color: var(--fg); }

/* Иконки и степперы на паузе (на всех устройствах) */
.hud-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hud-exit svg { width: 16px; height: 16px; }
.hud-steppers { display: flex; flex-wrap: wrap; gap: 8px; }
.stepper {
  display: inline-flex; align-items: center;
  height: 38px; border-radius: 999px;
  border: 1px solid var(--hud-line);
  background: color-mix(in srgb, var(--fg) 5%, transparent);
}
.stepper button {
  width: 40px; height: 100%; border: 0; border-radius: 999px;
  background: transparent; color: var(--fg); font-size: 16px; font-weight: 600;
}
.stepper button:hover { background: color-mix(in srgb, var(--fg) 10%, transparent); }
.stepper span { min-width: 88px; text-align: center; color: var(--fg); font-size: 13.5px; font-variant-numeric: tabular-nums; }
[data-facing="environment"] > .cam-layer, .cam-preview[data-facing="environment"] video { transform: none; }

/* Элементы только для телефона или только для компьютера */
html:not([data-device="mobile"]) [data-mobile] { display: none !important; }
html[data-device="mobile"] [data-desktop] { display: none !important; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 999px;
  border: 1px solid transparent; background: transparent; color: var(--ink-2);
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ——— Узкие экраны ——— */
@media (max-width: 960px) {
  .about { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 1fr; }
  .settings-col { position: static; max-height: none; }
  .sheet { min-height: 70vh; }
}
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .stats { order: 3; flex-basis: 100%; }
  .actions { margin-left: auto; }
  .btn { padding: 0 13px; height: 38px; }
  .btn-rec { padding: 0 14px 0 12px; }
  .layout { padding: 4px 12px 16px; gap: 14px; }
  .toolbar { padding: 10px 12px; }
  .editor-mirror, .editor textarea { padding: 20px 18px 40px; font-size: 17px; }
  .cheatsheet dl { grid-template-columns: 1fr; gap: 2px; }
  .cheatsheet dd { margin-bottom: 8px; }
  .hud-keys { display: none; }
  .take { grid-template-columns: 1fr; }
  .about { margin: 8px 12px 24px; padding: 24px 4px; }
  .about-faq { grid-template-columns: 1fr; }
}


/* ——— Телефоны и планшеты: интерфейс как у приложения ——— */
html[data-device="mobile"] body { -webkit-tap-highlight-color: transparent; }
html[data-device="mobile"] :is(button, a, .stage, .chip) { touch-action: manipulation; }
html[data-device="mobile"] :is(input, select, textarea) { font-size: 16px; } /* iOS не приближает поля от 16px */
html[data-device="mobile"] :is(kbd, .hud-keys) { display: none !important; }

/* Шапка: логотип, язык, настройки; строка с длительностью под ней */
html[data-device="mobile"] .topbar {
  z-index: 40; /* выше нижней панели: лист выбора языка открывается снизу поверх неё */
  flex-wrap: wrap; gap: 4px 6px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 6px 16px;
  background: var(--canvas); backdrop-filter: none; -webkit-backdrop-filter: none;
}
html[data-device="mobile"] .topbar .mode-switch { display: none; }
html[data-device="mobile"] .stats { order: 3; flex-basis: 100%; font-size: 13.5px; }
html[data-device="mobile"] .lang-menu { margin-left: auto; }
html[data-device="mobile"] .lang-trigger { height: 40px; }

/* Нижняя панель: запись и «Начать чтение» */
html[data-device="mobile"] .actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: var(--canvas);
  border-top: 1px solid var(--line-soft);
}
html[data-device="mobile"] .split { flex: 1; min-width: 0; }
html[data-device="mobile"] .split-main { flex: 1; justify-content: center; height: 54px; font-size: 16.5px; }
html[data-device="mobile"] .split-toggle { height: 54px; padding: 0 18px 0 15px; }
.rec-quick {
  position: relative; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 54px; height: 54px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--sheet); color: var(--ink-2);
}
.rec-quick svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.rec-quick[aria-pressed="true"] { border-color: var(--tally); color: var(--tally); background: color-mix(in srgb, var(--tally) 8%, var(--sheet)); }
.rec-quick[aria-pressed="true"]::after {
  content: ""; position: absolute; top: 10px; right: 10px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--tally); box-shadow: 0 0 0 2px var(--sheet);
}
html[data-device="mobile"] body.typing .actions { display: none; }

/* Сценарий на весь экран */
html[data-device="mobile"] .layout { display: block; padding: 2px 8px calc(92px + env(safe-area-inset-bottom)); }
html[data-device="mobile"] .editor-col { gap: 8px; }
html[data-device="mobile"] .sheet { min-height: calc(100dvh - 190px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); border-radius: 18px; }
html[data-device="mobile"] .toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 10px 12px; gap: 8px; }
html[data-device="mobile"] .toolbar::-webkit-scrollbar { display: none; }
html[data-device="mobile"] .toolbar .sep { display: none; }
html[data-device="mobile"] .chip { flex: none; height: 38px; padding: 0 15px; font-size: 15px; }
html[data-device="mobile"] .auto-link { flex: none; margin-left: 2px; padding: 0 6px; font-size: 15px; white-space: nowrap; }
html[data-device="mobile"] .chip-paste { order: -1; }
/* «Готово» всегда видна у правого края ленты, даже когда чипы прокручены */
html[data-device="mobile"] .chip-done {
  display: none; position: sticky; right: 0; margin-left: auto;
  font-weight: 600; color: var(--c-cmd); background: var(--sheet); border-color: var(--line);
  box-shadow: -14px 0 12px -2px var(--sheet);
}
html[data-device="mobile"] body.typing .chip-done { display: inline-flex; }
html[data-device="mobile"] .editor { min-height: 52dvh; }
html[data-device="mobile"] :is(.editor-mirror, .editor textarea) { padding: 14px 16px 48px; font-size: 17px; line-height: 1.7; }
html[data-device="mobile"] .cheatsheet { padding: 0 6px; }
html[data-device="mobile"] .about { margin: 8px 6px 0; padding: 24px 6px; }

/* Панель разметки прилипает к клавиатуре (сдвиг считает app.js по visualViewport) */
html[data-device="mobile"] body.typing .toolbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
  background: var(--sheet); border-top: 1px solid var(--line); border-bottom: 0;
  padding: 8px 10px;
}

/* Настройки — нижняя шторка */
html[data-device="mobile"] .settings-col {
  position: fixed; left: 0; right: 0; top: auto; bottom: 0; z-index: 45;
  max-height: 90dvh; overflow-y: auto; overscroll-behavior: contain;
  padding: 0 18px calc(24px + env(safe-area-inset-bottom));
  border: 0; border-radius: 22px 22px 0 0;
  box-shadow: 0 -18px 50px -20px rgba(0, 0, 0, 0.45);
  transform: translateY(105%); visibility: hidden;
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 0.28s;
}
html[data-device="mobile"] .settings-col.open { transform: none; visibility: visible; transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
html[data-device="mobile"] .settings-col.dragging { transition: none; }
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 44;
  background: rgba(10, 12, 16, 0.42);
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet-head {
  position: sticky; top: 0; z-index: 3;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  margin: 0 -18px 4px; padding: 20px 18px 12px;
  background: var(--panel);
  touch-action: none;
}
.sheet-grab { position: absolute; top: 8px; left: 50%; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: var(--line); }
.sheet-head h2 { grid-column: 2; margin: 0; font-size: 16.5px; font-weight: 600; }
.sheet-head .mode-switch { grid-column: 1; justify-self: start; }
.sheet-done { grid-column: 3; justify-self: end; border: 0; background: none; padding: 6px 2px; color: var(--c-cmd); font-size: 16px; font-weight: 600; }
html[data-device="mobile"] .monitor { max-width: 132px; margin: 0 auto 6px; }
html[data-device="mobile"] .monitor-body { padding: 6px; border-radius: 24px; }
html[data-device="mobile"] .monitor-screen { border-radius: 18px; }
html[data-device="mobile"] .cam { top: 13px; width: 32px; height: 9px; margin-left: -16px; border-radius: 6px; background: #000; box-shadow: none; z-index: 3; }
html[data-device="mobile"] .cam-led { display: none; }
html[data-device="mobile"] .monitor-stand, html[data-device="mobile"] .monitor figcaption::before { display: none; }
html[data-device="mobile"] .monitor figcaption { padding-top: 8px; text-align: center; }
html[data-device="mobile"] .monitor-play { right: 50%; transform: translateX(50%); bottom: 10px; white-space: nowrap; }
html[data-device="mobile"] .group { gap: 16px; }
html[data-device="mobile"] input[type="range"] { height: 34px; }
html[data-device="mobile"] input[type="range"]::-webkit-slider-thumb { width: 28px; height: 28px; margin-top: -11px; }
html[data-device="mobile"] input[type="range"]::-moz-range-thumb { width: 28px; height: 28px; }
html[data-device="mobile"] .seg button { height: 36px; padding: 0 14px; font-size: 15px; }
html[data-device="mobile"] .switch { min-height: 40px; font-size: 15.5px; }
html[data-device="mobile"] .switch input { width: 51px; height: 31px; }
html[data-device="mobile"] .switch input::before { width: 27px; height: 27px; }
html[data-device="mobile"] .switch input:checked::before { transform: translateX(20px); }
html[data-device="mobile"] .row > span { font-size: 15.5px; }
html[data-device="mobile"] .row select { height: 40px; max-width: 58vw; }
html[data-device="mobile"] .pauses input { height: 38px; width: 60px; }
html[data-device="mobile"] .btn-small { height: 42px; padding: 0 18px; font-size: 15px; }

/* Меню — листы снизу */
html[data-device="mobile"] :is(.lang-list, .start-menu) {
  position: fixed; left: 8px; right: 8px; top: auto; bottom: calc(8px + env(safe-area-inset-bottom));
  width: auto; max-width: none; max-height: 72dvh; overflow-y: auto;
  padding: 8px; border-radius: 20px; z-index: 50;
  box-shadow: 0 0 0 100vmax rgba(10, 12, 16, 0.42), 0 20px 50px -10px rgba(0, 0, 0, 0.4);
  transform-origin: bottom center; animation: sheet-in 0.2s ease-out;
}
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
html[data-device="mobile"] .lang-list a, html[data-device="mobile"] .start-menu button { height: 52px; font-size: 16.5px; border-radius: 12px; }

/* Окна — снизу на всю ширину */
html[data-device="mobile"] .dialog { width: 100%; max-width: 100%; max-height: 92dvh; margin: auto 0 0; border-radius: 22px 22px 0 0; }
html[data-device="mobile"] .dialog[open] { animation: sheet-in 0.22s ease-out; }
html[data-device="mobile"] .dialog-body { padding: 24px 18px calc(24px + env(safe-area-inset-bottom)); }
html[data-device="mobile"] .dialog-close { width: 36px; height: 36px; }
html[data-device="mobile"] .dialog-tabs button { height: 38px; font-size: 15px; }
html[data-device="mobile"] .dialog-actions .btn { flex: 1 1 100%; justify-content: center; height: 48px; font-size: 15.5px; }
/* Превью камеры на телефоне — кадр целиком, без обрезки: что видно, то и пишется */
html[data-device="mobile"] .cam-layer { object-fit: contain; background: #000; }
html[data-device="mobile"] .cam-preview { aspect-ratio: auto; height: 44dvh; }
html[data-device="mobile"] .cam-preview video { object-fit: contain; }
html[data-device="mobile"] .take { grid-template-columns: 1fr; }
html[data-device="mobile"] .take video { aspect-ratio: auto; max-height: 52dvh; object-fit: contain; }
html[data-device="mobile"] .take-actions .btn { flex: 1; justify-content: center; height: 44px; }

/* Чтение */
html[data-device="mobile"] .hud-top { top: calc(10px + env(safe-area-inset-top)); left: 16px; right: 12px; }
html[data-device="mobile"] .hud-where { font-size: 13px; }
html[data-device="mobile"] .hud-exit { width: 44px; height: 44px; padding: 0; justify-content: center; }
html[data-device="mobile"] .hud-exit svg { width: 20px; height: 20px; }
html[data-device="mobile"] .hud-panel {
  left: 0; right: 0; bottom: 0; transform: none; width: auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0; gap: 14px;
}
html[data-device="mobile"] .hud-context { font-size: 16px; }
html[data-device="mobile"] .hud-controls { flex-wrap: nowrap; gap: 10px; }
html[data-device="mobile"] .hud-btn { height: 52px; }
html[data-device="mobile"] .hud-icon { order: 1; width: 52px; padding: 0; justify-content: center; flex: none; }
html[data-device="mobile"] .hud-icon svg { width: 22px; height: 22px; }
html[data-device="mobile"] #hudRestart { order: 3; }
html[data-device="mobile"] .hud-play { order: 2; flex: 1; justify-content: center; font-size: 16.5px; }
html[data-device="mobile"] :is(.hud-exit, .hud-icon) .lbl { display: none; }
html[data-device="mobile"] .hud-steppers { flex-wrap: nowrap; }
html[data-device="mobile"] .stepper { flex: 1; height: 46px; justify-content: space-between; }
html[data-device="mobile"] .stepper button { width: 52px; font-size: 18px; }
html[data-device="mobile"] .stepper span { min-width: 0; font-size: 14px; }
html[data-device="mobile"] .hud-sections { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
html[data-device="mobile"] .hud-sections button { flex: none; height: 34px; font-size: 14px; }
html[data-device="mobile"] .rec-badge { left: 16px; bottom: calc(14px + env(safe-area-inset-bottom)); }
html[data-device="mobile"] .toast { top: calc(14px + env(safe-area-inset-top)); }
html[data-device="mobile"] .handle { width: 28px; height: 64px; margin-top: -32px; background: transparent; }
html[data-device="mobile"] .handle::after { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 36px; margin: -18px 0 0 -3px; border-radius: 3px; background: var(--dim); }
html[data-device="mobile"] .handle-l { left: -26px; }
html[data-device="mobile"] .handle-r { right: -26px; }

@media (prefers-reduced-motion: reduce) {
  .lang-list, .start-menu { animation: none; }
  html[data-device="mobile"] :is(.settings-col, .dialog[open], .lang-list, .start-menu) { transition: none; animation: none; }
  .dialog[open] { animation: none; }
  .cue, .toast, .switch input, .switch input::before, .chip, .btn { transition: none; }
  .word.countdown { animation: none; }
}
