/* ===========================================================
   Монтажний стіл — оформлення
   Мова форми: телевізійний пульт. Темна панель, бурштиновий
   сигнальний колір (як лампа «в ефірі»), таймкоди моноширинним.
   =========================================================== */

:root {
  --void:      #0E1116;
  --panel:     #161B22;
  --raised:    #1D242E;
  --sunken:    #11161D;
  --edge:      #2A323D;
  --edge-soft: #212933;

  --ink:       #E8EDF3;
  --ink-mid:   #A9B5C4;
  --ink-dim:   #74808F;

  --tally:     #FFB020;
  --tally-hot: #FFC554;
  --tally-ink: #171003;
  --code:      #56D6C6;
  --alarm:     #FF6067;
  --alarm-bg:  rgba(255, 96, 103, .10);

  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 12px 32px -18px rgba(0,0,0,.9);
  --radius: 12px;
  --radius-sm: 8px;

  --display: "Unbounded", "Onest", system-ui, sans-serif;
  --body: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --gap: 20px;
  --lane: 1180px;
}

[data-theme="light"] {
  --void:      #E7EBF0;
  --panel:     #FFFFFF;
  --raised:    #F3F6F9;
  --sunken:    #EDF1F5;
  --edge:      #D2DAE3;
  --edge-soft: #E1E7ED;

  --ink:       #0F151C;
  --ink-mid:   #48566A;
  --ink-dim:   #6B7A8C;

  --tally:     #B87400;
  --tally-hot: #965E00;
  --tally-ink: #FFFFFF;
  --code:      #0B7767;
  --alarm:     #C22C33;
  --alarm-bg:  rgba(194, 44, 51, .08);

  --shadow: 0 1px 2px rgba(20,30,45,.06), 0 10px 28px -20px rgba(20,30,45,.45);
}

* { box-sizing: border-box; }

/* Обов'язково перед усім іншим: класи на кшталт .modal-veil чи .spinner
   задають display, і цим перебивають атрибут hidden. Без цього рядка
   невидима модалка накриває сторінку й перехоплює всі кліки. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0 0 96px;
  background:
    radial-gradient(1100px 520px at 50% -220px, color-mix(in srgb, var(--tally) 7%, transparent), transparent 70%),
    var(--void);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}

/* ---------------------------------------------------- банер сесії */

.session-banner {
  background: var(--alarm);
  color: #fff;
  padding: 10px 20px;
  text-align: center;
  font-weight: 500;
}
.session-banner a { color: #fff; }

/* ---------------------------------------------------- шапка */

.console {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px max(20px, calc((100vw - var(--lane)) / 2));
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--edge);
}

.console__mark {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.console__name {
  font-family: var(--display);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -.02em;
  white-space: nowrap;
}

/* Сигнальна лампа: спокійна в очікуванні, пульсує під час роботи */
.tally {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex: none;
  background: var(--ink-dim);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink-dim) 16%, transparent);
  transition: background .2s ease, box-shadow .2s ease;
}
.tally[data-state="busy"] {
  background: var(--tally);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tally) 26%, transparent);
  animation: tally-pulse 1.15s ease-in-out infinite;
}
.tally[data-state="done"] {
  background: var(--code);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--code) 22%, transparent);
}
.tally[data-state="error"] {
  background: var(--alarm);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--alarm) 24%, transparent);
}

@keyframes tally-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

.console__tools {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
}

.console__status {
  color: var(--ink-dim);
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: lowercase;
}

.console__user {
  color: var(--ink-mid);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.console__exit {
  color: var(--ink-dim);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.console__exit:hover { color: var(--ink); border-bottom-color: var(--edge); }

.icon-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
  background: var(--raised);
  color: var(--ink-mid);
  cursor: pointer;
  padding: 0;
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink-dim); }
.icon-btn__glyph {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: inset -4px -1px 0 0 var(--raised);
}
[data-theme="light"] .icon-btn__glyph { box-shadow: none; }

/* ---------------------------------------------------- лічильник черги */

