:root { --bg: #000; --s: #0A0A0A; --b: #1A1A1A; --fg: #fff; --mute: #6b6b6b; --icon: #a3a3a3; color-scheme: dark; }
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; background: #000; color: #fff; overflow: hidden; user-select: none;
  font: 12px/1.3 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible { outline: 1px solid #fff; outline-offset: 1px; }
#app { height: 100%; }
.vhold { position: fixed; left: 0; top: 0; width: 2px; height: 2px; overflow: hidden; opacity: 0; pointer-events: none; }
.vhold video, .vhold audio { width: 2px; height: 2px; }

/* ── Home ─────────────────────────────── */
.home { height: 100%; display: grid; place-items: center; transition: opacity .5s; }
.home-inner { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.orb { width: 168px; height: 168px; border-radius: 50%; position: relative;
  background: radial-gradient(circle, #fff 0 16%, rgba(255,255,255,.62) 30%, rgba(255,255,255,.16) 50%, rgba(255,255,255,0) 70%);
  animation: breathe 4.8s ease-in-out infinite; transition: transform .4s cubic-bezier(.3,0,.2,1); }
.orb::after { content: ""; position: absolute; inset: -40%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255,255,255,.12), rgba(255,255,255,0) 62%); }
.orb:hover { transform: scale(1.04); }
.orb.hot { animation: none; transform: scale(1.18); filter: brightness(1.15); }
.orb.busy { animation: breathe 1.1s ease-in-out infinite; }
.orb.expand { animation: expand .56s cubic-bezier(.7,0,.25,1) forwards; }
@keyframes breathe { 0%,100% { transform: scale(.93); opacity: .82; } 50% { transform: scale(1.04); opacity: 1; } }
@keyframes expand { to { transform: scale(16); opacity: 0; } }
.home.leaving .cap, .home.leaving .pills, .home.leaving .meta { opacity: 0; transition: opacity .25s; }
.cap { color: #8a8a8a; font-size: 11px; letter-spacing: .08em; }
.pills { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 560px; }
.pill { display: flex; align-items: center; border: 1px solid var(--b); background: var(--s); border-radius: 999px; color: #a0a0a0; }
.pill:hover { border-color: #3a3a3a; color: #fff; }
.pill-t { padding: 5px 4px 5px 12px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill-t small { color: #555; }
.pill-x { width: 24px; height: 24px; display: grid; place-items: center; color: #555; border-radius: 50%; }
.pill-x:hover { color: #fff; }
.meta { color: #444; font-size: 10px; letter-spacing: .06em; min-height: 12px; }

/* ── Editor ───────────────────────────── */
.editor { position: relative; height: 100%; display: grid; grid-template-rows: 40px minmax(0,1fr) auto; animation: fadeIn .45s ease; }
@keyframes fadeIn { from { opacity: 0; transform: scale(.985); } }
.top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 8px; border-bottom: 1px solid var(--b); }
.top .l { display: flex; align-items: center; gap: 6px; min-width: 0; }
.top .c { display: flex; align-items: center; gap: 2px; }
.top .r { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.ib { width: 28px; height: 28px; display: grid; place-items: center; flex: none; border-radius: 6px; color: var(--icon); border: 1px solid transparent; }
.ib:hover:not(:disabled) { color: #fff; }
.ib.on { color: #fff; border-color: var(--b); background: var(--s); }
.ib:disabled { opacity: .35; cursor: default; }
.sep { width: 1px; height: 16px; background: var(--b); margin: 0 4px; flex: none; }
.mini-orb span { width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 0 10px rgba(255,255,255,.55);
  background: radial-gradient(circle, #fff 0 32%, rgba(255,255,255,.35) 60%, transparent 74%); }
.title { outline: none; padding: 3px 6px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 34vw; color: #d0d0d0; user-select: text; cursor: text; }
.title:hover { color: #fff; }
.title:focus { background: var(--s); box-shadow: inset 0 0 0 1px var(--b); color: #fff; text-overflow: clip; }
.saved { width: 6px; height: 6px; border-radius: 50%; flex: none; transition: .3s; background: #6b6b6b; }
.saved.saving { background: transparent; box-shadow: inset 0 0 0 1px var(--mute); }
.saved.syncing { background: #fff; animation: syncPulse 1s ease-in-out infinite; }
.saved.synced { background: #fff; box-shadow: 0 0 6px rgba(255,255,255,.8); }
.saved.error { background: transparent; box-shadow: inset 0 0 0 1px #fff; }
@keyframes syncPulse { 50% { opacity: .35; } }
.btn-export { height: 26px; padding: 0 14px; margin-left: 6px; border-radius: 999px; background: #fff; color: #000; font-weight: 600; letter-spacing: .02em; }
.btn-export:hover { box-shadow: 0 0 14px rgba(255,255,255,.35); }

.stage { position: relative; display: grid; place-items: center; overflow: hidden; }
.stage canvas, .stage .safe { grid-area: 1 / 1; }
.stage canvas { display: block; background: #000; box-shadow: 0 0 0 1px var(--b); cursor: pointer; }
.safe { pointer-events: none; }
.empty { position: absolute; color: #444; font-size: 11px; letter-spacing: .06em; pointer-events: none; }
.drop-hint { position: absolute; inset: 0; display: none; place-items: center; pointer-events: none; z-index: 40;
  background: rgba(0,0,0,.7); box-shadow: inset 0 0 0 1px #fff; color: #fff; letter-spacing: .1em; }
.editor.drop .drop-hint { display: grid; }

/* ── Timeline ─────────────────────────── */
.tl { height: 56px; display: flex; border-top: 1px solid var(--b); transition: height .28s cubic-bezier(.4,0,.2,1); }
.tl.x { height: 180px; }
.tl-tools { display: flex; align-items: center; gap: 2px; padding: 0 8px; border-right: 1px solid var(--b); }
.tl.x .tl-tools { flex-direction: column; justify-content: center; }
.tl-wrap { position: relative; flex: 1; min-width: 0; }
.tl-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }

/* ── Transition pill ──────────────────── */
.txpill { position: absolute; z-index: 30; transform: translateX(-50%); display: flex; align-items: center; gap: 1px; padding: 3px;
  background: var(--s); border: 1px solid var(--b); border-radius: 999px; box-shadow: 0 10px 34px rgba(0,0,0,.9); animation: pop .16s ease; white-space: nowrap; }
.txpill .ib { width: 26px; height: 26px; border-radius: 50%; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 4px); } }
.frames { min-width: 34px; text-align: center; font-variant-numeric: tabular-nums; color: #fff; cursor: ns-resize; }
.frames.warn { color: #9a9a9a; text-decoration: underline dotted #555; }
.chip { height: 22px; display: flex; align-items: center; gap: 3px; padding: 0 7px; border-radius: 999px; border: 1px solid var(--b); color: var(--mute); margin: 0 1px; }
.chip b { font-weight: 500; font-size: 10px; }
.chip:hover, .chip.on { color: #fff; border-color: #3a3a3a; }
.vbtn { height: 24px; padding: 0 10px; border-radius: 999px; color: #fff; font-size: 11px; }
.vbtn:hover:not(:disabled) { background: #161616; }
.vbtn:disabled { opacity: .3; cursor: default; }

/* ── Export popover ───────────────────── */
.pop { position: fixed; z-index: 50; width: 260px; padding: 6px; background: var(--s); border: 1px solid var(--b); border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,.9); animation: fadeIn .14s ease; }
.opt { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: 100%; padding: 9px 10px; border-radius: 8px; text-align: left; }
.opt:hover { background: #141414; }
.opt b { font-weight: 600; font-size: 12px; }
.opt span { color: var(--mute); font-size: 10.5px; }
.segs { display: flex; gap: 4px; padding: 0 10px 8px; }
.seg { height: 22px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--b); color: var(--mute); font-size: 11px; }
.seg.on { color: #000; background: #fff; border-color: #fff; }
.hr { display: block; height: 1px; background: var(--b); margin: 2px 4px; }

/* ── Toasts / progress ────────────────── */
.toasts { position: fixed; left: 50%; top: 52px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { padding: 7px 14px; background: var(--s); border: 1px solid var(--b); border-radius: 999px; color: #ddd; animation: fadeIn .2s; transition: opacity .3s; }
.toast.out { opacity: 0; }
.prog { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); z-index: 60; width: 300px; padding: 10px 12px 12px; padding-right: 40px;
  background: var(--s); border: 1px solid var(--b); border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.9); }
.prog-l { display: flex; justify-content: space-between; color: #bbb; margin-bottom: 8px; font-size: 11px; }
.pct { font-variant-numeric: tabular-nums; color: #fff; }
.bar { height: 2px; background: var(--b); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: #fff; box-shadow: 0 0 8px #fff; transition: width .15s; }
.prog-x { position: absolute; right: 6px; top: 8px; }

/* ── R2 meter + cloud pills ───────────── */
.meter-box { min-height: 18px; display: flex; justify-content: center; }
.meter { display: flex; flex-direction: column; align-items: center; gap: 5px; color: #555; font-size: 10px; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.meter .mbar { display: block; width: 120px; height: 1px; background: var(--b); }
.meter .mbar b { display: block; height: 100%; background: #555; }
.meter.warn { color: #fff; }
.meter.warn .mbar b { background: #fff; box-shadow: 0 0 6px #fff; }
.meter.off { color: #333; }
.pill.cloud { border-style: dashed; }
.pill.cloud em { font-style: normal; color: #555; }

/* ── Ease toggle ──────────────────────── */
.ease { height: 26px; display: flex; align-items: center; gap: 4px; padding: 0 8px; border-radius: 999px; color: #fff; font-size: 11px; }
.ease:hover:not(:disabled) { background: #161616; }
.ease:disabled { opacity: .3; cursor: default; }

/* ── Transitions Gallery ──────────────── */
.editor.gal .txpill { display: none; }
.gallery { position: absolute; inset: 0; z-index: 25; background: #000; display: flex; flex-direction: column; animation: fadeIn .2s ease; }
.ghead { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--b); }
.gtitle { font-size: 12px; font-weight: 600; letter-spacing: .04em; }
.gtarget { color: var(--mute); font-size: 11px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fpills { display: flex; gap: 4px; }
.fpill { height: 24px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--b); color: var(--mute); font-size: 11px; }
.fpill:hover { color: #fff; }
.fpill.on { background: #fff; color: #000; border-color: #fff; }
.ggrid { flex: 1; overflow: auto; padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; align-content: start; }
.gcard { display: flex; flex-direction: column; gap: 8px; padding: 6px; border: 1px solid transparent; border-radius: 10px; background: #000; transition: border-color .15s, background .15s; }
.gcard:hover { border-color: var(--b); background: var(--s); }
.gtile { position: relative; border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 1px var(--b); }
.gtile canvas { display: block; width: 100%; height: auto; background: #000; }
.badge { position: absolute; top: 6px; right: 6px; padding: 1px 6px; border-radius: 999px; background: rgba(0,0,0,.75); border: 1px solid var(--b); font-size: 10px; font-variant-numeric: tabular-nums; }
.gdel { position: absolute; top: 5px; left: 5px; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: rgba(0,0,0,.75); color: var(--mute); opacity: 0; transition: opacity .15s; }
.gcard:hover .gdel { opacity: 1; }
.gdel:hover { color: #fff; }
.gmeta { display: flex; flex-direction: column; gap: 5px; padding: 0 2px; }
.gmeta b { font-weight: 500; font-size: 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 3px; }
.tags i { font-style: normal; font-size: 9.5px; color: #777; border: 1px solid var(--b); border-radius: 999px; padding: 0 6px; line-height: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gapply { height: 26px; border-radius: 999px; border: 1px solid var(--b); color: #bbb; font-size: 11px; }
.gcard:hover .gapply { background: #fff; color: #000; border-color: #fff; }
.gempty { grid-column: 1 / -1; color: #444; text-align: center; padding: 40px 0; font-size: 11px; }

/* ── Transition Box (overlays the bottom of the stage; stage keeps its size) ── */
.tbox { position: absolute; left: 0; right: 0; bottom: 0; z-index: 22; background: rgba(0,0,0,.94); border-top: 1px solid var(--b);
  backdrop-filter: blur(6px); animation: boxIn .2s ease; }
@keyframes boxIn { from { transform: translateY(12px); opacity: 0; } }
.bhead { display: flex; align-items: center; gap: 10px; padding: 6px 10px 0 14px; }
.btitle { font-weight: 600; font-size: 11px; letter-spacing: .04em; }
.bhint { color: var(--mute); font-size: 10.5px; flex: 1; }
.trks { display: flex; border: 1px solid var(--b); border-radius: 999px; padding: 1px; }
.trk { height: 20px; padding: 0 9px; border-radius: 999px; color: var(--icon); font-size: 10px; font-weight: 600; letter-spacing: .04em; }
.trk.on { background: #fff; color: #000; }
.brow { display: flex; align-items: flex-start; gap: 8px; padding: 8px 14px 10px; overflow-x: auto; scrollbar-width: thin; scrollbar-color: #262626 transparent; }
.bgroup { flex: none; align-self: center; writing-mode: vertical-rl; transform: rotate(180deg); color: #666; font-size: 9px; letter-spacing: .1em; text-transform: uppercase; padding-left: 4px; border-left: 1px solid var(--b); }
.bcard { flex: none; position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px; border-radius: 8px;
  border: 1px solid transparent; cursor: grab; outline: none; }
.bcard:hover, .bcard:focus-visible { border-color: var(--b); background: var(--s); }
.bcard:active { cursor: grabbing; }
.bcard canvas { display: block; border-radius: 4px; box-shadow: 0 0 0 1px var(--b); background: #000; }
.bcard b { font-weight: 500; font-size: 10px; color: #ccc; max-width: 64px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bcard.vault b { color: #fff; }
.bbadge { position: absolute; top: 7px; right: 7px; font-size: 9px; padding: 0 4px; border-radius: 999px; background: rgba(0,0,0,.75); border: 1px solid var(--b); font-variant-numeric: tabular-nums; }
.bempty { align-self: center; color: #555; font-size: 10.5px; white-space: nowrap; }
body.dnd .tl-wrap { box-shadow: inset 0 0 0 1px rgba(255,255,255,.35); }

/* ── Pill layer tag ───────────────────── */
.layer { height: 20px; display: grid; place-items: center; padding: 0 7px; margin: 0 3px 0 2px; border-radius: 999px; border: 1px solid var(--b); color: var(--icon); font-size: 9.5px; font-weight: 700; letter-spacing: .05em; }
.layer.v2 { background: #fff; color: #000; border-color: #fff; }

/* ── Upload History popover ───────────── */
.hpop { position: fixed; z-index: 55; max-height: min(70vh, 560px); display: flex; flex-direction: column; background: var(--s); border: 1px solid var(--b);
  border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.9); animation: fadeIn .14s ease; }
.hhead { display: flex; align-items: center; gap: 8px; padding: 8px 6px 8px 14px; border-bottom: 1px solid var(--b); color: var(--icon); }
.hhead b { flex: 1; color: #fff; font-size: 12px; font-weight: 600; }
.hlist { overflow-y: auto; padding: 4px; }
.hrow { display: flex; align-items: center; gap: 10px; padding: 8px 8px; border-radius: 8px; }
.hrow:hover { background: #121212; }
.hrow.cur { box-shadow: inset 2px 0 0 #fff; }
.hkind { flex: none; min-width: 38px; text-align: center; font-size: 9.5px; font-weight: 600; padding: 2px 5px; border-radius: 999px; border: 1px solid #262626; color: #ccc; }
.hmain { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hmain b { font-weight: 500; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hmain small { color: #8a8a8a; font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hopen { flex: none; height: 24px; padding: 0 11px; border-radius: 999px; border: 1px solid #333; color: #fff; font-size: 11px; }
.hopen:hover:not(:disabled) { background: #fff; color: #000; border-color: #fff; }
.hopen:disabled { color: #666; border-color: var(--b); cursor: default; }
.hempty { color: #666; text-align: center; padding: 24px 0; font-size: 11px; }
.hfoot { border-top: 1px solid var(--b); padding: 10px 0 9px; display: flex; justify-content: center; }
.hbtn { display: flex; align-items: center; gap: 6px; height: 26px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--b); color: var(--icon); font-size: 11px; }
.hbtn:hover { color: #fff; border-color: #333; }
