:root {
  --bg: #0b0b0d;
  --bg-2: #101014;
  --surface: #141418;
  --surface-2: #1a1a20;
  --line: #2a2a32;
  --text: #f3f3f6;
  --muted: #9a9aa4;
  --faint: #6e6e78;
  --fill: #ececf1;
  --ink: #101014;
  --cue: #7c6cff;
  --cue-soft: rgba(124, 108, 255, 0.22);
  --danger: #ff5d73;
  --ok: #6ee7b7;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --radius: 16px;
  --radius-sm: 10px;
  --hit: 44px;
  --font-ui: "Sora", "Avenir Next", "Segoe UI", sans-serif;
  --font-caption: "Montserrat", "Avenir Next Condensed", sans-serif;
  --topbar: 56px;
  --playback: 52px;
  --timeline: 92px;
  --sheet-peek: 148px;
  --keyboard-inset: 0px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

*,
*::before,
*::after { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea, select {
  font: inherit;
  color: inherit;
}
button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
img, video, canvas { max-width: 100%; display: block; }

.app {
  min-height: 100dvh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  background:
    radial-gradient(120% 60% at 50% -10%, #1a1730 0%, transparent 55%),
    var(--bg);
}

.screen { display: none; flex: 1; min-height: 0; }
.app:is([data-route="welcome"],.cappa-ui-route-welcome) #screen-welcome,
.app:is([data-route="trimSetup"],.cappa-ui-route-trimSetup) #screen-trimSetup,
.app:is([data-route="languageSetup"],.cappa-ui-route-languageSetup) #screen-languageSetup,
.app:is([data-route="longVideoNotice"],.cappa-ui-route-longVideoNotice) #screen-longVideoNotice,
.app:is([data-route="processing"],.cappa-ui-route-processing) #screen-processing,
.app:is([data-route="launchReady"],.cappa-ui-route-launchReady) #screen-launchReady,
.app:is([data-route="editor"],.cappa-ui-route-editor) #screen-editor,
.app:is([data-route="export"],.cappa-ui-route-export) #screen-export { display: flex; flex-direction: column; }

.file-banner {
  display: none;
  margin: calc(var(--safe-top) + 8px) 16px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}
.file-banner code {
  display: block;
  margin-top: 8px;
  padding: 8px;
  background: #0a0a0c;
  border-radius: 8px;
  font-size: 12px;
  overflow-x: auto;
}
html.file-protocol .file-banner { display: block; }

/* Welcome */
.welcome {
  padding: calc(var(--safe-top) + 28px) 24px calc(var(--safe-bottom) + 24px);
  max-width: 430px;
  width: 100%;
  margin: 0 auto;
}
.brand-kicker {
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--faint);
  font-weight: 600;
}
.welcome h1 {
  margin: 10px 0 8px;
  font-size: 34px;
  letter-spacing: -0.04em;
  line-height: 1.05;
  font-weight: 700;
}
.welcome .lede {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
  max-width: 28ch;
}
.hero-card {
  position: relative;
  border-radius: 28px;
  padding: 22px 20px 20px;
  background:
    linear-gradient(180deg, #1d1b28 0%, #121218 100%);
  border: 1px solid #2c2a38;
  min-height: 168px;
  overflow: hidden;
}
.hero-card::after {
  content: "";
  position: absolute;
  right: -30px;
  top: -40px;
  width: 160px;
  height: 160px;
  background: radial-gradient(circle, rgba(124,108,255,0.35), transparent 68%);
  pointer-events: none;
}
.hero-card h2 {
  margin: 0 0 6px;
  font-size: 22px;
  letter-spacing: -0.03em;
}
.hero-card p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
}
.btn {
  min-height: var(--hit);
  min-width: var(--hit);
  padding: 0 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
}
.btn-fill {
  background: var(--fill);
  color: var(--ink);
}
.btn-ghost {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.recent {
  margin-top: 28px;
}
.recent h3 {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--faint);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.recent-item {
  width: 100%;
  text-align: left;
  padding: 14px 12px;
  border-radius: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--hit);
  background: var(--surface);
  border: 1px solid var(--line);
  margin-bottom: 8px;
}
.recent-item b { display: block; font-size: 15px; }
.recent-item span { color: var(--muted); font-size: 12px; }

/* Import / processing */
.stack-page {
  padding: calc(var(--safe-top) + 16px) 20px calc(var(--safe-bottom) + 20px);
  max-width: 430px;
  width: 100%;
  margin: 0 auto;
  gap: 16px;
}
.page-title { font-size: 28px; margin: 8px 0 0; letter-spacing: -0.04em; }
.drop {
  margin-top: 12px;
  border: 1px dashed #3a3a46;
  border-radius: 24px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #121216;
  text-align: center;
  padding: 24px;
}
.drop strong { font-size: 18px; }
.drop span { color: var(--muted); font-size: 14px; }
.hidden-file { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.progress-track {
  height: 6px;
  border-radius: 999px;
  background: #22222a;
  overflow: hidden;
  margin-top: 20px;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--fill);
  border-radius: inherit;
  transition: width 160ms linear;
}
.process-detail { color: var(--muted); margin-top: 10px; font-size: 14px; }

/* Editor */
#screen-editor {
  position: relative;
  background: #070709;
}
.editor-top {
  height: calc(var(--topbar) + var(--safe-top));
  padding: var(--safe-top) 6px 0;
  display: grid;
  grid-template-columns: var(--hit) 1fr auto auto var(--hit);
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}
.icon-btn {
  width: var(--hit);
  height: var(--hit);
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--text);
}
.icon-btn:disabled { opacity: 0.35; }
.icon-btn svg { width: 22px; height: 22px; }
.project-title {
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.export-btn {
  min-width: 72px;
  height: 34px;
  border-radius: 999px;
  background: #00c2d2;
  color: #111;
  font-size: 13px;
  font-weight: 700;
  margin-right: 8px;
}
.welcome-header h1 {
  margin: 0 0 18px;
  font-size: 22px;
  font-weight: 600;
}
.hero-start {
  width: 100%;
  text-align: left;
  padding: 22px 20px;
  border-radius: 28px;
  background: #16161a;
  border: 1px solid var(--line);
  min-height: 88px;
}
.hero-start strong { display: block; font-size: 22px; }
.hero-start span { color: var(--muted); font-size: 14px; }
.flow-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.flow-title { font-weight: 600; font-size: 15px; }
.flow-sub { color: var(--faint); font-size: 12px; }
.text-back {
  min-height: 44px;
  text-align: left;
  font-weight: 600;
}
#trim-video { width: 100%; max-height: 280px; background: #000; border-radius: 14px; }

.preview-wrap {
  flex: 1 1 auto;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 16px 8px;
}
#preview-surface {
  position: relative;
  width: min(100%, calc((100dvh - 320px) * 9 / 16));
  max-width: 100%;
  aspect-ratio: 9 / 16;
  background: #09090c;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(0,0,0,0.45);
}
#preview-video,
#preview-poster,
#preview-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#preview-poster { object-fit: cover; }
#preview-video { object-fit: contain; background: #000; }
#preview-overlay { pointer-events: none; }
#preview-hit {
  position: absolute;
  inset: 0;
  z-index: 2;
}
.preview-selected {
  outline: 2px solid rgba(124,108,255,0.9);
  outline-offset: -2px;
}

