/* ==========================================================================
   OPPE CLIPS — studio stylesheet
   Independent dark and light palettes with clear, high-contrast controls.
   ========================================================================== */

/* FILE MAP: themes, base, buttons, shell, start screen, source form, inspector,
   preview/editor, timeline/render, facecam, footer, animations, responsive. */

/* DARK THEME — YouTube-inspired charcoal surfaces with a restrained red accent. */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --navy: #0f0f0f;
  --navy-2: #212121;
  --accent: #ff0033;
  --accent-strong: color-mix(in srgb, var(--accent) 85%, black);
  --accent-soft: color-mix(in srgb, var(--accent) 20%, white);
  --accent-wash: color-mix(in srgb, var(--accent) 12%, var(--paper));
  --accent-text: var(--text);
  --on-accent: #111;
  --paper: #0f0f0f;
  --white: #181818;
  --text: #f1f1f1;
  --line: #2a2a2a;
  --line-strong: #404040;
  --muted: #c0c0c0;
  --subtle: #a0a0a0;
  --danger: #d12c4a;
  --danger-wash: #351920;
  --ok: #55d99a;
  --ok-wash: #142d24;
  --warn: #ffd45c;
}

/* LIGHT THEME — Twitch-inspired purple accents on clean, soft-white surfaces. */
:root[data-theme="light"] {
  color-scheme: light;
  --navy: #24133e;
  --navy-2: #eee7fa;
  --accent: #9146ff;
  --accent-strong: color-mix(in srgb, var(--accent) 70%, black);
  --accent-soft: color-mix(in srgb, var(--accent) 20%, white);
  --accent-wash: color-mix(in srgb, var(--accent) 8%, var(--paper));
  --accent-text: var(--text);
  --on-accent: #fff;
  --paper: #f7f5fa;
  --white: #fff;
  --text: #19151f;
  --line: #e4dff0;
  --line-strong: #c8bfd5;
  --muted: #403847;
  --subtle: #5b5264;
  --danger: #d12c4a;
  --danger-wash: #ffe9ed;
  --ok: #087b51;
  --ok-wash: #e0f8eb;
  --warn: #805500;
}

/* SHARED LAYOUT TOKENS — these affect both themes. */
:root {
  --radius: 12px;
  --display: 'Archivo Black', 'DM Sans', sans-serif;
  --stage-h: clamp(440px, calc(100svh - 360px), 820px);
}

/* ==========================================================================
   RESET / BASE
   ========================================================================== */
*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--text);
  font: 400 14px/1.5 'DM Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}

body.facecam-modal-open { overflow: hidden; }

h1, h2, h3, p { margin: 0; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

[hidden] { display: none !important; }

::selection { background: var(--accent); color: var(--on-accent); }

a { color: inherit; text-underline-offset: 3px; }

:where(button, a, summary, input, select, [tabindex]):focus-visible {
  outline: 3px solid var(--accent-strong);
  outline-offset: 2px;
}

.ui-icon {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.eyebrow,
.tiny-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.field-label span {
  color: var(--subtle);
  font-size: 12px;
  font-weight: 500;
}

.field-hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.field-hint.is-error,
.thumbnail-hint.is-error { color: var(--danger); font-weight: 600; }

/* ==========================================================================
   BUTTONS — one primary and one secondary look for the whole app
   ========================================================================== */
.source-preview-button,
.facecam-open-button,
.facecam-done-button,
.facecam-load-button,
.download-button,
.cookie-button.is-primary,
.source-summary-discard,
.layer-tool-done,
.render-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 18px;
  border: 2px solid var(--navy);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color .15s ease, color .15s ease, transform .1s ease;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 12%, transparent);
}

.source-preview-button:hover:not(:disabled),
.facecam-open-button:hover:not(:disabled),
.facecam-done-button:hover:not(:disabled),
.facecam-load-button:hover:not(:disabled),
.download-button:hover,
.cookie-button.is-primary:hover,
.source-summary-discard:hover,
.render-action:hover:not(:disabled):not([data-state="done"]):not(.is-cooldown) {
  background: var(--navy);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .28);
}

.source-preview-button:active:not(:disabled),
.facecam-open-button:active:not(:disabled),
.facecam-done-button:active:not(:disabled),
.facecam-load-button:active:not(:disabled),
.download-button:active,
.cookie-button.is-primary:active,
.source-summary-discard:active,
.render-action:active:not(:disabled):not([data-state="done"]):not(.is-cooldown) {
  transform: scale(.98);
}

.source-preview-button:disabled,
.facecam-load-button:disabled {
  opacity: .55;
  cursor: not-allowed;
  box-shadow: none;
}

.facecam-clear-button,
.timeline-reset,
.make-another-button,
.thumbnail-button,
.cookie-button.is-secondary,
.source-summary-cancel,
.source-summary-change {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--white);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  transition: background-color .15s ease, transform .12s ease;
}

.facecam-clear-button:hover,
.timeline-reset:hover,
.make-another-button:hover,
.thumbnail-button:hover,
.cookie-button.is-secondary:hover,
.source-summary-cancel:hover,
.source-summary-change:hover { background: var(--accent-wash); }

.facecam-clear-button:active,
.timeline-reset:active,
.make-another-button:active,
.thumbnail-button:active,
.cookie-button.is-secondary:active,
.source-summary-cancel:active,
.source-summary-change:active { transform: translateY(1px); }

/* ==========================================================================
   APP SHELL + TOP BAR
   ========================================================================== */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(16px, 3vw, 40px);
  position: relative;
  z-index: 2;
  height: 72px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(18px);
  transition: background-color .25s ease, border-color .25s ease;
}

.topbar-actions { display: inline-flex; align-items: center; gap: 12px; }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--white);
  color: var(--accent-text);
  transition: transform .18s ease, color .2s ease, background-color .25s ease, border-color .25s ease, box-shadow .18s ease;
}

.theme-toggle:hover {
  transform: translateY(-2px) rotate(-6deg);
  border-color: var(--accent-strong);
  box-shadow: 0 0 22px color-mix(in srgb, var(--accent) 18%, transparent);
}

.theme-toggle:active { transform: scale(.94); }
.theme-toggle-icon { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle-icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle-icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle-icon-moon { display: block; color: var(--accent-text); }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-family: var(--display);
  font-size: 19px;
  letter-spacing: .02em;
  text-decoration: none;
}

.brand-mark {
  display: block;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border-radius: 50%;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand em {
  padding: 2px 8px 3px;
  border-radius: 6px;
  background: var(--accent);
  font-style: normal;
}

.topbar-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: color-mix(in srgb, var(--white) 88%, transparent);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-wash);
  animation: status-pulse 2.4s ease-in-out infinite;
}

.status-divider {
  width: 1px;
  height: 14px;
  background: var(--line-strong);
}

/* ==========================================================================
   WORKSPACE
   ========================================================================== */
.workspace {
  position: relative;
  flex: 1;
  display: grid;
  grid-template-columns: clamp(400px, 25vw, 500px) minmax(0, 1fr);
  align-items: stretch;
  min-width: 0;
}

.workspace:not(.is-start-screen) {
  background: var(--paper);
}

.control-panel {
  position: relative;
  z-index: 1;
  min-width: 0;
  padding: 28px 28px 48px;
  border-right: 1px solid var(--line);
  background: var(--white);
}

