:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #f7f7f7;
  --surface-high: #efefef;
  --line: #dddddd;
  --line-strong: #c3c3c3;
  --ink: #232323;
  --ink-strong: #0a0a0a;
  --ink-subtle: #505050;
  --ink-muted: #636363;
  --rec: #e10542;
  --rec-ink: #b8043a;
  --on-rec: #ffffff;
  --danger: #b32733;
  --waiting: #7d5010;
  --ok: #15702f;
  --warn-bg: #f6efe3;
  --scrim: rgba(0, 0, 0, 0.92);
  --shadow-pop: 0 8px 28px rgba(0, 0, 0, 0.18);

  --z-sticky: 10; --z-overlay: 100; --z-toast: 200;

  --xxs: 2px; --xs: 4px; --sm: 8px; --md: 12px; --lg: 16px;
  --xl: 20px; --xxl: 24px; --section: 32px; --block: 44px;

  --r-chip: 999px; --r-control: 10px; --r-card: 14px; --r-panel: 16px;
  --fast: 140ms; --normal: 200ms;
  --ease: cubic-bezier(0.25, 1, 0.5, 1);

  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", "Consolas", monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d;
  --surface: #161616;
  --surface-high: #1f1f1f;
  --line: #2c2c2c;
  --line-strong: #444444;
  --ink: #dedede;
  --ink-strong: #f6f6f6;
  --ink-subtle: #a9a9a9;
  --ink-muted: #898989;
  --rec: #ff3659;
  --rec-ink: #ff3659;
  --on-rec: #0a0a0a;
  --danger: #f66c6d;
  --waiting: #e3ad52;
  --ok: #3cc48b;
  --warn-bg: #241d10;
  --scrim: rgba(0, 0, 0, 0.92);
  --shadow-pop: 0 10px 34px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; flex: 0 0 auto; }
::selection { background: var(--ink-strong); color: var(--bg); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong); border-radius: 999px;
  border: 3px solid var(--bg); background-clip: padding-box;
}
::-webkit-scrollbar-track { background: transparent; }

/* ---------- каркас ---------- */

#shell { display: flex; height: 100vh; }

#rail {
  width: 84px; flex: 0 0 84px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center;
  padding: var(--lg) 0; gap: var(--xs);
  -webkit-app-region: drag;
}

#rail .brand {
  font-weight: 700; font-size: 11px; letter-spacing: 0.08em;
  color: var(--ink-muted); margin-bottom: var(--xl); text-align: center;
}

.rail-item {
  -webkit-app-region: no-drag;
  width: 64px; padding: var(--sm) 0; border: 0; background: transparent;
  border-radius: var(--r-control); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--ink-muted); transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.rail-item:hover { background: var(--surface-high); color: var(--ink); }
.rail-item[aria-current="page"] { background: var(--surface-high); color: var(--ink-strong); }
.rail-item svg { width: 20px; height: 20px; stroke-width: 1.7; }
.rail-item span { font-size: 11px; font-weight: 500; }

.rail-dot {
  width: 7px; height: 7px; border-radius: 999px; background: var(--rec);
  animation: pulse 1.6s var(--ease) infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

#content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#main { flex: 1; min-height: 0; display: flex; flex-direction: column; }

#livebar {
  flex: 0 0 auto; display: flex; align-items: center; gap: var(--md);
  padding: var(--sm) var(--block); font-size: 13.5px; font-weight: 500;
  border-bottom: 1px solid var(--line);
}
#livebar[hidden] { display: none; }
#livebar.rec { background: var(--rec); color: var(--on-rec); }
#livebar.lost { background: var(--danger); color: var(--bg); }
#livebar .live-time { font-family: var(--mono); font-variant-numeric: tabular-nums; }
#livebar .live-meter { display: flex; gap: 2px; height: 12px; align-items: center; width: 120px; }
#livebar .live-meter i { flex: 1; height: 100%; border-radius: 1px; background: currentColor; opacity: 0.25; }
#livebar .live-meter i.on { opacity: 1; }
#livebar .grow { flex: 1; }
#livebar svg { width: 18px; height: 18px; }
#livebar button {
  border: 1px solid currentColor; background: transparent; color: inherit;
  border-radius: var(--r-chip); padding: 3px 12px; font-size: 12px; cursor: pointer;
}