.playback {
  flex: 0 0 var(--playback);
  display: grid;
  grid-template-columns: var(--hit) 1fr auto;
  align-items: center;
  padding: 0 10px;
  gap: 8px;
}
.time-readout {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.timeline-chrome {
  flex: 0 0 auto;
  padding: 0 8px 4px;
}
.timeline-tools {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-bottom: 4px;
}
.zoom-btn {
  width: 36px;
  height: 32px;
  border-radius: 8px;
  background: #16161c;
  color: var(--text);
  font-size: 16px;
}
#timeline {
  position: relative;
  height: var(--timeline);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  background: #101014;
  border-top: 1px solid #1f1f26;
  border-radius: 12px 12px 0 0;
}
.timeline-track {
  position: relative;
  height: 100%;
}
.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #fff;
  z-index: 3;
  pointer-events: none;
}
.playhead::before {
  content: "";
  position: absolute;
  top: 0;
  left: -5px;
  width: 12px;
  height: 8px;
  background: #fff;
  border-radius: 0 0 3px 3px;
}
.cue-block {
  position: absolute;
  top: 22px;
  height: 52px;
  border-radius: 8px;
  background: var(--cue-soft);
  border: 1px solid rgba(124,108,255,0.45);
  color: #ece8ff;
  font-size: 11px;
  padding: 8px 14px 8px 14px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  touch-action: none;
}
.cue-block.is-selected {
  background: rgba(124,108,255,0.4);
  border-color: #b7adff;
  z-index: 2;
}
.cue-handle {
  position: absolute;
  top: 0;
  width: 22px;
  height: 100%;
}
.cue-handle.start { left: 0; }
.cue-handle.end { right: 0; }
.cue-handle::after {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  width: 3px;
  background: rgba(255,255,255,0.7);
  border-radius: 2px;
}
.cue-handle.start::after { left: 6px; }
.cue-handle.end::after { right: 6px; }

