:root {
  color-scheme: dark;
  --bg: #07040d; --panel: #110b1c; --panel2: #1a1129; --line: #2e2343; --text: #efe9ff; --dim: #9b8fb5;
  --pink: #ff2bd6; --cyan: #00e5ff; --lime: #39ff14; --warn: #ffcc00; --red: #ff3355;
  --r: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 13px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel2); border-radius: 8px; padding: 6px 10px; }
button:hover { border-color: #4b3a6b; }
button.on { background: #3a0f45; border-color: var(--pink); box-shadow: 0 0 0 1px var(--pink) inset; }
input[type=text], input[type=search], input[type=number], input:not([type]), select, textarea { background: #0b0714; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; min-width: 0; }
input[type=range] { accent-color: var(--pink); }
input[type=checkbox] { accent-color: var(--pink); }
h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--dim); margin: 0 0 8px; font-weight: 700; }
.muted { color: var(--dim); }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }

/* header */
header { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: #0c0716; flex-wrap: wrap; }
.logo { font: 900 26px/1 Impact, "Arial Black", sans-serif; letter-spacing: .08em; background: linear-gradient(90deg, var(--pink), #ffee00, var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); display: inline-block; }
.dot.ok { background: var(--lime); box-shadow: 0 0 8px var(--lime); }
.bpm { display: flex; align-items: center; gap: 4px; padding: 4px 6px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.bpm b { font: 800 22px/1 ui-monospace, Menlo, monospace; min-width: 66px; text-align: center; }
.bpm button { padding: 4px 7px; }
.meter { font-size: 12px; padding: 3px 4px; }
.beats { display: flex; gap: 4px; }
.beats i { width: 14px; height: 14px; border-radius: 4px; background: #241a35; display: block; }
.beats i.on { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.beats i.on:first-child { background: var(--pink); box-shadow: 0 0 10px var(--pink); }
.master { display: flex; align-items: center; gap: 6px; }
.safe.on { background: #0f3a1a; border-color: var(--lime); box-shadow: 0 0 0 1px var(--lime) inset; }
.hype { width: 70px; height: 10px; border-radius: 5px; background: #241a35; overflow: hidden; }
.hype i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ff6a00, #ff2050); transition: width .2s; }
.spacer { flex: 1; }

/* layout */
main { display: grid; grid-template-columns: 330px 1fr 340px; height: calc(100% - 52px); min-height: 0; }
main > * { min-height: 0; overflow: auto; }
aside { padding: 10px; display: flex; flex-direction: column; gap: 10px; }
aside.left { border-right: 1px solid var(--line); }
aside.right { border-left: 1px solid var(--line); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; }
.center { display: flex; flex-direction: column; min-width: 0; }

/* tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.tabs button { padding: 5px 9px; font-size: 12px; }

/* toolbar */
.toolbar { display: flex; gap: 6px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chip { padding: 4px 9px; border-radius: 999px; font-size: 12px; }
.chip kbd { margin-left: 5px; opacity: .7; font: inherit; font-size: 10px; }

/* device grid */
#gridView { padding: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; align-content: start; overflow: auto; flex: 1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; }
.card.targeted { border-color: var(--pink); box-shadow: 0 0 0 1px var(--pink); }
.card.sel { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan); }
.card.focus { outline: 2px dashed #fff; outline-offset: 2px; }
.card.off { opacity: .45; }
.card .pv { background: #000; display: flex; align-items: center; justify-content: center; height: 140px; cursor: pointer; position: relative; }
.card .pv canvas { max-width: 100%; max-height: 140px; display: block; }
.card .badge { position: absolute; left: 6px; top: 6px; font-size: 11px; padding: 2px 6px; border-radius: 6px; background: #000b; }
.card .body { padding: 8px; display: grid; gap: 5px; }
.card .name { font-weight: 700; background: transparent; border: 1px solid transparent; padding: 2px 4px; border-radius: 6px; width: 100%; }
.card .name:hover, .card .name:focus { border-color: var(--line); }
.card .meta { font-size: 11px; color: var(--dim); display: flex; gap: 8px; flex-wrap: wrap; }
.card .meta .bad { color: var(--warn); }
.card .row { gap: 4px; flex-wrap: nowrap; }
.card .row button { padding: 3px 6px; font-size: 12px; }
.card select, .card input.grp { font-size: 12px; padding: 3px 5px; }
.empty { padding: 40px; text-align: center; color: var(--dim); grid-column: 1 / -1; }
.empty img { width: 220px; height: 220px; background: #fff; border-radius: 12px; padding: 8px; }

/* stage */
#stageView { flex: 1; position: relative; min-height: 0; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: #05030a; touch-action: none; }
.stage-tools { position: absolute; left: 10px; top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.stage-help { position: absolute; right: 10px; bottom: 10px; color: var(--dim); font-size: 11px; text-align: right; pointer-events: none; }

/* pads */
.pads { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.pads .pad { padding: 14px 14px; }
.pad { padding: 14px 18px; font-weight: 800; letter-spacing: .04em; border-radius: 12px; user-select: none; touch-action: none; }
.pad.flash { background: #2a2a2a; }
.pad.strobe { background: #2a2a38; }
.pad.black { background: #000; }
.pad.drop { background: linear-gradient(90deg, #6a00ff, #ff0080); border: 0; }
.pad:active, .pad.active { filter: brightness(1.8); transform: translateY(1px); }
kbd { font: 10px ui-monospace, monospace; border: 1px solid #fff3; border-radius: 4px; padding: 0 4px; color: var(--dim); margin-left: 4px; }

/* effects */
.cat { margin-bottom: 10px; }
.fxs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }
.fx { text-align: left; font-size: 12px; padding: 6px 8px; position: relative; }
.fx .ps { color: var(--warn); margin-left: 3px; }
.fx.cur { border-color: var(--cyan); background: #0b2633; }
.fx:disabled { opacity: .3; cursor: not-allowed; }
.params { display: grid; gap: 8px; }
.param { display: grid; grid-template-columns: 96px 1fr auto; gap: 6px; align-items: center; font-size: 12px; }
.param label { color: var(--dim); }
.param input[type=color] { width: 100%; height: 26px; border: 1px solid var(--line); background: none; border-radius: 6px; padding: 0 2px; }
.param output { font: 11px ui-monospace, monospace; color: var(--dim); min-width: 34px; text-align: right; }
.palettes { display: flex; flex-wrap: wrap; gap: 4px; grid-column: 2 / 4; }
.palettes button { width: 34px; height: 18px; padding: 0; border-radius: 4px; }
.palettes button.on { outline: 2px solid #fff; }
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.presets button { font-size: 11px; padding: 8px 4px; min-height: 44px; }
.presets button .k { color: var(--dim); font-size: 10px; display: block; }
.presets.saving button { border-style: dashed; border-color: var(--warn); }

/* media */
#ytPlayer, #ytWrap iframe { width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; background: #000; display: block; }
.list { max-height: 200px; overflow: auto; display: grid; gap: 3px; margin-top: 6px; }
.list button { text-align: left; font-size: 12px; padding: 5px 7px; display: flex; gap: 8px; align-items: center; }
.list button img { width: 34px; height: 34px; border-radius: 4px; object-fit: cover; }
.list button.cur { border-color: var(--cyan); }
.now { font-weight: 700; margin: 6px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter { height: 40px; display: flex; gap: 2px; align-items: flex-end; background: #0b0714; border-radius: 6px; padding: 3px; }
.meter i { flex: 1; background: linear-gradient(0deg, var(--cyan), var(--pink)); border-radius: 2px; min-height: 1px; }
.progress { height: 8px; border-radius: 4px; background: #241a35; overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--pink)); transition: width .15s; }
.ptext { font-size: 11px; color: var(--dim); margin-top: 3px; }
.lyric-now { font-size: 15px; font-weight: 700; min-height: 22px; color: #fff; }
.lyric-next { font-size: 12px; color: var(--dim); min-height: 16px; }
textarea { width: 100%; min-height: 70px; font: 11px ui-monospace, monospace; }
.small { font-size: 11px; }
code { font: 11px ui-monospace, monospace; background: #0b0714; padding: 1px 4px; border-radius: 4px; word-break: break-all; }

/* dialogs */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 18px; max-width: 560px; }
dialog::backdrop { background: #000b; }
.join-qr { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.join-qr img { width: 220px; height: 220px; background: #fff; border-radius: 12px; padding: 8px; }
.urls { display: grid; gap: 4px; font: 12px ui-monospace, monospace; }

.gate { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: radial-gradient(circle at 30% 20%, #3a0a5a, transparent 55%), #050009f2; }
.gate .box { max-width: 560px; }
.gate .warn { border: 2px solid var(--warn); background: #2a2000; color: #fff4c8; border-radius: 14px; padding: 14px 16px; font-size: 14px; line-height: 1.5; }
.gate .warn strong { color: var(--warn); }
.gate .row { margin-top: 14px; }
.gate .row button { padding: 12px 16px; font-weight: 800; font-size: 14px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #000d; border: 1px solid var(--line); padding: 8px 14px; border-radius: 10px; opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 60; }
.toast.show { opacity: 1; }

@media (max-width: 1100px) {
  main { grid-template-columns: 1fr; height: auto; }
  main > * { overflow: visible; }
  aside.left, aside.right { border: 0; }
  #stageView { min-height: 420px; }
  #gridView { max-height: none; }
}

.notice { border: 1px solid var(--warn); background: #2a2000; color: #fff4c8; border-radius: 8px; padding: 8px 10px; margin-top: 8px; font-size: 12px; line-height: 1.4; }
a.bm { display: inline-block; padding: 3px 9px; border-radius: 7px; background: linear-gradient(90deg, var(--pink), var(--cyan)); color: #000; font-weight: 800; text-decoration: none; cursor: grab; }
details summary { cursor: pointer; font-size: 12px; }

/* banks */
.cat h2 { cursor: pointer; display: flex; align-items: center; gap: 6px; }
.cat h2 kbd { margin: 0; }
.cat:not(.active) .fxs { display: none; }
.cat:not(.active) h2:hover { color: var(--text); }
.cat.active h2 { color: var(--cyan); }
.fx kbd.k { margin: 0 6px 0 0; color: var(--cyan); border-color: #00e5ff55; }
.palette { width: min(560px, 92vw); padding: 12px; }
.palette input { width: 100%; font-size: 16px; padding: 10px 12px; }
.palette .list { max-height: 60vh; }
.palette .list button { display: flex; gap: 8px; align-items: center; }
.palette .list button.cur { border-color: var(--cyan); background: #0b2633; }
table.keys { border-collapse: collapse; font-size: 13px; }
table.keys td { padding: 3px 10px 3px 0; vertical-align: top; }
table.keys kbd { margin: 0 2px 0 0; font-size: 11px; color: var(--text); }

.card .size { align-items: center; }
.card .size input.diag { width: 52px; font-size: 11px; padding: 2px 4px; }
.card .size button { padding: 1px 5px; font-size: 12px; }
.card.crowd .badge::after { content: ' · 🕺 crowd'; }

/* room editor */
.stage-tools input[type=number] { width: 62px; padding: 3px 5px; font-size: 12px; }
.stage-tools .tabs button { padding: 5px 10px; }
.tray { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 6px 10px; border: 1px dashed #4a3a66; border-radius: 10px; background: #0d0718cc; min-height: 36px; }
.tray .chip { cursor: grab; touch-action: none; }
.stage-help { bottom: 58px; }
.inspector { position: absolute; right: 10px; top: 56px; width: 230px; background: #0d0718ee; border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; gap: 6px; font-size: 12px; }
.inspector label { display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 6px; }
.inspector input, .inspector select { width: 100%; padding: 3px 5px; font-size: 12px; }
.stage3d { position: absolute; inset: 0; perspective: 1800px; overflow: hidden; background: radial-gradient(circle at 50% 30%, #140a24, #05030a); cursor: grab; touch-action: none; }
.world3d { position: absolute; left: 0; top: 0; transform-style: preserve-3d; transform-origin: 0 0; }
.face3d, .dev3d { position: absolute; left: 0; top: 0; transform-origin: 0 0; backface-visibility: hidden; }
.face3d.wall { background: linear-gradient(#ffffff08 1px, transparent 1px) 0 0 / 50px 50px, linear-gradient(90deg, #ffffff08 1px, transparent 1px) 0 0 / 50px 50px, #120c1ecc; outline: 1px solid #ffffff30; }
.face3d.floor { background: linear-gradient(#ffffff0a 1px, transparent 1px) 0 0 / 50px 50px, linear-gradient(90deg, #ffffff0a 1px, transparent 1px) 0 0 / 50px 50px, #0b0814; outline: 1px solid #ffffff40; backface-visibility: visible; }
.face3d.table { background: #4a301a; outline: 1px solid #8a6a44; backface-visibility: visible; }
.face3d.wall::after { content: attr(data-label); position: absolute; left: 6px; top: 4px; font: 700 14px system-ui; color: #ffffff40; }
.dev3d { outline: 1px solid #ffffff60; box-shadow: 0 0 20px #00000080; }

/* target chips scroll sideways instead of wrapping, so selecting a screen
   never changes the toolbar height (and never shifts the room view) */
#targets { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: thin; }
.toolbar { flex-wrap: nowrap; }
.toolbar .chip { white-space: nowrap; }
.toolbar .tabs { flex-wrap: nowrap; flex: none; }
#targets { flex: 1; min-width: 0; }
.inspector { top: auto; right: auto; left: 10px; bottom: 58px; }

/* group sections in the Screens view */
.group-head { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-left: 4px solid var(--gc, var(--line)); background: #120c1e; border-radius: 8px; margin-top: 4px; }
.group-head .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gc); display: block; }
.group-head .gname { font-weight: 800; background: transparent; border: 1px solid transparent; width: 160px; }
.group-head .gname:hover, .group-head .gname:focus { border-color: var(--line); }
.group-head button { padding: 3px 8px; font-size: 12px; }
.group-head button.span.on { background: #3a0f45; border-color: var(--pink); }

/* autopilot dialog */
.ap-dlg { width: min(760px, 94vw); }
.ap-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center; }
.ap-grid label { display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.lanes { display: grid; gap: 6px; max-height: 50vh; overflow: auto; }
.lane { display: grid; grid-template-columns: 210px 1fr; gap: 4px 10px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #0d0718; }
.lane.off { opacity: .45; }
.lane .pool { grid-column: 1 / 3; display: flex; gap: 4px; flex-wrap: wrap; }
.lane select { grid-column: 1 / 2; }
.room-code { font: 800 15px/1 ui-monospace, monospace; letter-spacing: .14em; padding: 6px 10px; }
.join-code { font: 900 44px/1.1 ui-monospace, monospace; letter-spacing: .18em; margin: 6px 0; }
.urls a { color: var(--cyan, #00e5ff); word-break: break-all; }
#ctlUrl { word-break: break-all; }
.xfer { margin: 6px 0 0; }
.xfer .bar { height: 6px; border-radius: 3px; background: #ffffff1a; overflow: hidden; }
.xfer .bar i { display: block; height: 100%; background: linear-gradient(90deg, #ff2bd6, #00e5ff); width: 0; transition: width .3s; }