.preview-panel {
  --stage-gap: 48px;
  display: grid;
  grid-template-columns: auto minmax(360px, 880px);
  justify-content: center;
  align-items: start;
  gap: var(--stage-gap);
  min-width: 0;
  padding: 36px clamp(24px, 3vw, 64px) 64px;
}

/* Desktop editor: one viewport tall, no page scroll. The preview takes all height left after the top bar, footer
   and the controls under the frame (220px); the side panels stay narrow and only scroll if a tab truly overflows. */
@media (min-width: 1280px) {
  :root { --stage-h: clamp(380px, calc(100svh - 220px), 1500px); }

  .app-shell:has(.workspace:not(.is-start-screen)) { height: max(100svh, 600px); min-height: 0; }
  .app-shell:has(.workspace:not(.is-start-screen)) .topbar { height: 56px; }
  .app-shell:has(.workspace:not(.is-start-screen)) footer { flex-wrap: nowrap; height: 34px; padding-block: 0; }

  .workspace:not(.is-start-screen) {
    --side-max: clamp(400px, 25vw, 640px);
    --side-gap: clamp(24px, 2.4vw, 64px);
    grid-template-columns: minmax(340px, 1fr) auto minmax(340px, 1fr);
    grid-template-rows: minmax(0, 1fr);
    min-height: 0;
    overflow: hidden;
  }

  .workspace:not(.is-start-screen) .preview-panel { display: contents; }

  /* Sidebar and editor sit flush against the preview column, so both gaps are exactly --side-gap. */
  .workspace:not(.is-start-screen) .control-panel {
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    border-right: 0;
    background: transparent;
    padding: 20px 6px 16px max(28px, calc(100% - var(--side-max)));
  }

  .workspace:not(.is-start-screen) .preview-column {
    grid-column: 2;
    justify-content: center;
    gap: 14px;
    padding: 20px var(--side-gap) 16px;
  }

  .workspace:not(.is-start-screen) .preview-play-button { min-height: 44px; }

  .workspace:not(.is-start-screen) .editor-side {
    grid-column: 3;
    align-self: stretch;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    gap: clamp(12px, 2.4svh, 32px);
    padding: 20px max(28px, calc(100% - var(--side-max))) 16px 6px;
  }

  /* Heights follow the viewport so the Video tab fits on laptop screens too. */
  .workspace:not(.is-start-screen) .source-summary { padding-bottom: clamp(10px, 1.8svh, 20px); }
  .workspace:not(.is-start-screen) .inspector-tab { min-height: clamp(38px, 5.4svh, 48px); }
  .workspace:not(.is-start-screen) .inspector-group { gap: clamp(7px, 1.3svh, 14px); padding: clamp(8px, 1.6svh, 24px) 0; }
  .workspace:not(.is-start-screen) .segment { padding: clamp(6px, 1svh, 12px) 12px; }
  .workspace:not(.is-start-screen) .segment-icon { width: clamp(30px, 4svh, 38px); height: clamp(30px, 4svh, 38px); }
  .workspace:not(.is-start-screen) .text-input { height: clamp(36px, 5svh, 44px); }
  .workspace:not(.is-start-screen) .layer-toolbar { min-height: 48px; }
  .workspace:not(.is-start-screen) .timeline-editor { gap: clamp(8px, 1.6svh, 14px); }
  .workspace:not(.is-start-screen) .timeline-track { height: clamp(44px, 7svh, 56px); }
  .workspace:not(.is-start-screen) .queue-card { gap: clamp(10px, 1.8svh, 16px); padding-top: clamp(12px, 2.2svh, 28px); }
  .workspace:not(.is-start-screen) .render-action { min-height: clamp(48px, 6.4svh, 60px); }
}

/* Short laptop screens: drop the secondary captions so the Video tab still fits without scrolling. */
@media (min-width: 1280px) and (max-height: 720px) {
  .workspace:not(.is-start-screen) .segment small,
  .workspace:not(.is-start-screen) .toggle-row small { display: none; }
}

/* ==========================================================================
   START SCREEN — full-bleed hero with a luminous form card
   ========================================================================== */
.workspace.is-start-screen {
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
  background: var(--paper);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: auto;
}

.workspace.is-start-screen .control-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(400px, 540px);
  align-items: center;
  gap: clamp(40px, 6vw, 112px);
  width: 100%;
  max-width: 1380px;
  margin: 0 auto;
  padding: clamp(32px, 6vh, 72px) clamp(20px, 4vw, 64px);
  border: 0;
  background: transparent;
}

.workspace:not(.is-start-screen) .start-story { display: none; }

/* FIT TO SCREEN: app.js (fitStartScreen) measures the hero and sets --start-fit to the largest
   scale that still fits the window with margins, so big screens are filled and nothing is cut off.
   The start screen has no draggable overlays, so zoom is safe here. */
.workspace.is-start-screen .control-panel { zoom: var(--start-fit, 1); }

/* Stay hidden until app.js has applied the fit, so the page never visibly rescales on refresh. */
.workspace.is-start-screen:not(.is-fitted) .control-panel { opacity: 0; }

/* Before the fit is applied the hero is taller than the window; no page scrollbar may flash up and shift the layout. */
@media (min-width: 981px) {
  html:has(.workspace.is-start-screen:not(.is-fitted)) { overflow: hidden; }
}

.start-story-kicker {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.start-story-kicker span {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 22px color-mix(in srgb, var(--accent) 42%, transparent);
  animation: status-pulse 2.2s ease-in-out infinite;
}

.workspace.is-start-screen.is-fitted .start-story { animation: gamer-rise .95s cubic-bezier(.16, 1, .3, 1) both; }

.start-story h1 {
  font-family: 'Montserrat', sans-serif;
  font-size: clamp(44px, 5.6vw, 88px);
  font-weight: 900;
  line-height: .98;
  letter-spacing: -.035em;
}

.start-story h1 em {
  padding: 0 .06em;
  color: var(--accent-text);
  font-style: normal;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.start-story .intro {
  max-width: 34em;
  margin-top: 26px;
  color: var(--muted);
  font-size: clamp(16px, 1.3vw, 19px);
  line-height: 1.55;
}

.start-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 32px;
  margin: 40px 0 0;
  padding: 0;
  list-style: none;
}

.start-steps li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  transition: transform .2s ease;
}

.start-steps li:hover { transform: translateY(-3px); }

.clip-showcase {
  max-width: 100%;
  margin-top: 32px;
  overflow: hidden;
}

.clip-showcase-label {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.clip-showcase-viewport {
  overflow: hidden;
  padding-block: 14px;
  mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
}

.clip-showcase-track {
  display: flex;
  width: max-content;
  animation: showcase-drift 36s linear infinite;
}

/* Keep the groups in index.html identical and wider than the visible carousel. */
.clip-showcase-group {
  display: flex;
  flex: none;
  gap: 14px;
  padding-right: 14px;
}

.clip-example {
  flex: 0 0 112px;
  animation: clip-card-float 5.6s ease-in-out infinite;
}

.clip-showcase-group .clip-example:nth-child(2) { animation-delay: -1.8s; }
.clip-showcase-group .clip-example:nth-child(3) { animation-delay: -3.6s; }

.clip-example-frame {
  position: relative;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 14px;
  background: var(--navy);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .24);
  transition: transform .3s ease, box-shadow .3s ease;
}

