:root {
  --bg: #0a0c0f;
  --panel: #11141a;
  --panel2: #171b22;
  --raise: #1f242d;
  --line: #2a313c;
  --text: #e8ebf0;
  --dim: #98a1b0;
  --faint: #5d6673;
  --accent: #ffb627;
  --accent-bg: rgba(255, 182, 39, 0.22);
  --cue: #5aa9ff;
  --cue-bg: rgba(90, 169, 255, 0.16);
  --play: #ff4f70;
  --ok: #4fd18b;
  --warn: #ffd166;
  --bad: #ff6b6b;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: grid;
  grid-template-rows: 44px minmax(0, 1fr) 210px 28px;
  grid-template-columns: minmax(0, 1fr);
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 var(--sans);
  overflow: hidden;
  user-select: none;
}
.dim { color: var(--dim); }
.grow { flex: 1; }
kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.4em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--raise);
  color: var(--text);
  font: 11px/1.6 var(--mono);
  text-align: center;
}
kbd + kbd { margin-left: 2px; }

/* ---------- header ---------- */
.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font: 700 15px var(--mono); letter-spacing: 0.08em; }
.brand span { color: var(--accent); }
.modesw { display: inline-flex; flex-shrink: 0; padding: 2px; gap: 2px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); }
.modesw button { padding: 2px 10px; border: 0; border-radius: 5px; background: none; color: var(--dim); font: 12px var(--sans); }
.modesw button:hover { background: var(--raise); color: var(--text); }
.modesw button.on { background: var(--accent); color: var(--bg); font-weight: 600; }
.mode-write .transcribe-only, .mode-transcribe .write-only { display: none; }
.files { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font: 13px var(--mono); }
.files .sep { color: var(--faint); margin: 0 6px; }
nav { display: flex; gap: 6px; }
button {
  font: 13px var(--sans);
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
button:hover { background: var(--raise); border-color: var(--faint); }
button.hl { border-color: var(--accent); }
button kbd { font-size: 10px; }

/* ---------- main ---------- */
main {
  display: grid;
  grid-template-columns: minmax(380px, 38%) minmax(0, 1fr);
  min-height: 0;
  border-bottom: 1px solid var(--line);
}
.right { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stage.drop { outline: 2px dashed var(--accent); outline-offset: -8px; }
video { width: 100%; height: 100%; object-fit: contain; display: block; }
.empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 16px;
  pointer-events: none;
}
.has-video .empty { display: none; }
.overlay {
  position: absolute;
  left: 5%;
  right: 5%;
  bottom: 6%;
  text-align: center;
  pointer-events: none;
}
.overlay span {
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: clamp(16px, 2.2vw, 30px);
  line-height: 1.4;
  padding: 0.08em 0.4em;
  white-space: pre-line;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* scrubber: the whole video at a glance, between the video and its controls. A thin
   line until the pointer is over it, then full size with a knob. The strip itself keeps
   its height, so nothing moves and there's room to aim. */
.scrub {
  position: relative;
  height: 16px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  cursor: pointer;
  touch-action: none;
}
.scrub::before, .scrub canvas, .scrubfill {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  top: 7px;
  height: 2px;
  border-radius: 1px;
  transition: top 0.12s, height 0.12s;
}
/* the track, then the played part, then the block marks on top */
.scrub::before { background: var(--raise); }
.scrub canvas { width: calc(100% - 24px); z-index: 1; }
.scrubfill { right: auto; width: calc((100% - 24px) * var(--at-f, 0)); background: rgba(255, 79, 112, 0.45); pointer-events: none; }
.scrub:hover::before, .scrub.on::before, .scrub:hover canvas, .scrub.on canvas, .scrub:hover .scrubfill, .scrub.on .scrubfill { top: 5px; height: 6px; border-radius: 3px; }
.scrubknob {
  position: absolute;
  top: 4px;
  left: calc(12px + (100% - 24px) * var(--at-f, 0));
  width: 2px;
  height: 8px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--play);
  pointer-events: none;
  z-index: 2;
  transition: top 0.12s, width 0.12s, height 0.12s, margin-left 0.12s, border-radius 0.12s;
}
/* a slim tick at the playhead until the pointer is over the bar, then a round knob */
.scrub:hover .scrubknob, .scrub.on .scrubknob { top: 3px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; }
.scrubtime {
  position: absolute;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 2px 6px;
  font: 600 11px var(--mono);
  color: var(--text);
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: 4px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
}
.scrubtime[hidden] { display: none; }

.transport {
  display: flex;
  align-items: center;
  flex-wrap: wrap; /* in a narrow window the indicators drop to a second line */
  gap: 6px 8px;
  padding: 6px 12px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.clock { font: 600 15px var(--mono); white-space: nowrap; }
.clock.copy { cursor: copy; border-radius: 4px; }
.clock.copy:hover { color: var(--accent); }
.pill {
  font: 600 11px var(--mono);
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--raise);
  color: var(--dim);
}
.pill.on { background: var(--play); color: #fff; }
/* player controls */
.ctrls { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.ctrls button {
  width: 24px;
  height: 24px;
  padding: 0;
  justify-content: center;
  color: var(--dim);
  background: none;
  border-color: transparent;
}
.ctrls button:hover { color: var(--text); background: var(--raise); border-color: var(--line); }
.ctrls button.big { width: 30px; color: var(--text); background: var(--panel2); border-color: var(--line); }
.ctrls button.on { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.ctrls svg { width: 14px; height: 14px; fill: currentColor; }
.ctrls svg.stroke { fill: none; }
.ctrls .big svg { width: 15px; height: 15px; }
.ctrls .i-pause, .ctrls.playing .i-play { display: none; }
.ctrls.playing .i-pause { display: inline; }
.ctrlsep { width: 1px; height: 16px; margin: 0 4px; background: var(--line); }
#ind { display: flex; flex-shrink: 0; margin-left: auto; gap: 6px; font: 12px var(--mono); }
#ind span {
  white-space: nowrap;
  padding: 1px 8px;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--faint);
  cursor: pointer;
}
#ind span.on { color: var(--text); border-color: var(--faint); }

.editor {
  padding: 8px 12px 10px;
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
}
.editing .editor { box-shadow: inset 3px 0 0 var(--accent); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 6px; font: 12px var(--mono); }
.meta label { color: var(--dim); display: flex; align-items: center; gap: 6px; }
.idx { font-weight: 700; color: var(--accent); min-width: 3em; }
input.time {
  width: 10.5em;
  font: 13px var(--mono);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px 6px;
}
input.time:focus, textarea:focus { outline: none; border-color: var(--accent); }
#edStats .warn { color: var(--warn); }
#edStats .bad { color: var(--bad); }
textarea {
  width: 100%;
  resize: none;
  font: 18px/1.45 var(--sans);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  user-select: text;
}
textarea::placeholder { color: var(--faint); font-size: 14px; }
textarea:disabled { opacity: 0.5; }

/* ---------- list ---------- */
.listwrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
}
.listhead, .row {
  display: grid;
  grid-template-columns: 46px 112px minmax(0, 1fr) 20px;
  gap: 8px;
  padding: 0 6px 0 10px;
}
.listhead {
  font: 11px var(--mono);
  color: var(--faint);
  text-transform: uppercase;
  padding-top: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.list { flex: 1; overflow-y: auto; min-height: 0; }
.list .emptyhint { padding: 24px 16px; color: var(--dim); line-height: 2; }
.row {
  padding-top: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid #1a1e25;
  border-left: 3px solid transparent;
  cursor: pointer;
}
.row:hover { background: var(--panel2); }
/* delete button at the end of each row: faint until the row is pointed at */
.rowdel {
  align-self: start;
  width: 20px;
  height: 20px;
  padding: 0;
  font: 15px/1 var(--sans);
  color: var(--faint);
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.35;
}
.row:hover .rowdel, .row.sel .rowdel { opacity: 1; }
.rowdel:hover { color: var(--bad); border-color: var(--bad); background: rgba(255, 107, 107, 0.12); }
.row .n { font: 12px var(--mono); color: var(--faint); padding-top: 2px; }
.row .t { font: 12px var(--mono); display: flex; flex-direction: column; }
.row .t i { font-style: normal; color: var(--faint); }
.row .tx {
  white-space: pre-line;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.row .tx.blank { color: var(--faint); }
.row.active { border-left-color: var(--play); }
.row.sel { background: var(--accent-bg); }
.row.sel .n { color: var(--accent); font-weight: 700; }

/* ---------- timeline ---------- */
.timeline {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  overflow: hidden;
}
#ruler { display: block; width: 100%; height: 26px; cursor: text; flex: none; }
.lane { position: relative; flex: 1; overflow: hidden; cursor: crosshair; border-top: 1px solid var(--line); }
#wave { position: absolute; inset: 0; width: 100%; height: 100%; }
#cues { position: absolute; inset: 0; }
.cue {
  position: absolute;
  top: 12px;
  bottom: 12px;
  background: var(--cue-bg);
  border: 2px solid var(--cue);
  border-radius: 6px;
  cursor: grab;
  overflow: hidden;
  color: var(--text);
}
.cue:hover { background: rgba(90, 169, 255, 0.26); }
.cue.active { border-color: #9fcbff; }
.cue.sel { background: var(--accent-bg); border-color: var(--accent); z-index: 2; }
.cue.marking { background: rgba(255, 79, 112, 0.18); border: 2px dashed var(--play); z-index: 3; pointer-events: none; }
.cue .ci {
  position: absolute;
  top: 3px;
  left: 12px;
  font: 700 11px var(--mono);
  color: var(--cue);
}
.cue.sel .ci { color: var(--accent); }
.cue .ct {
  position: absolute;
  top: 20px;
  left: 12px;
  right: 12px;
  bottom: 4px;
  font-size: 13px;
  line-height: 1.3;
  white-space: pre-line;
  overflow: hidden;
  pointer-events: none;
}
.cue .hl, .cue .hr {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  cursor: ew-resize;
  z-index: 1;
}
.cue .hl { left: 0; }
.cue .hr { right: 0; }
.cue.narrow .hl, .cue.narrow .hr { width: 33%; }
.cue .hl::after, .cue .hr::after {
  content: "";
  position: absolute;
  top: 25%;
  bottom: 25%;
  width: 4px;
  border-radius: 2px;
  background: var(--cue);
  opacity: 0.7;
}
.cue .hl::after { left: 2px; }
.cue .hr::after { right: 2px; }
.cue.sel .hl::after, .cue.sel .hr::after { background: var(--accent); opacity: 1; }
.cue .hl:hover::after, .cue .hr:hover::after { opacity: 1; background: #fff; top: 10%; bottom: 10%; }
.dragging, .dragging * { cursor: grabbing !important; }
.dragging.resize, .dragging.resize * { cursor: ew-resize !important; }

#dragtip {
  position: absolute;
  top: 2px;
  z-index: 5;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--text);
  color: var(--bg);
  font: 600 11px var(--mono);
  white-space: nowrap;
  pointer-events: none;
}
.overview { position: relative; height: 10px; flex: none; background: var(--bg); border-top: 1px solid var(--line); cursor: pointer; }
#ovWin { position: absolute; top: 1px; bottom: 1px; min-width: 4px; background: var(--faint); border-radius: 2px; }
.playhead {
  position: absolute;
  top: 0;
  bottom: 10px;
  left: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--play);
  pointer-events: none;
  z-index: 4;
}
.playhead::before {
  content: "";
  position: absolute;
  top: 0;
  left: -5px;
  border: 6px solid transparent;
  border-top: 8px solid var(--play);
}

/* ---------- status ---------- */
.status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  font-size: 12px;
}
#toast { min-width: 0; color: var(--accent); transition: opacity 0.4s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#toast.fade { opacity: 0; }
.hint { margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--dim); white-space: nowrap; }
.hint kbd { margin-left: 6px; }

