:root{
  --bg:#08080a;
  --panel:#0f0f12;
  --sunk:#0b0b0e;
  --line:#1c1c21;
  --line-soft:#141419;
  --fg:#e8e8ec;
  --dim:#71717c;
  --dimmer:#45454f;
  --accent:#d9a05b;
  --accent-soft:rgba(217,160,91,.13);
  --bad:#8a4a45;
  --r:9px;
  --side:372px;
  --ease:cubic-bezier(.22,.61,.36,1);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:var(--bg);
  color:var(--fg);
  font:400 13px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",ui-sans-serif,system-ui,Roboto,Helvetica,Arial,sans-serif;
  -webkit-font-smoothing:antialiased;
  overflow:hidden;
}
button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}
input{font:inherit;color:inherit}
svg{display:block}
::selection{background:var(--accent-soft)}

/* ---------------- shell ---------------- */
.shell{
  height:100%;
  display:grid;
  grid-template-columns:minmax(0,1fr) var(--side);
}
.main{display:flex;flex-direction:column;min-width:0;min-height:0}

/* ---------------- stage ---------------- */
.stage{
  position:relative;
  flex:1;
  min-height:0;
  display:flex;
  padding:20px 18px;
}
.screen{
  position:relative;
  margin:auto;
  width:100%;
  max-width:100%;
  max-height:100%;
  aspect-ratio:16/9;
  background:#000;
  border-radius:var(--r);
  overflow:hidden;
  box-shadow:0 0 0 1px var(--line-soft), 0 18px 60px -30px #000;
}
.frame{position:absolute;inset:0;z-index:2;opacity:0;transition:opacity .4s var(--ease)}
body.live .frame{opacity:1}
#player,.frame iframe{width:100%;height:100%;border:0;display:block}

.idle{
  position:absolute;inset:0;z-index:1;
  display:grid;place-items:center;
  color:var(--dimmer);
  opacity:1;
  transition:opacity .35s var(--ease);
}
body.live .idle{opacity:0}
.idle svg{width:88px;height:88px;animation:spin 26s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){.idle svg{animation:none}}

/* Our surface sits over the iframe so mouse + keyboard stay with us. */
.veil{position:absolute;inset:0;z-index:3}
#stage.fs .screen:not(.show) .veil{cursor:none}

/* ---------------- player chrome ---------------- */
.top{
  position:absolute;left:0;right:0;top:0;z-index:4;
  display:none;padding:15px 20px 28px;
  pointer-events:none;opacity:0;
  transition:opacity .2s var(--ease);
  background:linear-gradient(180deg,rgba(0,0,0,.82) 0%,rgba(0,0,0,0) 100%);
}
#stage.fs .top{display:block}
#stage.fs .screen.show .top{opacity:1}
.now{
  display:block;font-size:14px;color:#fff;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  text-shadow:0 1px 4px rgba(0,0,0,.8);
}

.bar{
  position:absolute;left:0;right:0;bottom:0;z-index:5;
  display:flex;flex-direction:column;gap:7px;
  padding:34px 14px 11px;
  background:linear-gradient(180deg,rgba(0,0,0,0) 0%,rgba(0,0,0,.5) 40%,rgba(0,0,0,.88) 100%);
  opacity:0;transform:translateY(8px);pointer-events:none;
  transition:opacity .2s var(--ease),transform .2s var(--ease);
}
.screen.show .bar{opacity:1;transform:none;pointer-events:auto}
#stage.fs .bar{padding:40px 26px 18px;gap:9px}

.ctl{display:flex;align-items:center;gap:5px}
.spring{flex:1;min-width:8px}
.time{
  margin-left:9px;
  font-size:11.5px;color:#c9c9d2;font-variant-numeric:tabular-nums;
  white-space:nowrap;text-shadow:0 1px 3px rgba(0,0,0,.7);
}