.queue-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 7px;
  background: color-mix(in srgb, var(--tally) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--tally) 42%, transparent);
  border-radius: 999px;
  color: var(--tally);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.queue-chip:hover { background: color-mix(in srgb, var(--tally) 24%, transparent); }

.queue-chip__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: tally-pulse 1.15s ease-in-out infinite;
}

/* ---------------------------------------------------- панель черги */

.queue {
  background: var(--panel);
  border: 1px solid color-mix(in srgb, var(--tally) 34%, var(--edge));
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow);
}

.queue__head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.queue__title {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 14px;
}

.queue__head .btn { margin-left: auto; }

.queue__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.queue__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  background: var(--sunken);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.queue__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.queue__stage { color: var(--ink-dim); font-size: 12px; }

.queue__age {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-dim);
  flex: none;
}
.queue__age[data-late="1"] { color: var(--alarm); font-weight: 600; }

.queue__state {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-dim);
}
.queue__state[data-state="running"] {
  background: var(--tally);
  animation: tally-pulse 1.15s ease-in-out infinite;
}

.queue__note {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--ink-dim);
}

.alert--warn {
  background: color-mix(in srgb, var(--tally) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--tally) 45%, transparent);
  color: var(--tally);
  margin-top: 0;
}

.alert--busy {
  background: color-mix(in srgb, var(--tally) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--tally) 40%, transparent);
  color: var(--tally);
}

/* ---------------------------------------------------- каркас */

.stage {
  max-width: var(--lane);
  margin: 0 auto;
  padding: 28px 20px 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* ---------------------------------------------------- рядок завантаження */

.deck {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.deck__label {
  display: block;
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 9px;
}

.deck__row { display: flex; gap: 10px; }

.deck__input {
  flex: 1;
  min-width: 0;
  padding: 13px 15px;
  font: inherit;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink);
  background: var(--sunken);
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.deck__input::placeholder { color: var(--ink-dim); }
.deck__input:focus {
  outline: none;
  border-color: var(--tally);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tally) 18%, transparent);
}

.deck__hint {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--ink-dim);
}

/* ---------------------------------------------------- вкладки */

.tabs {
  display: flex;
  gap: 6px;
  margin: -4px 0 20px;
  padding: 4px;
  background: var(--sunken);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius-sm);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  font: inherit;
  text-align: left;
  color: var(--ink-dim);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.tab:hover { color: var(--ink-mid); }
.tab.is-active {
  background: var(--panel);
  border-color: var(--edge);
  color: var(--ink);
}

.tab__name { font-size: 14px; font-weight: 600; }
.tab__hint { font-size: 11.5px; color: var(--ink-dim); }
.tab.is-active .tab__hint { color: var(--ink-mid); }

/* ---------------------------------------------------- стан бібліотек */

.tools {
  border-top: 1px solid var(--edge-soft);
  padding-top: 14px;
}

.tools__toggle {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-dim);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
.tools__toggle:hover { color: var(--ink); }

.tools__body {
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
}

.tools__list { list-style: none; margin: 0 0 12px; padding: 0; }

.tools__row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 5px 0;
  font-size: 13px;
  font-family: var(--mono);
}
.tools__row + .tools__row { border-top: 1px solid var(--edge-soft); }

.tools__pkg { min-width: 190px; color: var(--ink); }
.tools__ver { color: var(--ink-dim); }
.tools__flag { margin-left: auto; font-size: 11.5px; }
.tools__flag[data-old="1"] { color: var(--tally); font-weight: 600; }
.tools__flag[data-old="0"] { color: var(--code); }

.tools__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.tools__note { font-size: 12px; color: var(--ink-dim); }
.tools__actions .btn { margin-left: auto; }

/* ---------------------------------------------------- метадані */

.meta {
  display: flex;
  align-items: center;
  gap: 26px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--edge-soft);
}

.meta__item { display: flex; flex-direction: column; gap: 2px; }

