:root {
  --bg: #0d0f14; --panel: #161a22; --panel2: #1e2330; --line: #2a3040; --fg: #eef2fb; --muted: #8b93a7;
  --accent: #19d3c5; --accent2: #7c5cff; --danger: #ff5470; --clip: #2b3550; --text: #ffb020; --music: #7c5cff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); overflow: hidden;
  font: 14px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; user-select: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
#app { display: flex; flex-direction: column; height: 100%; }

.top { display: flex; align-items: center; gap: 6px; padding: 8px 10px; }
.top .title { flex: 1; text-align: center; font-weight: 700; letter-spacing: .3px; }
.top .dur { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }
.icon { width: 36px; height: 36px; border-radius: 10px; background: var(--panel); font-size: 18px; }
.icon:disabled { opacity: .35; }

.stagewrap { flex: 0 0 auto; display: flex; justify-content: center; align-items: center; padding: 0 10px;
  height: 42vh; }
.stage { position: relative; background: #000; overflow: hidden; border-radius: 10px; height: 100%;
  aspect-ratio: 9 / 16; max-width: 100%; box-shadow: 0 6px 30px rgba(0,0,0,.5); }
.layers, .texts { position: absolute; inset: 0; }
.layers { z-index: 1; }
.texts { z-index: 10; }
.layers > video, .layers > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  opacity: 0; transition: opacity .12s linear; will-change: transform, opacity; }
.layers.fill > video, .layers.fill > img { object-fit: cover; }
.layers > .on { opacity: 1; }
.texts > div { position: absolute; transform: translate(-50%, -50%); white-space: pre; text-align: center;
  font-weight: 800; color: #fff; -webkit-text-stroke: 1px rgba(0,0,0,.6);
  text-shadow: 0 2px 6px rgba(0,0,0,.7); touch-action: none; padding: 2px 6px; border-radius: 6px; }
.texts > div.sel { outline: 2px dashed var(--text); }
.mark { position: absolute; z-index: 11; right: 2.5%; bottom: 2%; font-size: 10px; color: rgba(255,255,255,.7);
  text-shadow: 0 1px 2px #000; font-weight: 700; }
.empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 20px; color: var(--muted); }
.vhs::after, .retro::after { content: ""; position: absolute; inset: 0; pointer-events: none; }