/* Bottom sheet */
.sheet {
  flex: 0 0 auto;
  background: #121217;
  border-top: 1px solid #2a2a32;
  border-radius: 18px 18px 0 0;
  padding: 0 12px calc(var(--safe-bottom) + 10px);
  max-height: min(58dvh, 420px);
  transform: translateY(0);
  margin-bottom: var(--keyboard-inset);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sheet.is-collapsed {
  max-height: calc(var(--sheet-peek) + var(--safe-bottom));
}
.sheet-handle {
  width: 44px;
  height: 18px;
  margin: 4px auto 2px;
  display: grid;
  place-items: center;
}
.sheet-handle span {
  width: 36px;
  height: 4px;
  border-radius: 99px;
  background: #3a3a44;
}
.sheet-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}
.sheet-tab {
  flex: 0 0 auto;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.sheet-tab.is-active {
  background: #ececf1;
  color: #111;
}
.sheet-body {
  overflow-y: auto;
  min-height: 0;
  padding-bottom: 8px;
  overscroll-behavior: contain;
}
.sheet-pane { display: none; }
.sheet-pane.is-active { display: block; }
.field-label {
  display: block;
  font-size: 12px;
  color: var(--faint);
  margin: 10px 0 6px;
  font-weight: 600;
}
#cue-text {
  width: 100%;
  min-height: 88px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0c0c10;
  padding: 12px;
  resize: none;
  line-height: 1.35;
}
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  background: #1b1b22;
  border: 1px solid var(--line);
  font-size: 13px;
}
.chip.is-active { background: var(--fill); color: var(--ink); border-color: transparent; }
.slider {
  width: 100%;
  height: 32px;
}
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid transparent;
}
.swatch.is-active { border-color: #fff; }

.kbd-bar {
  display: none;
  justify-content: flex-end;
  padding: 6px 0;
}
.app.is-keyboard .kbd-bar { display: flex; }
.app.is-keyboard .timeline-chrome,
.app.is-keyboard .playback { display: none; }
.app.is-keyboard .sheet { max-height: 42dvh; }

/* Export / processing shared */
.status-hero {
  margin-top: 40px;
  text-align: left;
}

/* Tablet */
@media (min-width: 768px) {
  .app:is([data-route="editor"],.cappa-ui-route-editor) #screen-editor {
    display: grid;
    grid-template-columns: 1fr 320px;
    grid-template-rows: auto 1fr auto auto;
  }
  .editor-top { grid-column: 1 / -1; }
  .preview-wrap { grid-row: 2; }
  .playback { grid-column: 1; }
  .timeline-chrome { grid-column: 1; }
  .sheet {
    grid-column: 2;
    grid-row: 2 / span 3;
    max-height: none;
    border-radius: 0;
    border-top: 0;
    border-left: 1px solid var(--line);
    margin-bottom: 0;
  }
  .sheet.is-collapsed { max-height: none; }
  #preview-surface {
    width: min(420px, 100%);
  }
}

@font-face {
  font-family: "DejaVu Sans";
  src: url("../fonts/DejaVuSans-Bold.ttf") format("truetype");
  font-display: swap;
  font-weight: 700 900;
}
@font-face {
  font-family: "DejaVu Serif";
  src: url("../fonts/DejaVuSerif-Bold.ttf") format("truetype");
  font-display: swap;
  font-weight: 700 900;
}
@font-face {
  font-family: "Sour Gummy";
  src: url("../fonts/SourGummy.ttf") format("truetype");
  font-display: swap;
  font-weight: 100 900;
}
@font-face {
  font-family: "Helvetica Neue LT Std";
  src: url("../fonts/HelveticaNeueLTStd-Bd.ttf") format("truetype");
  font-display: swap;
  font-weight: 800 900;
}

@media (max-width: 767px) {
  .app:is([data-route="editor"],.cappa-ui-route-editor) { height: 100dvh; min-height: 100dvh; overflow: hidden; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) #screen-editor { height: 100dvh; min-height: 0; flex: 1 1 100%; overflow: hidden; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .editor-top { flex: 0 0 calc(54px + var(--safe-top)); }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .preview-wrap { flex: 1 1 0; min-height: 260px; overflow: hidden; padding-top: 6px; padding-bottom: 4px; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) #preview-surface { height: min(100%, 450px); width: auto; min-width: 0; max-height: min(100%, 450px); }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .playback { flex: 0 0 46px; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .sheet { flex: 0 1 min(40dvh, 360px); min-height: 215px; max-height: min(40dvh, 360px); overflow: hidden; margin-top: 0; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .sheet.is-collapsed { flex-basis: 148px; min-height: 148px; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .sheet-handle { flex: 0 0 20px; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .sheet-tabs { flex: 0 0 45px; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .sheet-body { flex: 1 1 auto; min-height: 0; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .sheet-pane.is-active { min-height: 0 !important; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .sheet-pane:is([data-pane="style"],.cappa-ui-pane-style).is-active { min-height: 300px !important; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .sheet-pane:is([data-pane="edit"],.cappa-ui-pane-edit).is-active { min-height: 250px !important; }
}