.meta__key {
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.meta__value { font-size: 15px; font-weight: 600; }

.meta .btn { margin-left: auto; }
.meta .btn + .btn { margin-left: 0; }
.meta__value--soft { font-size: 13px; font-weight: 500; color: var(--code); }

/* ---------------------------------------------------- кнопки */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease,
              color .15s ease, transform .08s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn--primary {
  background: var(--tally);
  color: var(--tally-ink);
}
.btn--primary:not(:disabled):hover { background: var(--tally-hot); }

.btn--ghost {
  background: var(--raised);
  border-color: var(--edge);
  color: var(--ink-mid);
}
.btn--ghost:not(:disabled):hover { color: var(--ink); border-color: var(--ink-dim); }

.btn--stop {
  background: transparent;
  border-color: var(--alarm);
  color: var(--alarm);
}
.btn--stop:not(:disabled):hover { background: var(--alarm-bg); }

.btn--download {
  background: var(--code);
  color: #06201C;
  text-decoration: none;
}
[data-theme="light"] .btn--download { color: #fff; }
.btn--download:hover { filter: brightness(1.08); }

.btn--sm { padding: 7px 12px; font-size: 12.5px; }

.btn.is-busy .btn__label { opacity: .55; }

/* ---------------------------------------------------- покриття відео */

.overview {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 20px 22px 16px;
  box-shadow: var(--shadow);
}

.overview__head { margin-bottom: 16px; }

.overview__title {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -.01em;
}

.overview__note {
  margin: 5px 0 0;
  font-size: 12.5px;
  color: var(--ink-dim);
}

.overview__lanes { display: flex; flex-direction: column; gap: 5px; }

.lane {
  position: relative;
  height: 24px;
  background: var(--sunken);
  border-radius: 5px;
  overflow: hidden;
}

.lane__bar {
  position: absolute;
  top: 0;
  bottom: 0;
  min-width: 4px;
  background: color-mix(in srgb, var(--tally) 62%, transparent);
  border-radius: 5px;
  border: none;
  padding: 0 8px;
  color: var(--tally-ink);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  transition: background .15s ease;
}
.lane__bar:hover,
.lane__bar:focus-visible { background: var(--tally); }

.overview__ruler {
  position: relative;
  height: 22px;
  margin-top: 8px;
  border-top: 1px solid var(--edge-soft);
}

.tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  padding-top: 5px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-dim);
  white-space: nowrap;
}
.tick::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 1px;
  height: 4px;
  background: var(--edge);
}
.tick:first-child { transform: none; }
.tick:first-child::before { left: 0; }
.tick:last-child { transform: translateX(-100%); }
.tick:last-child::before { left: auto; right: 0; }

/* ---------------------------------------------------- картки */

.cards { display: flex; flex-direction: column; gap: var(--gap); }

.card {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  scroll-margin-top: 84px;
  outline: none;
}
.card.is-lit {
  border-color: var(--tally);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tally) 15%, transparent), var(--shadow);
}
.card.is-working { border-color: color-mix(in srgb, var(--tally) 55%, var(--edge)); }

.card__head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--edge-soft);
}

.card__index {
  font-size: 13px;
  font-weight: 600;
  color: var(--tally);
}

.card__span {
  font-size: 14px;
  font-weight: 600;
  color: var(--code);
}

.card__length {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--ink-dim);
}

.card__summary {
  margin: 14px 0 18px;
  color: var(--ink-mid);
  font-size: 14.5px;
}

/* ---------------------------------------------------- шкала фрагмента */

.scrub { padding: 6px 9px 2px; }

.scrub__rail {
  position: relative;
  height: 10px;
  background: var(--sunken);
  border-radius: 5px;
  touch-action: none;
}

.scrub__fill {
  position: absolute;
  top: 0;
  bottom: 0;
  background: color-mix(in srgb, var(--tally) 55%, transparent);
  border-radius: 5px;
}