.page { flex: 1; overflow-y: auto; padding: var(--section) var(--block); }
.page.split { display: flex; padding: 0; overflow: hidden; }

h1.screen { font-size: 28px; line-height: 1.2; letter-spacing: -0.02em; font-weight: 600;
  margin: 0 0 var(--xxl); color: var(--ink-strong); }
h2.section { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-muted); margin: var(--section) 0 var(--md); }
h2.section:first-child { margin-top: 0; }

/* ---------- элементы ---------- */

.btn {
  -webkit-app-region: no-drag;
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink);
  border-radius: var(--r-control); padding: 9px 16px; cursor: pointer; font-weight: 500;
  min-height: 38px; display: inline-flex; align-items: center; gap: var(--sm);
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.btn:hover:not(:disabled) { background: var(--surface-high); border-color: var(--ink-muted); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--ink-strong); outline-offset: 2px; }
.btn.primary { background: var(--ink-strong); color: var(--bg); border-color: var(--ink-strong); }
.btn.primary:hover:not(:disabled) { opacity: 0.88; background: var(--ink-strong); }
.btn.rec { background: var(--rec); color: var(--on-rec); border-color: var(--rec); }
.btn.rec:hover:not(:disabled) { opacity: 0.9; background: var(--rec); }
.btn.ghost { border-color: transparent; color: var(--ink-subtle); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-high); color: var(--ink); }
.btn.danger { color: var(--danger); border-color: transparent; }
.btn.danger:hover:not(:disabled) { background: var(--surface-high); }
.btn svg { width: 17px; height: 17px; stroke-width: 1.8; }

.field { display: flex; flex-direction: column; gap: var(--sm); margin-bottom: var(--lg); }
.field > label { font-size: 13px; font-weight: 500; color: var(--ink-subtle); }
.hint { display: block; font-size: 12px; line-height: 1.5; color: var(--ink-muted); }
input[type="text"], input[type="number"], textarea, select {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-control);
  padding: 10px 12px; width: 100%; transition: border-color var(--fast) var(--ease);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--ink-strong); }
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--ink-strong); outline-offset: 2px;
}
::placeholder { color: var(--ink-muted); opacity: 1; }
textarea { resize: vertical; min-height: 96px; font-family: var(--mono); font-size: 13px; line-height: 1.6; }
select { cursor: pointer; }

.chips { display: flex; flex-wrap: wrap; gap: var(--sm); }
.chip {
  border: 1px solid var(--line); background: transparent; color: var(--ink-subtle);
  border-radius: var(--r-chip); padding: 7px 14px; cursor: pointer; font-size: 13px;
  font-weight: 500; display: inline-flex; align-items: center; gap: var(--sm);
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease),
              color var(--fast) var(--ease);
}
.chip:hover { border-color: var(--ink-muted); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink-strong); color: var(--bg); border-color: var(--ink-strong); }
.dot { width: 8px; height: 8px; border-radius: var(--r-chip); flex: 0 0 8px; }
.dot.lg { width: 10px; height: 10px; flex: 0 0 10px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-card); padding: var(--xl);
}

.badge {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 3px 9px; border-radius: var(--r-chip); background: var(--surface-high);
  color: var(--ink-muted); white-space: nowrap;
}
.badge.ready { color: var(--ok); }
.badge.work { color: var(--waiting); }
.badge.fail { color: var(--danger); }
.badge.rec { color: var(--rec-ink); }

.switch { display: flex; align-items: center; gap: var(--md); cursor: pointer; padding: var(--sm) 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch input:focus-visible + .track { outline: 2px solid var(--ink-strong); outline-offset: 2px; }
.switch .track {
  width: 40px; height: 23px; border-radius: 999px; background: var(--line-strong);
  position: relative; transition: background var(--fast) var(--ease); flex: 0 0 40px;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px;
  border-radius: 999px; background: var(--bg); transition: transform var(--fast) var(--ease);
}
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(17px); }

