/* ==========================================================================
   Subtitle & Lyric Sync: "creative studio" look.
   Tokens first; dark mode follows the system unless the user picks a theme
   (html[data-theme="light" | "dark"]).
   ========================================================================== */

:root {
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Bricolage Grotesque", "Inter", system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", Consolas, monospace;

  --bg: #f6f4fb;
  --glow-1: rgba(118, 84, 255, 0.16);
  --glow-2: rgba(255, 95, 126, 0.12);
  --surface: #ffffff;
  --surface-2: #f5f3fa;
  --surface-3: #ece8f5;
  --border: #e8e4f1;
  --border-strong: #d6d0e4;
  --text: #19152a;
  --muted: #6b6582;
  --accent: #6a46f5;
  --accent-strong: #5631e8;
  --accent-soft: rgba(106, 70, 245, 0.1);
  --accent-ring: rgba(106, 70, 245, 0.28);
  --accent-text: #ffffff;
  --grad: linear-gradient(135deg, #6a46f5 0%, #a744e0 55%, #e2457c 100%);
  --error: #d6304f;
  --shadow-sm: 0 1px 2px rgba(25, 21, 42, 0.05);
  --shadow: 0 1px 2px rgba(25, 21, 42, 0.04), 0 12px 32px -16px rgba(40, 24, 90, 0.18);
  --shadow-lg: 0 24px 60px -20px rgba(40, 24, 90, 0.35);
  --radius: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --card-pad: 24px;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a84a0' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0b14;
    --glow-1: rgba(124, 92, 255, 0.22);
    --glow-2: rgba(255, 95, 126, 0.12);
    --surface: #16131f;
    --surface-2: #1c1827;
    --surface-3: #262133;
    --border: #2a2538;
    --border-strong: #3a334b;
    --text: #f0edf7;
    --muted: #a39cb8;
    --accent: #9d86ff;
    --accent-strong: #b3a1ff;
    --accent-soft: rgba(157, 134, 255, 0.14);
    --accent-ring: rgba(157, 134, 255, 0.35);
    --error: #ff6d86;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px -20px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0b14;
  --glow-1: rgba(124, 92, 255, 0.22);
  --glow-2: rgba(255, 95, 126, 0.12);
  --surface: #16131f;
  --surface-2: #1c1827;
  --surface-3: #262133;
  --border: #2a2538;
  --border-strong: #3a334b;
  --text: #f0edf7;
  --muted: #a39cb8;
  --accent: #9d86ff;
  --accent-strong: #b3a1ff;
  --accent-soft: rgba(157, 134, 255, 0.14);
  --accent-ring: rgba(157, 134, 255, 0.35);
  --error: #ff6d86;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px -20px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 520px at 12% -8%, var(--glow-1), transparent 70%),
    radial-gradient(800px 480px at 95% 0%, var(--glow-2), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.55 var(--font-ui);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-ring); }
.no-transitions *, .no-transitions *::before { transition: none !important; }
a { color: var(--accent); }
u { text-decoration-color: var(--accent); text-underline-offset: 3px; }

.top, main, footer { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap;
  padding-top: 36px; padding-bottom: 8px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { flex: none; width: 48px; height: 48px; filter: drop-shadow(0 8px 18px rgba(106, 70, 245, 0.35)); }
.top h1 {
  margin: 0; font: 800 30px/1.05 var(--font-display); letter-spacing: -0.035em;
}
.top h1 .grad-text {
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 16px 0 24px; padding: 0; width: 100%; }
.badges li {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px 5px 9px; font-size: 13px; font-weight: 500; color: var(--muted);
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  border: 1px solid var(--border); border-radius: 999px;
  backdrop-filter: blur(8px);
}
.badges svg { color: var(--accent); }

footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px;
  padding-top: 8px; padding-bottom: 40px; color: var(--muted); font-size: 13px;
}

/* ---------- Cards & headings ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--card-pad);
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  /* "backwards", not "both": a lingering transform would trap the
     fill-the-window preview inside the card. */
  animation: rise 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) backwards;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .card, .font-menu { animation: none !important; } * { transition: none !important; } }

h2 {
  display: flex; align-items: center; gap: 10px; margin: 0 0 14px;
  font: 700 18px/1.2 var(--font-display); letter-spacing: -0.015em;
}
h3, h4 { font-family: var(--font-display); letter-spacing: -0.01em; }
.num {
  display: inline-grid; place-items: center; flex: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--grad); color: #fff; font: 700 13px var(--font-ui);
  box-shadow: 0 4px 12px -4px rgba(106, 70, 245, 0.6);
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; gap: 22px; } }