/* ---------- help ---------- */
.help {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}
.help[hidden] { display: none; }
.helpbox {
  width: min(1100px, 94vw);
  max-height: 90vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 24px;
}
.helpbox h2 { margin: 0 0 12px; font-size: 18px; }
.helpbox h2 .dim { font-weight: 400; font-size: 14px; }
.helpbox h3 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 13px; }
dt { white-space: nowrap; color: var(--dim); }
dd { margin: 0; }

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; grid-template-rows: 40% minmax(0, 1fr); }
  .right { order: -1; }
  .listwrap { border-right: 0; border-top: 1px solid var(--line); }
  nav button kbd, .hint { display: none; }
  .cols { grid-template-columns: 1fr; }
}

/* ---------- version and updates ---------- */
button.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}
button.link:hover { background: none; text-decoration: underline; }
button.link:disabled { color: var(--faint); cursor: default; text-decoration: none; }
.ver {
  flex-shrink: 0;
  padding: 1px 8px;
  font: 11px var(--mono);
  color: var(--dim);
  white-space: nowrap;
}
.ver.new { color: var(--bg); background: var(--accent); border-color: var(--accent); font-weight: 600; }
.ver.new:hover { background: var(--warn); }
.updbox {
  width: min(560px, 92vw);
  max-height: 90vh;
  overflow: auto;
  padding: 20px 24px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  user-select: text;
}
.wizard { width: min(600px, 92vw); }
.wzhead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.wzcard { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.wzcard:hover { border-color: var(--faint); }
.wzcard:has(input:checked) { border-color: var(--accent); background: var(--raise); }
.wzcard input { margin-top: 3px; }
.wzchoice { width: 100%; text-align: left; font: inherit; color: var(--text); background: none; }
.wzchoice:hover, .wzchoice:focus-visible { border-color: var(--accent); background: var(--raise); }
.wzcard > span { display: flex; flex-direction: column; gap: 2px; }
.wizard section[hidden], #wzBack[hidden] { display: none; }
.wizard ul { margin: 8px 0; padding-left: 20px; }
.wzkeys { margin: 4px 0; }
.updalert {
  position: fixed;
  top: 56px;
  left: 50%;
  z-index: 40;
  width: min(520px, calc(100vw - 32px));
  padding: 16px 20px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  transform: translateX(-50%);
  animation: updalert-in 0.25s ease-out;
  user-select: text;
}
.updalert[hidden] { display: none; }
.updalert h2 { margin: 0 0 4px; font-size: 17px; }
.updalert ul { margin: 6px 0; padding-left: 20px; }
.updalert p { margin: 8px 0; }
.updalert .small { font-size: 12px; }
.updalert pre { margin: 8px 0; padding: 10px 12px; font: 12px var(--mono); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; user-select: all; }
.btnlink { align-self: center; color: var(--accent); }
@keyframes updalert-in { from { opacity: 0; transform: translate(-50%, -16px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (prefers-reduced-motion: reduce) { .updalert { animation: none; } }
.tipbox { margin-top: 16px; padding: 10px 14px; border: 1px solid var(--cue); border-radius: 8px; background: var(--bg); font-size: 13px; }
.tipbox[hidden] { display: none; }
.tipbox strong:first-child { color: var(--cue); }
.tipbox p { margin: 6px 0; }
.updbox::backdrop { background: rgba(0, 0, 0, 0.7); }
.updbox h2 { margin: 0 0 12px; font-size: 18px; }
.updbox h3 { margin: 18px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.updbox p { margin: 8px 0; }
.updbox .small { font-size: 12px; }
.updbox a { color: var(--accent); }
.updbox code { font: 12px var(--mono); }
.updbox pre { margin: 8px 0; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; user-select: all; }
.updbtns { display: flex; gap: 8px; margin-top: 16px; }
.updnew { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; margin-bottom: 12px; padding: 10px 12px; border: 1px solid var(--accent); border-radius: 6px; }
.updopt { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.updstatus { font-size: 13px; }

.ttsbody.off { opacity: 0.45; pointer-events: none; }
.ttsvoice { display: flex; gap: 8px; min-width: 0; }
.ttsvoice select { flex: 1; }
.ttsgrid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 12px; align-items: center; margin: 12px 0; }
.ttsgrid select, .updbox select {
  min-width: 0;
  font: 13px var(--sans);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
}
.updopt + .updopt { margin-top: 6px; }
.warnbox { padding: 8px 10px; border: 1px solid var(--warn); border-radius: 6px; color: var(--warn); font-size: 13px; }
.warnbox[hidden] { display: none; }
#edStats .tts { white-space: nowrap; }
.autotag { padding: 0 5px; border: 1px solid var(--cue); border-radius: 4px; color: var(--cue); font: 11px var(--mono); }
.autotag[hidden] { display: none; }
#list .over { color: var(--bad); }
#ttsWeb[hidden], #ttsWebGet[hidden], #ttsAllStop[hidden], #ttsAllExactRow[hidden], #ttsAll[hidden], #ttsExport[hidden], #ttsFitAll[hidden], #ttsFitStop[hidden], .jobbar[hidden] { display: none; }
.jobbar { width: 220px; height: 10px; vertical-align: middle; accent-color: var(--accent); }
#ttsPiperNote:empty, #ttsExportNote:empty { display: none; }
.edspeed { display: inline-flex; align-items: center; gap: 4px; }
.edsay { padding: 1px 6px; font: 11px var(--mono); color: var(--dim); background: none; border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
.edsay:hover { color: var(--text); border-color: var(--faint); }
.edsay.on { color: var(--cue); border-color: var(--cue); }
.edsay[hidden] { display: none; }
.sayrows { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; gap: 6px 8px; align-items: center; margin: 12px 0 4px; }
.sayrows:empty { display: none; }
.sayrows input { min-width: 0; font: 14px var(--sans); color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
.sayrows .arrow { color: var(--faint); }
.sayrows .missing { grid-column: 1 / -1; margin: -2px 0 2px; font-size: 12px; color: var(--warn); }
.sayrows .missing[hidden] { display: none; }
.edspeed[hidden] { display: none; }
.edspeed select {
  max-width: 150px;
  font: 12px var(--mono);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 2px;
}

/* ---------- quick navigation / timecode palette ---------- */
#palette { align-items: flex-start; padding-top: 12vh; }
.palbox {
  width: min(640px, 92vw);
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.paltitle { font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin-bottom: 8px; }
#palInput {
  width: 100%;
  font: 18px var(--mono);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  outline: none;
}
#palInput:focus { border-color: var(--accent); }
.palhint { font-size: 12px; margin: 6px 2px; }
.pallist { max-height: 50vh; overflow-y: auto; }
.palrow {
  display: grid;
  grid-template-columns: 52px 110px minmax(0, 1fr);
  gap: 8px;
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
}
.palrow .n, .palrow .t { font: 12px var(--mono); color: var(--dim); padding-top: 2px; }
.palrow .tx { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palrow:hover { background: var(--panel2); }
.palrow.on { background: var(--accent-bg); }
.palrow.on .n { color: var(--accent); font-weight: 700; }


/* ---------- tooltips ---------- */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  z-index: 30;
  width: max-content;
  max-width: 260px;
  padding: 6px 9px;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font: 500 12px/1.4 var(--sans);
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  white-space: normal;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -3px);
  transition: opacity 0.12s, transform 0.12s;
}
[data-tip]:hover::after,
[data-tip]:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
  transition-delay: 0.35s;
}
[data-tip].tip-end::after { left: auto; right: 0; transform: translateY(-3px); }
[data-tip].tip-end:hover::after,
[data-tip].tip-end:focus-visible::after { transform: none; }
.dragging [data-tip]::after { display: none; }

/* ---------- list search ---------- */
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
#listSearch {
  flex: 1;
  min-width: 0;
  font: 14px var(--sans);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  outline: none;
}
#listSearch:focus { border-color: var(--accent); }
#listSearch::placeholder { color: var(--faint); }
#listCount { font: 12px var(--mono); white-space: nowrap; }
.row[hidden] { display: none; }
.row mark { background: var(--accent); color: var(--bg); border-radius: 2px; padding: 0 1px; }
.cue.faded { opacity: 0.3; }

/* ---------- audio track picker ---------- */
.trackpick { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 0 1 auto; font: 12px var(--mono); color: var(--dim); }
.trackpick[hidden] { display: none; }
#trackSel {
  width: 100%;
  min-width: 90px;
  max-width: 340px;
  text-overflow: ellipsis;
  font: 12px var(--mono);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
}
#trackSel:focus { outline: none; border-color: var(--accent); }
/* the footer is at the bottom of the window, so its tips open upwards */
.status [data-tip]::after { top: auto; bottom: calc(100% + 8px); }

/* AI help drawer: slides in from the right, over the video side */
.aidrawer {
  position: fixed;
  top: 44px;
  right: 0;
  bottom: 238px; /* above the timeline, which stays in use while writing */
  width: min(420px, 100vw);
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.35);
  transform: translateX(0);
  transition: transform 0.18s ease-out;
}
.aidrawer[hidden] { display: flex; transform: translateX(105%); visibility: hidden; transition: transform 0.18s ease-in, visibility 0s 0.18s; }
.aihead { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.aihead strong { white-space: nowrap; }
#aiWho { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aihead button, .aicompose button, .aisetup button { font: 13px var(--sans); }
.aisetup { padding: 4px 12px 10px; border-bottom: 1px solid var(--line); overflow-y: auto; max-height: 60%; }
.aisetup[hidden] { display: none; }
.aisetup input:not([type="checkbox"]) {
  min-width: 0; font: 13px var(--sans); color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px;
}
.aimodel { display: flex; gap: 6px; min-width: 0; }
.aimodel select { flex: 1; min-width: 0; }
.ailog { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.aimsg { padding: 8px 10px; border-radius: 8px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.aimsg.user { align-self: flex-end; max-width: 88%; background: var(--raise); }
.aimsg.assistant { background: var(--panel2); border: 1px solid var(--line); }
.aimsg.note { color: var(--dim); font-size: 12px; background: none; padding: 0 2px; }
.aimsg.error { color: var(--bad); border: 1px solid var(--bad); }
.aimsg .frames { display: flex; gap: 4px; margin-bottom: 6px; }
.aimsg .frames img { height: 44px; border-radius: 3px; }
.aimsg .acts { display: flex; gap: 6px; margin-top: 8px; white-space: normal; }
.aimsg.draft { border-color: var(--accent); }
.aimsg .tag { display: block; font: 11px var(--mono); color: var(--accent); margin-bottom: 4px; }
.aicompose { padding: 8px 10px 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.aicompose textarea { font: 14px/1.4 var(--sans); }
.airow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.airow label { display: inline-flex; align-items: center; gap: 4px; }
#aiStop[hidden] { display: none; }
#aiBtn.on { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.aidrawer [hidden] { display: none !important; }
#aiNotes { width: 100%; margin: 6px 0 2px; font: 13px/1.45 var(--sans); }
#aiNotesBtn.on { color: var(--accent); border-color: var(--accent); }
#verBtn.on { color: var(--accent); border-color: var(--accent); }
#newDlg [hidden] { display: none; }
