/* GREY VIDS — Monochrome Studio design system */
:root {
  --bg: #0a0a0a;
  --surface: #131313;
  --surface-lo: #0e0e0e;
  --panel: #141414;
  --panel-2: #1a1a1a;
  --panel-3: #1f1f1f;
  --panel-4: #2a2a2a;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --line-3: rgba(255, 255, 255, 0.24);
  --fg: #e5e2e1;
  --fg-hi: #ffffff;
  --muted: #8e9192;
  --muted-2: #737373;
  --faint: #525252;
  --inv-bg: #e5e2e1;
  --inv-fg: #0a0a0a;
  --danger: #ffb4ab;
  --ok: #b7f5c8;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  --sans: "Inter", -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", Menlo, monospace;
  --deck-w: 248px;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #ffffff;
  --surface: #fafafa;
  --surface-lo: #f5f5f5;
  --panel: #f5f5f5;
  --panel-2: #efefef;
  --panel-3: #e9e9e9;
  --panel-4: #dedede;
  --line: rgba(0, 0, 0, 0.08);
  --line-2: rgba(0, 0, 0, 0.14);
  --line-3: rgba(0, 0, 0, 0.26);
  --fg: #1c1b1b;
  --fg-hi: #000000;
  --muted: #5f6061;
  --muted-2: #737373;
  --faint: #a3a3a3;
  --inv-bg: #0a0a0a;
  --inv-fg: #ffffff;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 400 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
body { overscroll-behavior: none; }
::selection { background: var(--fg); color: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--panel-4); }
::-webkit-scrollbar-track { background: transparent; }

.ms { font-family: "Material Symbols Outlined"; font-weight: 400; font-style: normal; font-size: 18px; line-height: 1; letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap; direction: ltr; -webkit-font-feature-settings: "liga"; font-feature-settings: "liga"; -webkit-font-smoothing: antialiased; user-select: none; }
.ms.sm { font-size: 15px; }
.ms.lg { font-size: 22px; }
.ms.fill { font-variation-settings: "FILL" 1; }

.mono { font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.mono-xs { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 0.06em; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.hi { color: var(--fg-hi); }
.upper { text-transform: uppercase; }
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.gap-xs { gap: 4px; } .gap-sm { gap: 8px; } .gap-md { gap: 12px; } .gap-lg { gap: 20px; } .gap-xl { gap: 32px; }
.mt-sm { margin-top: 8px; } .mt-md { margin-top: 12px; } .mt-lg { margin-top: 20px; } .mt-xl { margin-top: 32px; }
.sup { font-size: 12px; font-weight: 500; vertical-align: super; margin-left: 2px; color: var(--muted); letter-spacing: 0; }
.h-display { font-size: clamp(2.2rem, 4vw, 4.5rem); font-weight: 600; letter-spacing: -0.04em; line-height: 1; margin: 0; }
.h-lg { font-size: 2.25rem; font-weight: 500; letter-spacing: -0.03em; line-height: 1.15; margin: 0; }
.h-md { font-size: 1.5rem; font-weight: 500; letter-spacing: -0.02em; line-height: 1.25; margin: 0; }
.h-sm { font-size: 1.05rem; font-weight: 500; letter-spacing: -0.01em; margin: 0; }
.deg { display: inline-block; width: 0.28em; height: 0.28em; border: 0.07em solid currentColor; border-radius: 50%; vertical-align: 0.9em; margin-left: 0.08em; opacity: 0.8; }

/* ------------------------------------------------------------------ shell */
#app { display: flex; min-height: 100vh; }
.deck { position: fixed; inset: 0 auto 0 0; width: var(--deck-w); background: var(--surface-lo); border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 60; }
.deck-head { height: 56px; display: flex; align-items: center; gap: 8px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.live { background: var(--panel-4); color: var(--fg-hi); padding: 1px 5px; }
.deck-nav { display: flex; flex-direction: column; gap: 2px; padding: 12px 10px; }
.deck-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; color: var(--muted); border-left: 2px solid transparent; font-size: 14.5px; transition: background 0.12s, color 0.12s; }
.deck-nav a:hover { background: var(--panel-2); color: var(--fg); }
.deck-nav a.active { background: var(--panel-3); color: var(--fg-hi); border-left-color: var(--fg-hi); }
.deck-foot { margin-top: auto; padding: 16px 20px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--fg-hi); margin-right: 6px; vertical-align: 1px; }
.dot.off { background: var(--faint); }
.dot.busy { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

.main-col { margin-left: var(--deck-w); flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 50; height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); gap: 12px; }
.brand { color: var(--fg-hi); display: flex; align-items: center; }
.brand svg { display: block; }
.sep-left { border-left: 1px solid var(--line-2); padding-left: 16px; color: var(--muted); }
.project-chip { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--surface-lo); padding: 3px 8px; }
.project-chip input { background: none; border: 0; outline: 0; font: inherit; color: var(--fg-hi); width: 22ch; text-transform: uppercase; }
.save-state { min-width: 50px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--fg); color: var(--bg); display: grid; place-items: center; }
.theme-toggle { display: flex; align-items: center; border: 1px solid var(--line-2); border-radius: 999px; padding: 2px; gap: 2px; }
.theme-toggle .ms { width: 22px; height: 22px; display: grid; place-items: center; font-size: 14px; border-radius: 50%; color: var(--muted); }
[data-theme="dark"] .theme-toggle .ms:first-child, [data-theme="light"] .theme-toggle .ms:last-child { background: var(--panel-4); color: var(--fg-hi); }
.link:hover { color: var(--fg-hi); }