.clip-example-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .35s ease;
}

.clip-example-caption {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.clip-example:hover .clip-example-frame {
  box-shadow: 0 16px 34px rgba(0, 0, 0, .38), 0 0 22px color-mix(in srgb, var(--accent) 16%, transparent);
  transform: translateY(-4px) rotate(-1deg);
}

.clip-example:hover .clip-example-frame img { transform: scale(1.04); }

.start-step-number {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--navy-2);
  color: var(--text);
  font-family: var(--display);
  font-size: 14px;
}

.workspace.is-start-screen .source-setup {
  --orbit-angle: 0deg;
  position: relative;
  isolation: isolate;
  padding: clamp(24px, 3vw, 36px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--white);
  box-shadow: none;
  backdrop-filter: blur(18px);
  transition: background-color .25s ease, border-color .25s ease, box-shadow .25s ease, transform .22s ease;
}

.workspace.is-start-screen.is-fitted .source-setup { animation: gamer-rise 1s .12s cubic-bezier(.16, 1, .3, 1) both; }

.workspace.is-start-screen .source-setup:hover { transform: translateY(-3px); }

.workspace.is-start-screen .source-setup::before {
  position: absolute;
  z-index: 0;
  inset: -4px;
  padding: 2px;
  border-radius: 28px;
  background: conic-gradient(
    from var(--orbit-angle),
    transparent 0deg 260deg,
    color-mix(in srgb, var(--accent) 45%, transparent) 292deg,
    var(--accent) 326deg,
    transparent 360deg
  );
  content: "";
  opacity: 1;
  pointer-events: none;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  animation: orbit-border 7s linear infinite;
}

.workspace.is-start-screen .source-setup > * {
  position: relative;
  z-index: 1;
}

.start-form-heading { margin-bottom: 22px; }

.start-form-kicker {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.start-form-heading h2 {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -.02em;
  line-height: 1.1;
}

.start-form-heading p { margin-top: 6px; color: var(--muted); }

/* ==========================================================================
   SOURCE FORM
   ========================================================================== */
.control-lock {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--accent-wash);
}

.control-lock-message { font-weight: 600; }

.form-fields.is-locked {
  opacity: .4;
  filter: grayscale(.5);
  pointer-events: none;
  user-select: none;
}

.source-kind-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  border-radius: 12px;
  background: var(--accent-wash);
}

.source-kind {
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  transition: background-color .15s ease, color .15s ease;
}

.source-kind:hover:not(.active) { color: var(--text); background: rgba(255, 255, 255, .06); }
.source-kind.active { background: var(--accent); color: var(--on-accent); box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 18%, transparent); }

.input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 12px 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--white);
  transition: box-shadow .15s ease;
}

.input-wrap:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }

.input-icon { display: grid; place-items: center; color: var(--accent-strong); }

.input-wrap input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
}

.input-wrap input::placeholder { color: var(--subtle); }

.source-badge {
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--accent-wash);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
}

.source-upload-panel input[type="file"] {
  width: 100%;
  padding: 12px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper);
  font-size: 13px;
}

.source-upload-panel input[type="file"]::file-selector-button,
input[type="file"]::file-selector-button {
  min-height: 38px;
  margin-right: 12px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  cursor: pointer;
}

.source-quality { margin-top: 20px; }
.source-quality .field-label { margin-bottom: 8px; }
.source-quality .source-kind-switch { margin-bottom: 0; }

.source-preview-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
}

.source-preview-button {
  width: 100%;
  min-height: 56px;
  font-size: 16px;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 12%, transparent);
}

.button-arrow {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .15s ease;
}

.source-preview-button:hover:not(:disabled) .button-arrow { transform: translateX(4px); }

.source-preview-row .field-hint { margin: 0; text-align: center; }

.terms-notice {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.terms-notice a { color: var(--accent-text); font-weight: 700; }

:root[data-theme="light"] .workspace.is-start-screen .source-kind {
  border: 1px solid transparent;
}

:root[data-theme="light"] .workspace.is-start-screen .source-kind.active,
:root[data-theme="light"] .workspace.is-start-screen .input-wrap {
  border-color: #111;
}

:root[data-theme="light"] .workspace.is-start-screen .source-preview-button {
  border-color: #111;
}

:root[data-theme="light"] .workspace.is-start-screen .source-setup {
  border-color: #111;
}

:root[data-theme="light"] .workspace.is-start-screen .field-hint,
:root[data-theme="light"] .workspace.is-start-screen .terms-notice {
  font-weight: 500;
}

.source-progress {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--accent-wash);
}

.source-progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.source-progress-copy span { font-weight: 700; font-variant-numeric: tabular-nums; }

.source-progress-track {
  height: 12px;
  margin: 10px 0 8px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--paper);
}

.source-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width .2s ease;
}

.source-progress.is-indeterminate .source-progress-track span {
  width: 36% !important;
  animation: source-progress-scan 1.1s ease-in-out infinite;
}

.source-progress small { color: var(--muted); font-size: 12px; }

/* ==========================================================================
   SOURCE SUMMARY (editor open)
   ========================================================================== */
.source-summary {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.source-summary-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.source-summary-kind {
  padding: 5px 9px;
  border-radius: 7px;
  background: var(--accent-wash);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
}

.source-summary-copy { display: flex; flex: 1; flex-direction: column; min-width: 0; }

.source-summary-copy strong,
.source-summary-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-summary-copy small { color: var(--muted); font-size: 12px; }

.source-summary-change { min-height: 34px; padding: 0 12px; font-size: 12px; }

.source-summary-confirm {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border-radius: 10px;
  background: var(--accent-wash);
  font-size: 13px;
}

.source-summary-confirm-actions { display: flex; gap: 8px; }
.source-summary-discard { min-height: 38px; padding: 0 14px; font-size: 13px; }

/* ==========================================================================
   INSPECTOR TABS + GROUPS
   ========================================================================== */
.inspector-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 20px 0 0;
  border-bottom: 1px solid var(--line);
}

.source-summary[hidden] + .inspector-tabs { margin-top: 0; }

.workspace.is-start-screen .inspector-tabs,
.workspace.is-start-screen .inspector-panel { display: none; }

.inspector-tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  transition: color .15s ease, background-color .15s ease;
}

.inspector-tab svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.inspector-tab:hover { color: var(--text); background: var(--accent-wash); }

.inspector-tab.active { color: var(--text); }

.inspector-tab.active::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -2px;
  left: 0;
  height: 5px;
  background: var(--accent);
}

.inspector-panel { padding-top: 4px; }

.inspector-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}

.inspector-group:last-child { border-bottom: 0; }

.group-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.005em;
}

.group-hint { margin-top: -6px; color: var(--muted); font-size: 13px; }

/* ==========================================================================
   FORM CONTROLS
   ========================================================================== */
.text-input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1.5px solid var(--line-strong);
  border-radius: 10px;
  background: var(--white);
  font-size: 14px;
  outline: 0;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.text-input:hover { border-color: var(--line-strong); }