.empty { color: var(--ink-muted); text-align: center; padding: var(--block) var(--xl); }
.empty strong { display: block; color: var(--ink-subtle); font-weight: 600; margin-bottom: var(--sm); }

kbd {
  font-family: var(--mono); font-size: 11px; background: var(--surface-high);
  border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: 5px; padding: 2px 6px; color: var(--ink-subtle);
}

/* ---------- экран записи ---------- */

.record-panel {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--section);
  align-items: center; padding: var(--section); margin-bottom: var(--section);
  max-width: 900px;
}

.orb {
  width: 132px; height: 132px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--rec); color: var(--on-rec); display: grid; place-items: center;
  position: relative; transition: transform var(--fast) var(--ease);
}
.orb:hover { transform: scale(1.03); }
.orb:disabled { opacity: 0.5; cursor: default; transform: none; }
.orb svg { width: 46px; height: 46px; }
.orb.live::before {
  content: ""; position: absolute; inset: -14px; border-radius: 999px;
  background: var(--rec); opacity: 0.16; animation: halo 1.6s var(--ease) infinite;
}
@keyframes halo { 0%,100% { transform: scale(1); opacity: 0.16; } 50% { transform: scale(1.08); opacity: 0.05; } }

.timer {
  font-family: var(--mono); font-size: 54px; line-height: 1.05; letter-spacing: -0.02em;
  font-weight: 500; color: var(--ink-strong); font-variant-numeric: tabular-nums;
}
.timer.idle { color: var(--ink-muted); }

.meter { display: flex; gap: 3px; height: 26px; align-items: center; margin: var(--md) 0;
  max-width: 560px; }
.meter i {
  flex: 1; height: 100%; border-radius: 2px; background: var(--line);
  transition: background 90ms linear;
}
.meter i.on { background: var(--ink-subtle); }
.meter i.on.hot { background: var(--rec); }

.warn {
  background: var(--warn-bg);
  border: 1px solid var(--waiting); color: var(--ink);
  border-radius: var(--r-control); padding: var(--md) var(--lg); margin-bottom: var(--lg);
  display: flex; gap: var(--md); align-items: center; font-size: 14px;
}
.warn svg { width: 20px; height: 20px; flex: 0 0 20px; stroke-width: 1.8; color: var(--waiting); }

/* ---------- список лекций ---------- */

#list-pane {
  width: clamp(300px, 25vw, 460px); flex: 0 1 auto; border-right: 1px solid var(--line);
  overflow-y: auto; padding: var(--xl); background: var(--surface);
  transition: flex-basis var(--normal) var(--ease), width var(--normal) var(--ease);
}
#list-pane.collapsed { flex-basis: 0; width: 0; padding: 0; overflow: hidden; border-right: 0; }
#detail-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
#detail-pane.blank { overflow-y: auto; }
#tab-body { flex: 1; min-height: 0; overflow-y: auto; padding: var(--xxl) var(--section); }
#tab-body > .md, #tab-body > #segments { margin-inline: auto; }
.detail-top { padding: var(--lg) var(--section) 0; }

.lecture {
  width: 100%; text-align: left; border: 1px solid transparent; background: transparent;
  border-radius: var(--r-card); padding: var(--md) var(--lg); cursor: pointer;
  margin-bottom: var(--xs); transition: background var(--fast) var(--ease);
}
.lecture:hover { background: var(--surface-high); }
.lecture[aria-current="true"] { background: var(--surface-high); border-color: var(--line-strong); }
.lecture .row { display: flex; align-items: center; gap: var(--sm); }
.lecture .title { font-weight: 500; color: var(--ink-strong); flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lecture .meta { font-size: 12px; color: var(--ink-muted); margin-top: 3px;
  display: flex; gap: var(--md); align-items: center; }

.month { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-muted); padding: var(--lg) var(--lg) var(--sm); position: sticky; top: 0;
  background: var(--surface); z-index: var(--z-sticky); }

.progress { height: 3px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: var(--sm); }
.progress i { display: block; height: 100%; background: var(--waiting); transition: width var(--normal) var(--ease); }

/* ---------- деталь ---------- */

