/* ScrollReel editor.
   Neutral graphite workspace in the spirit of pro video tools: the colour is
   reserved for meaning. Vermilion = the one primary action (render) and
   progress; mint = done / ready; everything else is greyscale. */
:root {
  --chrome: #111214;
  --surface: #151619;
  --surface-2: #1b1c20;
  --surface-3: #232429;
  --surface-4: #2d2e34;
  --stage: #0b0b0d;
  --line: #26272c;
  --line-strong: #36373e;
  --text: #ececee;
  --text-2: #a2a2aa;
  --text-3: #6d6d76;
  --rec: #ff5a3c;
  --rec-hover: #ff7055;
  --rec-ink: #1d0b05;
  --ok: #7fd4c1;
  --focus: #7fd4c1;

  --radius: 7px;
  --appbar-h: 52px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  color-scheme: dark;
}

* { box-sizing: border-box; min-width: 0; }

/* Author `display` rules would otherwise beat the UA's [hidden] rule. */
[hidden] { display: none !important; }

.visually-hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

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

/* clip, not hidden: hidden on both html and body makes body a scroll
   container, which silently breaks every position: sticky below it. */
html { overflow-x: clip; }
/* The editor is a fixed-viewport app: the page itself never scrolls; only
   the panels inside .workspace do. */
body.app {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--chrome);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

/* ---------------------------------------------------------------- App bar */
.appbar {
  flex: none;
  position: relative;
  z-index: 30;
  height: var(--appbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--chrome);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
  border-radius: 4px;
}
.brand-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rec); }
.appbar-divider { width: 1px; height: 18px; background: var(--line-strong); }

.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 18px;
  color: var(--text-3);
  font-size: 12.5px;
}
.checklist li { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.checklist-mark {
  position: relative;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  transition: background 0.2s ease, border-color 0.2s ease;
}
.checklist-mark::after {
  content: "";
  position: absolute;
  left: 3.5px;
  top: 1.5px;
  width: 3.5px;
  height: 6.5px;
  border: solid var(--chrome);
  border-width: 0 1.6px 1.6px 0;
  transform: rotate(45deg);
  opacity: 0;
}
.has-text .checklist [data-step="text"],
.has-audio .checklist [data-step="audio"],
.has-image .checklist [data-step="image"] { color: var(--text); }
.has-text .checklist [data-step="text"] .checklist-mark,
.has-audio .checklist [data-step="audio"] .checklist-mark,
.has-image .checklist [data-step="image"] .checklist-mark { background: var(--ok); border-color: var(--ok); }
.has-text .checklist [data-step="text"] .checklist-mark::after,
.has-audio .checklist [data-step="audio"] .checklist-mark::after,
.has-image .checklist [data-step="image"] .checklist-mark::after { opacity: 1; }

.appbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.appbar-controls { display: flex; gap: 8px; }

/* ---------------------------------------------------------------- Workspace */
.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr) 340px;
  grid-template-rows: minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  position: relative;
}
/* position: relative contains the absolutely-positioned hidden <select>s
   behind the segmented controls; without it they escape the panel's scroll
   area and stretch the page. */