.text-input:focus {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.text-input::placeholder { color: var(--subtle); }

.text-input.is-invalid { border-color: var(--danger); background: var(--danger-wash); }

.select-input {
  appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.settings-span { grid-column: 1 / -1; }

.range-input { width: 100%; height: 28px; accent-color: var(--accent-strong); cursor: pointer; }

.color-control {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 12px 0 6px;
  border: 1.5px solid var(--line-strong);
  border-radius: 10px;
  background: var(--white);
}

.color-control input {
  width: 44px;
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.color-control span { font-size: 12px; font-weight: 700; letter-spacing: .08em; }

.section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.section-line { flex: 1; height: 1px; background: var(--line); }

.crop-controls { display: flex; flex-direction: column; gap: 10px; padding-top: 6px; }
.crop-controls .field-hint { margin: 0; }
.crop-reset { align-self: flex-start; }

/* Option cards (clip mode, treatment) */
.segmented { display: grid; grid-template-columns: 1fr; gap: 8px; }

.segment {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text);
  text-align: left;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}

.segment:not(:disabled):hover { border-color: var(--line-strong); }

.segment.active {
  border-color: var(--accent-strong);
  background: var(--accent-wash);
  box-shadow: inset 0 0 0 1px var(--accent-strong), 0 0 20px color-mix(in srgb, var(--accent) 8%, transparent);
}

.segment:disabled { opacity: .4; cursor: not-allowed; }

.segment-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-wash);
  color: var(--text);
  transition: background-color .15s ease;
}

.segment.active .segment-icon { background: var(--accent); color: var(--on-accent); }

.segment > span:not(.segment-icon) { min-width: 0; font-size: 14px; font-weight: 700; line-height: 1.25; }

.segment small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

/* Switches */
.toggle-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
}

.toggle-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle-box {
  position: relative;
  flex: none;
  width: 46px;
  height: 26px;
  border: 2px solid var(--navy);
  border-radius: 999px;
  background: var(--white);
  transition: background-color .15s ease;
}

.toggle-box::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--navy);
  transition: transform .18s cubic-bezier(.3, 1.4, .5, 1);
}

.toggle-row input:checked + .toggle-box { background: var(--accent); }
.toggle-row input:checked + .toggle-box::after { background: var(--on-accent); }
.toggle-row input:checked + .toggle-box::after { transform: translateX(20px); }
.toggle-row input:focus-visible + .toggle-box { outline: 3px solid var(--accent-strong); outline-offset: 2px; }

.toggle-row > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.toggle-row b { font-size: 14px; }
.toggle-row small { color: var(--muted); font-size: 12px; }

.toggle-row.is-coming-soon { cursor: not-allowed; }

.soon-badge {
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--accent-wash);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* Status chips */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  box-shadow: inset 0 0 0 1.5px var(--line);
}

.status-chip::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
}

.status-chip[data-state="marked"] { background: var(--ok-wash); color: var(--ok); box-shadow: none; }
.status-chip[data-state="marked"]::before { background: var(--ok); }
.status-chip[data-state="error"],
.status-chip.is-error { background: var(--danger-wash); color: var(--danger); box-shadow: none; }
.status-chip[data-state="error"]::before,
.status-chip.is-error::before { background: var(--danger); }

.facecam-marker { display: flex; flex-direction: column; gap: 10px; }
.facecam-marker .group-hint { margin: 0; }

.facecam-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.facecam-open-button { min-height: 38px; padding: 0 14px; font-size: 13px; }

/* Title + style */
.title-preview-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
}

.mini-title {
  margin-top: 6px;
  font-family: var(--display);
  font-size: 18px;
  white-space: pre-line;
}

.wrap-note { color: var(--subtle); font-size: 12px; }

.visual-presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.visual-preset {
  min-width: 0;
  padding: 8px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  text-align: left;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.visual-preset:hover { border-color: var(--accent-strong); }
.visual-preset.active { border-color: var(--accent-strong); box-shadow: inset 0 0 0 1px var(--accent-strong), 0 0 18px color-mix(in srgb, var(--accent) 8%, transparent); }

.visual-preset > span:last-child { display: block; margin-top: 8px; }
.visual-preset b, .visual-preset small { display: block; }
.visual-preset b { font-size: 12px; }
.visual-preset small { margin-top: 2px; color: var(--muted); font-size: 11px; }

.preset-swatch {
  display: grid;
  place-items: center;
  width: 100%;
  height: 40px;
  overflow: hidden;
  border-radius: 7px;
  background: #080c12;
  font-size: 20px;
}

.preset-swatch-viral { color: #ffe500; font-family: 'Anton', sans-serif; -webkit-text-stroke: 2px #000; }
.preset-swatch-clean { background: #172129; color: #fff; font-family: 'Montserrat', sans-serif; font-weight: 900; }
.preset-swatch-neon { background: #160525; color: #28e7ff; font-family: 'Bangers', cursive; text-shadow: 2px 2px #ff39ce; }

/* ==========================================================================
   PREVIEW — one big 9:16 frame, no stage box
   ========================================================================== */
.preview-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.preview-stage {
  position: relative;
  isolation: isolate;
  display: flex;
  justify-content: center;
}

.preview-stage::before {
  position: absolute;
  z-index: -1;
  inset: 12% 5%;
  border-radius: 50%;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--accent) 16%, transparent), transparent 68%);
  content: "";
  filter: blur(30px);
  pointer-events: none;
  animation: aura-drift 7s ease-in-out infinite alternate;
}

/* The progress bar already shows the percentage, so the status line is only for results and errors. */
.source-preview-row:has(~ .source-progress:not([hidden])) #source-preview-status:not(.is-error) { display: none; }

.stage-label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.stage-label b {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}

.vertical-preview,
.result-card {
  position: relative;
  height: var(--stage-h);
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border-radius: 20px;
  background: var(--navy);
  outline: 1px solid rgba(241, 245, 242, .12);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .52), 0 0 42px color-mix(in srgb, var(--accent) 8%, transparent);
}

.result-card video {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--navy);
  object-fit: contain;
}

.preview-bg {
  position: absolute;
  inset: -20px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 15%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 60%),
    linear-gradient(135deg, #0b2a3a 0%, #04141d 100%);
  filter: blur(14px);
  transform: scale(1.12);
}

.preview-bg video { width: 100%; height: 100%; object-fit: cover; }

.preview-main {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 25% 20%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 55%),
    linear-gradient(160deg, #0b2a3a 0%, #04141d 100%);
}

.vertical-preview.has-source .preview-main { background: transparent; }
.vertical-preview.has-source .preview-bg { opacity: .9; }

.preview-video,
.preview-facecam-layer video {
  position: absolute;
  display: block;
  max-width: none;
  transform-origin: top left;
}