.btn{
  display:grid;place-items:center;
  width:32px;height:32px;
  border-radius:8px;
  color:#c2c2cb;
  transition:color .16s var(--ease),background .16s var(--ease);
}
.btn svg{width:18px;height:18px}
.btn:hover{color:#fff;background:#ffffff1a}
.btn:active{background:#ffffff26}
.btn:disabled{opacity:.32;pointer-events:none}
.btn-sm{width:29px;height:29px}
.btn-sm svg{width:16px;height:16px}
.btn-run{
  width:38px;height:38px;border-radius:50%;
  color:#fff;box-shadow:inset 0 0 0 1px #ffffff2b;
}
.btn-run svg{width:19px;height:19px}
.btn-run:hover{background:#ffffff1f}
body.running .btn-run{color:var(--accent);box-shadow:inset 0 0 0 1px rgba(217,160,91,.45)}
.btn.on{color:var(--accent)}
.btn:focus-visible{outline:1px solid var(--accent);outline-offset:2px}

/* footer key button lives on panel, not video */
.btn-xs{width:24px;height:24px;color:var(--dimmer);border-radius:6px}
.btn-xs svg{width:14px;height:14px}
.btn-xs:hover{color:var(--fg);background:#ffffff0f}

/* ---------------- sliders ---------------- */
.scrub,.vol{
  -webkit-appearance:none;appearance:none;
  background:transparent;cursor:pointer;
}
.scrub{--p:0%;width:100%;height:14px;display:block}
.vol{--p:70%;width:82px;height:16px;flex:0 0 auto}

.scrub::-webkit-slider-runnable-track{
  height:3px;border-radius:3px;
  background:linear-gradient(90deg,var(--accent) 0 var(--p),rgba(255,255,255,.26) var(--p) 100%);
}
.scrub::-webkit-slider-thumb{
  -webkit-appearance:none;width:11px;height:11px;border-radius:50%;
  background:var(--accent);margin-top:-4px;
  transform:scale(0);transition:transform .14s var(--ease);
}
.screen.show .scrub:hover::-webkit-slider-thumb,
.screen.show .scrub:active::-webkit-slider-thumb,
.screen.show .scrub:focus-visible::-webkit-slider-thumb{transform:scale(1)}
.scrub::-moz-range-track{height:3px;border-radius:3px;background:rgba(255,255,255,.26)}
.scrub::-moz-range-progress{height:3px;border-radius:3px;background:var(--accent)}
.scrub::-moz-range-thumb{width:11px;height:11px;border:0;border-radius:50%;background:var(--accent)}

.vol::-webkit-slider-runnable-track{
  height:3px;border-radius:3px;
  background:linear-gradient(90deg,#fff 0 var(--p),rgba(255,255,255,.26) var(--p) 100%);
}
.vol::-webkit-slider-thumb{
  -webkit-appearance:none;width:10px;height:10px;border-radius:50%;
  background:#fff;margin-top:-3.5px;
}
.vol::-moz-range-track{height:3px;border-radius:3px;background:rgba(255,255,255,.26)}
.vol::-moz-range-progress{height:3px;border-radius:3px;background:#fff}
.vol::-moz-range-thumb{width:10px;height:10px;border:0;border-radius:50%;background:#fff}
body.muted .vol{opacity:.4}
.scrub:focus-visible,.vol:focus-visible{outline:1px solid var(--accent);outline-offset:3px;border-radius:3px}

/* ---------------- fullscreen ---------------- */
body.fs{background:#000}
#stage.fs{padding:0}
#stage.fs .screen{
  border-radius:0;box-shadow:none;max-height:none;
  aspect-ratio:auto;position:absolute;inset:0;margin:0;
}
#stage.fs .idle{display:none}

/* ---------------- side ---------------- */
.side{
  display:flex;flex-direction:column;min-height:0;
  background:var(--panel);
  border-left:1px solid var(--line-soft);
}
.side-head{padding:14px 14px 10px;flex:0 0 auto}
.add{
  display:flex;align-items:center;gap:9px;
  height:36px;padding:0 11px;
  background:var(--sunk);
  border:1px solid var(--line-soft);
  border-radius:8px;
  transition:border-color .18s var(--ease),background .18s var(--ease);
}
.add:focus-within{border-color:#2a2a33;background:#0d0d11}
.add-ico{display:grid;place-items:center;color:var(--dimmer);flex:0 0 auto}
.add-ico svg{width:14px;height:14px}
.add:focus-within .add-ico{color:var(--dim)}
.add-in{
  flex:1;min-width:0;border:0;background:transparent;outline:0;
  font-size:12.5px;color:var(--fg);
}
.add.flash{animation:flash .5s var(--ease)}
@keyframes flash{0%{border-color:var(--accent)}100%{border-color:var(--line-soft)}}

/* ---------------- queue ---------------- */
.qwrap{position:relative;flex:1;min-height:0;display:flex;flex-direction:column}

.scrollup{
  position:absolute;top:0;left:0;right:0;height:10px;z-index:6;
  display:flex;align-items:center;justify-content:center;
  overflow:hidden;
  pointer-events:none;opacity:0;
  background:linear-gradient(180deg,rgba(15,15,18,.9),rgba(15,15,18,0));
  transition:opacity .18s var(--ease),height .16s var(--ease);
}
body.dragging .scrollup:not(.off){pointer-events:auto;opacity:1}
.scrollup svg{width:14px;height:14px;color:var(--accent);opacity:0;transition:opacity .14s var(--ease)}
.scrollup.on{height:30px;background:linear-gradient(180deg,var(--panel) 18%,rgba(15,15,18,.88) 68%,rgba(15,15,18,0) 100%)}
.scrollup.on svg{opacity:1;animation:nudge .85s ease-in-out infinite}
@keyframes nudge{0%,100%{transform:translateY(0)}50%{transform:translateY(-3px)}}
@media (prefers-reduced-motion:reduce){.scrollup.on svg{animation:none}}

.queue{
  list-style:none;margin:0;padding:2px 8px 10px;
  flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;
  scrollbar-width:thin;scrollbar-color:#26262d transparent;
}
.queue::-webkit-scrollbar{width:9px}
.queue::-webkit-scrollbar-thumb{background:#22222a;border:3px solid var(--panel);border-radius:9px}
.queue::-webkit-scrollbar-thumb:hover{background:#31313b}

.gap{
  height:8px;position:relative;list-style:none;
  transition:height .16s var(--ease);
}
.gap::after{
  content:"";position:absolute;left:8px;right:8px;top:50%;
  height:2px;margin-top:-1px;border-radius:2px;
  background:var(--accent);opacity:0;transform:scaleX(.6);
  transition:opacity .14s var(--ease),transform .14s var(--ease);
}
.gap.on{height:30px}
.gap.on::after{opacity:1;transform:scaleX(1)}

.item{
  position:relative;
  display:flex;align-items:flex-start;gap:10px;
  padding:7px 8px 7px 10px;
  border-radius:8px;
  cursor:pointer;
  user-select:none;
  transition:background .16s var(--ease),opacity .25s var(--ease);
}
.item:hover{background:#ffffff07}
.item.sel{background:#ffffff0a}
.item.cur{background:var(--accent-soft)}
.item.dragging{opacity:.32}
.item.done{opacity:.42}
.item.done.cur,.item.done:hover{opacity:1}

.rail{
  position:absolute;left:2px;top:9px;bottom:9px;width:2px;border-radius:2px;
  background:transparent;transition:background .18s var(--ease);
}
.item.sel .rail{background:var(--dimmer)}
.item.cur .rail{background:var(--accent)}
.item.err .rail{background:var(--bad)}

.thumb{
  position:relative;flex:0 0 auto;
  width:104px;height:58px;border-radius:5px;overflow:hidden;
  background:#000;box-shadow:0 0 0 1px var(--line-soft);
}
.thumb img{width:100%;height:100%;object-fit:cover;display:block;opacity:0;transition:opacity .3s var(--ease)}
.thumb img.on{opacity:1}
.item.err .thumb img{filter:grayscale(1);opacity:.35}

.meta{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px;padding-top:1px}
.ttl{
  font-size:12.5px;line-height:1.32;color:var(--fg);
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;
  overflow:hidden;word-break:break-word;
}
.item.err .ttl{color:var(--dim)}
.sub{
  display:flex;align-items:center;gap:6px;
  font-size:11px;color:var(--dim);letter-spacing:.01em;
  overflow:hidden;
}
.sub i{font-style:normal;flex:0 0 auto}
.sub i:empty{display:none}
.sub .who{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sub .dur{font-variant-numeric:tabular-nums}
.sub .sep{color:var(--dimmer)}

.kill{
  flex:0 0 auto;align-self:center;
  display:grid;place-items:center;
  width:22px;height:22px;border-radius:6px;
  color:var(--dimmer);opacity:0;
  transition:opacity .15s var(--ease),color .15s var(--ease),background .15s var(--ease);
}
.kill svg{width:12px;height:12px}
.item:hover .kill{opacity:1}
.kill:hover{color:var(--fg);background:#ffffff0f}
.kill:focus-visible{opacity:1;outline:1px solid var(--accent);outline-offset:1px}

.item.pulse{animation:pulse .7s var(--ease)}
@keyframes pulse{0%{background:var(--accent-soft)}100%{background:transparent}}

/* ---------------- footer ---------------- */
.side-foot{
  flex:0 0 auto;
  display:flex;align-items:center;gap:10px;
  height:40px;padding:0 10px 0 16px;
  border-top:1px solid var(--line-soft);
}
.foot-stats{flex:1;min-width:0;display:flex;align-items:center;gap:9px}
.stat{font-size:11px;color:var(--dimmer);font-variant-numeric:tabular-nums}
.stat-t{color:var(--dim)}
body.keyopen .foot-stats{display:none}

.keyrow{display:none;flex:1;min-width:0}
body.keyopen .keyrow{display:block}
body.keyopen .btn-xs{color:var(--accent)}
.key-in{
  width:100%;height:26px;padding:0 9px;
  background:var(--sunk);
  border:1px solid var(--line-soft);border-radius:6px;
  outline:0;font-size:11.5px;color:var(--dim);
  font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
}
.key-in:focus{border-color:#2a2a33;color:var(--fg)}

/* ---------------- probe ---------------- */
#probe{position:fixed;right:0;bottom:0;width:240px;height:135px;opacity:0;pointer-events:none;z-index:-1;border:0}

/* ---------------- narrow ---------------- */
@media (max-width:900px){
  .shell{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) minmax(0,1fr)}
  .side{border-left:0;border-top:1px solid var(--line-soft)}
  .stage{padding:12px}
}