.pane { position: relative; background: var(--surface); overflow-y: auto; overscroll-behavior: contain; }
.pane-source { border-right: 1px solid var(--line); }
.pane-inspector {
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.inspector-scroll { position: relative; flex: 1; overflow-y: auto; overscroll-behavior: contain; }

/* ---------------------------------------------------------------- Sections */
.section {
  margin: 0;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.legendToggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 44px;
  padding: 0 10px 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.legendToggle:hover { background: rgba(255, 255, 255, 0.02); }
.legendToggle:focus-visible { outline-offset: -2px; }
.legendLabel { flex: 1; }
.chevron {
  width: 14px;
  height: 14px;
  flex: none;
  color: var(--text-3);
  transition: transform 0.15s ease;
}
.section.collapsed .chevron { transform: rotate(-90deg); }
.section.collapsed .fieldsetBody { display: none; }

.reqTodo { font-size: 11.5px; font-weight: 500; color: var(--text-3); }
.reqCheck {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(127, 212, 193, 0.14);
  color: var(--ok);
}
.reqCheck svg { width: 11px; height: 11px; }
.reqCheck:not([hidden]) + .reqTodo { display: none; }

.sectionResetBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.sectionResetBtn svg { width: 13px; height: 13px; }
.legendToggle:hover .sectionResetBtn,
.sectionResetBtn:focus-visible { opacity: 1; }
.sectionResetBtn:hover { background: var(--surface-3); color: var(--text); }
@media (hover: none) { .sectionResetBtn { opacity: 1; } }

.fieldsetBody {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 2px 16px 20px;
}

/* ---------------------------------------------------------------- Fields */
.field { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.field-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
}
.field-label output {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 14px; align-items: end; }
.inline-row { display: flex; align-items: center; gap: 8px; }
.inline-row > select,
.inline-row > input[type="range"] { flex: 1; }
.inline-row--between { justify-content: space-between; }
.inline-row--end { justify-content: flex-end; margin-top: -8px; }
.muted { color: var(--text-3); }

.subhead {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.subhead span { font-weight: 400; color: var(--text-3); }

.help { margin: 0; font-size: 12px; line-height: 1.55; color: var(--text-2); }
.help--status:empty { display: none; }

.notice {
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-2);
}
#customFontInfo { overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- Inputs */
input[type="text"], input[type="number"], select {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type="number"] { font-variant-numeric: tabular-nums; }
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a2a2aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
}
select option { background: var(--surface-2); color: var(--text); }
input[type="text"]:hover, input[type="number"]:hover, select:hover { border-color: var(--line-strong); }
input[type="text"]:focus, input[type="number"]:focus, select:focus {
  outline: none;
  border-color: var(--text-3);
  box-shadow: 0 0 0 3px rgba(127, 212, 193, 0.16);
}
input:disabled, select:disabled { opacity: 0.45; cursor: not-allowed; }
.input-sm { width: 64px; flex: none; }
.select-sm { width: 64px !important; flex: none !important; }

.suffix-input { position: relative; display: block; }
.suffix-input input { padding-right: 26px; }
.suffix-input span {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-size: 12px;
  pointer-events: none;
}

/* Range */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 2px; border-radius: 2px; background: var(--line-strong); }
input[type="range"]::-moz-range-track { height: 2px; border-radius: 2px; background: var(--line-strong); }
input[type="range"]::-moz-range-progress { height: 2px; border-radius: 2px; background: var(--text-2); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -6px;
  border: 0;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  transition: box-shadow 0.15s ease;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
input[type="range"]:hover::-webkit-slider-thumb { box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.07), 0 1px 3px rgba(0, 0, 0, 0.6); }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--chrome), 0 0 0 5px var(--focus); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--chrome), 0 0 0 5px var(--focus); }

/* Colour swatch */
.swatch-field {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 32px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
}
input[type="color"] {
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 4px; }
input[type="color"]::-moz-color-swatch { border: 0; border-radius: 4px; }

/* Switch (styled checkbox) */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.switch input {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: none;
  width: 30px;
  height: 18px;
  margin: 0;
  border-radius: 999px;
  background: var(--line-strong);
  cursor: pointer;
  transition: background 0.15s ease;
}
.switch input::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-2);
  transition: transform 0.15s ease, background 0.15s ease;
}
.switch input:checked { background: var(--text); }
.switch input:checked::before { transform: translateX(12px); background: var(--chrome); }