/* Constrained mobile editor: the preview and chrome share the viewport; panes scroll in place. */
@media (max-width: 767px) {
  #screen-editor {
    height: 100dvh;
    min-height: 0;
    flex: 1 1 100%;
    overflow: hidden;
  }
  .editor-top { flex: 0 0 calc(54px + var(--safe-top)); }
  .preview-wrap {
    flex: 1 1 0;
    min-height: 260px;
    overflow: hidden;
    padding-top: 6px;
    padding-bottom: 4px;
  }
  #preview-surface {
    height: min(100%, 450px);
    width: auto;
    min-width: 0;
    max-height: min(100%, 450px);
  }
  .playback { flex: 0 0 46px; }
  .sheet {
    flex: 0 1 min(40dvh, 360px);
    min-height: 215px;
    max-height: min(40dvh, 360px);
    overflow: hidden;
    margin-top: 0;
  }
  .sheet.is-collapsed { flex-basis: 148px; min-height: 148px; }
  .sheet-handle { flex: 0 0 20px; }
  .sheet-tabs { flex: 0 0 45px; }
  .sheet-body { flex: 1 1 auto; min-height: 0; }
  .sheet-pane.is-active { min-height: 0 !important; }
  .sheet-pane:is([data-pane="style"],.cappa-ui-pane-style).is-active { min-height: 300px !important; }
  .sheet-pane:is([data-pane="edit"],.cappa-ui-pane-edit).is-active { min-height: 250px !important; }
  .sheet-tab { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; height:45px; font-size:9px; font-weight:650; letter-spacing:.035em; text-transform:uppercase; }
  .sheet-tab svg { width:15px; height:15px; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
  .style-picker-heading { display:flex; justify-content:space-between; align-items:center; }
  .style-picker-heading .field-label { margin: 6px 0; }
  .scope-note { color: #91879f; font-size: 10px; }
  .style-search-wrap {
    height: 32px;
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 4px 0 10px;
    padding: 0 10px;
    border: 1px solid #332c40;
    border-radius: 9px;
    background: #100d17;
  }
  .style-search-wrap svg { width: 13px; height: 13px; fill: none; stroke: #92899d; stroke-width: 1.8; flex: 0 0 13px; }
  .style-search-wrap input { width: 100%; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 12px; }
  .style-search-wrap input::placeholder { color: #8f8698; }
  #preset-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 0 1px 10px;
  }
  .style-card {
    min-width: 0;
    height: 116px;
    padding: 7px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 12px;
    text-align: left;
    background: #211b2a;
  }
  .style-card.is-active { outline: 2px solid #a88ad5; border-color: #d2b9f2; }
  .style-card-preview {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 7px 5px;
    overflow: hidden;
    border-radius: 8px;
    background:
      linear-gradient(180deg, rgba(10,7,16,.05), rgba(10,7,16,.5)),
      url("../images/onboarding-india-mirror.jpg") center 54% / cover,
      #392d48;
  }
  .style-card-sample {
    max-width: 100%;
    padding: 3px 4px;
    border-radius: 3px;
    color: var(--sample-color);
    background: var(--sample-bg, transparent);
    font-family: var(--sample-font);
    font-size: 11px;
    font-weight: var(--sample-weight);
    line-height: 1.12;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0,0,0,.8);
    -webkit-text-stroke: var(--sample-stroke-width) var(--sample-stroke);
    overflow-wrap: anywhere;
  }
  .style-card-name { padding: 0 3px 2px; color: #f5f0fb; font-size: 11px; font-weight: 600; }
}

/* Desktop */
@media (min-width: 1100px) {
  .app:is([data-route="editor"],.cappa-ui-route-editor) #screen-editor {
    grid-template-columns: 1fr 360px;
  }
  .preview-wrap { padding: 16px 24px; }
  #preview-surface { width: min(480px, 100%); }
  .timeline-chrome { padding: 0 16px 12px; }
  --timeline: 110px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* Released Cappa mobile surface: quiet violet canvas, compact controls, gold import/export. */
:root {
  --bg: #0b0913;
  --bg-2: #110e1b;
  --surface: #171321;
  --surface-2: #211b2f;
  --line: #332c43;
  --text: #f6f2fb;
  --muted: #b8b0c7;
  --faint: #8e849f;
  --fill: #f1bd55;
  --ink: #241907;
  --cue: #9f82ff;
  --cue-soft: rgba(159, 130, 255, 0.22);
  --font-ui: -apple-system, BlinkMacSystemFont, "Avenir Next", "Segoe UI", sans-serif;
}

html, body { width: 100%; overflow-x: clip; background: #0b0913; }
.app {
  width: 100%;
  max-width: 100vw;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  background: radial-gradient(120% 64% at 50% -12%, #241b38 0%, transparent 58%), #0b0913;
}
button, a, select, input, textarea { max-width: 100%; }
[hidden] { display: none !important; }

.welcome {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  padding: calc(var(--safe-top) + 18px) 20px calc(var(--safe-bottom) + 24px);
  gap: 0;
}
.welcome-header {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.welcome-header h1 { margin: 0; font-size: 19px; letter-spacing: -0.02em; }
.settings-button {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(221, 209, 245, .14);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #dfd6ee;
  background: rgba(255,255,255,.045);
}
.settings-button svg { width: 17px; height: 17px; fill: currentColor; }
.hero-start {
  position: relative;
  min-height: clamp(330px, 56svh, 510px);
  border: 1px solid #59446f;
  border-radius: 28px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 14px;
  overflow: hidden;
  text-align: left;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(22, 14, 32, .12) 10%, rgba(24, 14, 35, .18) 42%, rgba(14, 10, 22, .88) 100%),
    url("../images/onboarding-india-mirror.jpg") center 42% / cover,
    linear-gradient(150deg, #3a2753 0%, #251a38 52%, #171222 100%);
  box-shadow: inset 0 1px rgba(255,255,255,.1);
}
.hero-start::before, .hero-start::after { content: ""; position: absolute; pointer-events: none; }
.hero-start::before {
  width: min(72vw, 270px);
  aspect-ratio: 1;
  top: 7%;
  right: -7%;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, rgba(216,191,255,.12), rgba(152,111,218,.08) 48%, transparent 72%);
}
.hero-start::after {
  inset: 0;
  background: linear-gradient(180deg, transparent 38%, rgba(15,10,22,.2) 62%, rgba(15,10,22,.5));
}
.hero-start > * { position: relative; z-index: 1; }
.hero-start strong { font-size: 23px; font-weight: 650; }
.hero-plus {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  color: #281b08;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffd875, #e8a934);
  box-shadow: 0 8px 28px rgba(228,169,52,.24);
  font-size: 36px;
  line-height: 1;
  font-weight: 300;
}
.welcome-import { margin: 16px 0 0; color: #f1eaf9; font-size: 15px; font-weight: 600; }
.welcome-detail { margin: 7px 0 0; color: #aaa0ba; font-size: 13px; line-height: 1.5; }
.recent { margin-top: 22px; }
.recent h3 { color: #c3b8d1; }
.recent-item { background: #171321; border-color: #30283d; margin: 0 0 8px; }
.recent-item b { color: var(--text); }
.recent-item span { color: var(--muted); }
.recent-item .recent-arrow { font-size: 24px; align-self: center; }
.welcome-settings-panel {
  position: absolute;
  z-index: 5;
  top: calc(var(--safe-top) + 68px);
  right: 20px;
  width: min(270px, calc(100vw - 40px));
  padding: 16px;
  border: 1px solid #413750;
  border-radius: 16px;
  color: var(--text);
  background: #1a1524;
  box-shadow: 0 14px 40px rgba(0,0,0,.36);
}
.welcome-settings-panel p { color: var(--muted); font-size: 13px; line-height: 1.4; }
.welcome-settings-panel div { display: flex; gap: 18px; }
.welcome-settings-panel a, .text-link { color: #eed08f; text-decoration: none; font-size: 13px; }

.stack-page { padding-top: calc(var(--safe-top) + 20px); }
.btn-fill { background: linear-gradient(145deg, #ffd875, #e8aa39); color: #271b08; }
.btn-ghost { background: #1a1623; border-color: #393145; }
.slider { accent-color: #dbb657; }
.select-field {
  min-height: 48px;
  width: 100%;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}
.toggle-row, .fit-row { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 14px; color: var(--text); }
.toggle-row small { display: block; color: var(--muted); margin-top: 3px; }
.language-options { display: grid; gap: 10px; }
.empty-captions-hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.background-note { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.language-options .field-label { margin-bottom: -5px; }

#screen-editor {
  min-height: 100svh;
  height: auto;
  overflow: visible;
  background: #0a0810;
}
.editor-top {
  width: 100%;
  height: calc(54px + var(--safe-top));
  grid-template-columns: 40px minmax(0,1fr) 38px 38px 74px;
  gap: 3px;
  padding: var(--safe-top) 10px 0;
}
.editor-top .icon-btn { width: 38px; height: 40px; }
.project-title { padding: 0 6px; font-size: 13px; }
.export-btn {
  width: 68px;
  min-width: 0;
  height: 36px;
  margin: 0;
  border-radius: 12px;
  color: #261b09;
  background: linear-gradient(145deg, #ffd875, #e8aa39);
  font-size: 13px;
}
.preview-wrap {
  flex: 0 0 auto;
  min-height: 0;
  padding: 8px 12px 6px;
}
#preview-surface {
  flex: 0 0 auto;
  width: min(76vw, 420px, calc((100svh - 332px) * 0.5625));
  min-width: min(230px, 70vw);
  max-height: 620px;
  aspect-ratio: 9 / 16;
  border-radius: 20px;
  box-shadow: 0 10px 38px rgba(0,0,0,.3);
}
.preview-wrap:has(.restore-media:not([hidden])) #preview-surface { opacity: .72; }
.restore-media {
  position: absolute;
  z-index: 4;
  align-self: center;
  max-width: calc(100% - 48px);
  padding: 11px 14px;
  border: 1px solid rgba(246,242,251,.3);
  border-radius: 12px;
  background: rgba(24,19,33,.94);
  color: var(--text);
  font-size: 12px;
}
.preview-selected { outline-color: #e7bf69; }
#preview-surface.can-move-caption { cursor: crosshair; touch-action: none; }
#preview-surface.is-moving-caption { cursor: grabbing; }
.playback { flex: 0 0 48px; padding: 0 16px; }
.time-readout { color: #aca4b8; }
.sheet {
  max-height: none;
  margin-top: 4px;
  border-color: #2b2536;
  border-radius: 20px 20px 0 0;
  padding: 0 14px calc(var(--safe-bottom) + 12px);
  background: #15111d;
}
.sheet.is-collapsed { max-height: calc(var(--sheet-peek) + var(--safe-bottom)); }
.sheet-tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; overflow: hidden; border-bottom: 1px solid #2a2434; }
.sheet-tab {
  min-width: 0;
  height: 45px;
  padding: 0 3px;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  color: #aaa1b7;
  font-size: 12px;
  white-space: nowrap;
}
.sheet-tab.is-active { color: #fff; background: transparent; border-bottom-color: #e0b653; }
.sheet-body { padding: 6px 0 10px; }
.sheet-pane { padding: 0 2px; }
.sheet-pane.is-active { min-height: 128px; }
.sheet-pane:is([data-pane="style"],.cappa-ui-pane-style).is-active { min-height: 248px; }
.sheet-pane:is([data-pane="color"],.cappa-ui-pane-color).is-active { min-height: 152px; }
.sheet-pane:is([data-pane="size"],.cappa-ui-pane-size).is-active { min-height: 136px; }
.sheet-pane:is([data-pane="edit"],.cappa-ui-pane-edit).is-active { min-height: 260px; }
.sheet-pane:is([data-pane="timeline"],.cappa-ui-pane-timeline).is-active { min-height: 200px; }
.field-label { color: #aaa1b8; }
.chip { min-height: 36px; background: #211b2b; border-color: #383043; font-size: 12px; }
.chip.is-active { background: #e4bd64; color: #241a08; }
.swatch.is-active { outline: 2px solid #dfb85d; outline-offset: 2px; border-color: #15111d; }
.caption-list { max-height: 112px; overflow-y: auto; margin: 0 0 8px; }
.caption-row {
  width: 100%; min-height: 42px; display: grid; grid-template-columns: 28px minmax(0,1fr) 42px; align-items: center; gap: 8px;
  padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,.06); text-align: left;
}
.caption-row.is-selected { background: rgba(172,145,230,.12); }
.caption-number, .caption-time { color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.caption-copy { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.timeline-chrome { padding: 2px 0 4px; }
#timeline { border-radius: 10px; border: 1px solid #2c2636; background: #100d16; max-width: 100%; }
.timeline-actions { padding: 0 2px; }
.move-caption-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; }
.move-caption-row strong, .move-caption-row span { display: block; }
.move-caption-row strong { font-size: 13px; }
.move-caption-row span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.move-caption-row .btn { min-height: 34px; padding: 0 14px; font-size: 12px; }
.move-caption-row .btn.is-active { border-color: #dfb85d; color: #f3d58c; }
.timeline-actions .field-label { margin: 3px 0 0; }
.timeline-actions .slider { height: 26px; }
.timeline-actions .action-grid { margin-top: 4px; }
.timeline-actions .action-grid .btn { min-height: 34px; }
.export-btn:disabled { opacity: .45; }
#screen-export .btn, #screen-export .text-link { width: 100%; justify-content: center; }
#screen-export .text-link { display: block; text-align: center; }
#screen-export { gap: 14px; }
.app-update {
  position: fixed;
  z-index: 20;
  left: max(12px, var(--safe-left));
  right: max(12px, var(--safe-right));
  bottom: calc(12px + var(--safe-bottom));
  min-height: 52px;
  padding: 8px 10px 8px 14px;
  border: 1px solid #4a3e59;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #201a2a;
  color: var(--text);
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  font-size: 13px;
}
.app-update button { padding: 8px 12px; border-radius: 10px; background: #e5bc62; color: #261c08; font-size: 12px; font-weight: 700; }

@media (max-width: 374px) {
  .editor-top { grid-template-columns: 36px minmax(0,1fr) 34px 34px 68px; padding-left: 6px; padding-right: 6px; }
  .editor-top .icon-btn { width: 34px; }
  .export-btn { width: 64px; }
  .sheet { padding-left: 10px; padding-right: 10px; }
  .sheet-tab { font-size: 11px; }
}

@media (min-width: 768px) {
  #screen-editor { min-height: 100vh; overflow: hidden; }
  .sheet { max-height: none; }
  .sheet-pane.is-active { min-height: 0; }
  .sheet-pane:is([data-pane="style"],.cappa-ui-pane-style).is-active { min-height: 248px; }
  #preview-surface { width: min(420px, 64vw, calc((100vh - 180px) * .5625)); }
}

@media (max-width: 767px) {
  .app:is([data-route="editor"],.cappa-ui-route-editor) { height: 100dvh !important; min-height: 100dvh !important; overflow: hidden; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) #screen-editor { height: 100dvh !important; min-height: 0 !important; flex: 1 1 100%; overflow: hidden; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .editor-top { flex: 0 0 calc(54px + var(--safe-top)); }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .preview-wrap { flex: 1 1 0 !important; min-height: 260px !important; overflow: hidden; padding-top: 6px; padding-bottom: 4px; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) #preview-surface { height: min(100%, 450px) !important; width: auto !important; min-width: 0 !important; max-height: min(100%, 450px) !important; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .playback { flex: 0 0 46px; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .sheet { flex: 0 1 min(40dvh, 360px) !important; min-height: 215px; max-height: min(40dvh, 360px); overflow: hidden; margin-top: 0; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .sheet.is-collapsed { flex-basis: 148px !important; min-height: 148px; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .sheet-handle { flex: 0 0 20px; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .sheet-tabs { flex: 0 0 45px; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .sheet-body { flex: 1 1 auto; min-height: 0; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .sheet-pane.is-active { min-height: 0 !important; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .sheet-pane:is([data-pane="style"],.cappa-ui-pane-style).is-active { min-height: 300px !important; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .sheet-pane:is([data-pane="edit"],.cappa-ui-pane-edit).is-active { min-height: 250px !important; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .sheet-tab { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; height:45px; font-size:9px; font-weight:650; letter-spacing:.035em; text-transform:uppercase; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .sheet-tab svg { width:15px; height:15px; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .style-picker-heading { display:flex; justify-content:space-between; align-items:center; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .style-picker-heading .field-label { margin: 6px 0; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .scope-note { color: #91879f; font-size: 10px; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .style-search-wrap { height:32px; display:flex; align-items:center; gap:7px; margin:4px 0 10px; padding:0 10px; border:1px solid #332c40; border-radius:9px; background:#100d17; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .style-search-wrap svg { width:13px; height:13px; fill:none; stroke:#92899d; stroke-width:1.8; flex:0 0 13px; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .style-search-wrap input { width:100%; min-width:0; height:100%; border:0; outline:0; background:transparent; color:var(--text); font-size:12px; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) #preset-row { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; padding:0 1px 10px; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .style-card { min-width:0; height:116px; padding:7px; display:flex; flex-direction:column; gap:7px; border:1px solid rgba(255,255,255,.1); border-radius:12px; text-align:left; background:#211b2a; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .style-card.is-active { outline:2px solid #a88ad5; border-color:#d2b9f2; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .style-card-preview { flex:1 1 auto; width:100%; min-height:0; display:flex; align-items:flex-end; justify-content:center; padding:7px 5px; overflow:hidden; border-radius:8px; background:linear-gradient(180deg,rgba(10,7,16,.05),rgba(10,7,16,.5)),url("../images/onboarding-india-mirror.jpg") center 54%/cover,#392d48; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .style-card-sample { max-width:100%; padding:3px 4px; border-radius:3px; color:var(--sample-color); background:var(--sample-bg,transparent); font-family:var(--sample-font); font-size:11px; font-weight:var(--sample-weight); line-height:1.12; text-align:center; text-shadow:0 1px 2px rgba(0,0,0,.8); -webkit-text-stroke:var(--sample-stroke-width) var(--sample-stroke); overflow-wrap:anywhere; }
  .app:is([data-route="editor"],.cappa-ui-route-editor) .style-card-name { padding:0 3px 2px; color:#f5f0fb; font-size:11px; font-weight:600; }
}

/* Match the release onboarding composition: full-bleed photo, live-style caption sample, fixed gold action. */
.app:is([data-route="welcome"],.cappa-ui-route-welcome) { min-height: 100svh; height: 100dvh; overflow: hidden; }
.app:is([data-route="welcome"],.cappa-ui-route-welcome) #screen-welcome { min-height: 0; flex: 1 1 100%; }
.app:is([data-route="welcome"],.cappa-ui-route-welcome) .welcome {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 520px;
  height: 100%;
  min-height: 0;
  padding: calc(var(--safe-top) + 18px) 0 calc(var(--safe-bottom) + 22px);
  overflow: hidden;
}
.welcome-visual { position: absolute; z-index: -1; inset: 0; overflow: hidden; background: #0c0913; }
.welcome-visual img { width: 100%; height: 100%; object-fit: cover; object-position: center 48%; transform: scale(1.2); }
.welcome-visual::before { content:""; position:absolute; inset:0; background: linear-gradient(180deg,rgba(7,5,12,.23) 0%,transparent 27%,transparent 47%,rgba(12,8,18,.15) 61%,rgba(11,8,17,.8) 82%,#0b0913 100%),linear-gradient(90deg,rgba(11,8,17,.24),transparent 24%,transparent 76%,rgba(11,8,17,.2)); }
.welcome-header { flex: 0 0 auto; position:relative; z-index:2; min-height:40px; margin:0; padding:0 20px; }
.welcome-header h1 { font-size:22px; font-weight:800; text-shadow:0 1px 14px rgba(0,0,0,.28); }
.welcome-visual-caption { position:absolute; top:62%; left:7%; right:7%; color:#fff; font-family:"Avenir Next",system-ui,sans-serif; font-size:clamp(22px,7vw,34px); font-weight:850; letter-spacing:-.035em; text-align:center; text-shadow:0 2px 3px rgba(0,0,0,.85),0 8px 25px rgba(0,0,0,.52); }
.welcome-add {
  flex:0 0 auto;
  min-height:60px;
  margin: auto 20px 0;
  padding: 0 18px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  border:1px solid rgba(255,255,255,.22);
  border-radius:24px;
  color:#261b09;
  background:linear-gradient(145deg,#ffd875,#e8aa39);
  font-size:20px;
  font-weight:850;
  box-shadow:0 8px 26px rgba(0,0,0,.22);
}
.welcome-add span { font-size:23px; line-height:1; font-weight:800; }
.welcome-settings-panel { top:calc(var(--safe-top) + 66px); right:20px; }
.app:is([data-route="welcome"],.cappa-ui-route-welcome) .recent { position:absolute; z-index:2; left:20px; right:20px; bottom:calc(var(--safe-bottom) + 98px); max-height:35svh; overflow:auto; padding:10px 0 2px; margin:0; }
.app:is([data-route="welcome"],.cappa-ui-route-welcome) .recent h3 { color:#f2eaf8; text-shadow:0 1px 8px rgba(0,0,0,.8); }
.app:is([data-route="welcome"],.cappa-ui-route-welcome) .recent-item { background:rgba(21,16,29,.86); border-color:rgba(255,255,255,.16); backdrop-filter:blur(8px); }

/* Let pointer gestures reach captions without the browser taking over scrolling. */
#preview-hit { touch-action: none; user-select: none; -webkit-user-select: none; }
#preview-surface.is-moving-caption #preview-hit { cursor: grabbing; }

/* Editor-only corner brackets follow the rendered caption, never the video frame. */
#preview-surface.preview-selected { outline: none; }
.caption-drag-bracket { position:absolute; z-index:3; pointer-events:none; }
.caption-drag-bracket i { position:absolute; width:11px; height:11px; border:solid #fff; border-width:0; filter:drop-shadow(0 1px 1px #0009); }
.caption-drag-bracket i:nth-child(1) { top:0; left:0; border-top-width:1.5px; border-left-width:1.5px; border-top-left-radius:4px; }
.caption-drag-bracket i:nth-child(2) { top:0; right:0; border-top-width:1.5px; border-right-width:1.5px; border-top-right-radius:4px; }
.caption-drag-bracket i:nth-child(3) { bottom:0; left:0; border-bottom-width:1.5px; border-left-width:1.5px; border-bottom-left-radius:4px; }
.caption-drag-bracket i:nth-child(4) { bottom:0; right:0; border-bottom-width:1.5px; border-right-width:1.5px; border-bottom-right-radius:4px; }
