/* Editor: CapCut-like vertical stack on phones. */
.editor {
  height: 100%;
  display: flex; flex-direction: column;
  background: var(--bg);
  user-select: none; -webkit-user-select: none;
}

/* Top bar */
.ed-top {
  flex: none;
  display: flex; align-items: center; gap: 4px;
  padding: calc(var(--safe-top) + 6px) 10px 6px 6px;
}
.ed-top-mid { flex: 1; display: flex; justify-content: center; }
.export-btn { height: 32px; padding: 0 16px; margin-left: 4px; }

/* Preview */
.preview {
  flex: 0 0 40%;
  min-height: 180px;
  position: relative;
  display: flex;
  background: #000;
}
.preview-canvas-host {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.preview-canvas { display: block; background: #000; }
.video-pool { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; left: 0; top: 0; }
.pool-video { width: 1px; height: 1px; }
.fs-exit { display: none; position: absolute; top: calc(var(--safe-top) + 8px); right: 8px; background: rgba(0, 0, 0, 0.5); }

.editor.is-fullscreen .preview {
  position: fixed; inset: 0; z-index: 50;
  flex: none;
}
.editor.is-fullscreen .fs-exit { display: inline-flex; }

/* Transport row */
.transport {
  flex: none;
  height: 44px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 8px 0 14px;
  border-bottom: 1px solid var(--divider);
}
.time-label { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-2); }
.play-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  transition: transform var(--t-fast) var(--ease);
}
.play-btn:active { transform: scale(0.9); }
.transport-right { display: flex; justify-content: flex-end; }
.transport-right .icon-btn { width: 36px; height: 36px; }

/* Timeline */
.timeline-host { flex: 1; min-height: 120px; position: relative; display: flex; flex-direction: column; }
.timeline {
  position: relative;
  flex: 1;
  overflow: hidden;
  touch-action: pan-x;
}
.tl-canvas { position: absolute; left: 0; top: 0; pointer-events: none; }
.tl-scroller {
  position: absolute; inset: 0;
  overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.tl-scroller::-webkit-scrollbar { display: none; }
.tl-spacer { height: 1px; }
.tl-playhead {
  position: absolute; top: 2px; bottom: 0; left: 50%;
  width: 2px; margin-left: -1px;
  background: #fff;
  border-radius: 2px;
  pointer-events: none;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
}
.tl-playhead::before {
  content: ""; position: absolute; top: -2px; left: 50%;
  width: 10px; height: 10px; margin-left: -5px;
  background: #fff; border-radius: 3px;
}
.tl-lefttools { position: absolute; display: flex; gap: 6px; }
.tl-tool {
  width: 50px; height: 54px;
  border-radius: 10px;
  background: var(--panel-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 10px; color: var(--text-2);
}
.tl-tool.on { color: var(--accent); }
.tl-add {
  position: absolute;
  width: 40px; height: 40px;
  border-radius: 10px;
  background: #fff; color: #111;
  display: grid; place-items: center;
  transition: transform var(--t-fast) var(--ease);
}
.tl-add:active { transform: scale(0.92); }
.tl-empty { position: absolute; font-size: 13px; color: var(--text-3); white-space: nowrap; pointer-events: none; }
.tl-empty.pulse { animation: pulse 1.6s var(--ease) 3; }
@keyframes pulse { 50% { color: var(--accent); } }

.import-pill {
  position: absolute; left: 50%; bottom: 8px; z-index: 5;
  transform: translate(-50%, 12px);
  opacity: 0; pointer-events: none;
  max-width: 92%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: rgba(30, 30, 30, 0.95);
  border: 1px solid var(--divider);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12px; font-weight: 600; color: var(--text-2);
  transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease);
}
.import-pill.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }

/* Bottom toolbar */
.toolbar {
  flex: none;
  display: flex; gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 8px 6px calc(var(--safe-bottom) + 8px);
  background: var(--panel);
  border-top: 1px solid var(--divider);
}
.toolbar::-webkit-scrollbar { display: none; }
.tool {
  flex: none;
  width: 66px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 6px 0;
  border-radius: 10px;
  font-size: 11px; color: var(--text-2);
  transition: background var(--t-fast) var(--ease);
}
.tool .icon { color: var(--text); }
.tool:active { background: rgba(255, 255, 255, 0.06); }