.scrub__grip {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 26px;
  margin-left: -9px;
  transform: translateY(-50%);
  background: var(--tally);
  border: 2px solid var(--panel);
  border-radius: 5px;
  cursor: ew-resize;
  padding: 0;
  touch-action: none;
}
.scrub__grip::after {
  content: "";
  position: absolute;
  inset: 7px 6px;
  border-left: 1px solid color-mix(in srgb, var(--tally-ink) 45%, transparent);
  border-right: 1px solid color-mix(in srgb, var(--tally-ink) 45%, transparent);
}
.scrub__grip:hover, .scrub__grip:focus-visible { background: var(--tally-hot); }
.scrub__grip.is-dragging { background: var(--tally-hot); }

/* ---------------------------------------------------- поля часу */

.times {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}

.times__field { flex: 1; display: flex; flex-direction: column; gap: 5px; }

.times__key {
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.times__input {
  padding: 10px 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--code);
  background: var(--sunken);
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
}
.times__input:focus {
  outline: none;
  border-color: var(--code);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--code) 16%, transparent);
}
.times__input.is-wrong {
  border-color: var(--alarm);
  color: var(--alarm);
}

/* ---------------------------------------------------- цитати */

.quotes { margin-top: 16px; }

.quotes__toggle {
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-dim);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  user-select: none;
}
.quotes__toggle::-webkit-details-marker { display: none; }
.quotes__toggle::before {
  content: "";
  width: 0;
  height: 0;
  border: 4px solid transparent;
  border-left-color: currentColor;
  transition: transform .15s ease;
}
.quotes[open] .quotes__toggle::before { transform: rotate(90deg) translateX(-1px); }
.quotes__toggle:hover { color: var(--ink); }

.quotes__body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 12px;
}

.quotes__block { min-width: 0; }

.quotes__key {
  display: block;
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 6px;
}

.quotes blockquote {
  margin: 0;
  padding: 11px 13px;
  background: var(--sunken);
  border-left: 2px solid var(--edge);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13.5px;
  color: var(--ink-mid);
}

/* ---------------------------------------------------- дії */

.card__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

/* ---------------------------------------------------- прогрес */

.progress {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--sunken);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius-sm);
}

.progress__top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 9px;
  font-size: 13px;
}

.progress__stage { color: var(--ink); font-weight: 500; }
.progress__percent { color: var(--tally); font-weight: 600; }

.progress__rail {
  height: 6px;
  background: var(--edge-soft);
  border-radius: 3px;
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  width: 0;
  background: var(--tally);
  border-radius: 3px;
  transition: width .25s ease;
}

.progress__foot {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--ink-dim);
  min-height: 15px;
}

/* ---------------------------------------------------- готовий файл */

.done {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--code) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--code) 32%, transparent);
  border-radius: var(--radius-sm);
}

.done__note { font-size: 12px; color: var(--ink-mid); }

/* ---------------------------------------------------- панелі оформлення */

.panel {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.fragment-format {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--edge-soft);
}

.panel__head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.panel__head--inline { margin-bottom: 14px; }

.panel__title {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -.01em;
}
.panel__title--sm { font-size: 13px; }

.panel__actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------------------------------------------------- поля результату */

.fields { display: flex; flex-direction: column; gap: 16px; }

.field {
  background: var(--sunken);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.field__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--edge-soft);
}

.field__key {
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-dim);
  font-weight: 600;
}

.field__count {
  font-size: 11px;
  color: var(--ink-dim);
  margin-left: auto;
}
.field__count[data-fit="ok"]   { color: var(--code); }
.field__count[data-fit="off"]  { color: var(--tally); }

.copy {
  padding: 5px 10px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-mid);
  background: var(--raised);
  border: 1px solid var(--edge);
  border-radius: 6px;
  cursor: pointer;
}
.copy:hover { color: var(--ink); border-color: var(--ink-dim); }
.copy.is-done { color: var(--code); border-color: var(--code); }

.field__area {
  display: block;
  width: 100%;
  min-height: 74px;
  padding: 13px;
  font: inherit;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  background: transparent;
  border: 0;
  resize: vertical;
  overflow: hidden;
}
.field__area:focus { outline: none; background: color-mix(in srgb, var(--tally) 4%, transparent); }