.preview-video {
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-facecam-layer {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 8.333%;
  overflow: hidden;
  background-repeat: no-repeat;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}

.preview-facecam-layer video { object-fit: fill; }

.preview-play-button {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 20px;
  border: 2px solid var(--navy);
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  transition: background-color .15s ease, color .15s ease, transform .1s ease;
}

.preview-play-button:hover { background: var(--accent); color: var(--on-accent); box-shadow: 0 0 22px color-mix(in srgb, var(--accent) 14%, transparent); }
.preview-play-button:active { transform: scale(.98); }
.preview-play-button svg { width: 18px; height: 18px; }
.preview-stage.has-result ~ .preview-play-button { display: none; }

/* Text overlays share the hook styles; positions are driven by app.js. */
.preview-hook {
  position: absolute;
  z-index: 3;
  top: 13px;
  left: 6.48%;
  width: 87.04%;
  color: #fff;
  font-family: 'Archivo Black';
  text-align: center;
  font-size: 14px;
  line-height: 1.05;
  -webkit-text-stroke: 4px #000;
  paint-order: stroke fill;
  text-shadow: 1px 2px 2px rgba(0, 0, 0, .6);
  white-space: pre-line;
}

.preview-hook mark { background: none; color: var(--preview-accent, #ffe500); }
.preview-hook-layer { display: block; white-space: pre-line; }
.preview-hook-front { color: var(--preview-text, #fff); }
.preview-hook-outer { position: relative; }

.vertical-preview[data-preset="neon-gaming"] .preview-hook-middle,
.vertical-preview[data-preset="neon-gaming"] .preview-hook-front { position: absolute; inset: 0; }

.preview-eyebrow,
.preview-cta,
.preview-watermark,
.preview-progress { position: absolute; z-index: 3; }

.preview-eyebrow {
  top: 7px;
  left: 50%;
  max-width: 52%;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--preview-accent, #ffe500);
  color: #080b12;
  font: 900 7px 'Montserrat', sans-serif;
  line-height: 1.25;
  letter-spacing: .15em;
  overflow-wrap: anywhere;
  text-align: center;
  transform: translateX(-50%);
}

.preview-cta {
  bottom: 48px;
  left: 50%;
  max-width: 78%;
  padding: 5px 9px;
  border-radius: 5px;
  background: #fff;
  color: #080b12;
  font: 900 11px 'Montserrat', sans-serif;
  text-align: center;
  transform: translateX(-50%);
}

.preview-watermark {
  top: 10px;
  right: 9px;
  padding: 3px 6px;
  border-radius: 4px;
  background: rgba(8, 12, 18, .58);
  color: #fff;
  font: 700 7px 'Oswald', sans-serif;
  letter-spacing: .08em;
}

.preview-progress {
  right: 10px;
  bottom: 3px;
  left: 10px;
  height: 3px;
  overflow: hidden;
  border-radius: 3px;
  background: rgba(255, 255, 255, .22);
}

.preview-progress span {
  display: block;
  width: 62%;
  height: 100%;
  border-radius: inherit;
  background: var(--preview-accent, #ffe500);
  box-shadow: 0 0 8px var(--preview-accent, #ffe500);
}

.vertical-preview[data-preset="viral-punch"] .preview-hook { font-family: 'Anton', sans-serif; }

.vertical-preview[data-preset="clean-creator"] .preview-hook {
  padding: 7px 5px;
  border-radius: 7px;
  background: rgba(8, 14, 20, .82);
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  line-height: 1.08;
  -webkit-text-stroke: 0;
}

.vertical-preview[data-preset="neon-gaming"] .preview-hook {
  font-family: 'Bangers', cursive;
  letter-spacing: .04em;
  -webkit-text-stroke: 0;
  text-shadow: none;
}

.vertical-preview[data-preset="neon-gaming"] .preview-hook-outer {
  color: #160525;
  -webkit-text-stroke: var(--neon-outer-stroke) #160525;
  paint-order: stroke fill;
  text-shadow: 0 0 var(--neon-glow-tight) var(--preview-glow), 0 0 var(--neon-glow-wide) var(--preview-glow);
}

.vertical-preview[data-preset="neon-gaming"] .preview-hook-middle {
  color: #ff39ce;
  -webkit-text-stroke: var(--neon-inner-stroke) #ff39ce;
  paint-order: stroke fill;
  transform: translate(var(--neon-offset), var(--neon-offset));
}

.vertical-preview[data-preset="neon-gaming"] .preview-hook-front {
  color: var(--preview-text);
  -webkit-text-stroke: var(--neon-front-stroke) #160525;
  paint-order: stroke fill;
  text-shadow: 0 0 var(--neon-glow-tight) var(--preview-glow);
}

.vertical-preview[data-preset="neon-gaming"] .preview-hook-front mark { color: var(--preview-accent); }

.preview-hook[data-animation="word-pop"] { animation: preview-pop .6s cubic-bezier(.16, 1.2, .3, 1) both; }
.preview-hook[data-animation="slide-up"] { animation: preview-slide .6s cubic-bezier(.16, 1, .3, 1) both; }
.preview-hook[data-animation="zoom-in"] { animation: preview-zoom .55s cubic-bezier(.16, 1.25, .3, 1) both; }
.preview-hook[data-animation="typewriter"] { clip-path: inset(0 0 0 0); animation: preview-type 1.4s steps(12) both; }

/* Creator badge: a logo pill that rolls the name out and folds it back up. Every size is in
   canvas pixels × --ps, with the same geometry and motion as BadgeLayer in
   renderer/src/layers.tsx. app.js sets --badge-w, --badge-name-w, --badge-roll and --badge-pop. */
.creator-badge {
  position: absolute;
  z-index: 2;
  top: 89.8%;
  left: 12.25px;
  --badge-w: 300;
  --badge-name-w: 196;
  --badge-roll: 1;
  --badge-pop: 1;
}

.creator-pill {
  position: absolute;
  top: 0;
  left: 0;
  width: calc((74px + (30px + var(--badge-name-w) * 1px) * var(--badge-roll)) * var(--ps));
  height: calc(74px * var(--ps));
  overflow: hidden;
  border-radius: 999px;
  background: rgba(16, 16, 22, .66);
  box-shadow:
    inset 0 0 0 calc(2px * var(--ps)) rgba(255, 255, 255, .32),
    0 calc(10px * var(--ps)) calc(28px * var(--ps)) rgba(0, 0, 0, .38);
  opacity: var(--badge-pop);
  transform: scale(var(--badge-pop));
  transform-origin: calc(37px * var(--ps)) calc(37px * var(--ps));
}

.creator-badge .creator-mark {
  position: absolute;
  top: calc(8px * var(--ps));
  left: calc(8px * var(--ps));
  display: grid;
  place-items: center;
  width: calc(58px * var(--ps));
  height: calc(58px * var(--ps));
  padding: calc(8px * var(--ps));
  overflow: hidden;
  border-radius: 50%;
  background: #fff;
}

.creator-badge .creator-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }

.creator-badge .creator-name {
  position: absolute;
  top: 0;
  left: calc(88px * var(--ps));
  display: flex;
  align-items: center;
  height: calc(74px * var(--ps));
  color: #fff;
  font: 800 calc(34px * var(--ps)) / 1 Arial, sans-serif;
  white-space: nowrap;
  opacity: calc(var(--badge-roll) * var(--badge-roll));
}

/* Draggable overlays: sized in canvas pixels × --ps (preview width / 1080). */
.vertical-preview { --ps: .2269; }

.preview-main .preview-hook,
.preview-main .preview-eyebrow,
.preview-main .preview-cta,
.preview-main .preview-watermark,
.preview-main .creator-badge {
  right: auto;
  bottom: auto;
  width: max-content;
  translate: -50% -50%;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  outline: 1px dashed transparent;
  outline-offset: 3px;
  transition: outline-color .15s ease;
}

.preview-main [data-overlay]:hover { outline-color: rgba(255, 255, 255, .75); }

.preview-main [data-overlay].is-selected,
.preview-main [data-overlay]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.preview-main [data-overlay].is-dragging { cursor: grabbing; }

.preview-word { display: inline-block; margin-right: .24em; }
.preview-word.is-line-end { margin-right: 0; }

.preview-main .preview-hook { max-width: calc(940px * var(--ps)); text-transform: uppercase; }

.vertical-preview[data-preset="clean-creator"] .preview-main .preview-hook {
  padding: calc(20px * var(--ps)) calc(28px * var(--ps));
  border-radius: calc(30px * var(--ps));
}

.preview-main .preview-eyebrow,
.preview-main .preview-cta,
.preview-main .preview-watermark {
  transform: none;
  padding: calc(20px * var(--ps)) calc(28px * var(--ps));
  text-transform: uppercase;
  overflow-wrap: normal;
}

.preview-main .preview-eyebrow {
  max-width: calc(500px * var(--ps));
  border-radius: 999px;
  font: 900 calc(30px * var(--ps)) / 1 'Montserrat', sans-serif;
  letter-spacing: calc(7px * var(--ps));
  text-align: center;
}

.preview-main .preview-cta {
  max-width: calc(660px * var(--ps));
  border-radius: calc(18px * var(--ps));
  font: 900 calc(42px * var(--ps)) / 1 'Montserrat', sans-serif;
  letter-spacing: calc(1px * var(--ps));
  text-align: center;
}

.preview-main .preview-watermark {
  max-width: calc(240px * var(--ps));
  border-radius: calc(12px * var(--ps));
  font: 700 calc(28px * var(--ps)) / 1 'Oswald', sans-serif;
  letter-spacing: calc(2px * var(--ps));
  text-align: right;
}

.preview-main .creator-badge {
  width: calc(var(--badge-w) * 1px * var(--ps));
  height: calc(74px * var(--ps));
}

.snap-guide {
  position: absolute;
  z-index: 6;
  pointer-events: none;
  background: #ff4fd8;
  box-shadow: 0 0 6px rgba(255, 79, 216, .7);
}

.snap-guide-x { top: 0; bottom: 0; left: 50%; width: 1px; translate: -50% 0; }
.snap-guide-y { top: 50%; right: 0; left: 0; height: 1px; translate: 0 -50%; }

/* ==========================================================================
   EDITOR SIDE — header, text toolbar, timeline, render
   ========================================================================== */
.editor-side {
  display: flex;
  flex-direction: column;
  gap: 32px;
  min-width: 0;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.preview-header h2 {
  font-family: var(--display);
  font-size: 30px;
  font-weight: 400;
  letter-spacing: -.025em;
  line-height: 1;
}

.format-pill {
  padding: 5px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--accent-wash);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.layer-toolbar {
  container-type: inline-size;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--white);
}

.preview-panel:has(.preview-stage.has-result) .layer-toolbar { display: none; }

.layer-toolbar-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.layer-toolbar-hint-icon {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--accent-strong);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.layer-toolbar-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  width: 100%;
}

.layer-toolbar-name {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.layer-toolbar-name::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1.5px var(--line-strong), 0 0 14px color-mix(in srgb, var(--accent) 30%, transparent);
}

.layer-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 1.5px solid var(--line-strong);
  border-radius: 9px;
  background: var(--white);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease;
}

.layer-tool svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.layer-tool:hover:not(:disabled) { border-color: var(--accent-strong); background: var(--accent-wash); }
.layer-tool.is-active { border-color: var(--accent-strong); background: var(--accent); color: var(--on-accent); }
.layer-tool:disabled { opacity: .45; cursor: not-allowed; }

.layer-size {
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  border: 1.5px solid var(--line-strong);
  border-radius: 9px;
  background: var(--white);
}

.layer-size .layer-tool { min-width: 36px; padding: 0 10px; border: 0; border-radius: 0; }

.layer-size-value {
  min-width: 48px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: center;
}

.layer-tool-done { min-height: 36px; padding: 0 16px; border-radius: 9px; font-size: 13px; }
.layer-tool-done:hover:not(:disabled) { background: var(--accent); }

@container (max-width: 590px) {
  .layer-toolbar-name { display: none; }
  .layer-toolbar-tools { justify-content: center; }
}

@container (max-width: 490px) {
  .layer-tool:not(.layer-tool-done):not(.layer-tool-icon) span { display: none; }
  .layer-tool:not(.layer-tool-done):not(.layer-tool-icon) { width: 40px; padding: 0; }
}

/* ==========================================================================
   TIMELINE
   ========================================================================== */
.timeline-editor { display: flex; flex-direction: column; gap: 14px; }

.timeline-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.timeline-heading strong {
  display: block;
  margin-top: 2px;
  font-family: var(--display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.timeline-actions { display: flex; align-items: center; gap: 10px; }

#preview-time {
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--accent-wash);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.timeline-reset { min-height: 34px; padding: 0 12px; font-size: 12px; }

/* IN/OUT handles live outside the lane (IN's right edge and OUT's left edge are the
   trim points), so every lane percentage maps to the same source time for the
   filmstrip, the selection, and the playhead. */
.timeline-track {
  --timeline-handle: 14px;
  position: relative;
  height: 56px;
  margin: 4px 4px 8px;
  overflow: hidden;
  border: 2px solid var(--navy);
  border-radius: 0;
  background: var(--navy);
  touch-action: none;
}

.timeline-lane {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--timeline-handle);
  right: var(--timeline-handle);
  overflow: hidden;
  cursor: pointer;
}

.timeline-filmstrip {
  position: absolute;
  inset: 0;
  background-color: var(--accent-wash);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.timeline-selection-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  border-top: 3px solid var(--accent);
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 0 0 100vmax rgba(4, 20, 29, .82);
  pointer-events: none;
}

.timeline-range {
  position: absolute;
  top: 0;
  z-index: 3;
  width: calc(100% - var(--timeline-handle));
  height: 100%;
  margin: 0;
  padding: 0;
  pointer-events: none;
  appearance: none;
  background: transparent;
}

.timeline-range-in { left: 0; }
.timeline-range-out { left: var(--timeline-handle); }

.timeline-range::-webkit-slider-runnable-track,
.timeline-playhead::-webkit-slider-runnable-track { height: 100%; background: transparent; }

.timeline-range::-moz-range-track,
.timeline-playhead::-moz-range-track { height: 100%; background: transparent; }

.timeline-playhead {
  position: absolute;
  z-index: 4;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  appearance: none;
  background: transparent;
  cursor: ew-resize;
  pointer-events: none;
}

.timeline-playhead::-webkit-slider-thumb {
  width: 3px;
  height: 52px;
  border: 0;
  border-radius: 2px;
  appearance: none;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .45), 0 0 8px rgba(255, 255, 255, .55);
  cursor: ew-resize;
  pointer-events: auto;
}

.timeline-playhead::-moz-range-thumb {
  width: 3px;
  height: 52px;
  border: 0;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .45), 0 0 8px rgba(255, 255, 255, .55);
  cursor: ew-resize;
  pointer-events: auto;
}

.timeline-range::-webkit-slider-thumb {
  width: var(--timeline-handle);
  height: 52px;
  border: 0;
  appearance: none;
  background: linear-gradient(var(--navy), var(--navy)) center / 2px 16px no-repeat, var(--accent);
  cursor: ew-resize;
  pointer-events: auto;
}

.timeline-range::-moz-range-thumb {
  width: var(--timeline-handle);
  height: 52px;
  border: 0;
  background: linear-gradient(var(--navy), var(--navy)) center / 2px 16px no-repeat, var(--accent);
  cursor: ew-resize;
  pointer-events: auto;
}

.timeline-range-in::-webkit-slider-thumb,
.timeline-range-in::-moz-range-thumb,
.timeline-range-out::-webkit-slider-thumb,
.timeline-range-out::-moz-range-thumb { border-radius: 0; }

.timeline-range:focus-visible::-webkit-slider-thumb,
.timeline-playhead:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 2px #fff; }

.timeline-range:focus-visible::-moz-range-thumb,
.timeline-playhead:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 2px #fff; }

.timeline-range:focus-visible,
.timeline-playhead:focus-visible { outline: 0; }

.timeline-scale {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.timeline-time-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
}

.timeline-time-input {
  width: 92px;
  height: 36px;
  border: 1.5px solid var(--line-strong);
  border-radius: 9px;
  background: var(--white);
  color: var(--text);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: center;
  outline: 0;
}

.timeline-time-input:focus { border-color: var(--accent-strong); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.timeline-time-input.is-invalid { border-color: var(--danger); background: var(--danger-wash); }

.timeline-jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 3px;
  text-underline-offset: 4px;
}

.timeline-jump:hover { background: var(--accent-wash); }
.timeline-jump .ui-icon { width: 16px; height: 16px; }

.timeline-editor p { color: var(--subtle); font-size: 12px; }

/* ==========================================================================
   RENDER / QUEUE + RESULT
   ========================================================================== */
.queue-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.queue-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.queue-state {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  box-shadow: inset 0 0 0 1.5px var(--line);
}

.queue-state.running { background: var(--accent-wash); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent-strong); animation: status-pulse 1.4s ease-in-out infinite; }
.queue-state.done { background: var(--ok-wash); color: var(--ok); box-shadow: none; }

.queue-body {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 10px 14px;
}

.queue-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--accent-wash);
  color: var(--accent);
}