.detail-head { display: flex; align-items: center; gap: var(--md); margin-bottom: var(--md); }
.detail-head .who { flex: 1; min-width: 0; }
.detail-head h1 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; margin: 0;
  color: var(--ink-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: text; border-radius: 5px; }
.detail-head h1:focus { outline: 2px solid var(--ink-strong); outline-offset: 3px; white-space: normal; }
.detail-head .sub { font-size: 12.5px; color: var(--ink-muted); margin-top: 1px;
  display: flex; gap: var(--sm); flex-wrap: wrap; align-items: center; }
.detail-head .sub .sep { opacity: 0.5; }
.actions { display: flex; gap: var(--sm); flex-wrap: wrap; padding-bottom: var(--md); }

.banner {
  display: flex; align-items: center; gap: var(--md); margin-bottom: var(--md);
  border: 1px solid var(--line); background: var(--surface);
  border-radius: var(--r-control); padding: var(--sm) var(--md); font-size: 13px;
}
.banner.fail { border-color: var(--danger); color: var(--danger); }
.banner.work { border-color: var(--waiting); color: var(--ink); }
.banner .grow { flex: 1; }

.tabs { display: flex; gap: var(--xs); border-bottom: 1px solid var(--line);
  margin: 0 calc(-1 * var(--section)); padding: 0 var(--section); }
.tab {
  border: 0; background: transparent; color: var(--ink-muted); cursor: pointer;
  padding: var(--md) var(--lg); font-weight: 500; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color var(--fast) var(--ease);
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink-strong); border-bottom-color: var(--ink-strong); }