/* ---------------------------------------------------- дрібне */

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-top: 14px;
}
.alert--error {
  background: var(--alarm-bg);
  border: 1px solid color-mix(in srgb, var(--alarm) 40%, transparent);
  color: var(--alarm);
}

.spinner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  font-size: 13.5px;
  color: var(--ink-dim);
}
.spinner span {
  width: 14px;
  height: 14px;
  border: 2px solid var(--edge);
  border-top-color: var(--tally);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  padding: 56px 20px;
  text-align: center;
}
.empty__line { margin: 0; color: var(--ink-dim); font-size: 14px; }

/* ---------------------------------------------------- модалка */

.modal-veil {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 9, 13, .68);
  backdrop-filter: blur(3px);
}

.modal {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 30px 70px -30px rgba(0,0,0,.8);
}

.modal__title {
  margin: 0 0 8px;
  font-family: var(--display);
  font-weight: 600;
  font-size: 16px;
}

.modal__text { margin: 0 0 20px; color: var(--ink-mid); font-size: 14px; }

.modal__actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------------------------------------------------- вхід */

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate__box {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}

.gate__mark {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 6px;
}

.gate__name {
  font-family: var(--display);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -.02em;
}

.gate__note {
  margin: 0 0 24px;
  font-size: 13.5px;
  color: var(--ink-dim);
}

.gate__field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }

.gate__key {
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.gate__input {
  padding: 12px 14px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--sunken);
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
}
.gate__input:focus {
  outline: none;
  border-color: var(--tally);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tally) 18%, transparent);
}

.gate .btn { width: 100%; margin-top: 8px; }

/* ---------------------------------------------------- фокус і доступність */

:focus-visible {
  outline: 2px solid var(--tally);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------------------------------------------------- вузькі екрани */

@media (max-width: 720px) {
  .deck__row { flex-direction: column; }
  .deck__input { width: 100%; }
  .btn { width: 100%; }
  .btn--sm { width: auto; }
  .meta { gap: 18px; }
  .meta .btn { margin-left: 0; width: 100%; }
  .times { flex-direction: column; }
  .quotes__body { grid-template-columns: 1fr; }
  .card__head { flex-wrap: wrap; gap: 8px; }
  .card__length { margin-left: 0; width: 100%; }
  .tabs { flex-direction: column; }
  .tools__actions .btn { margin-left: 0; width: 100%; }
  .tools__pkg { min-width: 0; }
  .console__user { display: none; }
  .console__status { display: none; }
  .card, .panel, .deck, .overview { padding: 16px; }
}


/* ===========================================================
   Розширений редактор
   =========================================================== */

.editor-veil {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(6, 9, 13, .74);
  backdrop-filter: blur(3px);
}

.editor {
  width: min(1240px, 100%);
  max-height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, .85);
  overflow: hidden;
}

.editor__head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--edge);
}

.editor__title {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 15px;
}

.editor__close {
  margin-left: auto;
  width: 30px;
  height: 30px;
  font-size: 20px;
  line-height: 1;
  color: var(--ink-dim);
  background: transparent;
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.editor__close:hover { color: var(--ink); border-color: var(--ink-dim); }

.editor__body {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr);
  gap: 18px;
  padding: 18px;
  overflow: auto;
}

.editor__left { min-width: 0; }

.editor__player-box {
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: 320px;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.editor__player-box iframe { width: 100%; height: 100%; border: 0; }

.editor__note {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--tally);
}

.editor__controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 14px 0 10px;
  flex-wrap: wrap;
}

.edge-switch {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--sunken);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius-sm);
}

.edge {
  padding: 6px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-dim);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
.edge.is-active { background: var(--tally); color: var(--tally-ink); }

.editor__zoom {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  font-size: 12.5px;
  color: var(--ink-dim);
}
.zoom-btn {
  width: 28px;
  height: 28px;
  font: inherit;
  font-size: 17px;
  line-height: 1;
  color: var(--ink);
  background: var(--sunken);
  border: 1px solid var(--edge);
  border-radius: 6px;
  cursor: pointer;
}
.zoom-btn:hover { border-color: var(--tally); color: var(--tally); }
.zoom-btn:disabled { opacity: .35; cursor: not-allowed; }