.queue-icon .ui-icon { width: 22px; height: 22px; }
.queue-icon[data-state="working"] { background: var(--accent); color: var(--on-accent); }
.queue-icon[data-state="working"] [data-queue-icon="working"] { animation: worker-spin 1s linear infinite; }
.queue-icon[data-state="done"] { background: var(--ok-wash); color: var(--ok); border-color: var(--ok); }
.queue-icon[data-state="error"] { background: var(--danger-wash); color: var(--danger); border-color: var(--danger); }

.queue-copy { display: flex; flex-direction: column; min-width: 0; }
.queue-copy strong { font-size: 15px; }
.queue-copy span { color: var(--muted); font-size: 13px; }

.queue-progress-row {
  display: none;
  grid-column: 1 / -1;
  align-items: center;
  gap: 12px;
}

.queue-card:has(.queue-icon[data-state="working"]) .queue-progress-row { display: flex; }

.queue-progress {
  flex: 1;
  height: 12px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--paper);
}

.queue-progress span {
  position: relative;
  display: block;
  width: 0;
  height: 100%;
  overflow: hidden;
  background: var(--accent);
  transition: width .3s ease;
}

.queue-progress span::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 60px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .7), transparent);
  animation: progress-sheen 1.4s linear infinite;
}

.render-action {
  width: 100%;
  min-height: 60px;
  font-size: 16px;
}

