@font-face { font-family: "Poppins"; src: url("/assets/fonts/Poppins_400Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Poppins"; src: url("/assets/fonts/Poppins_600SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Poppins"; src: url("/assets/fonts/Poppins_800ExtraBold.ttf") format("truetype"); font-weight: 800; font-display: swap; }
:root {
  --bg: #050811; --surface: #0A1222; --surface-2: #0D1930; --surface-3: #13233F; --line: #19304A; --text: #F4F7FF; --muted: #9AAAC4; --faint: #667792;
  --cyan: #00E5FF; --blue: #1677FF; --purple: #762BFF; --magenta: #E62BFF; --danger: #FF4D6D;
  --grad: linear-gradient(100deg, #00E5FF 0%, #1677FF 38%, #762BFF 72%, #E62BFF 100%);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.45 Poppins, system-ui, sans-serif; -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.ic { display: inline-flex; } .ic svg { width: 18px; height: 18px; }
#app { height: 100dvh; display: flex; flex-direction: column; }

.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); background: rgba(10, 18, 34, .9); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .05em; font-size: .95rem; }
.brand img { width: 30px; height: 30px; border-radius: 26%; }
.grow { flex: 1; }
.icon { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: inline-grid; place-items: center; cursor: pointer; font-size: 1.1rem; }
.icon:active { transform: scale(.96); }
.lang { border: 1px solid var(--line); background: none; color: var(--muted); border-radius: 999px; padding: 6px 10px; font-size: .78rem; font-weight: 700; cursor: pointer; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface-2); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn.primary { background: var(--grad); border: 0; color: #fff; box-shadow: 0 10px 24px -12px rgba(22, 119, 255, .9); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: .86rem; }
.btn.ghost { background: none; }
.btn.danger { color: #ff8da1; border-color: rgba(255, 77, 109, .4); }
.btn:disabled { opacity: .4; cursor: default; }
@media (max-width: 520px) { .topbar .btn.primary .lbl { display: none; } .topbar .btn.primary { width: 42px; padding: 0; } .brand span { display: none; } }

.work { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 360px; }
.view { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.stage-wrap { position: relative; flex: 1 1 auto; min-height: 0; margin: 14px auto 8px; max-width: calc(100% - 28px); height: calc(100% - 200px); border-radius: 16px; overflow: hidden;
  background: #000; box-shadow: 0 24px 60px -30px rgba(22, 119, 255, .6); }
.stage { width: 100%; height: 100%; display: block; object-fit: contain; }
.controls { display: flex; align-items: center; gap: 12px; padding: 4px 14px; }
.round { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--grad); color: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: 0 8px 20px -10px rgba(22, 119, 255, .9); }
.round svg { width: 20px; height: 20px; }
.clock { font: 600 .9rem ui-monospace, "SF Mono", Menlo, monospace; color: var(--muted); }
.zoom { margin-left: auto; display: flex; gap: 6px; }
.zoom .icon { width: 32px; height: 32px; }
.timeline { position: relative; overflow-x: auto; overflow-y: hidden; padding: 6px 0 10px; border-top: 1px solid var(--line); background: var(--surface); min-height: 140px; touch-action: pan-x; }
.timeline .inner { position: relative; height: 128px; }
.ruler { position: relative; height: 18px; }
.ruler span { position: absolute; top: 0; font-size: .64rem; color: var(--faint); transform: translateX(-50%); }
.ruler span:first-child { transform: none; }
.timeline .row { position: relative; height: 34px; margin-top: 4px; }
.timeline .row.v { height: 46px; }
.clip, .txt, .mus { position: absolute; top: 0; bottom: 0; border-radius: 9px; border: 2px solid transparent; cursor: pointer; overflow: hidden; padding: 0 6px; text-align: left; }
.clip { background: #1b3157 center / auto 100% repeat-x; }
.clip span { position: absolute; right: 4px; bottom: 2px; font-size: .62rem; font-weight: 700; background: rgba(0, 0, 0, .55); padding: 0 5px; border-radius: 5px; }
.clip .tr { position: absolute; left: 0; top: 0; bottom: 0; width: 8px; background: linear-gradient(90deg, rgba(255, 255, 255, .7), transparent); }
.clip.on, .txt.on { border-color: #fff; box-shadow: 0 0 0 2px var(--blue); }
.txt { background: #2F6BFF; font-size: .72rem; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.mus { background: linear-gradient(90deg, #762BFF, #a46bff); font-size: .72rem; font-weight: 600; white-space: nowrap; }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 10px rgba(255, 255, 255, .8); pointer-events: none; }
.playhead::before { content: ""; position: absolute; top: -2px; left: -5px; border: 6px solid transparent; border-top-color: #fff; }

.side { min-height: 0; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--surface); }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 2px 8px; border: 0; background: none; color: var(--faint); font-size: .72rem; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--text); border-bottom-color: var(--cyan); }
.panel { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.pname { font-weight: 600; font-size: .85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 6px; }
.muted { color: var(--muted); margin: 0; } .small { font-size: .8rem; }
.field { display: grid; gap: 4px; font-size: .84rem; color: var(--muted); }
.field span { display: flex; justify-content: space-between; }
.field output { color: var(--text); font-weight: 600; }
input[type=range] { width: 100%; accent-color: var(--cyan); }
textarea { width: 100%; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); padding: 10px; font: 600 1rem Poppins, sans-serif; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-size: .88rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 6px 12px; font-size: .8rem; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--grad); border-color: transparent; color: #fff; }
.sw { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; }
.sw.on { outline: 3px solid var(--cyan); outline-offset: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.mtile { position: relative; aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-3) center / cover; cursor: pointer; display: grid; place-items: center; }
.mtile span { position: absolute; left: 4px; bottom: 4px; right: 4px; font-size: .62rem; font-weight: 700; background: rgba(0, 0, 0, .6); border-radius: 6px; padding: 1px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.drop { display: none; }
#app.empty .drop { display: flex; flex: 1; align-items: center; justify-content: center; padding: 20px; }
#app.empty .stage-wrap, #app.empty .controls, #app.empty .timeline { display: none; }
.drop-in { text-align: center; max-width: 460px; padding: 40px 26px; border-radius: 26px; border: 2px dashed #23415F;
  background: radial-gradient(80% 100% at 50% 0, rgba(0, 229, 255, .08), transparent), var(--surface); }
.drop-in .ic svg { width: 46px; height: 46px; color: var(--cyan); }
.drop-in h2 { margin: 12px 0 6px; font-size: 1.3rem; }
.drop-in p { margin: 0 0 18px; color: var(--muted); }
body.dragging .drop-in, body.dragging .stage-wrap { outline: 3px dashed var(--cyan); outline-offset: 4px; }

.modal { position: fixed; inset: 0; z-index: 50; background: rgba(2, 4, 10, .72); display: grid; place-items: center; padding: 16px; backdrop-filter: blur(6px); }
.sheet { width: min(440px, 100%); max-height: 92dvh; overflow: auto; border-radius: 22px; padding: 22px; background: var(--surface); border: 1px solid var(--line); display: grid; gap: 12px; text-align: center; }
.sheet h3 { margin: 0; }
.sheet .bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; padding: 0; border: 0; }
.sheet .bar i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .2s; }
.result { width: 100%; max-height: 50dvh; border-radius: 14px; background: #000; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; transition: .25s; z-index: 60; background: var(--surface-3); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 14px; font-size: .88rem; max-width: calc(100% - 32px); pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { border-color: rgba(255, 77, 109, .6); }

@media (max-width: 900px) {
  #app { height: auto; min-height: 100dvh; }
  .work { grid-template-columns: 1fr; }
  .stage-wrap { height: auto; max-height: 56dvh; flex: none; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
  .panel { overflow: visible; padding-bottom: 40px; }
  .topbar { position: sticky; top: 0; z-index: 5; backdrop-filter: blur(10px); }
  .tabs { position: sticky; top: 62px; z-index: 2; background: var(--surface); }
}