.option {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.option-body { display: flex; flex-direction: column; gap: 16px; padding-left: 40px; }

/* Segmented control */
.segmented {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.segmented-btn {
  flex: 1;
  height: 26px;
  padding: 0 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.segmented-btn:hover { color: var(--text); }
.segmented-btn[aria-checked="true"] {
  background: var(--surface-4);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}
.segmented-btn:disabled { cursor: not-allowed; opacity: 0.5; }
.segmented-btn svg { width: 15px; height: 15px; }

/* Aspect ratio picker */
.ratioPicker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.ratioCard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 2px 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-2);
  font: inherit;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.ratioCard:hover { border-color: var(--line-strong); color: var(--text); }
.ratioCard[aria-checked="true"] { background: var(--surface-4); border-color: var(--line-strong); color: var(--text); }
.ratioCard:disabled { cursor: not-allowed; opacity: 0.5; }
.ratioGlyph { display: flex; align-items: center; justify-content: center; height: 22px; }
.ratioGlyph > span { display: block; border: 1.5px solid currentColor; border-radius: 2px; }
.ratioGlyph--custom { border-style: dashed !important; }

/* ---------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}
.btn svg { width: 15px; height: 15px; flex: none; }
.btn:disabled { cursor: not-allowed; opacity: 0.45; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); }
.btn-quiet { background: transparent; color: var(--text-2); }
.btn-quiet:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-secondary { background: var(--surface-3); border-color: var(--line-strong); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-4); }
.btn-primary {
  width: 100%;
  height: 40px;
  background: var(--rec);
  color: var(--rec-ink);
  font-size: 14px;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: var(--rec-hover); }
.btn-primary:disabled { opacity: 1; background: var(--surface-3); color: var(--text-2); }
.btn-done {
  width: 100%;
  height: 40px;
  border-color: rgba(127, 212, 193, 0.5);
  color: var(--ok);
  font-weight: 600;
}
.btn-done:hover { background: rgba(127, 212, 193, 0.08); }
.btn-done.downloading { pointer-events: none; opacity: 0.7; }

.filebtn {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease;
}
.filebtn:hover { background: var(--surface-3); }
.filebtn:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.filebtn svg { width: 14px; height: 14px; color: var(--text-2); }
.filebtn:has(input:disabled) { opacity: 0.45; cursor: not-allowed; }

.spinner {
  width: 14px;
  height: 14px;
  flex: none;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- Drop zones */
.drop {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.drop:hover { border-color: var(--text-3); background: rgba(255, 255, 255, 0.015); }
.drop:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
/* The real input covers the zone so click-to-browse and drag-and-drop are native. */
.drop input[type="file"] {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.drop input[type="file"]:disabled { cursor: not-allowed; }
.drop-icon {
  position: relative;
  z-index: 1;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: var(--surface-3);
  color: var(--text-2);
}
.drop-icon svg { width: 16px; height: 16px; }
.drop-text { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.drop-title { font-size: 13px; font-weight: 500; color: var(--text); }
.drop-sub {
  font-size: 12px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drop-action {
  position: relative;
  z-index: 1;
  flex: none;
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-2);
}
.drop-compact { padding: 8px 10px; }
.drop-compact .drop-icon { width: 28px; height: 28px; }

.has-audio .drop-audio { border-style: solid; border-color: var(--line); background: var(--surface-2); }
.has-audio .drop-audio .drop-icon { background: rgba(127, 212, 193, 0.12); color: var(--ok); }
.fs-audio:has(#musicStatusRow:not([hidden])) .drop-compact { border-style: solid; border-color: var(--line); background: var(--surface-2); }

.drop-image {
  flex-direction: column;
  justify-content: center;
  aspect-ratio: 16 / 10;
  padding: 16px;
  text-align: center;
  overflow: hidden;
}
.drop-image .drop-text { flex: none; align-items: center; }
.drop-thumb {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.drop-title--filled { display: none; }
.drop-image:has(.drop-thumb:not([hidden])) {
  justify-content: flex-end;
  align-items: stretch;
  border-style: solid;
  border-color: var(--line);
}
.drop-image:has(.drop-thumb:not([hidden]))::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(180deg, transparent 45%, rgba(0, 0, 0, 0.75));
}
.drop-image:has(.drop-thumb:not([hidden])) .drop-icon { display: none; }
.drop-image:has(.drop-thumb:not([hidden])) .drop-text { align-items: flex-start; }
.drop-image:has(.drop-thumb:not([hidden])) .drop-title--empty { display: none; }
.drop-image:has(.drop-thumb:not([hidden])) .drop-title--filled { display: block; }
.drop-image:has(.drop-thumb:not([hidden])) .drop-sub { color: rgba(255, 255, 255, 0.7); }

/* ---------------------------------------------------------------- Script editor */
.editor {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.editor:focus-within { border-color: var(--text-3); box-shadow: 0 0 0 3px rgba(127, 212, 193, 0.12); }

#quillToolbar.ql-toolbar.ql-snow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: 4px 6px;
  border: 0;
  border-bottom: 1px solid var(--line);
  font-family: inherit;
}
#quillToolbar.ql-toolbar.ql-snow .ql-formats { margin-right: 6px; padding-right: 6px; border-right: 1px solid var(--line); }
#quillToolbar.ql-toolbar.ql-snow .ql-formats:last-child { border-right: 0; }
#quillToolbar button { border-radius: 5px; }
#quillToolbar button:hover { background: var(--surface-3); }
#quillToolbar .ql-stroke { stroke: var(--text-2); }
#quillToolbar .ql-fill { fill: var(--text-2); }
#quillToolbar button:hover .ql-stroke, #quillToolbar button.ql-active .ql-stroke,
#quillToolbar .ql-picker-label:hover .ql-stroke { stroke: var(--text); }
#quillToolbar button:hover .ql-fill, #quillToolbar button.ql-active .ql-fill { fill: var(--text); }
#quillToolbar button.ql-active { background: var(--surface-4); }
#quillToolbar .ql-picker-label { border: 0; color: var(--text-2); }
#quillToolbar .ql-picker-options {
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

#textEditor.ql-container.ql-snow {
  border: 0;
  height: clamp(220px, 38vh, 460px);
  resize: vertical;
  overflow: hidden;
  font-family: inherit;
  font-size: 14px;
}
#textEditor .ql-editor {
  height: 100%;
  overflow-y: auto;
  padding: 12px 14px;
  line-height: 1.6;
  color: var(--text);
}
#textEditor .ql-editor.ql-blank::before { left: 14px; right: 14px; color: var(--text-3); font-style: normal; }

.emojiPickerFormats { position: relative; }
.emojiPickerBtn {
  width: 28px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.emojiPicker {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  width: 284px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}
.emojiPickerHeader { display: flex; align-items: center; gap: 6px; }
.emojiPickerHeader input[type="text"] { flex: 1; height: 30px; background: var(--surface-2); }
.emojiPickerCloseBtn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.emojiPickerCloseBtn:hover { background: var(--surface-4); color: var(--text); }
.emojiPickerCloseBtn svg { width: 14px; height: 14px; }
.emojiGrid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-height: 224px;
  overflow-y: auto;
}
.emojiGrid button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}
.emojiGrid button:hover { background: var(--surface-4); }
.emojiGrid img { width: 22px; height: 22px; display: block; }
.emojiGrid .emojiEmpty { grid-column: 1 / -1; padding: 16px 0; text-align: center; font-size: 12px; color: var(--text-2); }

/* ---------------------------------------------------------------- Motion */
.sync-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.sync-panel .btn { align-self: flex-start; }

/* ---------------------------------------------------------------- Progress & render */
.progressWrap { display: flex; flex-direction: column; gap: 6px; }
.progressBar { height: 4px; border-radius: 2px; background: var(--line-strong); overflow: hidden; }
.progressFill { height: 100%; width: 0%; background: var(--rec); transition: width 0.25s ease; }
#analyzeProgressFill { background: var(--ok); }
.progressLabel { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }

.renderBox {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
  cursor: pointer;
}
.link-btn:hover { text-decoration-color: currentColor; }
.link-btn:disabled { color: var(--text-3); cursor: default; }

.rate-prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--text-2);
}
.credit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11.5px;
  color: var(--text-3);
}
.credit strong { font-weight: 600; color: var(--text-2); }