.stepper { height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-bottom: 1px solid var(--line); }
.steps { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; color: var(--faint); overflow-x: auto; white-space: nowrap; }
.steps a { display: flex; align-items: center; gap: 8px; padding: 6px 10px; color: var(--faint); }
.steps a i { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--line-3); display: inline-block; }
.steps a.done { color: var(--muted); }
.steps a.done i { background: var(--panel-4); border-color: var(--panel-4); position: relative; }
.steps a.done i::after { content: ""; position: absolute; inset: 0; font-size: 9px; line-height: 13px; text-align: center; color: var(--fg); }
.steps a.active { background: var(--panel-3); color: var(--fg-hi); }
.steps a.active i { width: 6px; height: 6px; background: var(--fg-hi); border: 0; }
#dur-chip { color: var(--fg-hi); padding: 0 8px; }
#view { flex: 1; min-height: 0; }

/* ------------------------------------------------------------ primitives */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 18px; border: 1px solid var(--line-2); color: var(--fg-hi); font-weight: 500; white-space: nowrap; transition: background 0.1s, opacity 0.1s, border-color 0.1s; }
.btn:hover { border-color: var(--line-3); background: var(--panel-2); }
.btn.primary { background: var(--inv-bg); color: var(--inv-fg); border-color: var(--inv-bg); font-weight: 600; }
.btn.primary:hover { opacity: 0.9; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.xs { height: 24px; padding: 0 8px; font-size: 12px; gap: 4px; }
.btn.lg { height: 52px; padding: 0 24px; font-size: 16px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; color: var(--muted); border: 1px solid transparent; }
.icon-btn:hover { color: var(--fg-hi); background: var(--panel-3); }
.icon-btn.boxed { border-color: var(--line-2); background: var(--panel-2); }
.icon-btn.on { color: var(--fg-hi); background: var(--panel-4); }
.icon-btn:disabled { opacity: 0.35; pointer-events: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; background: var(--panel-2); border: 1px solid var(--line); color: var(--fg); font-family: var(--mono); font-size: 12px; white-space: nowrap; }
button.chip:hover { border-color: var(--line-3); color: var(--fg-hi); }
.chip.on { background: var(--inv-bg); color: var(--inv-fg); border-color: var(--inv-bg); }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; background: rgba(10, 10, 10, 0.78); color: #f1f1f1; font-family: var(--mono); font-size: 11.5px; backdrop-filter: blur(6px); letter-spacing: 0.02em; }
.badge { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; padding: 2px 8px; background: var(--panel-3); color: var(--fg-hi); }

.seg { display: inline-flex; border: 1px solid var(--line-2); background: var(--panel-2); padding: 2px; gap: 2px; }
.seg button { font-family: var(--mono); font-size: 12px; padding: 5px 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.seg button:hover { color: var(--fg-hi); }
.seg button.on { background: var(--inv-bg); color: var(--inv-fg); font-weight: 600; }
.ar { display: inline-block; border: 1.4px solid currentColor; border-radius: 1px; }
.ar.r916 { width: 7px; height: 12px; } .ar.r45 { width: 9px; height: 11px; } .ar.r11 { width: 10px; height: 10px; } .ar.r169 { width: 13px; height: 8px; }
.seg button.on .ar { background: currentColor; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .lbl { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; }
.input, .select, .textarea { width: 100%; background: var(--surface-lo); border: 1px solid var(--line-2); color: var(--fg-hi); padding: 8px 10px; outline: none; border-radius: 0; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--fg-hi); }
.input.sm, .select.sm { padding: 5px 8px; font-size: 13px; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 14px) 55%, calc(100% - 9px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 26px; }
.bare { background: none; border: 0; outline: none; color: inherit; width: 100%; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 16px; background: transparent; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; background: var(--panel-4); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--fg-hi); margin-top: -6.5px; border: 0; }
input[type="color"] { -webkit-appearance: none; width: 28px; height: 28px; border: 1px solid var(--line-2); padding: 0; background: none; cursor: pointer; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch { border: 0; }

.panel { background: var(--panel); border: 1px solid var(--line); }
.hair-grid { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.hair-grid > * { background: var(--surface); }
.divider { height: 1px; background: var(--line); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.kbd { font-family: var(--mono); font-size: 10.5px; padding: 1px 5px; border: 1px solid var(--line-2); color: var(--muted); }
.spin { animation: spin 0.9s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 4px; background: var(--panel-4); position: relative; overflow: hidden; }
.progress > i { position: absolute; inset: 0 auto 0 0; background: var(--fg-hi); transition: width 0.3s; }
.progress.indet > i { width: 30% !important; animation: indet 1.2s infinite ease-in-out; }
@keyframes indet { from { left: -30%; } to { left: 100%; } }

#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--panel-2); border: 1px solid var(--line-2); box-shadow: var(--shadow); padding: 10px 14px; min-width: 260px; max-width: 420px; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; animation: toastIn 0.18s ease-out; }
.toast.err { border-color: rgba(255, 180, 171, 0.5); }
.toast.err .ms { color: var(--danger); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }

.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 150; display: grid; place-items: center; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--line-2); box-shadow: var(--shadow); width: min(560px, 100%); max-height: 90vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

/* -------------------------------------------------------- composition bits */
.gv-frame { position: relative; overflow: hidden; background: #000; container-type: size; }
.gv-frame .gv-root { position: absolute; inset: 0; }
.thumb { position: relative; overflow: hidden; background: #111; }
.thumb .gv-root { pointer-events: none; }
@keyframes gvIn { from { opacity: 0; transform: translateY(calc(var(--u) * 40)); } }
.thumb.playing .el-in { animation: gvIn 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both; animation-delay: var(--d, 0s); }

/* ---------------------------------------------------------------- views */
.page { padding: 32px; max-width: 1680px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 32px; }

/* Templates / concept */
.prompt-box { border: 1px solid var(--line); background: var(--surface); padding: 24px 28px; }
.prompt-box textarea { width: 100%; background: none; border: 0; outline: 0; resize: none; font-size: 1.25rem; line-height: 1.5; color: var(--fg-hi); min-height: 72px; letter-spacing: -0.01em; }
.prompt-box textarea::placeholder { color: var(--faint); }
.source-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--panel-2); padding: 12px 16px; margin-top: 16px; }
.source-bar .src-input { display: flex; align-items: center; gap: 8px; background: var(--surface-lo); padding: 6px 10px; min-width: 260px; flex: 0 1 340px; font-family: var(--mono); font-size: 12.5px; border: 1px solid var(--line); }
.source-bar .src-input input { background: none; border: 0; outline: 0; width: 100%; color: var(--fg-hi); font: inherit; }
.src-card { display: flex; gap: 12px; align-items: flex-start; padding: 12px; background: var(--surface-lo); border: 1px solid var(--line); margin-top: 12px; }
.src-card img { width: 56px; height: 56px; object-fit: cover; }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.tpl-card { border: 1px solid var(--line); background: var(--surface); padding: 12px; cursor: pointer; transition: border-color 0.12s; position: relative; }
.tpl-card:hover { border-color: var(--line-3); }
.tpl-card.sel { border-color: var(--fg-hi); box-shadow: inset 0 0 0 1px var(--fg-hi); }
.tpl-card .thumb { aspect-ratio: 9 / 16; }
.tpl-card.land .thumb { aspect-ratio: 16 / 9; }
.tpl-card .tl { position: absolute; left: 14px; top: 14px; }
.tpl-card .bl { position: absolute; left: 14px; bottom: 14px; display: flex; gap: 6px; }
.tpl-card .br { position: absolute; right: 12px; bottom: 12px; width: 34px; height: 34px; border-radius: 50%; background: rgba(10, 10, 10, 0.8); color: #fff; display: grid; place-items: center; }
.tpl-card .meta { padding: 14px 4px 4px; }
.tpl-list .tpl-card { display: grid; grid-template-columns: 120px 1fr; gap: 16px; align-items: center; }
.tpl-list { grid-template-columns: 1fr; }
.tpl-list .tpl-card .overlay-tags { display: none; }

.tabs-text { display: flex; gap: 20px; }
.tabs-text button { color: var(--muted-2); font-size: 15px; }
.tabs-text button.on, .tabs-text button:hover { color: var(--fg-hi); }

.recent-row { display: grid; grid-auto-flow: column; grid-auto-columns: 160px; gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.recent { border: 1px solid var(--line); background: var(--surface); padding: 8px; cursor: pointer; }
.recent:hover { border-color: var(--line-3); }
.recent .thumb { aspect-ratio: 9/16; }

/* Script & voice */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 440px; min-height: calc(100vh - 104px); }
.split > .left { padding: 28px 32px; border-right: 1px solid var(--line); min-width: 0; }
.split > .right { padding: 28px 28px; position: sticky; top: 104px; height: calc(100vh - 104px); overflow-y: auto; }
.script-head { background: var(--surface); padding: 20px 24px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.scene-card { background: var(--surface); margin-bottom: 20px; border: 1px solid transparent; }
.scene-card.sel { border-color: var(--line-3); }
.scene-card .sc-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; border-bottom: 1px solid var(--line); gap: 10px; }
.scene-card .sc-body { display: grid; grid-template-columns: var(--thumb-w, 180px) 1fr; gap: 24px; padding: 20px 24px; }
.scene-card .sc-thumb { position: relative; cursor: pointer; align-self: start; }
.scene-card .sc-thumb .letter { position: absolute; right: 0; bottom: 0; background: rgba(10,10,10,0.85); color: #fff; font-family: var(--mono); font-size: 12px; padding: 2px 7px; }
.narr { font-size: 1.12rem; line-height: 1.6; color: var(--fg-hi); background: none; border: 0; outline: 0; resize: none; width: 100%; padding: 0; min-height: 60px; overflow: hidden; }
.narr:focus { box-shadow: 0 1px 0 var(--line-3); }
.sc-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 10px; flex-wrap: wrap; }
.onscreen { margin-top: 14px; border-top: 1px dashed var(--line-2); padding-top: 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.onscreen .full { grid-column: 1 / -1; }
.onscreen .input { font-size: 13px; padding: 6px 8px; }

.voice-list { display: flex; flex-direction: column; gap: 6px; max-height: 676px; overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; scrollbar-gutter: stable; }
.voice-item { flex: none; display: flex; align-items: center; gap: 14px; padding: 9px 14px; background: var(--panel-2); border: 1px solid transparent; cursor: pointer; }
.voice-item:hover { border-color: var(--line-2); }
.voice-item.sel { background: var(--panel-3); border-color: var(--line-3); }
.play-circle { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-4); color: var(--fg-hi); flex: none; }
.voice-item.sel .play-circle { background: var(--inv-bg); color: var(--inv-fg); }
.take { background: var(--panel-2); padding: 20px; margin-top: 20px; }
.wave { height: 72px; background: var(--surface-lo); display: flex; align-items: center; gap: 3px; padding: 0 16px; position: relative; overflow: hidden; }
.wave i { flex: 1; background: var(--fg); min-height: 3px; max-width: 4px; opacity: 0.9; }
.wave i.past { opacity: 0.35; }
.wave .ph { position: absolute; top: 6px; bottom: 6px; width: 1px; background: var(--fg-hi); }
.wave .ph::before { content: ""; position: absolute; top: -4px; left: -4px; border: 4px solid transparent; border-top-color: var(--fg-hi); }
.style-chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 4px; }
.style-chips button { font-family: var(--mono); font-size: 12px; padding: 9px 6px; background: var(--surface-lo); color: var(--muted); }
.style-chips button.on { background: var(--inv-bg); color: var(--inv-fg); }
.music-row { display: flex; align-items: center; gap: 12px; padding: 16px; background: var(--panel-2); margin-top: 20px; }
.engine-tabs { display: flex; border-bottom: 1px solid var(--line); margin: 16px 0 12px; gap: 18px; }
.engine-tabs button { padding: 8px 0; font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; color: var(--muted); border-bottom: 1px solid transparent; margin-bottom: -1px; }
.engine-tabs button.on { color: var(--fg-hi); border-bottom-color: var(--fg-hi); }
.notice { padding: 10px 12px; border: 1px dashed var(--line-3); color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.notice code { font-family: var(--mono); font-size: 11.5px; color: var(--fg-hi); background: var(--surface-lo); padding: 1px 4px; }

/* Live editor */
.editor { display: grid; grid-template-columns: 230px minmax(0, 1fr) 300px; grid-template-rows: minmax(0, 1fr) 214px; height: calc(100vh - 104px); }
.ed-left { grid-row: 1 / 2; grid-column: 1; border-right: 1px solid var(--line); overflow-y: auto; background: var(--surface-lo); }
.ed-right { grid-row: 1 / 2; grid-column: 3; border-left: 1px solid var(--line); overflow-y: auto; background: var(--surface-lo); }
.ed-center { grid-row: 1 / 2; grid-column: 2; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ed-toolbar { height: 46px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; border-bottom: 1px solid var(--line); gap: 8px; overflow-x: auto; }
.ed-stage-wrap { flex: 1; min-height: 0; display: grid; place-items: center; position: relative; background: repeating-conic-gradient(var(--surface) 0% 25%, var(--surface-lo) 0% 50%) 50% / 24px 24px; overflow: hidden; }
.ed-stage { position: relative; box-shadow: 0 0 0 1px var(--line-2), 0 20px 60px rgba(0,0,0,0.5); }
.ed-stage .el { cursor: move; }
.ed-stage .el:hover { outline: 1px dashed rgba(255,255,255,0.45); outline-offset: 1px; }
.ed-stage .el.editing { cursor: text; outline: 1px solid #fff; }
.ed-stage .el.editing .el-in { user-select: text; -webkit-user-select: text; outline: none; }
.sel-box { position: absolute; border: 1px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.6); pointer-events: none; z-index: 20; }
.sel-box .h { position: absolute; width: 9px; height: 9px; background: #fff; border: 1px solid #000; pointer-events: auto; }
.sel-box .h.nw { left: -5px; top: -5px; cursor: nwse-resize; } .sel-box .h.ne { right: -5px; top: -5px; cursor: nesw-resize; }
.sel-box .h.sw { left: -5px; bottom: -5px; cursor: nesw-resize; } .sel-box .h.se { right: -5px; bottom: -5px; cursor: nwse-resize; }
.sel-box .h.e { right: -5px; top: calc(50% - 5px); cursor: ew-resize; } .sel-box .h.w { left: -5px; top: calc(50% - 5px); cursor: ew-resize; }
.sel-box .h.n { top: -5px; left: calc(50% - 5px); cursor: ns-resize; } .sel-box .h.s { bottom: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.sel-box .h.rot { top: -28px; left: calc(50% - 6px); width: 12px; height: 12px; border-radius: 50%; cursor: grab; }
.sel-box .dim { position: absolute; left: 0; top: calc(100% + 6px); background: #fff; color: #000; font-family: var(--mono); font-size: 10.5px; padding: 1px 5px; white-space: nowrap; }
.guide { position: absolute; background: #4fd6ff; z-index: 19; pointer-events: none; }
.guide.v { width: 1px; top: 0; bottom: 0; } .guide.h { height: 1px; left: 0; right: 0; }
.stage-hud { position: absolute; left: 12px; top: 12px; display: flex; gap: 6px; z-index: 5; }
.stage-hud-r { position: absolute; right: 12px; top: 12px; display: flex; gap: 6px; z-index: 5; }
.player-host { position: relative; }
.player-host hyperframes-player { display: block; width: 100%; height: 100%; }

.ed-section { border-bottom: 1px solid var(--line); padding: 14px; }
.ed-section h4 { margin: 0 0 10px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; color: var(--muted); font-weight: 500; text-transform: uppercase; display: flex; justify-content: space-between; align-items: center; }
.scene-strip { display: flex; flex-direction: column; gap: 8px; }
.scene-mini { display: grid; grid-template-columns: 22px 64px 1fr; gap: 8px; align-items: center; padding: 6px; border: 1px solid transparent; cursor: pointer; }
.scene-mini:hover { background: var(--panel-2); }
.scene-mini.sel { border-color: var(--line-3); background: var(--panel-3); }
.scene-mini.drag-over { border-top: 2px solid var(--fg-hi); }
.layer { display: flex; align-items: center; gap: 8px; padding: 5px 6px; font-size: 12.5px; cursor: pointer; color: var(--muted); }
.layer:hover { background: var(--panel-2); color: var(--fg); }
.layer.sel { background: var(--panel-3); color: var(--fg-hi); }
.layer .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer .icon-btn { width: 22px; height: 22px; }
.props { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.props .full { grid-column: 1 / -1; }
.num { display: flex; align-items: center; border: 1px solid var(--line-2); background: var(--surface); }
.num span { font-family: var(--mono); font-size: 10.5px; color: var(--muted); padding: 0 6px; }
.num input { width: 100%; background: none; border: 0; outline: 0; padding: 5px 6px 5px 0; font-family: var(--mono); font-size: 12px; color: var(--fg-hi); }
.swatches { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.sw { width: 22px; height: 22px; border: 1px solid var(--line-2); cursor: pointer; position: relative; }
.sw.on { outline: 1px solid var(--fg-hi); outline-offset: 2px; }
.sw.none { background: linear-gradient(135deg, transparent 45%, var(--danger) 45% 55%, transparent 55%); }
.align-btns { display: flex; }
.align-btns button { flex: 1; height: 28px; display: grid; place-items: center; border: 1px solid var(--line-2); margin-left: -1px; color: var(--muted); }
.align-btns button.on { background: var(--inv-bg); color: var(--inv-fg); }

.dock { grid-column: 1 / -1; border-top: 1px solid var(--line); background: var(--surface-lo); display: flex; flex-direction: column; min-height: 0; }
.dock-bar { height: 40px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.timecode { font-family: var(--mono); font-size: 13px; color: var(--fg-hi); background: var(--surface); padding: 3px 8px; font-variant-numeric: tabular-nums; }
.tracks { flex: 1; overflow: auto; position: relative; }
.tracks-inner { position: relative; min-width: 100%; }
.ruler { height: 22px; position: sticky; top: 0; background: var(--surface-lo); z-index: 3; border-bottom: 1px solid var(--line); cursor: pointer; margin-left: 76px; }
.ruler .tick { position: absolute; top: 0; height: 100%; border-left: 1px solid var(--line-2); font-family: var(--mono); font-size: 9.5px; color: var(--faint); padding-left: 3px; line-height: 20px; }
.track { display: flex; height: 38px; border-bottom: 1px solid var(--line); }
.track .tlabel { width: 76px; flex: none; font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: 0.06em; display: flex; align-items: center; padding-left: 12px; position: sticky; left: 0; background: var(--surface-lo); z-index: 2; border-right: 1px solid var(--line); }
.track .lane { position: relative; flex: 1; }
.clipb { position: absolute; top: 4px; bottom: 4px; background: var(--panel-3); border: 1px solid var(--line-2); overflow: hidden; cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 0 8px; font-size: 11.5px; color: var(--fg); white-space: nowrap; }
.clipb.sel { border-color: var(--fg-hi); background: var(--panel-4); }
.clipb .grip { position: absolute; right: 0; top: 0; bottom: 0; width: 7px; cursor: ew-resize; background: linear-gradient(90deg, transparent 2px, var(--line-3) 2px 3px, transparent 3px 5px, var(--line-3) 5px 6px, transparent 6px); }
.clipb.vo { background: color-mix(in srgb, var(--panel-3) 70%, #4a4a4a); padding: 0 4px; gap: 1px; align-items: center; }
.clipb.vo i { flex: 1; background: var(--fg); opacity: 0.6; min-height: 2px; }
.clipb.cap { font-family: var(--mono); font-size: 9.5px; padding: 0 4px; color: var(--muted); }
.clipb.el { background: var(--panel-2); font-size: 10.5px; }
.clipb.music { background: repeating-linear-gradient(90deg, var(--panel-3) 0 6px, var(--panel-2) 6px 12px); color: var(--muted); font-family: var(--mono); font-size: 10.5px; }
.playhead { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--fg-hi); z-index: 4; pointer-events: none; }
.playhead::before { content: ""; position: absolute; top: 0; left: -5px; border: 5px solid transparent; border-top: 7px solid var(--fg-hi); }

/* Export */
.export { display: grid; grid-template-columns: minmax(0, 1fr) 460px; min-height: calc(100vh - 104px); }
.ex-stage { padding: 28px 40px; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.ex-top { display: flex; justify-content: space-between; align-items: center; padding-bottom: 20px; border-bottom: 1px solid var(--line); gap: 12px; flex-wrap: wrap; }
.ex-view { flex: 1; display: grid; place-items: center; padding: 28px 0; min-height: 420px; }
.ex-frame { position: relative; box-shadow: 0 30px 80px rgba(0,0,0,0.55); border: 1px solid var(--line-2); background: #000; }
.ex-frame .hud { position: absolute; top: 14px; left: 14px; right: 14px; display: flex; justify-content: space-between; pointer-events: none; z-index: 3; }
.ex-controls { background: var(--surface); border: 1px solid var(--line); padding: 14px 18px; }
.ex-controls .bar { height: 6px; background: var(--panel-4); cursor: pointer; position: relative; margin-top: 12px; }
.ex-controls .bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--fg); }
.play-sq { width: 42px; height: 42px; display: grid; place-items: center; background: var(--inv-bg); color: var(--inv-fg); }
.scene-chips { display: flex; gap: 2px; flex-wrap: wrap; }
.scene-chips button { font-family: var(--mono); font-size: 12px; padding: 5px 9px; color: var(--muted); }
.scene-chips button.on { background: var(--inv-bg); color: var(--inv-fg); }
.ex-side { padding: 32px 36px; display: flex; flex-direction: column; gap: 26px; }
.kv { background: var(--surface); border: 1px solid var(--line); padding: 14px 18px; }
.kv .v { font-family: var(--mono); font-size: 14px; color: var(--fg-hi); margin-top: 4px; }
.deliver { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.deliver button { background: var(--surface); border: 1px solid var(--line); height: 104px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; font-family: var(--mono); font-size: 12px; color: var(--fg); text-align: center; padding: 6px; }
.deliver button:hover { border-color: var(--line-3); }
.deliver button.on { border-color: var(--fg-hi); }
.dest { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.dest button { background: var(--surface); border: 1px solid var(--line); height: 50px; display: flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--mono); font-size: 12.5px; }
.dest button:hover { border-color: var(--line-3); }
.dest button.on { border-color: var(--fg-hi); background: var(--panel-3); }
.render-job { background: var(--surface); border: 1px solid var(--line-2); padding: 16px; }
.render-log { font-family: var(--mono); font-size: 10.5px; color: var(--muted); max-height: 90px; overflow: hidden; white-space: pre-wrap; margin-top: 10px; line-height: 1.5; }
.render-item { display: grid; grid-template-columns: 54px 1fr auto; gap: 12px; align-items: center; padding: 10px; background: var(--surface); border: 1px solid var(--line); }
.render-item img, .render-item .ph { width: 54px; height: 54px; object-fit: cover; background: var(--panel-3); }
.dl-master { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dl-master .spec { font-family: var(--mono); font-size: 12px; background: rgba(0,0,0,0.08); padding: 3px 8px; }

/* Library */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 20px; }
.lib-card { border: 1px solid var(--line); background: var(--surface); padding: 10px; }
.lib-card .thumb { aspect-ratio: 9 / 16; cursor: pointer; }
.lib-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Responsive */
.only-mobile { display: none; }
@media (max-width: 1280px) {
  .editor { grid-template-columns: 200px minmax(0, 1fr) 270px; }
  .export { grid-template-columns: minmax(0, 1fr) 380px; }
  .split { grid-template-columns: minmax(0, 1fr) 380px; }
}
@media (max-width: 1080px) {
  :root { --deck-w: 0px; }
  .deck { transform: translateX(-100%); width: 260px; transition: transform 0.2s; }
  .deck.open { transform: none; box-shadow: var(--shadow); }
  .only-mobile { display: inline-grid; }
  .split, .export { grid-template-columns: 1fr; }
  .split > .right { position: static; height: auto; border-top: 1px solid var(--line); }
  .ex-stage { border-right: 0; }
  .editor { grid-template-columns: 1fr; grid-template-rows: auto minmax(420px, 60vh) auto 220px; height: auto; }
  .ed-left, .ed-right, .ed-center, .dock { grid-row: auto !important; grid-column: 1 !important; }
  .ed-left, .ed-right { grid-row: auto; max-height: 320px; border: 0; border-bottom: 1px solid var(--line); }
  .ed-left { order: 1; } .ed-center { order: 2; } .ed-right { order: 3; } .dock { order: 4; }
}
@media (max-width: 720px) {
  .page { padding: 20px 16px; }
  .hide-sm { display: none !important; }
  .topbar, .stepper { padding: 0 12px; }
  .scene-card .sc-body { grid-template-columns: 1fr; }
  .scene-card .sc-thumb { max-width: 140px; }
  #aspect-seg button span.lbl-long { display: none; }
  .ex-side { padding: 20px 16px; }
  .ex-stage { padding: 16px; }
  .deliver, .dest { grid-template-columns: repeat(2, 1fr); }
}

/* no accidental text selection while dragging on canvas / timeline */
.editor .dock, .editor .tracks, .editor .ed-stage-wrap, .editor .scene-strip, .editor .layer, .ex-controls { -webkit-user-select: none; user-select: none; }
.editor .tracks { touch-action: none; }
.editor .ed-stage .el.editing .el-in { -webkit-user-select: text; user-select: text; }

.scene-fx { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 8px; align-items: end; margin-top: 12px; }
.scene-fx .fx-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.scene-fx .lbl { font-size: 10px; }
@media (max-width: 720px) { .scene-fx { grid-template-columns: 1fr 1fr; } }

/* editor v2: tabs, multi-select, presets */
.editor .ed-right { display: flex; flex-direction: column; }
.ed-tabs { display: grid; grid-template-columns: repeat(5, 1fr); border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface-lo); z-index: 2; }
.ed-tabs button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 2px 8px; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.04em; color: var(--muted); border-bottom: 2px solid transparent; }
.ed-tabs button:hover { color: var(--fg); }
.ed-tabs button.on { color: var(--fg-hi); border-bottom-color: var(--fg-hi); background: var(--panel-2); }
#e-inspector { overflow-y: auto; flex: 1; }
.sel-box.multi { border-style: dashed; }
.sel-outline { position: absolute; border: 1px solid rgba(79, 214, 255, 0.9); pointer-events: none; z-index: 19; }
.marquee { position: absolute; border: 1px solid #4fd6ff; background: rgba(79, 214, 255, 0.1); pointer-events: none; z-index: 21; }
.icon-row { display: flex; flex-wrap: wrap; gap: 4px; }
.icon-row .icon-btn { width: 34px; height: 30px; }
.tips { display: flex; flex-direction: column; gap: 6px; line-height: 1.6; }
.layer-list { display: flex; flex-direction: column; gap: 1px; }
.layer.child { padding-left: 26px; }
.layer.group { color: var(--fg); font-weight: 500; }
.layer.group .icon-btn { width: 20px; height: 20px; }
.clipb.el.grouped { border-left: 2px solid #4fd6ff; }
.preset-grid, .fx-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.fx-grid { grid-template-columns: repeat(2, 1fr); }
.preset { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 4px; background: var(--surface); border: 1px solid var(--line); font-size: 11px; color: var(--fg); text-align: center; line-height: 1.2; }
.preset:hover { border-color: var(--line-3); }
.preset.on { border-color: var(--fg-hi); background: var(--panel-3); }
.preset:disabled { opacity: 0.3; cursor: not-allowed; }
.pv { display: flex; gap: 3px; align-items: flex-end; height: 18px; }
.pv i { width: 7px; height: 14px; background: var(--fg); border-radius: 1px; display: block; }
.preset:hover .pv i, .preset.on .pv i { animation: pvAnim 0.9s cubic-bezier(.2,.8,.2,1) infinite; }
.preset .pv i:nth-child(2) { animation-delay: 0.08s !important; }
.preset .pv i:nth-child(3) { animation-delay: 0.16s !important; }
@keyframes pvAnim { 0% { opacity: 0; transform: translateY(8px); } 45%, 100% { opacity: 1; transform: none; } }
.preset:hover .pv-pop i, .preset:hover .pv-wordPop i, .preset:hover .pv-bounceIn i { animation-name: pvPop; }
.preset:hover .pv-zoom i, .preset:hover .pv-kenBurns i { animation-name: pvZoom; }
.preset:hover .pv-slideLeft i, .preset:hover .pv-wipe i, .preset:hover .pv-revealLeft i { animation-name: pvSlide; }
.preset:hover .pv-spinIn i, .preset:hover .pv-flipIn i { animation-name: pvSpin; }
.preset:hover .pv-blur i, .preset:hover .pv-trackingIn i { animation-name: pvBlur; }
.preset:hover .pv-glitch i { animation-name: pvGlitch; }
@keyframes pvPop { 0% { transform: scale(0); opacity: 0; } 50% { transform: scale(1.2); opacity: 1; } 70%, 100% { transform: none; } }
@keyframes pvZoom { 0% { transform: scale(1.8); opacity: 0; } 60%, 100% { transform: none; opacity: 1; } }
@keyframes pvSlide { 0% { transform: translateX(10px); opacity: 0; } 60%, 100% { transform: none; opacity: 1; } }
@keyframes pvSpin { 0% { transform: rotate(-180deg) scale(0); } 60%, 100% { transform: none; } }
@keyframes pvBlur { 0% { filter: blur(4px); opacity: 0; } 60%, 100% { filter: none; opacity: 1; } }
@keyframes pvGlitch { 0%, 40% { transform: translateX(-3px); } 20%, 60% { transform: translateX(3px); } 80%, 100% { transform: none; } }

@media (max-width: 1640px) { .ed-toolbar .btn .t { display: none; } .ed-toolbar .btn.xs { padding: 0 7px; } }
.voice-list::-webkit-scrollbar-thumb { background: var(--line-3); }
.voice-count { font-family: var(--mono); font-size: 11px; color: var(--muted); margin: -4px 0 8px; }

.sc-thumb, .mini-slot { cursor: pointer; }
.sc-thumb:hover .thumb, .scene-mini:hover .thumb { outline: 1px solid var(--fg-hi); }