.transport { display: flex; align-items: center; justify-content: space-between; padding: 6px 14px; }
.tc { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 70px; }
.play { width: 44px; height: 44px; border-radius: 50%; background: var(--fg); color: #000; font-size: 18px; }
.zoom button { width: 32px; height: 32px; border-radius: 8px; background: var(--panel); margin-left: 6px; font-size: 18px; }

.timeline { position: relative; flex: 1 1 auto; min-height: 150px; background: var(--panel); border-top: 1px solid var(--line); }
.playhead { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: #fff;
  z-index: 5; pointer-events: none; box-shadow: 0 0 6px rgba(255,255,255,.6); }
.scroller { position: absolute; inset: 0; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; }
.scroller::-webkit-scrollbar { display: none; }
.lanes { position: relative; height: 100%; padding: 12px 0; }
.lane { position: relative; height: 56px; margin-bottom: 8px; }
.lane-t, .lane-m { height: 26px; }
.clip { position: absolute; top: 0; height: 56px; border-radius: 8px; background: var(--clip) center / 100% 100%;
  border: 2px solid transparent; overflow: hidden; }
.clip .lbl { position: absolute; left: 4px; bottom: 3px; font-size: 10px; padding: 1px 4px; border-radius: 4px;
  background: rgba(0,0,0,.55); }
.clip .spd { position: absolute; right: 4px; top: 3px; font-size: 10px; padding: 1px 4px; border-radius: 4px;
  background: rgba(124,92,255,.85); }
.clip.sel { border-color: var(--accent); }
.clip .h { position: absolute; top: 0; bottom: 0; width: 18px; background: var(--accent); display: none;
  touch-action: none; }
.clip .h::after { content: ""; position: absolute; top: 18px; bottom: 18px; left: 7px; width: 4px; border-radius: 2px;
  background: #0d0f14; }
.clip.sel .h { display: block; }
.clip .h.l { left: 0; border-radius: 6px 0 0 6px; }
.clip .h.r { right: 0; border-radius: 0 6px 6px 0; }
.trans { position: absolute; top: 16px; width: 24px; height: 24px; margin-left: -12px; border-radius: 6px;
  background: #fff; color: #000; font-size: 12px; font-weight: 800; z-index: 3; transform: rotate(45deg);
  display: flex; align-items: center; justify-content: center; }
.trans span { transform: rotate(-45deg); }
.trans.cut { background: var(--panel2); color: var(--muted); }
.tbar { position: absolute; top: 0; height: 26px; border-radius: 6px; background: rgba(255,176,32,.25);
  border: 1px solid var(--text); font-size: 11px; padding: 4px 6px; overflow: hidden; white-space: nowrap; }
.tbar.sel { background: rgba(255,176,32,.55); }
.mbar { position: absolute; top: 0; height: 26px; border-radius: 6px; background: rgba(124,92,255,.25);
  border: 1px solid var(--music); font-size: 11px; padding: 4px 6px; overflow: hidden; white-space: nowrap; }
.mbar.sel { background: rgba(124,92,255,.55); }
.beat { position: absolute; top: 0; width: 1px; height: 26px; background: rgba(255,255,255,.35); }
.addlane { position: absolute; top: 0; height: 26px; padding: 4px 8px; font-size: 11px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 6px; }

.tools { display: flex; gap: 4px; overflow-x: auto; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--line); scrollbar-width: none; }
.tools::-webkit-scrollbar { display: none; }
.tool { flex: 0 0 auto; min-width: 64px; padding: 6px 6px; border-radius: 10px; text-align: center; }
.tool .i { display: block; font-size: 20px; line-height: 26px; }
.tool .l { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; }
.tool.danger .l { color: var(--danger); }
.tool:active { background: var(--panel); }

.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.sheet-body { position: absolute; left: 0; right: 0; bottom: 0; max-height: 72vh; overflow-y: auto; background: var(--panel);
  border-radius: 16px 16px 0 0; padding: 12px 14px calc(16px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; margin-bottom: 10px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid4 { grid-template-columns: repeat(4, 1fr); }
.opt { background: var(--panel2); border-radius: 10px; padding: 10px 6px; text-align: center; font-size: 12px;
  border: 2px solid transparent; }
.opt.on { border-color: var(--accent); }
.fprev { height: 64px; border-radius: 8px; background: #333 center / cover; margin-bottom: 6px; }
.lib { position: relative; aspect-ratio: 1; border-radius: 8px; background: var(--panel2) center / cover; overflow: hidden; }
.lib .k { position: absolute; left: 4px; bottom: 4px; font-size: 10px; background: rgba(0,0,0,.6); padding: 1px 4px; border-radius: 4px; }
.lib.audio { display: flex; align-items: center; justify-content: center; font-size: 26px; background: #2a2150; }
.row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.row label { min-width: 90px; color: var(--muted); font-size: 12px; }
.row input[type=range] { flex: 1; accent-color: var(--accent); }
.row .v { min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 10px; border-radius: 999px; background: var(--panel2); font-size: 12px; border: 1px solid transparent; }
.chip.on { border-color: var(--accent); color: var(--accent); }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--panel2); }
.swatch.on { border-color: #fff; }
textarea, input[type=text] { width: 100%; background: var(--panel2); color: var(--fg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px; font: inherit; resize: none; user-select: text; }
.big { width: 100%; padding: 12px; border-radius: 12px; background: var(--accent); color: #002; font-weight: 800; margin-top: 10px; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: rgba(20,24,34,.95);
  border: 1px solid var(--line); padding: 10px 14px; border-radius: 12px; z-index: 30; max-width: 86vw; text-align: center; }