.playerbar {
  display: flex; align-items: center; gap: var(--md); background: var(--surface);
  border-bottom: 1px solid var(--line); padding: var(--sm) var(--section);
  flex: 0 0 auto;
}
.playerbar .time { font-family: var(--mono); font-size: 12.5px; color: var(--ink-subtle);
  font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.playerbar input[type="range"] {
  flex: 1; accent-color: var(--rec); cursor: pointer; min-width: 180px;
  height: 32px; background: transparent;
}
.playerbar input[type="range"]:focus-visible {
  outline: 2px solid var(--ink-strong); outline-offset: 2px; border-radius: var(--r-chip);
}
.playerbar .muted { font-size: 13px; color: var(--ink-muted); }

.play-btn {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 999px; border: 0;
  background: var(--ink-strong); color: var(--bg); cursor: pointer;
  display: grid; place-items: center; transition: opacity var(--fast) var(--ease);
}
.play-btn:hover { opacity: 0.85; }
.play-btn svg { width: 18px; height: 18px; }
.skip-btn {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 999px; border: 0;
  background: transparent; color: var(--ink-muted); cursor: pointer; display: grid; place-items: center;
}
.skip-btn:hover { background: var(--surface-high); color: var(--ink); }
.skip-btn svg { width: 17px; height: 17px; }

.follow {
  margin-left: auto; border: 1px solid var(--line); background: transparent;
  color: var(--ink-muted); border-radius: var(--r-chip); padding: 7px 13px;
  font-size: 12px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.follow[aria-pressed="true"] { background: var(--ink-strong); color: var(--bg); border-color: var(--ink-strong); }

.theme-toggle {
  -webkit-app-region: no-drag;
  width: 40px; height: 40px; border-radius: var(--r-control); border: 0;
  background: transparent; color: var(--ink-muted); cursor: pointer;
  display: grid; place-items: center; margin-top: var(--sm);
}
.theme-toggle:hover { background: var(--surface-high); color: var(--ink); }
.theme-toggle svg { width: 18px; height: 18px; stroke-width: 1.7; }

.subject-row {
  width: 100%; text-align: left; border: 1px solid transparent; background: transparent;
  border-radius: var(--r-card); padding: var(--md) var(--lg); cursor: pointer;
  display: flex; align-items: center; gap: var(--md); margin-bottom: 2px;
  transition: background var(--fast) var(--ease);
}
.subject-row:hover { background: var(--surface-high); }
.subject-row[aria-current="true"] { background: var(--surface-high); border-color: var(--line-strong); }
.subject-row .name { flex: 1; min-width: 0; }
.subject-row .name b { display: block; font-weight: 500; color: var(--ink-strong);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subject-row .name span { font-size: 12px; color: var(--ink-muted); }
.subject-row .count { font-family: var(--mono); font-size: 12px; color: var(--ink-muted); }

.swatches { display: flex; flex-wrap: wrap; gap: var(--sm); }
.swatch {
  width: 32px; height: 32px; border-radius: var(--r-chip); border: 2px solid transparent;
  cursor: pointer; padding: 0;
}
.swatch:focus-visible { outline: 2px solid var(--ink-strong); outline-offset: 2px; }
.swatch[aria-pressed="true"] { border-color: var(--ink-strong); }

/* ---------- markdown ---------- */

.md { font-size: 17px; line-height: 1.75; max-width: 66ch; color: var(--ink); }
.md h1 { font-size: 27px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 var(--lg); color: var(--ink-strong); }
.md h2 { font-size: 21px; font-weight: 600; letter-spacing: -0.015em; margin: var(--section) 0 var(--md);
  color: var(--ink-strong); padding-bottom: var(--sm); border-bottom: 1px solid var(--line); }
.md h3 { font-size: 17px; font-weight: 600; margin: var(--xxl) 0 var(--sm); color: var(--ink-strong); }
.md p { margin: 0 0 var(--lg); }
.md ul, .md ol { margin: 0 0 var(--lg); padding-left: var(--xxl); }
.md li { margin-bottom: var(--sm); }
.md blockquote {
  margin: 0 0 var(--xl); padding: var(--lg) var(--xl); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-control);
}
.md blockquote p:last-child { margin-bottom: 0; }
.md code { font-family: var(--mono); font-size: 0.87em; background: var(--surface-high);
  padding: 2px 6px; border-radius: 5px; }
.md pre { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-control);
  padding: var(--lg); overflow-x: auto; margin: 0 0 var(--lg); }
.md pre code { background: transparent; padding: 0; }
.md .tex { font-family: var(--mono); font-size: 0.9em; background: var(--surface-high);
  padding: 2px 6px; border-radius: 5px; color: var(--ink-strong); }
.md .tex.block { display: block; padding: var(--md) var(--lg); margin: 0 0 var(--lg); text-align: center; }
.md img { max-width: 100%; border-radius: var(--r-control); border: 1px solid var(--line);
  display: block; margin: var(--lg) 0; cursor: zoom-in;
  width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: var(--surface); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: var(--section) 0; }
.md a { color: var(--ink-strong); text-decoration: underline; text-underline-offset: 3px; }
.md strong { color: var(--ink-strong); font-weight: 600; }
.md table { border-collapse: collapse; width: 100%; margin: 0 0 var(--lg); font-size: 15px; }
.md th, .md td { border: 1px solid var(--line); padding: var(--sm) var(--md); text-align: left; }
.md th { background: var(--surface); font-weight: 600; }

/* ---------- транскрипт ---------- */

.seg {
  display: flex; gap: var(--lg); padding: var(--sm) var(--md); border-radius: var(--r-control);
  cursor: pointer; transition: background var(--fast) var(--ease);
  width: 100%; text-align: left; border: 0; background: transparent; font: inherit; color: inherit;
}
.seg:focus-visible { outline: 2px solid var(--ink-strong); outline-offset: -2px; }
.seg:hover { background: var(--surface); }
.seg.active { background: var(--surface-high); }
.seg .ts { font-family: var(--mono); font-size: 12px; color: var(--ink-muted);
  flex: 0 0 52px; padding-top: 3px; font-variant-numeric: tabular-nums; }
.seg.active .ts { color: var(--rec-ink); }
.seg .txt { flex: 1; }

/* ---------- галерея ---------- */

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--lg); }
.shot { border: 1px solid var(--line); border-radius: var(--r-control); overflow: hidden;
  background: var(--surface); }
.shot img { width: 100%; display: block; cursor: zoom-in; aspect-ratio: 16/10; object-fit: cover; }
.shot .bar { display: flex; align-items: center; gap: var(--sm); padding: var(--sm) var(--md);
  font-size: 12px; color: var(--ink-muted); }
.shot.off img { opacity: 0.4; }