.error {
  max-height: 28vh;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid rgba(255, 90, 60, 0.35);
  border-radius: var(--radius);
  background: rgba(255, 90, 60, 0.08);
  color: #ffb6a6;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- Preview stage */
.previewPane {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 14px 24px 18px;
  background: var(--stage);
}
.stage-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stage-title { font-size: 12px; font-weight: 600; color: var(--text-2); }
.stage-meta { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); }

.previewFrameWrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#previewCanvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  background: #000;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 24px 60px rgba(0, 0, 0, 0.6);
}

.previewControls {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}
.transport-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.transport-btn svg { width: 16px; height: 16px; }
.transport-btn:hover:not(:disabled) { background: var(--surface-4); }
.transport-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.transport-btn--play { width: 40px; height: 40px; border: 0; background: var(--text); color: var(--chrome); }
.transport-btn--play:hover:not(:disabled) { background: #fff; }
#playBtn svg { transform: translateX(1px); }
.transport-btn--ghost { width: 32px; height: 32px; border: 0; background: transparent; color: var(--text-2); }
.transport-btn--ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.transport-btn--ghost svg { width: 14px; height: 14px; }

.timecode {
  flex: none;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.timecode--total { color: var(--text-3); }

/* Scrub bar: --pct (set by previewCanvas.js) paints the played portion. */
.seek {
  --pct: 0%;
  flex: 1;
  height: 20px;
}
input.seek::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--text) var(--pct), var(--line-strong) var(--pct));
}
input.seek::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line-strong); }
input.seek::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--text); }
input.seek::-webkit-slider-thumb { width: 12px; height: 12px; margin-top: -4px; opacity: 0; transition: opacity 0.15s ease; }
input.seek::-moz-range-thumb { width: 12px; height: 12px; opacity: 0; transition: opacity 0.15s ease; }
input.seek:hover::-webkit-slider-thumb, input.seek:active::-webkit-slider-thumb, input.seek:focus-visible::-webkit-slider-thumb { opacity: 1; }
input.seek:hover::-moz-range-thumb, input.seek:active::-moz-range-thumb, input.seek:focus-visible::-moz-range-thumb { opacity: 1; }
input.seek:hover::-webkit-slider-runnable-track { height: 6px; }
input.seek:hover::-webkit-slider-thumb { margin-top: -3px; }
.seek:disabled { cursor: default; opacity: 0.5; }