/* ---------- Drop zones ---------- */

.drop {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 196px; padding: 20px; text-align: center; cursor: pointer;
  background: var(--surface-2);
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-md);
  transition: border-color 0.15s, background-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.drop:hover, .drop.over {
  border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px);
}
.drop:focus-within { box-shadow: 0 0 0 4px var(--accent-ring); }
.drop.has-file { border-style: solid; border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.drop-icon {
  display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 8px;
  border-radius: 14px; background: var(--surface); color: var(--accent);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border);
}
.drop.has-file .drop-icon { background: var(--grad); color: #fff; box-shadow: 0 6px 16px -6px rgba(106, 70, 245, 0.6); }
.drop-main { font-weight: 600; word-break: break-word; }
.drop-main u { color: var(--accent); }
.drop-sub { color: var(--muted); font-size: 13px; }
.drop-small { min-height: 0; flex-direction: row; gap: 12px; padding: 14px 16px; text-align: left; justify-content: flex-start; }
.drop-small .drop-icon { width: 40px; height: 40px; margin: 0; border-radius: 12px; }
.drop-small .drop-text { display: flex; flex-direction: column; min-width: 0; }

.or { display: flex; align-items: center; gap: 12px; margin: 12px 0; color: var(--muted); font-size: 12px; font-weight: 500; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

/* ---------- Form controls ---------- */

textarea, select, button, .t-time, .font-search, .button-like {
  font: inherit; color: inherit;
}
textarea {
  display: block; width: 100%; resize: vertical; padding: 12px 14px; line-height: 1.6;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea::placeholder { color: var(--muted); opacity: 0.8; }
textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
textarea.over { border-color: var(--accent); background: var(--accent-soft); }

select {
  appearance: none; -webkit-appearance: none;
  height: 40px; padding: 0 36px 0 12px;
  background: var(--surface) var(--chevron) no-repeat right 10px center / 16px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
}
select:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border-strong)); }
select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
option, optgroup { background: var(--surface); color: var(--text); }

button, .button-like {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; cursor: pointer;
  font-weight: 600; font-size: 14px; white-space: nowrap;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, color 0.15s, background-color 0.15s, box-shadow 0.15s, transform 0.1s, filter 0.15s;
}
button:hover:not(:disabled), .button-like:hover { border-color: var(--accent); color: var(--accent); }
button:active:not(:disabled) { transform: translateY(1px); }
button:focus-visible, .button-like:focus-within { outline: none; box-shadow: 0 0 0 4px var(--accent-ring); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary {
  color: #fff; background: var(--grad); border: none;
  box-shadow: 0 10px 24px -10px rgba(106, 70, 245, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
button.primary:hover:not(:disabled) { color: #fff; filter: brightness(1.08) saturate(1.05); }
button.primary-outline { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); background: var(--accent-soft); }
button.small { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
#alignBtn { height: 44px; padding: 0 28px; font-size: 15px; border-radius: 14px; }

input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }

input[type="color"] {
  width: 44px; height: 32px; padding: 3px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 7px; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 7px; }
input[type="color"]:disabled { opacity: 0.4; cursor: not-allowed; }

/* Range sliders */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; margin: 0; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: var(--surface-3); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 999px; background: var(--surface-3); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent); box-shadow: 0 2px 6px rgba(20, 10, 60, 0.3);
  transition: transform 0.12s;
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent); box-shadow: 0 2px 6px rgba(20, 10, 60, 0.3);
}
input[type="range"]:hover::-webkit-slider-thumb, input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.15); }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 5px var(--accent-ring); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 5px var(--accent-ring); }