#viewer {
  position: fixed; inset: 0; background: var(--scrim); display: none;
  place-items: center; z-index: var(--z-overlay); padding: var(--section);
}
#viewer.open { display: grid; }
#viewer { cursor: zoom-out; }
#viewer img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: default; }
.viewer-close {
  position: absolute; top: var(--xxl); right: var(--xxl);
  width: 44px; height: 44px; border-radius: var(--r-chip); border: 0; cursor: pointer;
  background: var(--surface); color: var(--ink-strong);
  display: grid; place-items: center;
}
.viewer-close:hover { background: var(--surface-high); }
.viewer-close:focus-visible { outline: 2px solid var(--bg); outline-offset: 3px; }
.viewer-close svg { width: 22px; height: 22px; stroke-width: 1.8; }

/* ---------- прочее ---------- */

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--xl); }
.rows { display: flex; flex-direction: column; gap: var(--sm); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--lg); }

#toast {
  position: fixed; bottom: var(--xxl); left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink-strong); color: var(--bg); padding: var(--md) var(--xl);
  border-radius: var(--r-control); font-weight: 500; font-size: 14px;
  opacity: 0; pointer-events: none; z-index: var(--z-toast);
  transition: opacity var(--normal) var(--ease), transform var(--normal) var(--ease);
  max-width: 70vw; box-shadow: var(--shadow-pop);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.log { font-family: var(--mono); font-size: 12px; line-height: 1.65; color: var(--ink-subtle);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-control);
  padding: var(--lg); max-height: 420px; overflow-y: auto; white-space: pre-wrap; }

.keylist { display: flex; flex-direction: column; gap: var(--sm); }
.keyrow { display: flex; align-items: center; gap: var(--md); font-family: var(--mono); font-size: 13px; }
.keyrow .state { font-family: var(--font); font-size: 12px; margin-left: auto; }

@media (max-width: 1100px) {
  #list-pane { width: 290px; }
  .page { padding: var(--xxl); }
  #detail-pane { padding: var(--xl); }
  .record-panel { grid-template-columns: 1fr; justify-items: start; gap: var(--xl); }
}

/* ---------- уважение к отключённым анимациям ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .orb:hover { transform: none; }
}

/* ---------- утилиты, вынесенные из инлайн-стилей ---------- */

.col-wide { max-width: 820px; }
.col-narrow { max-width: 620px; }
.lede { color: var(--ink-muted); max-width: 70ch; margin: -12px 0 28px; }
.dropzone {
  border-style: dashed; text-align: center; padding: var(--xxl); cursor: pointer;
  display: flex; flex-direction: column; gap: var(--sm); align-items: center;
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.dropzone:hover, .dropzone.over { border-color: var(--ink-strong); background: var(--surface-high); }
.dropzone:focus-visible { outline: 2px solid var(--ink-strong); outline-offset: 2px; }
.dropzone b { font-size: 15px; color: var(--ink-strong); }
.dropzone.busy { opacity: 0.55; pointer-events: none; }
.import-block { max-width: 560px; }
.import-block .field { margin-bottom: var(--md); }
.shot-jump { padding: 4px 8px; min-height: 32px; font-size: 12px; }
.shot-switch { margin-left: auto; padding: 0; }
.centered-empty { margin-top: 20vh; }
.u-nums { font-variant-numeric: tabular-nums; }
.u-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-summary {
  padding: var(--md) var(--xl); cursor: pointer;
  display: flex; align-items: center; gap: var(--md);
}
.tpl-summary:focus-visible { outline: 2px solid var(--ink-strong); outline-offset: -2px; }
.empty-progress { max-width: 320px; margin: var(--lg) auto 0; }
.empty-action { margin-top: var(--xl); display: flex; justify-content: center; }
.search-field { margin-bottom: var(--md); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.upload-state {
  margin-top: var(--md); font-size: 13px; color: var(--ink-subtle);
  display: flex; flex-direction: column; gap: var(--sm);
}
.upload-state[hidden] { display: none; }
.upload-state .progress { margin-top: 0; }

/* ---------- вход ---------- */

#gate {
  position: fixed; inset: 0; z-index: var(--z-overlay);
  background: var(--bg); display: flex; align-items: center; justify-content: center;
  padding: var(--xl);
}
#gate[hidden] { display: none; }
.gate-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-panel); padding: var(--section);
}
.gate-card .brand-big {
  font-weight: 700; font-size: 13px; letter-spacing: 0.22em;
  color: var(--ink-muted); margin-bottom: var(--xxl);
}
.gate-card h1 { font-size: 22px; margin: 0 0 var(--xl); color: var(--ink-strong); }
.gate-msg { display: block; margin-top: var(--md); color: var(--danger); font-size: 13px; }
.gate-toggle {
  background: none; border: 0; padding: 0; margin-top: var(--lg);
  color: var(--ink-muted); font-size: 13px; cursor: pointer; text-decoration: underline;
}
.gate-toggle:hover { color: var(--ink); }