@media (hover: none) {
  input.seek::-webkit-slider-thumb { opacity: 1; width: 16px; height: 16px; margin-top: -6px; }
  input.seek::-moz-range-thumb { opacity: 1; }
}

/* ---------------------------------------------------------------- Responsive */
/* Mid widths: the workspace (not the page) scrolls the stacked settings;
   the preview pins on the right. */
@media (max-width: 1199px) {
  .workspace {
    overflow-y: auto;
    overscroll-behavior: contain;
    grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
    grid-template-rows: auto auto;
    grid-template-areas:
      "source preview"
      "inspector preview";
    align-items: start;
  }
  .pane, .pane-inspector, .inspector-scroll { overflow: visible; }
  .pane-source { grid-area: source; }
  .pane-inspector { grid-area: inspector; border-left: 0; border-right: 1px solid var(--line); }
  .previewPane {
    grid-area: preview;
    position: sticky;
    top: 0;
    height: calc(100vh - var(--appbar-h));
    height: calc(100dvh - var(--appbar-h));
  }
  .renderBox { position: sticky; bottom: 0; z-index: 5; }
}

/* Narrow: one column, preview first. */
@media (max-width: 859px) {
  .workspace { grid-template-columns: 1fr; grid-template-areas: "preview" "source" "inspector"; }
  .pane-source, .pane-inspector { border: 0; }
  .previewPane { position: static; height: auto; padding: 12px 16px 16px; }
  #previewCanvas { max-height: 58svh; }
  .fieldsetBody { padding: 2px 16px 20px; }
}

@media (max-width: 600px) {
  .checklist { display: none; }
  .appbar-divider { display: none; }
}
@media (max-width: 420px) {
  .btn-quiet .btn-label { display: none; }
}

@media (max-width: 380px) {
  .grid-2 { grid-template-columns: 1fr; }
  .ratioPicker { grid-template-columns: repeat(3, 1fr); }
}
