*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; }
:root { --setlist-w: min(26rem, 88vw); }
body {
  font: 400 15px/1.4 ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #f2f2f2;
  -webkit-font-smoothing: antialiased;
}

#stage { position: fixed; inset: 0; }
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
#stage canvas.on { display: block; }

/* ---- boot ---- */
#boot {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center;
  background: radial-gradient(120% 90% at 50% -10%, #16222e 0%, #05070a 65%);
  overflow-y: auto; padding: 2rem 1rem;
}
#boot[hidden] { display: none; }
.boot-card { width: min(62rem, 100%); margin: auto; text-align: center; }
.setnav { display: flex; gap: .4rem; justify-content: center; margin: 0 0 1.6rem; }
.setnav a {
  font-size: .76rem; letter-spacing: .06em; text-decoration: none;
  padding: .35rem .85rem; border-radius: 999px;
  border: 1px solid #202a36; color: #7b8695; transition: all .15s;
}
.setnav a:hover { border-color: #3c4b5c; color: #b6c2d0; }
.setnav a.on { background: #1b2733; border-color: #2d3d4e; color: #e9eff5; }
.boot-card h1 {
  margin: 0; font-size: clamp(2.6rem, 9vw, 5.5rem); font-weight: 800;
  letter-spacing: -0.045em; line-height: 0.92;
  background: linear-gradient(100deg, #2bb4c8, #ff6a00 48%, #b14cff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sub { margin: .7rem 0 0; color: #7f8a98; letter-spacing: .2em; text-transform: uppercase; font-size: .7rem; }
.lede {
  max-width: 40rem; margin: 1.8rem auto 0;
  font-size: clamp(.92rem, 1.6vw, 1.02rem); line-height: 1.65; color: #9fabba;
  text-wrap: pretty;
}

.src-toggle {
  display: inline-flex; margin: 2rem 0 1.6rem; padding: 3px; gap: 3px;
  border: 1px solid #222c38; border-radius: 11px; background: #0b1016;
}
.seg {
  border: 0; background: transparent; color: #74808f;
  padding: .45rem 1.1rem; border-radius: 8px; font-size: .84rem;
}
.seg:hover { background: #141c25; color: #a6b2c0; }
.seg.on { background: #223040; color: #e8eef5; }

.src-note { margin: -1.1rem 0 1.4rem; font-size: .8rem; color: #67727f; min-height: 1.2em; }

#track-panel { margin: 0 auto 1.6rem; max-width: 34rem; }
#track-panel[hidden] { display: none; }
.file-btn { display: inline-block; cursor: pointer; }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-btn span {
  display: inline-block; padding: .55rem 1.1rem; border-radius: 9px;
  border: 1px solid #2c3b4a; background: #0f161e; color: #cfd9e4; font-size: .86rem;
}
.file-btn:hover span { border-color: #4a5e73; background: #141d27; }
.file-btn input:focus-visible + span { outline: 2px solid #2bb4c8; outline-offset: 2px; }
.art-row {
  display: flex; align-items: center; justify-content: center; gap: .7rem;
  flex-wrap: wrap; margin: 1.3rem 0 0;
}
.art-label { font-size: .64rem; letter-spacing: .15em; text-transform: uppercase; color: #5e6b7a; }
#art-status { font-size: .8rem; color: #8a95a3; }
.file-btn.sm span { padding: .35rem .8rem; font-size: .78rem; }
.file-hint { margin: .8rem 0 0; font-size: .76rem; color: #5a6472; line-height: 1.6; }
#track-list { list-style: none; margin: 1rem 0 0; padding: 0; text-align: left; font-size: .8rem; }
#track-list li {
  display: flex; gap: .55rem; align-items: baseline;
  padding: .22rem 0; color: #7d8794; border-bottom: 1px solid rgba(255,255,255,.05);
}
#track-list li:last-child { border-bottom: 0; }
#track-list .ok { color: #2bb4c8; }
#track-list .no { color: #4e5865; }
#track-list .fn { color: #6a7585; margin-left: auto; max-width: 48%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; direction: rtl; }

.engines {
  display: grid; gap: .75rem; text-align: left;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
}
.engine {
  display: grid; gap: .3rem; align-content: start;
  padding: 1.1rem 1.15rem 1rem; border-radius: 14px;
  border: 1px solid #1d2733; background: #0a0f15; color: inherit; text-align: left;
  transition: border-color .16s, background .16s, transform .1s;
}
.engine:hover { border-color: #3a4a5c; background: #0f161e; transform: translateY(-2px); }
.engine:active { transform: translateY(0); }
.engine:focus-visible { outline: 2px solid #2bb4c8; outline-offset: 2px; }
.e-name { font-size: 1.22rem; font-weight: 700; letter-spacing: -0.02em; color: #f0f4f8; }
.e-tag { font-size: .64rem; letter-spacing: .15em; text-transform: uppercase; color: #5e6b7a; }
.e-desc { margin-top: .45rem; font-size: .82rem; line-height: 1.55; color: #8a95a3; text-wrap: pretty; }
.e-sw { display: flex; gap: 4px; margin-top: .85rem; }
.e-sw i { width: 22px; height: 5px; border-radius: 3px; display: block; }

button { font: inherit; cursor: pointer; }
.hint { margin: 1.8rem 0 0; font-size: .78rem; color: #5a6472; line-height: 1.7; }
.err { margin-top: .9rem; color: #ff6b6b; font-size: .85rem; }
.err[hidden] { display: none; }

/* ---- hud ---- */
#hud {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem;
  padding: 1.1rem clamp(1rem, 3vw, 2.2rem) clamp(1rem, 3vw, 1.8rem);
  background: linear-gradient(to top, rgba(0,0,0,.72), rgba(0,0,0,0));
  pointer-events: none; transition: opacity .35s;
}
#hud[hidden] { display: none; }
body.setlist-open #hud { padding-right: calc(var(--setlist-w) + 1.2rem); }
#hud.dim { opacity: 0; }
.hud-left { display: flex; align-items: center; gap: .9rem; min-width: 0; }

.transport { display: flex; gap: .3rem; pointer-events: auto; flex: none; }
.transport button {
  width: 2.1rem; height: 2.1rem; display: grid; place-items: center;
  border-radius: 8px; border: 1px solid rgba(255,255,255,.14);
  background: rgba(10,14,19,.55); color: #c2ccd8; font-size: .72rem; line-height: 1;
  backdrop-filter: blur(8px); transition: background .14s, border-color .14s, color .14s;
}
.transport button:hover { background: rgba(30,42,56,.85); border-color: rgba(255,255,255,.3); color: #fff; }
.transport button:active { transform: translateY(1px); }
.transport button:focus-visible { outline: 2px solid #2bb4c8; outline-offset: 2px; }
.transport button.off { color: #6b7684; }
#c-back { border-color: rgba(255,255,255,.22); }
.track { font-variant-numeric: tabular-nums; color: #7d8794; font-size: .8rem; letter-spacing: .08em; }
.track .sep { opacity: .4; margin: 0 .15em; }
.titles { min-width: 0; }
#h-title {
  font-size: clamp(1.15rem, 3.2vw, 2rem); font-weight: 700; letter-spacing: -0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 2px 18px rgba(0,0,0,.9);
}
#h-artist { font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: #93a0b0; }

.hud-right { display: flex; align-items: center; gap: .9rem; flex: none; }
.meter { width: 14px; height: 14px; }
.beat {
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; opacity: .15; transform: scale(.6);
  transition: transform .06s linear, opacity .06s linear;
}
.bpm { display: flex; align-items: baseline; gap: .25rem; font-variant-numeric: tabular-nums; }
#h-bpm { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.bpm small { font-size: .62rem; letter-spacing: .14em; color: #7d8794; }
.conf { width: 44px; height: 3px; border-radius: 2px; background: rgba(255,255,255,.14); overflow: hidden; }
.conf > div { height: 100%; width: 0; background: #2bb4c8; transition: width .25s; }
.viz, .src {
  font-size: .65rem; letter-spacing: .12em; text-transform: uppercase;
  padding: .3rem .55rem; border-radius: 6px;
  border: 1px solid rgba(255,255,255,.16); color: #b9c3cf; white-space: nowrap;
}
.src { border-color: rgba(43,180,200,.5); color: #2bb4c8; }
.presence { border-color: rgba(255,255,255,.22); color: #93a0b0; }
.presence.texture  { border-color: rgba(120,200,160,.5); color: #7fd3a8; }
.presence.showcase { border-color: rgba(255,170,70,.55); color: #ffb347; }
.src.demo { border-color: rgba(255,106,0,.55); color: #ff8c33; }

/* ---- setlist ---- */
#setlist {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 25;
  width: var(--setlist-w); padding: clamp(1.2rem, 3vw, 2rem);
  background: rgba(6,9,13,.9); backdrop-filter: blur(16px);
  border-left: 1px solid rgba(255,255,255,.08);
  overflow-y: auto;
}
#setlist[hidden] { display: none; }
#setlist h2 { margin: 0 0 1rem; font-size: .7rem; letter-spacing: .18em; text-transform: uppercase; color: #7d8794; font-weight: 600; }
#setlist ol { list-style: none; margin: 0; padding: 0; }
#setlist li {
  display: grid; grid-template-columns: 1.4rem 1fr auto; gap: .7rem; align-items: center;
  padding: .55rem .6rem; border-radius: 8px; cursor: pointer;
  border-left: 2px solid transparent;
}
#setlist li:hover { background: rgba(255,255,255,.05); }
#setlist li.active { background: rgba(255,255,255,.08); border-left-color: var(--accent, #2bb4c8); }
#setlist .num { font-variant-numeric: tabular-nums; color: #5f6a78; font-size: .8rem; }
#setlist .nm { min-width: 0; display: block; }
#setlist .t { display: block; font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#setlist .a { display: block; font-size: .74rem; color: #7d8794; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#setlist .sw { display: flex; gap: 3px; flex: none; }
#setlist .sw i { width: 9px; height: 18px; border-radius: 2px; display: block; }
.keys {
  margin-top: 1.6rem; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; flex-wrap: wrap; gap: .5rem 1rem; font-size: .72rem; color: #6c7684;
}
kbd {
  font: inherit; font-size: .68rem; padding: .1em .4em; margin-right: .15em;
  border: 1px solid rgba(255,255,255,.18); border-bottom-width: 2px; border-radius: 4px; color: #aab4c0;
}

/* ---- milkdrop style gallery ---- */
.styles-wrap { max-width: 82rem; margin: 0 auto; padding: 2.2rem 1.2rem 3rem; text-align: center; overflow-y: auto; height: 100%; }
body.expanded .styles-wrap { max-width: none; padding: 0; }
body.expanded .styles-wrap > :not(#panel) { display: none; }
body.expanded .styles-bar { position: fixed; inset: auto auto 1rem 50%; transform: translateX(-50%); z-index: 5; }
.styles-h1 { margin: 0; font-size: clamp(2rem, 5.5vw, 3.2rem); font-weight: 800; letter-spacing: -0.04em;
  background: linear-gradient(100deg, #2bb4c8, #ffd98a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lede.dim { color: #7d8794; font-size: .86rem; }
.lede.dim b { color: #cbd5e1; }
#start-wrap { margin: 1.8rem 0; }
.styles-bar { display: flex; gap: .7rem; align-items: center; justify-content: center; flex-wrap: wrap;
  margin: 1.2rem 0; padding: .5rem .8rem; border-radius: 999px; background: rgba(10,14,20,.75);
  border: 1px solid #1b2430; backdrop-filter: blur(10px); }
.dimlabel { font-size: .76rem; color: #7d8794; font-variant-numeric: tabular-nums; }
.dimlabel b { color: #e6edf4; font-size: 1rem; }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .7rem; }
@media (max-width: 62rem) { .grid { grid-template-columns: repeat(2, 1fr); } }
.tile { margin: 0; cursor: pointer; position: relative; border-radius: 10px; overflow: hidden;
  border: 1px solid #1b2430; transition: border-color .15s, transform .12s; }
.tile:hover { border-color: #3c4b5c; transform: translateY(-2px); }
.tile canvas { width: 100%; aspect-ratio: 16 / 10; display: block; background: #05070a; }
.tile figcaption { position: absolute; inset: auto 0 0 0; padding: .5rem .6rem;
  background: linear-gradient(to top, rgba(0,0,0,.82), rgba(0,0,0,0)); text-align: left; pointer-events: none; }
.tile figcaption b { display: block; font-size: .82rem; color: #eef3f8; }
.tile figcaption span { font-size: .66rem; color: #93a0b0; }
.tile.failed canvas { background: #1a0d0d; }
.tile.big { grid-column: 1 / -1; }
.tile.big canvas { aspect-ratio: auto; height: 100vh; }
body.expanded .grid { grid-template-columns: 1fr; gap: 0; }
body.expanded .tile { border: 0; border-radius: 0; }