.zoom-btn__value {
  min-width: 52px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-mid);
}

/* Смужка відтворення: біжить синхронно з плеєром YouTube */
.wave__playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 6px rgba(255, 255, 255, .8);
  pointer-events: none;
}
[data-theme="light"] .wave__playhead {
  background: #111;
  box-shadow: 0 0 6px rgba(0, 0, 0, .4);
}

.wave__playhead::after {
  content: "";
  position: absolute;
  top: -1px;
  left: -4px;
  border: 5px solid transparent;
  border-top-color: currentColor;
  color: inherit;
}

.editor__zoom select {
  padding: 5px 8px;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  background: var(--sunken);
  border: 1px solid var(--edge);
  border-radius: 6px;
}

.editor__overview {
  display: block;
  width: 100%;
  height: 34px;
  margin-bottom: 8px;
  background: var(--sunken);
  border-radius: 5px;
  cursor: pointer;
}

.wave {
  position: relative;
  height: 150px;
  background: var(--sunken);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  touch-action: none;
}

.wave__canvas { display: block; width: 100%; height: 100%; }

.wave__region {
  position: absolute;
  top: 0;
  bottom: 0;
  background: color-mix(in srgb, var(--tally) 12%, transparent);
  pointer-events: none;
}

.wave__cursor {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--code);
  pointer-events: none;
}

.wave__handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 12px;
  margin-left: -6px;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: ew-resize;
}
.wave__handle::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 5px;
  width: 2px;
  background: var(--tally);
}
.wave__handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 12px;
  height: 26px;
  margin-top: -13px;
  background: var(--tally);
  border: 2px solid var(--panel);
  border-radius: 4px;
}
.wave__handle:hover::after,
.wave__handle.is-dragging::after { background: var(--tally-hot); }

.editor__times {
  display: flex;
  gap: 12px;
  margin-top: 14px;
  align-items: flex-end;
}
.editor__times .times__field { flex: 1; }

.editor__length {
  padding: 10px 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-mid);
}

.editor__hint {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--ink-dim);
  line-height: 1.5;
}

.editor__right {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.subs {
  flex: 1;
  min-height: 240px;
  max-height: 520px;
  overflow-y: auto;
  background: var(--sunken);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius-sm);
  padding: 6px;
}

.sub {
  display: flex;
  gap: 10px;
  width: 100%;
  padding: 5px 8px;
  text-align: left;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}
.sub:hover { background: color-mix(in srgb, var(--tally) 12%, transparent); }

.sub__time { flex: none; font-size: 11.5px; color: var(--code); padding-top: 2px; }
.sub__text { min-width: 0; }

/* Не влізає в діапазон — закреслено й приглушено */
.sub.is-out { color: var(--ink-dim); }
.sub.is-out .sub__text { text-decoration: line-through; opacity: .65; }
.sub.is-out .sub__time { color: var(--ink-dim); }

.editor__foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--edge);
}

/* ---------------------------------------------------- заливка */

.publish {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--edge-soft);
}

.pub__field { display: block; margin-bottom: 14px; }
.pub__field--inline { flex: 1; margin-bottom: 0; }

.pub__key {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 6px;
}

.pub__count { font-size: 11px; letter-spacing: 0; text-transform: none; }
.pub__count[data-fit="ok"] { color: var(--code); }
.pub__count[data-fit="off"] { color: var(--alarm); }

.pub__input, .pub__area, .pub__select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--sunken);
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
}
.pub__area { resize: vertical; line-height: 1.55; }
.pub__area--short { font-size: 13px; }
.pub__select { margin-bottom: 8px; }
.pub__field--inline .pub__select { margin-bottom: 0; }

.pub__input:focus, .pub__area:focus, .pub__select:focus {
  outline: none;
  border-color: var(--tally);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tally) 18%, transparent);
}