.render-action[data-state="running"] {
  border-color: var(--danger);
  background: var(--white);
  color: var(--danger);
  cursor: pointer;
}

.render-action.render-action[data-state="running"]:hover:not(:disabled):not(.is-cooldown) {
  background: var(--danger);
  color: #fff;
}

.render-action[data-state="starting"] { opacity: .7; }

.render-action[data-state="done"] { display: none; }

.render-action.is-cooldown {
  border-color: var(--line-strong);
  background: var(--paper);
  color: var(--muted);
  box-shadow: none;
  font-variant-numeric: tabular-nums;
}

.render-action:disabled { cursor: default; }
.render-action.is-cooldown { cursor: not-allowed; }

.render-quota { color: var(--muted); font-size: 13px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.render-quota.is-low { color: var(--warn); }
.render-quota.is-empty { color: var(--danger); }

.result-actions-panel {
  display: none;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--white);
}

.preview-panel:has(.preview-stage.has-result) .result-actions-panel { display: flex; }

.result-actions-panel .eyebrow { color: var(--muted); }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.download-button { min-height: 48px; }
.thumbnail-button { min-height: 48px; border-width: 2px; }
.thumbnail-hint { color: var(--muted); font-size: 13px; }

/* ==========================================================================
   FACECAM MODAL
   ========================================================================== */
.facecam-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 4vw, 40px);
  background: rgba(3, 7, 10, .78);
}

.facecam-modal {
  width: min(920px, 100%);
  max-height: 92vh;
  overflow: auto;
  padding: 24px 28px 28px;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: var(--white);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .55), 0 0 48px color-mix(in srgb, var(--accent) 6%, transparent);
}

.facecam-modal-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
.facecam-modal-head .eyebrow { display: block; margin-bottom: 6px; }

.facecam-modal-head h3 {
  font-family: var(--display);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: -.02em;
}

.facecam-modal-close {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--white);
  font-size: 22px;
  line-height: 1;
}

.facecam-modal-close:hover { background: var(--accent-wash); }

.facecam-frame-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--navy);
}

.facecam-frame-empty { padding: 28px; text-align: center; }

.facecam-load-button { font-size: 13px; }

.facecam-frame-stage {
  position: relative;
  width: 100%;
  overflow: hidden;
  user-select: none;
  line-height: 0;
  touch-action: none;
}

.facecam-frame-stage img { display: block; width: 100%; cursor: crosshair; }

/* The box's outer edge is the exact stored boundary; the outside is dimmed so the
   included pixels stay fully visible. */
.facecam-rect {
  position: absolute;
  box-sizing: border-box;
  border: 1px solid var(--accent);
  background: transparent;
  box-shadow: 0 0 0 100vmax rgba(4, 20, 29, .55);
  cursor: move;
}

.facecam-rect .facecam-rect-handle {
  position: absolute;
  box-sizing: border-box;
  width: 12px;
  height: 12px;
  border: 2px solid var(--accent);
  border-radius: 2px;
  background: var(--navy);
  transition: transform .12s ease, background .12s ease;
}

.facecam-rect .facecam-rect-handle:hover { background: var(--accent); transform: scale(1.2); }

.facecam-rect .is-n, .facecam-rect .is-s { width: 22px; height: 8px; left: calc(50% - 11px); cursor: ns-resize; }
.facecam-rect .is-e, .facecam-rect .is-w { width: 8px; height: 22px; top: calc(50% - 11px); cursor: ew-resize; }
.facecam-rect .is-n { top: -4px; }
.facecam-rect .is-s { bottom: -4px; }
.facecam-rect .is-e { right: -4px; }
.facecam-rect .is-w { left: -4px; }
.facecam-rect .is-nw { left: -6px; top: -6px; cursor: nwse-resize; }
.facecam-rect .is-ne { right: -6px; top: -6px; cursor: nesw-resize; }
.facecam-rect .is-se { right: -6px; bottom: -6px; cursor: nwse-resize; }
.facecam-rect .is-sw { left: -6px; bottom: -6px; cursor: nesw-resize; }