.back-btn {
  display: none; align-items: center; gap: var(--sm);
  background: none; border: 0; color: var(--ink-muted);
  padding: var(--sm) 0; margin-bottom: var(--sm); cursor: pointer; font-size: 14px;
}
.back-btn:hover { color: var(--ink); }

/* ---------- телефон и планшет ---------- */

@media (max-width: 720px) {
  #shell { flex-direction: column; }

  #rail {
    order: 2; width: 100%; flex: 0 0 auto; height: auto;
    flex-direction: row; justify-content: space-around; align-items: center;
    border-right: 0; border-top: 1px solid var(--line);
    padding: var(--xs) var(--sm);
    padding-bottom: calc(var(--xs) + env(safe-area-inset-bottom));
    position: sticky; bottom: 0; z-index: var(--z-sticky);
  }
  #rail .brand { display: none; }
  #rail .theme-toggle { margin-top: 0 !important; }
  .rail-item { width: auto; flex: 1 1 0; padding: var(--xs) 0; font-size: 10px; }
  .rail-item svg { width: 22px; height: 22px; }

  #content { order: 1; min-height: 0; flex: 1 1 auto; }

  /* Две панели не помещаются: показываем ту, что открыта. */
  #split { display: block; }
  #list-pane { width: 100%; border-right: 0; }
  #detail-pane { display: none; }
  #split.showing-detail #list-pane { display: none; }
  #split.showing-detail #detail-pane { display: block; padding: var(--lg); }

  .page { padding: var(--lg); }
  .grid2 { grid-template-columns: 1fr; }
  h1.screen { font-size: 20px; }
  .back-btn { display: inline-flex; }

  /* Ползунок не влезает в строку рядом с кнопками — отдаём ему отдельный ряд. */
  .playerbar { flex-wrap: wrap; padding: var(--sm) var(--lg); row-gap: var(--xs); }
  .playerbar input[type="range"] { order: 10; flex: 1 0 100%; min-width: 0; }
  /* Общая длительность уже написана в шапке — на узком экране она лишняя. */
  .playerbar .time + input + .time { display: none; }

  .detail-top { padding: var(--sm) var(--lg) 0; }
  #tab-body { padding: var(--lg); }
  .detail-head h1 { font-size: 17px; }
  .tabs { overflow-x: auto; }
  .tab { white-space: nowrap; }
  .actions { flex-wrap: wrap; }
}

/* ---------- запись в браузере ---------- */

.rec-big {
  display: flex; flex-direction: column; align-items: center; gap: var(--lg);
  padding: var(--section) var(--xl);
}
.rec-dot {
  width: 96px; height: 96px; border-radius: 50%;
  border: 0; cursor: pointer; background: var(--rec); color: var(--on-rec);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-pop);
  transition: transform var(--fast) var(--ease);
}
.rec-dot:hover { transform: scale(1.04); }
.rec-dot svg { width: 40px; height: 40px; }
.rec-dot.on { background: var(--surface-high); color: var(--rec-ink); border: 2px solid var(--rec); }
.rec-clock {
  font-family: var(--mono); font-size: 34px; font-variant-numeric: tabular-nums;
  color: var(--ink-strong);
}
.rec-hint {
  max-width: 420px; text-align: center; color: var(--ink-muted);
  font-size: 13px; line-height: 1.55;
}

/* display в классах перебивает hidden — возвращаем ему силу */
[hidden] { display: none !important; }