.row { display: flex; align-items: end; gap: 14px; margin-top: 22px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.field output { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.field input[type="range"], .field select { width: 100%; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.link-btn { color: var(--accent); cursor: pointer; font-size: 13.5px; font-weight: 600; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.inline { display: flex; gap: 16px; }

/* Text box + full-screen editor button */
.text-wrap { position: relative; }
.text-wrap textarea { padding-right: 52px; }
.icon-btn {
  position: absolute; top: 8px; right: 8px;
  width: 34px; height: 34px; padding: 0; border-radius: 10px;
  color: var(--muted); background: var(--surface-2);
}

/* ---------- Status & messages ---------- */

.status { display: flex; align-items: center; gap: 14px; margin-top: 16px; font-size: 14px; color: var(--muted); }
.bar { flex: 0 0 220px; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > div {
  height: 100%; width: 0; border-radius: inherit; background: var(--grad); background-size: 200% 100%;
  transition: width 0.25s; animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.error {
  margin: 14px 0 0; padding: 10px 14px; font-size: 14px; color: var(--error);
  background: color-mix(in srgb, var(--error) 10%, transparent); border-radius: var(--radius-sm);
}
.note { color: var(--muted); font-size: 13px; }

/* ---------- Results: preview ---------- */

.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.results-head h2 { margin: 0; }
.pin-btn { color: var(--muted); }
.pin-btn[aria-pressed="true"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); background: var(--accent-soft); }

.stage {
  position: relative; overflow: hidden; background: #000;
  border-radius: 16px; box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
}
/* The preview is sized to the video itself (no black bars) and is the same
   size whether or not it's pinned. */
.stage { width: fit-content; max-width: 100%; margin: 0 auto; }
.stage video,
.stage:not(.video) canvas { display: block; width: auto; max-width: 100%; max-height: 60vh; margin: 0 auto; }
.stage.video canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; object-fit: contain; }
@media (max-width: 760px) {
  .stage video,
  .stage:not(.video) canvas { max-height: 50vh; }
}
#audio { display: block; width: 100%; margin-top: 12px; border-radius: 999px; }
#overlay.viz-editable { touch-action: none; } /* lets touch drag the visualizer instead of scrolling */

.controls-pane { container: settings / inline-size; min-width: 0; }
.preview-pane { min-width: 0; }

/* Pinned preview: stays stuck to the top of the window while the settings
   below it scroll. Only its backdrop changes when pinned, never its size. */
.preview-pane { margin: 0 calc(-1 * var(--card-pad)) 18px; padding: 12px var(--card-pad); }
.results-layout.pinned .preview-pane {
  position: sticky; top: 0; z-index: 15;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}

/* Full-screen preview (captions included): the button sits on the video's corner. */
.fs-btn {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 36px; height: 36px; padding: 0; border-radius: 10px;
  color: #fff; background: rgba(15, 10, 30, 0.55); border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px); box-shadow: none; opacity: 0.75;
}
.stage:hover .fs-btn, .fs-btn:focus-visible { opacity: 1; }
.fs-btn:hover:not(:disabled) { color: #fff; border-color: rgba(255, 255, 255, 0.5); background: rgba(15, 10, 30, 0.75); }
.fs-btn .fs-exit, .fs-btn.on .fs-enter { display: none; }
.fs-btn.on .fs-exit { display: block; }
/* Real full screen, or the fill-the-window fallback where that isn't allowed. */
.preview-pane:fullscreen, .results-layout .preview-pane.fs-fallback {
  display: flex; flex-direction: column; justify-content: center; gap: 12px;
  margin: 0; padding: 20px; background: #000; border: none;
}
.preview-pane.fs-fallback { position: fixed !important; inset: 0; z-index: 1000; backdrop-filter: none; }
.fs-lock, .fs-lock body { overflow: hidden; }
:is(.preview-pane:fullscreen, .preview-pane.fs-fallback) .stage { width: fit-content; max-width: 100%; margin: 0 auto; border-radius: 0; box-shadow: none; }
:is(.preview-pane:fullscreen, .preview-pane.fs-fallback) .stage video,
:is(.preview-pane:fullscreen, .preview-pane.fs-fallback) .stage:not(.video) canvas { width: auto; max-width: 100%; max-height: calc(100vh - 100px); margin: 0 auto; }
:is(.preview-pane:fullscreen, .preview-pane.fs-fallback) .stage.video video { max-height: calc(100vh - 40px); }
:is(.preview-pane:fullscreen, .preview-pane.fs-fallback) #audio { width: min(900px, 100%); height: 44px; margin: 0 auto; color-scheme: dark; }

/* ---------- Results: settings ---------- */

.basic {
  display: grid; grid-template-columns: 2fr 1.2fr 1fr 1fr auto auto; gap: 16px 18px;
  align-items: end; margin: 20px 0 16px; padding: 16px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.basic > .field:has(.check) { gap: 8px; }
/* Sized by the settings column, not the window, so it also fits beside the pinned preview. */
@container settings (max-width: 720px) { .basic { grid-template-columns: 1fr 1fr; } .font-field { grid-column: 1 / -1; } }

details > summary {
  display: flex; align-items: center; gap: 8px; width: max-content; padding: 6px 2px;
  list-style: none; cursor: pointer; user-select: none;
  font: 700 14.5px var(--font-display); color: var(--text);
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: ""; width: 20px; height: 20px; flex: none; border-radius: 6px;
  background: var(--accent-soft) var(--chevron) no-repeat center / 14px;
  transform: rotate(-90deg); transition: transform 0.2s;
}
details[open] > summary::before { transform: none; }
details > summary:hover { color: var(--accent); }
.advanced { margin-bottom: 18px; }
.advanced[open] > summary { margin-bottom: 8px; }

.panels { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 8px 0 0; }
fieldset {
  display: flex; flex-direction: column; gap: 12px; margin: 0; min-width: 0;
  padding: 12px 16px 16px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-md);
}
legend {
  padding: 3px 10px; font: 700 12px var(--font-ui); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
}
legend .check { color: var(--text); font-size: 12px; }
fieldset.off > :not(legend) { opacity: 0.4; pointer-events: none; }

/* Segmented control (background type, theme) */
.segmented {
  display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 4px;
  background: var(--surface-3); border-radius: 13px;
}
.segmented label {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 10px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--muted);
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.segmented label:hover { color: var(--text); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm), 0 2px 8px -4px rgba(40, 24, 90, 0.3); }
.segmented label:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--accent-ring); }

/* Background panel (audio files) */
.bg-panel {
  margin: 0 0 18px; padding: 18px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.bg-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; margin-bottom: 16px; }
.bg-head h3 { margin: 0; font-size: 16px; }
.bg-panel .segmented { background: var(--surface-3); }
.bg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px 18px; align-items: end; }
.bg-grid .wide { grid-column: span 2; }
@media (max-width: 500px) { .bg-grid .wide { grid-column: auto; } }
.file-pick { display: flex; flex-direction: column; gap: 6px; }
.button-like { width: max-content; height: 38px; }
.file-name { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.bg-effects { margin: 18px 0 0; padding-top: 12px; border-top: 1px solid var(--border); }
.bg-effects[open] > summary { margin-bottom: 12px; }
.sub-head { margin: 20px 0 10px; font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.span-all { grid-column: 1 / -1; margin: 0; }
.bg-output { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }

/* ---------- Subtitle timing editor ---------- */

.timing { margin: 18px 0 0; }
.timing[open] > summary { margin-bottom: 12px; }
.timing-bar { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.timing .note { margin: 10px 0; }
.timing-list {
  position: relative; max-height: 440px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.t-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  transition: background-color 0.15s, box-shadow 0.15s;
}
.t-row:last-child { border-bottom: none; }
.t-row:hover { background: var(--surface-2); }
.t-row.playing { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.t-num { width: 24px; text-align: right; color: var(--muted); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.t-pair { display: inline-flex; align-items: center; gap: 2px; }
.t-arrow { color: var(--muted); }
.t-time {
  width: 96px; height: 30px; padding: 0 8px; font: 500 13px var(--font-mono); color: inherit;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.t-time.small { width: 86px; font-size: 12px; }
.t-time:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.t-time.invalid { border-color: var(--error); box-shadow: 0 0 0 3px color-mix(in srgb, var(--error) 30%, transparent); }
.t-row button { height: 28px; padding: 0 9px; font-size: 12.5px; border-radius: 8px; box-shadow: none; }
.t-play { width: 28px; padding: 0 !important; color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.t-row button.t-now { width: 26px; padding: 0; border: none; background: none; font-size: 14px; }
.t-text { flex: 1; min-width: 160px; font-size: 14px; }
.t-words { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 8px 14px; padding: 8px 0 2px 34px; }
.t-word { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; padding: 3px 4px 3px 10px; background: var(--surface-2); border-radius: 10px; }

/* ---------- Downloads ---------- */

.downloads { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; padding-top: 20px; border-top: 1px solid var(--border); }
.dl-group { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: end; }
.dl-group.main button { height: 44px; padding: 0 20px; border-radius: 14px; }
.dl-label { width: 76px; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.more { margin-top: 2px; }
.more[open] > summary { margin-bottom: 12px; }
.more .dl-group + .dl-group { margin-top: 10px; }

/* ---------- Font picker ---------- */

.font-picker { position: relative; }
.font-btn { width: 100%; justify-content: space-between; font-weight: 400; text-align: left; color: var(--text); }
.font-btn svg { color: var(--muted); flex: none; }
.font-btn-label { font-size: 17px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.font-menu {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0;
  width: max(100%, 320px); max-width: calc(100vw - 32px); overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: pop 0.14s ease-out both;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
.font-menu.up { top: auto; bottom: calc(100% + 6px); }
.font-search {
  display: block; width: 100%; padding: 12px 14px;
  background: var(--surface-2); border: none; border-bottom: 1px solid var(--border); outline: none;
}
.font-list { max-height: min(420px, 55vh); overflow-y: auto; padding: 4px 6px 6px; }
.font-group {
  position: sticky; top: -4px; z-index: 1; padding: 10px 8px 4px; background: var(--surface);
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.font-option { padding: 6px 10px; border-radius: 9px; font-size: 20px; line-height: 1.3; color: var(--text); cursor: pointer; white-space: nowrap; }
.font-option.active { background: var(--accent-soft); }
.font-option[aria-selected="true"] { color: var(--accent); }
.font-empty { padding: 12px; color: var(--muted); font-size: 14px; }

/* ---------- Full-screen text editor ---------- */

dialog.editor {
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: none;
  background: var(--bg); color: var(--text);
}
dialog.editor::backdrop { background: rgba(10, 6, 25, 0.55); backdrop-filter: blur(4px); }
.editor-inner { display: flex; flex-direction: column; height: 100%; }
.editor-bar {
  display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap;
  padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.editor-bar h3 { margin: 0; font-size: 17px; }
.editor-stats, .editor-hint { color: var(--muted); font-size: 13px; }
.editor-stats { padding: 3px 10px; background: var(--surface-2); border-radius: 999px; font-weight: 600; }
.editor-actions { margin-left: auto; display: flex; gap: 8px; }
@media (max-width: 700px) { .editor-hint { display: none; } }
#dialogText {
  flex: 1; width: 100%; max-width: 960px; margin: 0 auto; resize: none;
  border: none; border-radius: 0; padding: 32px 24px; background: transparent; box-shadow: none;
  font-size: 18px; line-height: 1.8;
}

/* ---------- Theme switch ---------- */

.theme-switch { padding: 3px; background: color-mix(in srgb, var(--surface-3) 80%, transparent); }
.theme-switch label { padding: 6px 8px; }
.theme-switch svg { display: block; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Small screens ---------- */

@media (max-width: 600px) {
  :root { --card-pad: 18px; --radius: 18px; }
  .top { padding-top: 24px; }
  .top h1 { font-size: 26px; }
  .brand-mark { width: 42px; height: 42px; }
  .drop:not(.drop-small) { min-height: 160px; }
  .bar { flex-basis: 120px; }
  #alignBtn { flex: 1; }
}

/* Link back to the Toolerr home page, above the app's title */
.toolerr-bar { flex-basis: 100%; margin-bottom: -4px; }
.toolerr-link {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px 5px 8px;
  font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border: 1px solid var(--border); border-radius: 999px; backdrop-filter: blur(8px);
  transition: color 0.15s, border-color 0.15s;
}
.toolerr-link svg { display: block; flex: none; }
.toolerr-link .chev { transition: transform 0.15s; }
.toolerr-link:hover { color: var(--text); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.toolerr-link:hover .chev { transform: translateX(-2px); }
.toolerr-name { font: 800 14px var(--font-display); letter-spacing: -0.01em; color: var(--text); }
.toolerr-sub { padding-left: 7px; border-left: 1px solid var(--border-strong); }

/* Link to the Video Creator app, shown with the Folder montage background */
.app-callout {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px;
  margin: 0 0 16px; padding: 12px 14px; text-decoration: none; color: var(--text);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 9%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); border-radius: var(--radius-md);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.app-callout:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.app-callout-icon svg { display: block; }
.app-callout-text { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; }
.app-callout-text span { color: var(--muted); }
.app-callout-go { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; color: var(--accent); white-space: nowrap; }
.app-callout:hover .app-callout-go svg { transform: translateX(3px); }
.app-callout-go svg { transition: transform 0.15s; }

/* Back to top (same as the Toolerr site pages) */
.to-top {
  position: fixed; right: 24px; bottom: 24px; z-index: 60;
  display: grid; place-items: center; width: 46px; height: 46px; padding: 0; border: none; border-radius: 14px;
  color: #fff; background: var(--grad); box-shadow: 0 12px 26px -10px rgba(106, 70, 245, 0.75);
  opacity: 0; visibility: hidden; transform: translateY(12px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}
.to-top.show { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { transform: translateY(-2px); }
@media (max-width: 600px) { .to-top { right: 16px; bottom: 16px; width: 42px; height: 42px; } }