/* Keep the matching cursor for the whole drag, even once the pointer leaves the handle. */
.facecam-frame-stage.is-marking,
.facecam-frame-stage.is-marking * { cursor: crosshair !important; }
.facecam-frame-stage[data-drag-edges="move"], .facecam-frame-stage[data-drag-edges="move"] * { cursor: move !important; }
.facecam-frame-stage[data-drag-edges="n"], .facecam-frame-stage[data-drag-edges="n"] *,
.facecam-frame-stage[data-drag-edges="s"], .facecam-frame-stage[data-drag-edges="s"] * { cursor: ns-resize !important; }
.facecam-frame-stage[data-drag-edges="e"], .facecam-frame-stage[data-drag-edges="e"] *,
.facecam-frame-stage[data-drag-edges="w"], .facecam-frame-stage[data-drag-edges="w"] * { cursor: ew-resize !important; }
.facecam-frame-stage[data-drag-edges="nw"], .facecam-frame-stage[data-drag-edges="nw"] *,
.facecam-frame-stage[data-drag-edges="se"], .facecam-frame-stage[data-drag-edges="se"] * { cursor: nwse-resize !important; }
.facecam-frame-stage[data-drag-edges="ne"], .facecam-frame-stage[data-drag-edges="ne"] *,
.facecam-frame-stage[data-drag-edges="sw"], .facecam-frame-stage[data-drag-edges="sw"] * { cursor: nesw-resize !important; }

.facecam-frame-stage.is-marking .facecam-rect-handle { opacity: 0; }
.facecam-frame-stage.is-fine .facecam-loupe { border-color: #fff; }

.facecam-loupe {
  position: absolute;
  z-index: 5;
  box-sizing: border-box;
  width: 168px;
  height: 168px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--navy);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(0, 0, 0, .4);
  pointer-events: none;
}

.facecam-size-badge {
  position: absolute;
  left: -1px;
  bottom: calc(100% + 6px);
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--on-accent);
  font: 700 12px/1.3 'DM Sans', sans-serif;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}

.facecam-size-badge.is-inside { top: 6px; bottom: auto; left: 6px; }

.facecam-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 14px 0 0;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  list-style: none;
}

.facecam-shortcuts li { display: inline-flex; align-items: center; gap: 6px; }
.facecam-shortcuts small { color: var(--subtle); }

kbd,
.shortcut-key {
  display: inline-block;
  min-width: 24px;
  padding: 2px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--white);
  color: var(--text);
  font: 700 11px/1.4 'DM Sans', sans-serif;
  text-align: center;
  box-shadow: 0 2px 0 var(--line-strong);
}

.shortcut-key.is-mouse { background: var(--accent-wash); }

.facecam-marker-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.facecam-modal-buttons { display: flex; align-items: center; gap: 8px; }
.facecam-done-button { min-height: 40px; font-size: 13px; }

/* ==========================================================================
   FOOTER + COOKIE BANNER
   ========================================================================== */
footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
  padding: 20px clamp(16px, 3vw, 40px) 24px;
  border-top: 1px solid var(--line);
  background: var(--white);
  color: var(--muted);
  font-size: 12px;
}

.footer-line { display: flex; gap: 14px; }
.footer-line span:first-child { color: var(--text); font-family: var(--display); letter-spacing: .04em; }

.footer-legal { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-left: auto; }
.footer-legal a { color: var(--text); font-weight: 600; text-decoration: none; }
.footer-legal a:hover { text-decoration: underline; }
.cookie-settings-button { margin-top: 12px; padding: 7px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--white); font-size: 12px; font-weight: 700; }
.cookie-settings-button:hover { background: var(--accent-wash); }

.cookie-banner {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(420px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--white);
  box-shadow: 0 12px 32px rgba(4, 20, 29, .22);
}

.cookie-banner-text strong { display: block; margin-bottom: 4px; font-size: 15px; }
.cookie-banner-text p { color: var(--muted); font-size: 13px; }
.cookie-banner-actions { display: flex; justify-content: flex-end; gap: 8px; }
.cookie-button { min-height: 40px; font-size: 13px; }
.cookie-button.is-primary { font-weight: 700; }

/* ==========================================================================
   KEYFRAMES
   ========================================================================== */
/* Register the angle so the conic-gradient border can rotate smoothly. */
@property --orbit-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

@keyframes gamer-rise {
  from { opacity: 0; transform: translate3d(0, 20px, 0) scale(.985); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}
@keyframes orbit-border { to { --orbit-angle: 360deg; } }
@keyframes showcase-drift { to { transform: translateX(-50%); } }
@keyframes clip-card-float { 50% { transform: translateY(-5px); } }
@keyframes aura-drift {
  from { opacity: .55; transform: translate3d(0, -1%, 0) scale(.96); }
  to { opacity: 1; transform: translate3d(0, 1%, 0) scale(1.04); }
}
@keyframes gamer-beam { to { background-position: -220% 0; } }
@keyframes preview-pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }
@keyframes preview-slide { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes preview-zoom { from { opacity: 0; transform: scale(.35) rotate(-3deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes preview-type { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

@keyframes worker-spin { to { transform: rotate(360deg); } }
@keyframes progress-sheen { from { transform: translateX(-60px); } to { transform: translateX(360px); } }
@keyframes status-pulse { 50% { opacity: .78; } }
@keyframes source-progress-scan { from { transform: translateX(-110%); } to { transform: translateX(290%); } }

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

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1279px) {
  :root { --stage-h: clamp(420px, 68svh, 640px); }

  .workspace { grid-template-columns: 360px minmax(0, 1fr); }
  .control-panel { padding: 24px 22px 40px; }

  .preview-panel {
    grid-template-columns: minmax(0, 560px);
    justify-content: center;
    gap: 36px;
    padding-top: 32px;
  }
}

@media (max-width: 980px) {
  .workspace.is-start-screen .control-panel { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .workspace.is-start-screen .source-setup { max-width: 620px; }
}

@media (max-width: 899px) {
  :root { --stage-h: auto; }

  .workspace:not(.is-start-screen) { display: flex; flex-direction: column; }

  .control-panel { padding: 24px 16px 40px; border-right: 0; border-top: 1px solid var(--line); }

  .preview-panel { order: -1; padding: 24px 16px 32px; }

  .preview-column { align-items: stretch; }
  .preview-stage { width: 100%; }
  .stage-label { justify-content: center; }
  .preview-play-button { width: min(calc(100% - 8px), 360px); margin: 0 auto; }

  .vertical-preview,
  .result-card { width: min(calc(100% - 8px), 360px); height: auto; box-shadow: 0 12px 28px rgba(4, 20, 29, .2); }

  .result-card { margin-right: 8px; }
  .vertical-preview { margin-right: 8px; }

  .preview-header h2 { font-size: 24px; }
}

@media (max-width: 520px) {
  .topbar-status .status-divider,
  .topbar-status { font-size: 11px; }

  .start-steps { gap: 12px 20px; }
  .clip-showcase { margin-top: 26px; }
  .clip-example { flex-basis: 112px; }
  .clip-example-frame { height: 140px; }
  .visual-presets { grid-template-columns: 1fr; }
  .visual-preset { display: grid; grid-template-columns: 72px 1fr; align-items: center; gap: 10px; }
  .visual-preset > span:last-child { margin-top: 0; }
  .settings-grid { grid-template-columns: 1fr; }
  .cookie-banner { right: 16px; bottom: 16px; }
}
