:root {
  --bg: #0e0e11;
  --panel: #16161b;
  --panel2: #1f1f26;
  --line: #2a2a33;
  --text: #ececf1;
  --muted: #8d8d9b;
  --accent: #22d3ee;
  --clip: #26354f;
  --textc: #6d3fd8;
  --audio: #0f6e66;
  --danger: #f43f5e;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 Inter, system-ui, sans-serif;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr) clamp(200px, 30vh, 280px); /* the timeline gives the preview room on short laptop screens */
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
  user-select: none;
}

button {
  font: inherit; color: inherit;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}
button:hover:not(:disabled) { background: #282832; border-color: #3a3a46; }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); color: #04141b; border-color: transparent; font-weight: 700; }
button.primary:hover { background: #67e8f9; }
button.small { padding: 3px 8px; font-size: 12px; }
button.danger { color: var(--danger); }
button.link { background: none; border: none; color: var(--accent); padding: 2px 0; }
input, select, textarea {
  font: inherit; color: inherit;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 7px;
}
textarea { width: 100%; resize: vertical; user-select: text; }
input[type=range] { accent-color: var(--accent); padding: 0; background: none; border: none; width: 100%; }
input[type=color] { padding: 2px; height: 28px; }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.spacer { flex: 1; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; display: flex; align-items: center; gap: 8px; }
.logo {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 7px;
  background: linear-gradient(135deg, #22d3ee, #a855f7);
  color: #fff; font-size: 11px;
}
#projectName { background: transparent; border-color: transparent; width: 200px; }
#projectName:hover, #projectName:focus { border-color: var(--line); background: var(--panel2); }
.icon-btn { width: 34px; padding: 6px 0; font-size: 16px; }
.save-status { font-size: 12px; color: var(--muted); }
.save-status:not(:empty)::before { content: "● "; color: #34d399; }
.save-status.warn { color: #fbbf24; }
.save-status.warn::before { color: #fbbf24; }

/* ---------- Workspace ---------- */
.workspace { display: grid; grid-template-columns: 330px minmax(0, 1fr) 300px; min-height: 0; }
.panel { background: var(--panel); overflow-y: auto; padding: 12px; }
.media-panel { border-right: 1px solid var(--line); }
.inspector { border-left: 1px solid var(--line); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; margin: 4px 0 10px;
}
.panel-head ~ .panel-head { margin-top: 18px; }

.media-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.media-item { min-width: 0; }
.media-item .thumb {
  position: relative; aspect-ratio: 1;
  border-radius: 8px; background: #23232b center / cover no-repeat;
  border: 1px solid var(--line);
}
.media-item .thumb.audio { background-size: 100% 60%; background-color: #10302d; }
.media-item .note { position: absolute; top: 6px; left: 8px; font-size: 16px; }
.media-item .dur {
  position: absolute; bottom: 4px; left: 4px;
  font-size: 10px; background: rgba(0,0,0,.65); padding: 1px 5px; border-radius: 4px;
}
.media-item .add {
  position: absolute; bottom: 4px; right: 4px;
  width: 22px; height: 22px; padding: 0; border-radius: 50%;
  background: var(--accent); color: #04141b; border: none; font-weight: 800;
}
.media-item .add.layer { right: 30px; background: #a78bfa; font-size: 12px; }
.media-item .remove {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; padding: 0; border-radius: 50%;
  background: rgba(0,0,0,.65); border: none; font-size: 14px; line-height: 20px;
  opacity: 0; transition: opacity .15s;
}
.media-item:hover .remove, .media-item .remove:focus-visible { opacity: 1; }
.media-item .remove:hover { background: var(--danger) !important; }
.media-item.unused .thumb { opacity: .55; }
#cleanupBtn { margin-top: 8px; }
#cleanupBtn[hidden] { display: none; }
.media-item .name { font-size: 11px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-hint {
  border: 1px dashed var(--line); border-radius: 8px;
  padding: 18px 10px; text-align: center; color: var(--muted);
}
.add-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.add-buttons button { padding: 12px 6px; }

/* ---------- Preview ---------- */
.stage { display: flex; flex-direction: column; min-height: 0; min-width: 0; padding: 14px; }
.format-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; padding-bottom: 10px; }
.fmt {
  display: flex; align-items: center; gap: 4px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 0 4px 0 10px;
}
.fmt:hover { border-color: #3a3a46; }
.fmt-icon { color: var(--muted); font-size: 12px; }
.fmt select { border: none; background: transparent; padding: 5px 4px; font-size: 12px; font-weight: 600; cursor: pointer; }
.fmt select:focus { outline: none; }
.fmt:focus-within { border-color: var(--accent); }
.fmt-btn { cursor: pointer; font: inherit; font-size: 12px; color: var(--muted); }
.fmt-btn.on { color: #fca5a5; border-color: #ef444488; }
.fmt-badge { font-size: 11px; font-weight: 700; color: #fbbf24; border: 1px solid #fbbf2466; border-radius: 999px; padding: 4px 10px; }
.fmt-badge[hidden] { display: none; }
.preview-wrap { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; }
#preview { background: #000; border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.55); touch-action: none; }
.drop-hint {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  color: var(--muted); pointer-events: none;
}
.drop-hint[hidden], .empty-hint[hidden] { display: none; }
.drop-hint button { pointer-events: auto; }
.drop-icon { font-size: 34px; }
body.dragging-files .preview-wrap { outline: 2px dashed var(--accent); outline-offset: -6px; border-radius: 12px; }
.transport {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  padding-top: 10px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.play { width: 42px; height: 42px; border-radius: 50%; font-size: 15px; padding: 0; }

/* ---------- Inspector ---------- */
.inspector h3 { margin: 0 0 2px; font-size: 15px; }
.inspector section { border-top: 1px solid var(--line); padding: 12px 0 8px; margin-top: 12px; }
.inspector h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.row { display: grid; grid-template-columns: 78px minmax(0, 1fr) 42px; align-items: center; gap: 8px; margin: 7px 0; }
.row > span { color: var(--muted); }
.row output { font-size: 11px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.row select, .row input[type=number], .row input[type=color] { grid-column: 2 / 4; width: 100%; }
.row.check { grid-template-columns: auto 1fr; }
.fgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.fchip { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.fchip img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.fthumb { position: relative; display: block; isolation: isolate; }
.fthumb i { position: absolute; inset: 0; }
.fchip > span:not(.fthumb) { font-size: 11px; padding: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fchip.suggested { box-shadow: 0 0 0 2px #facc15; }
.fstar { position: absolute; top: 3px; right: 4px; color: #facc15; font-size: 14px; text-shadow: 0 1px 2px #000; }
.enhance-note { margin: 4px 0 8px; color: #fde68a; }
.fgroup { grid-column: 1 / -1; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 6px; }
.fchip.on { outline: 2px solid var(--accent); }
.row.kf-row { grid-template-columns: 70px minmax(0, 1fr) 38px 20px; gap: 6px; }
.kf-btn {
  width: 20px; height: 20px; padding: 0; border: none; background: none;
  color: #4a4a55; font-size: 13px; line-height: 20px;
}
.kf-btn:hover:not(:disabled) { background: none; color: var(--text); }
.kf-btn.has { color: #a78bfa; }
.kf-btn.on { color: #facc15; text-shadow: 0 0 6px rgba(250,204,21,.6); }
.block .silence {
  position: absolute; top: 0; bottom: 0; z-index: 1; pointer-events: none;
  background: repeating-linear-gradient(135deg, rgba(244,63,94,.55) 0 4px, rgba(244,63,94,.3) 4px 8px);
  border-left: 1px solid #f43f5e; border-right: 1px solid #f43f5e;
}
.block .kf {
  position: absolute; bottom: 3px; width: 9px; height: 9px; margin-left: -4.5px;
  background: #facc15; border: 1px solid #111; transform: rotate(45deg); z-index: 2; cursor: pointer;
}
.ramp-editor { width: 100%; height: 110px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; touch-action: none; cursor: crosshair; }
.ramp-editor circle { fill: #facc15; stroke: #111; cursor: grab; }
.egrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.echip { padding: 7px 4px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-group { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 10px 0 5px; }
.echip.on, .chip-row button.on { border-color: var(--accent); color: var(--accent); }
.chip-row { display: flex; gap: 4px; margin: 4px 0 2px; }
.chip-row button { flex: 1; padding: 3px 0; }
.insp-actions { display: flex; gap: 6px; margin-top: 16px; }
.hooks-card { width: min(640px, 96vw); max-height: 90vh; display: flex; flex-direction: column; }
.hooks-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding-right: 4px; }
.hook-item { text-align: left; padding: 8px 10px; font-size: 13px; font-weight: 600; }
.format-item { text-align: left; padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; }
.format-item span { font-size: 13px; }
.format-item small { font-size: 11px; }
.filler-list { display: flex; flex-direction: column; gap: 3px; margin: 8px 0 0; max-height: 220px; overflow-y: auto; }
.filler-row { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; background: #1d1d24; font-size: 12px; }
.filler-row.sound span:first-of-type { color: var(--muted); }
.filler-row button { padding: 1px 7px; }
.insp-actions button { flex: 1; }
.keys { list-style: none; padding: 0; margin: 0; }
.keys li { margin: 6px 0; color: var(--muted); }
kbd {
  display: inline-block; min-width: 22px; text-align: center;
  background: var(--panel2); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 5px; padding: 0 5px; margin-right: 6px; color: var(--text); font: 11px/18px Inter, sans-serif;
}
.flash-section { animation: flash 1s ease-out; }
@keyframes flash { from { background: rgba(34,211,238,.18); } to { background: transparent; } }

/* ---------- Timeline ---------- */
.timeline { background: var(--panel); border-top: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tl-toolbar { display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-bottom: 1px solid var(--line); }
.zoom { display: flex; align-items: center; gap: 6px; color: var(--muted); width: 180px; }
.tl-body { flex: 1; display: flex; min-height: 0; overflow-y: auto; }
.tl-labels { width: 70px; flex: none; border-right: 1px solid var(--line); padding-top: 26px; }
.tl-labels div { display: flex; align-items: center; padding-left: 10px; color: var(--muted); font-size: 11px; border-bottom: 1px solid #1d1d24; }
.tl-scroll { flex: 1; overflow-x: auto; overflow-y: hidden; position: relative; }
.tl-inner { position: relative; min-height: 100%; }
.ruler { height: 26px; position: relative; border-bottom: 1px solid var(--line); cursor: text; }
.tick {
  position: absolute; top: 0; height: 100%;
  border-left: 1px solid #3a3a45; padding: 3px 0 0 4px;
  font-size: 10px; color: var(--muted); pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.tick.minor { height: 6px; top: auto; bottom: 0; padding: 0; border-color: #2c2c35; }
.ruler .beat { position: absolute; bottom: 0; width: 2px; height: 6px; margin-left: -1px; background: #facc15; opacity: .7; pointer-events: none; }
.ruler .beat.bar { height: 11px; opacity: 1; }
.beat-line { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(250, 204, 21, .28); pointer-events: none; }
.beat-info { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.beat-info .small { padding: 2px 8px; }
.track { position: relative; border-bottom: 1px solid #1d1d24; }
.track-empty { position: absolute; left: 24px; top: 50%; transform: translateY(-50%); color: #55555f; font-size: 12px; pointer-events: none; }
.block {
  position: absolute; top: 4px; bottom: 4px;
  border-radius: 6px; overflow: hidden; cursor: grab;
  border: 1px solid rgba(255,255,255,.12);
  color: #fff; font-size: 11px;
}
.block.clip { background: var(--clip) left center / auto 100% repeat-x; }
.block.overlay { background: #4c3a7a left center / auto 100% repeat-x; }
.block.text { background: var(--textc); }
.block.audio { background: var(--audio) no-repeat; }
.block.selected { outline: 2px solid #fff; outline-offset: -1px; z-index: 2; }
.block.dragging { opacity: .8; z-index: 4; cursor: grabbing; box-shadow: 0 6px 20px rgba(0,0,0,.6); }
.blabel {
  position: absolute; left: 10px; right: 10px; top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0,0,0,.9); pointer-events: none;
}
.blabel b { margin-left: 6px; font-weight: 600; opacity: .8; }
.handle { position: absolute; top: 0; bottom: 0; width: 9px; cursor: ew-resize; z-index: 1; }
.handle.l { left: 0; } .handle.r { right: 0; }
.block:hover .handle { background: rgba(255,255,255,.35); }
.block.selected .handle { background: #fff; }
.tr-badge {
  position: absolute; top: 21px; z-index: 3;
  width: 22px; height: 22px; margin-left: -11px; padding: 0;
  border-radius: 6px; font-size: 12px; line-height: 1;
  background: #0e0e11; border: 1px solid #44444f;
}
.tr-badge.on { background: var(--accent); color: #04141b; border-color: transparent; font-weight: 800; }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; pointer-events: none; z-index: 5; }
.playhead::before {
  content: ""; position: absolute; top: 0; left: -5px;
  border: 6px solid transparent; border-top: 8px solid #fff;
}

/* ---------- Modal + toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; }
.modal[hidden] { display: none; }
.modal-card { width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.modal-card h2 { margin: 0 0 6px; font-size: 18px; }
.progress { height: 8px; background: var(--panel2); border-radius: 4px; overflow: hidden; margin: 14px 0; }
.progress > div { height: 100%; width: 0; background: linear-gradient(90deg, #22d3ee, #a855f7); }
.progress > div.busy { width: 30% !important; animation: busy 1.3s ease-in-out infinite; }
@keyframes busy { from { margin-left: -30%; } to { margin-left: 100%; } }
.modal-card .row { grid-template-columns: 78px minmax(0, 1fr); }
.modal-card .row select { grid-column: 2; }
.modal-card .row.check { grid-template-columns: auto 1fr; }
.modal-card.pm { width: min(880px, calc(100vw - 32px)); max-height: calc(100vh - 64px); display: flex; flex-direction: column; }
.pm-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.pm-head h2 { margin: 0; }
.pm-head button[hidden] { display: none; }
.pm-tabs { display: flex; gap: 4px; background: var(--panel2); padding: 3px; border-radius: 10px; }
.pm-tab { border: none; background: none; font-weight: 700; font-size: 15px; padding: 6px 14px; }
.pm-tab.on { background: var(--panel); color: var(--accent); }
.pm-badge.tpl { background: #a78bfa; }
.pm-none { grid-column: 1 / -1; padding: 40px 10px; text-align: center; }
.replace-btn { margin-top: 8px; }
.pm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; overflow-y: auto; padding: 2px; }
.pm-card { min-width: 0; cursor: pointer; border-radius: 10px; padding: 6px; border: 1px solid transparent; }
.pm-card:hover { background: var(--panel2); }
.pm-card.current { border-color: var(--accent); }
.pm-thumb {
  position: relative; aspect-ratio: 9 / 16; border-radius: 8px;
  background: #23232b center / cover no-repeat; border: 1px solid var(--line);
}
.pm-thumb .dur { position: absolute; bottom: 6px; left: 6px; font-size: 11px; background: rgba(0,0,0,.65); padding: 1px 6px; border-radius: 4px; }
.pm-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.pm-badge { position: absolute; top: 6px; left: 6px; font-size: 10px; font-weight: 700; background: var(--accent); color: #04141b; padding: 2px 6px; border-radius: 4px; }
.pm-name { font-weight: 600; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-actions { display: flex; gap: 4px; margin-top: 6px; opacity: 0; transition: opacity .15s; }
.pm-card:hover .pm-actions, .pm-card:focus-within .pm-actions { opacity: 1; }
.pm-actions button { flex: 1; padding: 3px 0; font-size: 11px; }
.pm-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.add-buttons .wide { grid-column: 1 / -1; }
.sticker-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.sticker-grid button { padding: 4px 0; font-size: 18px; line-height: 1.3; font-family: "Segoe UI Emoji", "Apple Color Emoji", sans-serif; }
.sticker-grid button.shape { font-size: 15px; color: #facc15; font-family: inherit; font-weight: 800; }
.emoji-big { font-size: 28px; font-family: "Segoe UI Emoji", "Apple Color Emoji", sans-serif; }
.fonts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin: 8px 0; max-height: 196px; overflow-y: auto; }
.font-chip { padding: 7px 2px; background: #2a2a33; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.font-chip.on { outline: 2px solid var(--accent); background: #33334a; }
.carousel-card { width: min(1040px, 96vw); max-height: 94vh; display: flex; flex-direction: column; }
.carousel-head { display: flex; align-items: baseline; gap: 12px; }
.carousel-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 14px; }
.carousel-grid { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; padding: 4px 2px 8px; }
.cslide { display: flex; flex-direction: column; gap: 5px; }
.cslide canvas { width: 100%; height: auto; border-radius: 8px; background: #000; }
.cslide textarea, .cslide input { width: 100%; font-size: 12px; resize: vertical; }
.cslide-actions { display: flex; align-items: center; gap: 6px; }
.cslide-actions .danger { margin-left: auto; color: var(--danger); }
.seg { display: inline-flex; }
.seg button { border-radius: 0; padding: 3px 8px; font-size: 11px; }
.seg button:first-child { border-radius: 6px 0 0 6px; }
.seg button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.seg button.on { border-color: var(--accent); color: var(--accent); }
.carousel-bar { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.carousel-bar p { margin: 6px 0; }
#exportModal { z-index: 1000; }
.prompter-card { width: min(1100px, 96vw); height: min(720px, 92vh); display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px; padding: 14px; }
.prompter-stage { position: relative; border-radius: 12px; overflow: hidden; background: #000; }
.prompter-stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.55; }
.prompter-stage video.mirrored { transform: scaleX(-1); }
.prompter-window { position: absolute; inset: 0; overflow: hidden; padding: 14% 7% 0; mask-image: linear-gradient(transparent 4%, #000 14%, #000 70%, transparent 96%); }
.prompter-text { color: #fff; font-family: Inter, sans-serif; font-weight: 700; line-height: 1.35; white-space: pre-wrap; text-shadow: 0 2px 8px rgba(0,0,0,0.8); will-change: transform; }
.prompter-line { position: absolute; left: 0; right: 0; top: 14%; height: 0; border-top: 2px dashed rgba(34,211,238,0.6); pointer-events: none; }
.prompter-count { position: absolute; inset: 0; display: grid; place-items: center; font: 800 160px Montserrat, sans-serif; color: #fff; text-shadow: 0 4px 20px #000; background: rgba(0,0,0,0.3); }
.prompter-count[hidden] { display: none; }
.prompter-side { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow-y: auto; }
.prompter-side textarea { width: 100%; flex: 1; min-height: 140px; resize: none; }
#prompterRecord.recording { background: var(--danger); border-color: var(--danger); color: #fff; }
.cover-card { width: min(820px, 96vw); max-height: 94vh; display: flex; flex-direction: column; }
.cover-body { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 18px; min-height: 0; overflow-y: auto; }
.cover-preview canvas { width: 100%; height: auto; border-radius: 10px; background: #000; }
.cover-picks { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin-bottom: 8px; }
.cover-pick { padding: 2px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; }
.cover-pick canvas { width: 100%; height: auto; border-radius: 4px; }
.cover-pick.on { outline: 2px solid var(--accent); }
.cover-side textarea { width: 100%; }
.ex-formats { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.ex-formats label { display: flex; align-items: center; gap: 5px; font-size: 12px; }
.brand-logo { display: flex; align-items: center; gap: 10px; }
.brand-logo img { height: 44px; max-width: 140px; object-fit: contain; background: repeating-conic-gradient(#2a2a33 0 25%, #1d1d24 0 50%) 0 0 / 12px 12px; border-radius: 6px; padding: 3px; }
.listing-btn { width: 100%; padding: 9px; margin-bottom: 6px; font-weight: 600; background: linear-gradient(135deg, #2a2418, #1d1d24); border-color: #5c4c22; }
.room-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin-bottom: 8px; }
.room-grid button { padding: 5px 2px; font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.listing-card { width: min(560px, 94vw); max-height: 92vh; overflow-y: auto; }
.listing-form { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; }
.listing-form .wide { grid-column: 1 / -1; }
.listing-form input:not([type]), .listing-form input[name]:not([type=color]):not([type=checkbox]) { min-width: 0; width: 100%; }
.listing-parts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 12px; }
.listing-parts label { display: flex; align-items: center; gap: 5px; }
.title-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 8px; }
.title-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px 6px; background: #1d1d24; overflow: hidden; }
.title-card .swatch { font-size: 15px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-card > span:not(.swatch) { font-size: 10px; color: var(--muted); }
.looks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.look { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 2px 3px; background: #2a2a33; }
.look span:not(.swatch) { font-size: 9px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.swatch { font-size: 17px; font-weight: 800; line-height: 1.2; padding: 0 4px; border-radius: 4px; }
.look.on { outline: 2px solid var(--accent); background: #33334a; }
.look-x { position: absolute; top: 0; right: 2px; font-style: normal; font-size: 12px; color: var(--muted); opacity: 0; }
.look:hover .look-x { opacity: 1; }
.look-x:hover { color: var(--danger); }
.sfx-search { width: 100%; margin-bottom: 6px; }
.sfx-group { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 8px 0 4px; }
.sfx-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.sfx-item { display: flex; min-width: 0; }
.sfx-item button { padding: 6px 4px; font-size: 11px; }
.sfx-item > button:first-child { flex: 1; min-width: 0; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 6px 0 0 6px; }
.sfx-play, .sfx-del { flex: none; width: 22px; padding: 0 !important; border-radius: 0 6px 6px 0; border-left: 0; color: var(--muted); }
.sfx-del { border-radius: 0 6px 6px 0; }
.sfx-item:has(.sfx-del) .sfx-play { border-radius: 0; }
.sfx-play:hover { color: var(--accent); }
.sfx-del:hover { color: var(--danger); }
.vo-meter > div { transition: width .06s; background: linear-gradient(90deg, #22c55e, #facc15 70%, #ef4444); }
.toast {
  position: fixed; left: 50%; bottom: 300px; transform: translate(-50%, 20px);
  background: #fff; color: #111; padding: 8px 14px; border-radius: 8px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Media panel: phone button beside Import, editing-copy badge */
.head-btns { display: flex; gap: 6px; }
.proxy-badge { position: absolute; top: 4px; left: 4px; font-size: 10px; font-weight: 700; background: rgba(250,204,21,.92); color: #1a1400; padding: 1px 5px; border-radius: 4px; }

/* Check before posting */
.check-card { width: min(620px, 96vw); max-height: 90vh; display: flex; flex-direction: column; }
.check-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 4px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; background: var(--panel2); border-left: 3px solid transparent; }
.check-row.bad { border-left-color: var(--danger); }
.check-row.warn { border-left-color: #f59e0b; }
.check-row.ok { opacity: .85; }
.check-icon { font-size: 16px; }
.check-text { flex: 1; min-width: 0; }
.check-text b { font-size: 13px; }

/* Post text */
.post-card { width: min(680px, 96vw); max-height: 92vh; display: flex; flex-direction: column; }
.post-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; margin-top: 10px; padding-right: 4px; }
.post-field textarea { width: 100%; resize: vertical; font: 13px/1.45 Inter, system-ui, sans-serif; }
.post-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.post-head b { flex: 1; font-size: 13px; }
.post-head .over { color: var(--danger); font-weight: 700; }
.post-tags { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }

/* Best clips */
.hl-card { width: min(680px, 96vw); max-height: 90vh; display: flex; flex-direction: column; }
.hl-opts { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; font-size: 13px; margin: 6px 0 10px; }
.hl-opts label { display: flex; align-items: center; gap: 6px; }
.hl-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 4px; }
.hl-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; background: var(--panel2); }
.hl-text { flex: 1; min-width: 0; }
.hl-text b { font-size: 13px; }

/* Phone uploads */
.phone-card { width: min(440px, 96vw); text-align: center; }
.phone-card #phoneQr { display: block; margin: 12px auto 8px; border-radius: 10px; background: #fff; }
.phone-url { word-break: break-all; }
.phone-cmd { text-align: left; background: var(--panel2); padding: 10px 12px; border-radius: 8px; font-size: 12px; white-space: pre-wrap; word-break: break-all; user-select: all; }

/* ---------- Left panel: tool tabs ---------- */
.media-panel { display: flex; min-height: 0; background: var(--panel); }
.tool-rail { width: 66px; flex: none; display: flex; flex-direction: column; gap: 2px; padding: 8px 5px; background: var(--bg); border-right: 1px solid var(--line); overflow-y: auto; }
.tool-rail button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 2px; border: 0; background: transparent; color: var(--muted); font-size: 10.5px; line-height: 1.15; border-radius: 8px; text-align: center; }
.tool-rail button b { font-size: 18px; line-height: 1; color: var(--text); opacity: .75; font-family: "Segoe UI Emoji", "Apple Color Emoji", inherit; }
.tool-rail button:hover { background: var(--panel2); color: var(--text); }
.tool-rail button.on { background: var(--panel2); color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.tool-rail button.on b { opacity: 1; }
.tool-panel { flex: 1; min-width: 0; }
.tool-search { width: 100%; margin-bottom: 10px; padding: 8px 10px; border-radius: 8px; }
.tool-pane .panel-head:first-child { margin-top: 0; }
.pane-tip { margin: 10px 2px 0; line-height: 1.45; }
.tool { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; padding: 9px 10px; margin-bottom: 6px; }
.tool > b { font-size: 18px; width: 24px; text-align: center; flex: none; font-family: "Segoe UI Emoji", "Apple Color Emoji", inherit; }
.tool > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tool > span b { font-size: 13px; }
.tool > span small { color: var(--muted); font-size: 11px; line-height: 1.3; }
.tool.estate { background: linear-gradient(135deg, #2a2418, #1d1d24); border-color: #5c4c22; }
.tool-panel.searching .tool-pane { display: block !important; }
.tool-panel.searching .tool-pane > :not(.tool) { display: none; }
.tool-panel.searching .tool.nomatch { display: none; }
.tool-pane[hidden] { display: none; }

/* ---------- Top bar: Finish menu, help ---------- */
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 900; width: 320px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 16px 40px rgba(0,0,0,.5); }
.menu-item { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; border: 0; background: transparent; padding: 9px 10px; border-radius: 8px; }
.menu-item:hover { background: var(--panel2); }
.menu-item > b { font-size: 18px; width: 24px; text-align: center; font-family: "Segoe UI Emoji", "Apple Color Emoji", inherit; }
.menu-item > span { display: flex; flex-direction: column; gap: 2px; }
.menu-item small { color: var(--muted); font-size: 11px; }
#helpBtn { font-weight: 800; }

/* ---------- Format bar: more settings ---------- */
.fmt-more { display: contents; }
.fmt-more[hidden] { display: none; }

/* ---------- Timeline toolbar groups ---------- */
.tl-divider { width: 1px; align-self: stretch; background: var(--line); margin: 2px 4px; }
.tl-group-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.tl-toolbar button:disabled { opacity: .4; }
.tl-hint { white-space: nowrap; }
@media (max-width: 1350px) { .tl-hint { display: none; } }

/* ---------- Getting started (right panel, nothing selected) ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.step { display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); }
.step.next { border-color: var(--accent); }
.step.done { opacity: .6; }
.step-num { width: 22px; height: 22px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: var(--line); }
.step.next .step-num { background: var(--accent); color: #04141b; }
.step.done .step-num { background: #16a34a; color: #fff; }
.step-body { flex: 1; min-width: 0; }
.step-body b { font-size: 13px; }
.step-body .muted { margin-top: 2px; }
.step-body button { margin-top: 7px; }
details.more summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---------- Welcome, help and tour ---------- */
.welcome-card { width: min(520px, 94vw); text-align: left; }
.welcome-logo { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--accent); color: #04141b; font-size: 22px; margin-bottom: 10px; }
.welcome-steps { margin: 16px 0 6px; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.welcome-steps li b { display: block; }
.welcome-steps li span { color: var(--muted); font-size: 13px; }
.help-card { width: min(560px, 94vw); max-height: 90vh; overflow-y: auto; }
.help-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.help-list { padding-left: 18px; line-height: 1.5; font-size: 13px; }
.tour { position: fixed; inset: 0; z-index: 2000; }
.tour-spot { position: fixed; border-radius: 12px; box-shadow: 0 0 0 9999px rgba(0,0,0,.62); outline: 2px solid var(--accent); transition: all .25s ease; pointer-events: none; }
.tour-bubble { position: fixed; width: 320px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: 0 16px 40px rgba(0,0,0,.55); transition: all .25s ease; }
.tour-bubble h3 { margin: 4px 0 6px; font-size: 16px; }
.tour-bubble p { margin: 0 0 12px; font-size: 13px; line-height: 1.5; color: var(--text); }
.tour-actions { display: flex; gap: 6px; align-items: center; }

/* Smaller laptop screens: a narrower tool panel leaves the preview more room. */
@media (max-width: 1400px) {
  .workspace { grid-template-columns: 290px minmax(0, 1fr) 290px; }
  .tool > span small { font-size: 10.5px; }
}

/* Jump chips at the top of a clip's settings: what's further down, one click away. */
.jump-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 4px; }
.jump-chips button { padding: 3px 8px; font-size: 11px; border-radius: 999px; }

/* Keyboard users can always see where they are (mouse clicks don't show the ring). */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fmt:has(select:focus-visible) { box-shadow: 0 0 0 2px var(--accent); }

/* People who've asked their system for less motion get instant transitions (the video itself still plays). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- My AI clone ---------- */
.clone-card { width: min(640px, 96vw); max-height: 92vh; overflow-y: auto; }
.clone-step { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.clone-step h4 { margin: 0 0 4px; }
.clone-ok { color: #4ade80; font-size: 12px; margin-left: 6px; }
.clone-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.clone-face { display: flex; gap: 10px; align-items: center; }
.clone-face img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; background: var(--panel2); flex: none; }
.clone-face img:not([src]), .clone-face img[src=""] { visibility: hidden; }
#cloneScript { width: 100%; resize: vertical; font: 13px/1.45 Inter, system-ui, sans-serif; }
.clone-make { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 4px 0 14px; font-size: 13px; }
.clone-make label { display: flex; gap: 6px; align-items: center; }
.clone-jobs { display: flex; flex-direction: column; gap: 6px; }
.clone-job { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; background: var(--panel2); }
.clone-job-text { flex: 1; min-width: 0; }
.clone-job-text b { font-size: 13px; }
.clone-job.failed .muted { color: var(--danger); }
.clone-job .progress { margin-top: 6px; }
.clone-credit { margin-top: 12px; }

/* ---------- Phones ----------
   The video on top, the timeline under it and the tool groups as a tab bar along the bottom. Tools and
   settings slide up as sheets over the timeline (body.sheet-tools / body.sheet-inspector). */
.phone-only, .tool-rail .phone-only { display: none; }
@media (pointer: coarse) {
  .handle { width: 16px; }
  .block.selected, .handle, .ruler { touch-action: none; } /* a selected item drags; anything else lets the finger scroll */
}
@media (max-width: 760px) {
  body {
    height: 100dvh;
    grid-template-rows: 46px minmax(0, 1fr) clamp(150px, 30dvh, 230px);
    padding-bottom: calc(56px + env(safe-area-inset-bottom));
  }
  .topbar { gap: 6px; padding: 0 8px; padding-top: env(safe-area-inset-top); }
  .brand { font-size: 0; gap: 0; }
  #saveStatus, .tl-hint, .tl-group-label, .tl-divider, .fmt-badge, [data-act="phone"] { display: none !important; }
  #projectName { width: auto; flex: 1; min-width: 56px; padding: 4px 6px; }
  .topbar button, .format-bar .fmt, .tl-toolbar button { white-space: nowrap; }
  #helpBtn { display: none; }
  .topbar .spacer { display: none; }
  .topbar > button.small, #finishBtn { padding: 6px 8px; }
  .icon-btn { width: 30px; }

  .workspace { display: block; position: relative; }
  .media-panel { display: contents; }
  .stage { height: 100%; padding: 6px 8px 2px; }
  .format-bar { gap: 4px; overflow-x: auto; flex-wrap: nowrap; }
  .fmt-more { position: absolute; z-index: 30; }
  .transport { padding: 2px 0; }

  .tool-rail {
    position: fixed; z-index: 45; left: 0; right: 0; bottom: 0;
    width: auto; height: calc(56px + env(safe-area-inset-bottom)); padding: 4px 4px env(safe-area-inset-bottom);
    flex-direction: row; gap: 0; overflow-x: auto; overflow-y: hidden;
    border-right: 0; border-top: 1px solid var(--line);
  }
  .tool-rail button { flex: 1 0 44px; padding: 4px 1px; font-size: 9.5px; }
  .tool-rail button b { font-size: 17px; }
  .tool-rail button.on { box-shadow: inset 0 3px 0 var(--accent); }
  body:not(.sheet-tools) .tool-rail button.on { color: var(--muted); background: transparent; box-shadow: none; }
  .tool-rail .phone-only { display: flex; }
  #editTab.has-sel b { color: var(--accent); opacity: 1; }

  .tool-panel, .inspector {
    position: fixed; z-index: 40; left: 0; right: 0; bottom: calc(56px + env(safe-area-inset-bottom));
    height: min(62dvh, 560px); border: 0; border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0; box-shadow: 0 -12px 40px rgba(0,0,0,.5);
    transform: translateY(calc(100% + 70px)); transition: transform .22s ease; padding-top: 44px;
  }
  body.sheet-tools .tool-panel, body.sheet-inspector .inspector { transform: none; }
  .sheet-close {
    position: fixed; z-index: 41; right: 10px; bottom: calc(56px + env(safe-area-inset-bottom) + min(62dvh, 560px) - 40px);
    display: none; padding: 6px 14px; border-radius: 999px;
  }
  body.sheet-tools .sheet-close, body.sheet-inspector .sheet-close { display: block; }

  .tl-toolbar { overflow-x: auto; flex-wrap: nowrap; padding: 5px 8px; }
  .tl-toolbar button { white-space: nowrap; flex: none; }
  .tl-toolbar .zoom input { width: 70px; }
  .tl-labels { width: 44px; font-size: 10px; }
  .tl-labels div { padding-left: 4px; overflow: hidden; }

  .modal-card, .modal-card.pm { width: calc(100vw - 16px) !important; max-height: calc(100dvh - 16px); overflow-y: auto; padding: 16px; }
  .prompter-card, .cover-body { grid-template-columns: minmax(0, 1fr) !important; }
  .modal-card select, .modal-card input:not([type=checkbox]):not([type=radio]):not([type=color]) { max-width: 100%; min-width: 0; }
  .menu { position: fixed; left: 8px; right: 8px; top: 50px; width: auto; }
  .carousel-form, .listing-form { grid-template-columns: minmax(0, 1fr) 1fr; }
  .toast { left: 8px; right: 8px; bottom: calc(66px + env(safe-area-inset-bottom)); max-width: none; transform: translate(0, 8px); }
  .toast.show { transform: none; }
}