/* Sheet contents used by the editor */
.form { display: flex; flex-direction: column; gap: 10px; }
.field-label { font-size: 12px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 6px; }
.hint { font-size: 13px; color: var(--text-3); line-height: 1.45; margin: 4px 0 0; }
.segmented { display: flex; gap: 8px; flex-wrap: wrap; }
.seg {
  flex: 1; min-width: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 8px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1.5px solid transparent;
  font-weight: 600; font-size: 13px;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.seg.on { border-color: var(--accent); color: var(--accent); }
.aspect-shape { display: block; border: 2px solid currentColor; border-radius: 3px; }
.swatches { display: flex; flex-wrap: wrap; gap: 12px; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--divider); }
.swatch.on { outline: 2.5px solid var(--accent); outline-offset: 3px; }
.help h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-2); margin: 16px 0 8px; }
.help p { color: var(--text-2); line-height: 1.5; font-size: 14px; }
.help-row { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--divider); font-size: 14px; }
.help-k { flex: 0 0 130px; color: var(--text-2); }
.import-list { display: flex; flex-direction: column; gap: 14px; }
.import-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.import-step { font-size: 12px; color: var(--text-2); margin: 3px 0 6px; }
.bar { height: 4px; border-radius: 4px; background: var(--panel-3); overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); transition: width var(--t-med) var(--ease); }

/* Landscape / desktop: preview gets the room, timeline stays full width.
   (The full desktop layout with side panels arrives in Stage 11.) */
@media (min-width: 900px) and (min-height: 600px) {
  .preview { flex-basis: 52%; }
  .toolbar { justify-content: center; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .preview { flex-basis: 46%; min-height: 120px; }
  .ed-top { padding-top: 4px; padding-bottom: 2px; }
  .toolbar { padding-top: 4px; }
  .tool { width: 58px; padding: 2px 0; }
}

/* ---- Stage 2: AI prompt bar ---- */
.prompt-bar {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: var(--panel);
  border-top: 1px solid var(--divider);
}
.prompt-ai {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  flex: none;
}
.prompt-input {
  flex: 1; min-width: 0;
  height: 40px; padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--divider);
  background: var(--panel-2);
  color: var(--text);
  font: inherit; font-size: 16px;
}
.prompt-send { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-3); flex: none; }
.prompt-status {
  flex: 1; min-width: 0; text-align: left;
  height: 40px; padding: 0 14px; border-radius: 999px;
  background: rgba(30, 230, 200, 0.12); color: var(--accent);
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.prompt-bar.busy .prompt-ai { animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(0.9); opacity: 0.75; } }

/* Toolbar: main tools / selected-clip tools */
.main-tools, .clip-tools { display: flex; gap: 2px; }
.tool.back { border-right: 1px solid var(--divider); border-radius: 0; margin-right: 4px; }
.editor.ai-busy .toolbar .tool:not(:first-child) { opacity: 0.4; pointer-events: none; }

/* Timeline lock while the AI edits */
.tl-lock {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  display: none; align-items: center; gap: 8px;
  max-width: 92%;
  padding: 7px 12px; border-radius: 999px;
  background: rgba(30, 230, 200, 0.14); color: var(--accent);
  font-size: 12px; font-weight: 600;
  pointer-events: none;
}
.timeline.is-locked .tl-lock { display: flex; }
.preview-banner {
  position: absolute; left: 50%; top: 8px; transform: translateX(-50%);
  padding: 6px 12px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.7); color: #fff; font-size: 12px; font-weight: 600;
  display: none;
}
.preview-banner.show { display: block; }