.pub__row { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

.pub__fixed {
  display: block;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--ink-mid);
  background: var(--sunken);
  border: 1px dashed var(--edge);
  border-radius: var(--radius-sm);
}

@media (max-width: 980px) {
  .editor__body { grid-template-columns: 1fr; }
  .subs { max-height: 260px; }
  .editor__times { flex-direction: column; align-items: stretch; }
}


/* ===========================================================
   Обкладинка
   =========================================================== */

.cover-veil {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(6, 9, 13, .74);
  backdrop-filter: blur(3px);
}

.cover {
  width: min(1180px, 100%);
  max-height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, .85);
  overflow: hidden;
}

.cover__body {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
  overflow: auto;
}

.cover__form { min-width: 0; }
.cover__preview { min-width: 0; display: flex; flex-direction: column; gap: 14px; }

.pub__hint {
  font-size: 10.5px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-dim);
  font-weight: 400;
}

.pub__file {
  width: 100%;
  padding: 9px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--ink-mid);
  background: var(--sunken);
  border: 1px dashed var(--edge);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.pub__file::file-selector-button {
  margin-right: 10px;
  padding: 5px 10px;
  font: inherit;
  font-size: 12px;
  color: var(--ink);
  background: var(--raised);
  border: 1px solid var(--edge);
  border-radius: 6px;
  cursor: pointer;
}

.pub__note {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-dim);
}

.side-switch {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--sunken);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius-sm);
}

.side {
  flex: 1;
  padding: 8px 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-dim);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
.side.is-active { background: var(--tally); color: var(--tally-ink); }

.cover__empty {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 20px;
  text-align: center;
  font-size: 13.5px;
  color: var(--ink-dim);
  background: var(--sunken);
  border: 1px dashed var(--edge);
  border-radius: var(--radius-sm);
}

.cover__figure { margin: 0; }
.cover__figure img {
  display: block;
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--edge);
}

.cover__meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-dim);
}
.cover__meta[data-fit="off"] { color: var(--alarm); }

.cover__actions { display: flex; gap: 10px; flex-wrap: wrap; }

.redo {
  padding: 14px 16px;
  background: var(--sunken);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius-sm);
}

.redo__key {
  display: block;
  margin-bottom: 10px;
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.redo__list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.redo__item {
  padding: 10px 12px;
  font: inherit;
  font-size: 13px;
  text-align: left;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.redo__item:hover { border-color: var(--tally); color: var(--tally); }

.cover__prompt { font-size: 12px; color: var(--ink-dim); }
.cover__prompt summary { cursor: pointer; }
.cover__prompt pre {
  margin: 10px 0 0;
  padding: 12px;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-mid);
  background: var(--sunken);
  border-radius: var(--radius-sm);
}

@media (max-width: 900px) {
  .cover__body { grid-template-columns: 1fr; }
  .redo__list { grid-template-columns: 1fr; }
}


.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13.5px;
  color: var(--ink-mid);
  cursor: pointer;
  user-select: none;
}
.toggle input { width: 16px; height: 16px; accent-color: var(--tally); cursor: pointer; }
.toggle:hover { color: var(--ink); }

.pub__file:disabled { opacity: .45; cursor: not-allowed; }


/* ---------------------------------------------------- галерея обкладинок */

.gallery {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.gallery__item {
  position: relative;
  flex: none;
  width: 116px;
  padding: 0;
  background: none;
  border: 2px solid var(--edge);
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
}
.gallery__item img { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.gallery__item:hover { border-color: var(--ink-dim); }
.gallery__item.is-active { border-color: var(--tally); }

.gallery__label {
  display: block;
  padding: 3px 0;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-dim);
  background: var(--sunken);
}
.gallery__item.is-active .gallery__label { color: var(--tally); }

.redo__hint {
  margin: 8px 0 12px;
  font-size: 12px;
  color: var(--ink-dim);
}


/* ---------------------------------------------------- компіляції */

.topics { list-style: none; margin: 0; padding: 0; display: flex;
          flex-direction: column; gap: 8px; }

.topic {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--sunken);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius-sm);
}
.topic__name { font-weight: 600; min-width: 0; overflow: hidden;
               text-overflow: ellipsis; white-space: nowrap; }