/* ---- Chat panel ---- */
.chat-sheet .sheet-body { padding: 0; display: flex; flex-direction: column; min-height: 0; flex: 1; }
.chat-sheet { height: 62%; max-height: none; }
.chat-sheet.full { height: auto; }
.chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-list { flex: 1; overflow-y: auto; padding: 8px 14px 12px; -webkit-overflow-scrolling: touch; }
.chat-footer { flex: none; border-top: 1px solid var(--divider); padding: 8px 12px 10px; background: var(--panel); }
.chat-compose { display: flex; gap: 8px; align-items: flex-end; }
.chat-input {
  flex: 1; min-height: 42px; max-height: 120px;
  padding: 10px 14px; border-radius: 20px;
  border: 1px solid var(--divider); background: var(--panel-2); color: var(--text);
  font: inherit; font-size: 16px; line-height: 1.35;
}
.chat-send { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); flex: none; }
.chat-stop { height: 42px; flex: none; }
.chat-options { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.chat-options .segmented { flex: none; gap: 4px; flex-wrap: nowrap; }
.chat-options .seg { padding: 6px 10px; min-width: 0; font-size: 12px; flex-direction: row; }
.chat-meter { flex: 1; text-align: right; font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.chat-suggest { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-bottom: 8px; }
.chat-suggest:empty { display: none; }
.suggest { flex: none; padding: 7px 12px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--divider); font-size: 13px; color: var(--text-2); }
.chat-expand { width: 36px; height: 36px; }
.chat-empty { padding: 18px 4px; color: var(--text-2); }
.chat-empty-title { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.chat-empty p { margin: 0 0 12px; line-height: 1.45; font-size: 14px; }
.chat-notice { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: var(--panel-2); font-size: 14px; color: var(--text-2); margin-top: 8px; }

.turn { margin: 12px 0 18px; }
.bubble-user {
  margin-left: auto; max-width: 85%; width: fit-content;
  background: var(--accent); color: var(--accent-ink);
  padding: 9px 13px; border-radius: 16px 16px 4px 16px;
  font-size: 14.5px; line-height: 1.4; white-space: pre-wrap;
}
.turn-card { margin-top: 8px; background: var(--panel-2); border-radius: 14px; padding: 10px 12px; font-size: 14px; line-height: 1.45; }
.turn-steps { margin: 0; padding-left: 22px; color: var(--text-2); font-size: 13px; }
.turn-steps .step { margin: 3px 0; }
.turn-steps .step > span { vertical-align: middle; }
.step-error { color: var(--danger); }
.step-note { color: var(--text-3); }
.step-running .spinner { margin-right: 6px; }
.step-detail summary { color: var(--accent); cursor: pointer; font-size: 12px; }
.step-detail p { white-space: pre-wrap; margin: 4px 0; color: var(--text-2); }
.turn-live { color: var(--text-3); font-size: 13px; margin-top: 6px; white-space: pre-wrap; display: flex; gap: 8px; align-items: center; }
.turn-summary { margin-top: 8px; color: var(--text); }
.turn-summary p { margin: 6px 0; }
.turn-summary ol, .turn-summary ul { margin: 6px 0; padding-left: 20px; }
.turn-summary li { margin: 2px 0; }
.turn-question { margin-top: 10px; }
.q-text { font-weight: 700; margin-bottom: 8px; }
.q-options { display: flex; flex-wrap: wrap; gap: 8px; }
.q-option { padding: 10px 14px; border-radius: 12px; background: var(--panel-3); border: 1.5px solid var(--accent); color: var(--text); font-weight: 600; font-size: 14px; }
.q-option:active { background: var(--accent); color: var(--accent-ink); }
.turn-answer { margin-top: 8px; font-size: 13px; color: var(--accent); }
.turn-note { margin-top: 8px; font-size: 13px; color: var(--text-3); }
.turn-error { margin-top: 8px; font-size: 13px; color: var(--danger); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.turn-foot { display: flex; gap: 10px; align-items: center; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--divider); font-size: 12px; color: var(--text-3); }
.link { color: var(--accent); font-size: 12px; font-weight: 600; }
.btn.small { height: 30px; padding: 0 12px; font-size: 12px; }
.btn.wide { width: 100%; height: 46px; font-size: 15px; margin-top: 8px; }
.spinner {
  display: inline-block; width: 14px; height: 14px; flex: none;
  border: 2px solid rgba(255, 255, 255, 0.2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Sheets: speed / volume / export / versions */
.speed-value { font-size: 28px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }
.range { width: 100%; accent-color: var(--accent); height: 28px; }
.range-row { margin: 4px 0; }
.range-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); }
.range-val { color: var(--text); font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { padding: 8px 12px; border-radius: 10px; background: var(--panel-2); font-size: 13px; font-weight: 600; border: 1.5px solid transparent; }
.chip-btn.on { border-color: var(--accent); color: var(--accent); }
.hint.error { color: var(--danger); }
.hint.center { text-align: center; }
.version-list { display: flex; flex-direction: column; }
.version { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--divider); }
.version.previewing { background: rgba(30, 230, 200, 0.08); border-radius: 10px; }
.version-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; flex: none; }
.version-main { flex: 1; min-width: 0; text-align: left; }
.version-label { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.version-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.version.current .version-icon { background: var(--accent); color: var(--accent-ink); }
.export-progress { text-align: center; padding: 12px 4px; }
.export-pct { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; }
.bar.big { height: 8px; margin: 12px 0; }
.export-phase { color: var(--text-2); font-size: 14px; }
.result-overlay { position: fixed; inset: 0; z-index: 80; background: #000; display: flex; flex-direction: column; padding: var(--safe-top) 0 calc(var(--safe-bottom) + 12px); }
.result-top { display: flex; align-items: center; gap: 8px; padding: 6px 8px; }
.result-info { color: var(--text-2); font-size: 13px; }
.result-video { flex: 1; min-height: 0; width: 100%; object-fit: contain; background: #000; }
.result-actions { padding: 10px 16px 0; }
.mode-pick { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.mode-pick .segmented { flex-wrap: nowrap; gap: 4px; }
.mode-pick .seg { padding: 6px 12px; min-width: 0; font-size: 12px; flex-direction: row; }
.mode-pick .credit-models .seg.on { border-color: #f5b945; color: #f5b945; }