.topic__count { font-family: var(--mono); font-size: 12px; color: var(--ink-dim); }
.topic__actions { margin-left: auto; display: flex; gap: 8px; flex: none; }

.mix__flash { font-size: 12px; color: var(--ink-dim); }
.mix__flash[data-ok="0"] { color: var(--tally); }

.picker { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--edge-soft); }
.picker__hint { margin: 0 0 12px; font-size: 12.5px; color: var(--ink-dim); }
.picker__total { font-size: 13px; color: var(--code); font-weight: 600; }
.picker__list { list-style: none; margin: 0 0 16px; padding: 0;
                display: flex; flex-direction: column; gap: 6px; }

.seg {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--sunken);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius-sm);
  cursor: grab;
}
.seg.is-dragging { opacity: .45; }
.seg input { width: 16px; height: 16px; accent-color: var(--tally); flex: none; }
.seg__body { min-width: 0; flex: 1; }
.seg__top { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.seg__time { font-family: var(--mono); font-size: 12px; color: var(--code); }
.seg__len { font-family: var(--mono); font-size: 12px; color: var(--ink-dim); }
.seg__date { font-family: var(--mono); font-size: 11.5px; color: var(--ink-dim); }
.seg__text { font-size: 13px; color: var(--ink-mid); margin-top: 3px;
             overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg__drop { color: var(--ink-dim); font-size: 15px; flex: none; cursor: grab; }


.picker__body { padding: 18px; overflow: auto; }
.picker__total { margin-left: auto; font-size: 13px; color: var(--code); font-weight: 600; }

.ready { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--edge-soft); }
.ready__list { list-style: none; margin: 10px 0 0; padding: 0;
               display: flex; flex-direction: column; gap: 6px; }
.ready__row { display: flex; align-items: center; gap: 12px; padding: 9px 12px;
              background: var(--sunken); border-radius: var(--radius-sm);
              font-size: 13px; }
.ready__when { font-family: var(--mono); font-size: 12px; color: var(--ink-dim); }
.ready__row .btn { margin-left: auto; }

.seg__guest { font-weight: 600; color: var(--tally); font-size: 12.5px; }

.seg__source { font-size: 12.5px; color: var(--ink-dim); cursor: help;
               border-bottom: 1px dotted var(--edge); }
.seg__source:hover { color: var(--ink-mid); }

.topic__period { font-size: 11.5px; color: var(--ink-dim); flex: none; }
.topic.is-archived { opacity: .65; }
.topic__mark { flex: none; padding: 2px 7px; font-size: 10.5px;
               letter-spacing: .06em; text-transform: uppercase;
               color: var(--ink-dim); border: 1px solid var(--edge);
               border-radius: 999px; }


/* ---------------------------------------------------- пакетне додавання */

.batch {
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--sunken);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius-sm);
}

.batch__actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.batch__state { font-size: 12px; color: var(--ink-dim); margin-right: auto; }

.batch__list { list-style: none; margin: 12px 0 0; padding: 0;
               max-height: 220px; overflow-y: auto;
               display: flex; flex-direction: column; gap: 4px; }

.batch__row { display: flex; align-items: center; gap: 10px;
              font-family: var(--mono); font-size: 11.5px; }
.batch__mark { flex: none; width: 14px; text-align: center; }
.batch__url { min-width: 0; overflow: hidden; text-overflow: ellipsis;
              white-space: nowrap; color: var(--ink-dim); }
.batch__note { margin-left: auto; flex: none; }
.batch__row[data-state="ok"] .batch__mark { color: var(--code); }
.batch__row[data-state="fail"] .batch__mark { color: var(--alarm); }
.batch__row[data-state="fail"] .batch__note { color: var(--alarm); }
.batch__row[data-state="working"] .batch__mark { color: var(--tally); }
