:root {
  --bg: #0d0c12;
  --panel: #16141f;
  --panel-2: #1d1a29;
  --line: #2a2638;
  --text: #ece8f5;
  --muted: #9a94ad;
  --accent: #ff7a3d;
  --accent-ink: #1a0d05;
  --a: #4cc9f0;
  --b: #f72585;
  --ok: #5ee6a8;
  --warn: #ffd166;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #221a35 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}
h2 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0; font-weight: 600; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; transition: background .12s, border-color .12s;
}
button:hover { border-color: #4a4463; background: #252136; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
button.primary:hover { background: #ff8f5c; }
button.ghost { background: transparent; color: var(--muted); }
button.on { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
input[type="text"], select {
  background: #0f0d17; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; min-width: 0;
}
.muted { color: var(--muted); }

.start { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(8, 7, 12, .92); backdrop-filter: blur(6px); padding: 16px; }
.start[hidden] { display: none; }
.start-card { text-align: center; max-width: 420px; }
.logo { font-size: clamp(38px, 9vw, 60px); font-weight: 800; letter-spacing: -.02em; background: linear-gradient(90deg, var(--a), var(--accent), var(--b)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { color: var(--muted); margin: 6px 0 26px; font-size: 17px; }
button.big { font-size: 18px; padding: 14px 28px; border-radius: 999px; }
.fine { color: var(--muted); font-size: 12.5px; margin-top: 18px; }

header { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; letter-spacing: -.01em; font-size: 18px; }
.status { display: flex; align-items: center; gap: 12px; }
.pill { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-variant-numeric: tabular-nums; font-weight: 600; }
.beatdots { display: inline-flex; gap: 5px; }
.beatdots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.beatdots i.on { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.beatdots i.on:first-child { background: #fff; box-shadow: 0 0 10px #fff; }

main { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 12px 16px 16px; max-width: 1400px; width: 100%; margin: 0 auto; min-height: 0; }
.decks { display: grid; grid-template-columns: minmax(0, 1fr) 170px minmax(0, 1fr); gap: 12px; align-items: stretch; }
.deck { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0; position: relative; }
.deck[data-deck="A"] { --c: var(--a); }
.deck[data-deck="B"] { --c: var(--b); }
.deck.live { border-color: color-mix(in srgb, var(--c) 60%, var(--line)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--c) 25%, transparent), 0 10px 40px -20px var(--c); }
.deck-top { display: flex; gap: 10px; align-items: center; min-width: 0; }
.badge { flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); }
.art { flex: none; width: 44px; height: 44px; border-radius: 8px; background: var(--panel-2) center/cover; }
.meta { min-width: 0; flex: 1; }
.title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub a { text-decoration: underline; text-decoration-color: #4a4463; text-underline-offset: 2px; }
.nums { flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.bpm { font-weight: 700; font-size: 18px; color: var(--c); }
.key { color: var(--muted); font-size: 12.5px; }
.wave-wrap { position: relative; height: 84px; border-radius: 8px; background: #0f0d17; border: 1px solid var(--line); overflow: hidden; }
.wave-wrap canvas { width: 100%; height: 100%; display: block; cursor: pointer; }
.wave-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13.5px; pointer-events: none; text-align: center; padding: 0 12px; }
.progress { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--c); transition: width .15s; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; margin-left: auto; }
.knobs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 12px; }
.knob { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); min-width: 0; }
.knob input { width: 100%; accent-color: var(--c); }
.tag { font-size: 11.5px; border-radius: 999px; padding: 2px 8px; border: 1px solid var(--line); color: var(--muted); }
.tag.hot { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, transparent); }

.xfader { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; justify-content: center; text-align: center; }
.xfader label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.xf-row { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.xf-row span:first-child { color: var(--a); } .xf-row span:last-child { color: var(--b); }
.xf-row input { flex: 1; min-width: 0; accent-color: var(--accent); }

.drums { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.drums-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.drums-ctl { display: flex; gap: 8px; }
.sync { font-size: 13px; font-weight: 650; border-radius: 999px; padding: 4px 12px; border: 1px solid var(--line); color: var(--muted); font-variant-numeric: tabular-nums; }
.sync.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 55%, transparent); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.sync.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 55%, transparent); }
.sync.off { color: var(--muted); }
.grid { display: grid; gap: 5px; }
.grid-row { display: grid; grid-template-columns: 78px repeat(16, minmax(0, 1fr)); gap: 4px; align-items: center; }
.grid-row .name { font-size: 12.5px; color: var(--muted); text-align: left; background: none; border: 0; padding: 2px 0; }
.grid-row .name.muted-voice { text-decoration: line-through; opacity: .5; }
.cell { height: 24px; padding: 0; border-radius: 5px; background: #100e18; border: 1px solid var(--line); }
.cell.beat { background: #18152300; border-color: #3a3550; }
.cell.on { background: var(--accent); border-color: var(--accent); }
.cell.now { box-shadow: 0 0 0 2px #fff8; }

.lower { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 12px; min-height: 300px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 0; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.add, .cmd { display: flex; gap: 8px; }
.add input, .cmd input { flex: 1; }
.cmd input { padding: 12px 14px; font-size: 16px; border-color: #3a3550; }
.list { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; min-height: 120px; max-height: 46vh; }
.list li { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 7px 6px; border-radius: 8px; }
.list li:hover { background: var(--panel-2); }
.list li.onA { box-shadow: inset 3px 0 0 var(--a); } .list li.onB { box-shadow: inset 3px 0 0 var(--b); }
.list .n { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; font-size: 13px; }
.list .t { min-width: 0; }
.list .t b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .t span { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .acts { display: flex; gap: 4px; align-items: center; }
.list .acts button { padding: 3px 8px; font-size: 12px; }
.list .info { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; margin-right: 4px; white-space: nowrap; }
.empty { color: var(--muted); padding: 18px 6px; }
.credit { color: var(--muted); font-size: 12px; margin: 0; }
.log { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 8px; min-height: 140px; max-height: 46vh; padding-right: 4px; }
.msg { max-width: 92%; padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.you { align-self: flex-end; background: #2a2440; border: 1px solid #3a3550; }
.msg.dj { align-self: flex-start; background: #12101a; border: 1px solid var(--line); }
.msg.dj.err { border-color: color-mix(in srgb, var(--b) 55%, transparent); }
.msg.dj b { color: var(--accent); font-weight: 650; }
.msg table { border-collapse: collapse; } .msg td { padding: 2px 10px 2px 0; vertical-align: top; } .msg td:first-child { color: var(--accent); white-space: nowrap; font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { font-size: 12.5px; padding: 4px 10px; border-radius: 999px; color: var(--muted); }

.board { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.pads { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
.pad { min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-weight: 650; background: #100e18; }
.pad .k { font-size: 11px; color: var(--muted); font-weight: 500; }
.pad.empty { border-style: dashed; color: var(--muted); }
.pad b { font-weight: 650; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pad small { font-size: 11px; font-weight: 400; color: var(--muted); }
.pad.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.pad-tools { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
button.on-edit { border-color: var(--accent); color: var(--accent); }
.loop-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.loop-bar h2 { margin-right: 4px; }
.loop-bar #loopStatus { font-size: 13px; }
.pad-editor { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 14px; margin-top: 12px; padding: 12px; border: 1px dashed var(--line); border-radius: 10px; }
.pad-editor[hidden] { display: none; }
.pad-editor-head { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
.pad-editor label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); min-width: 0; }
.pad-editor select, .pad-editor input[type="text"] { width: 100%; }
.pad-editor-actions { display: flex; align-items: end; }
.pad-editor p { grid-column: 1 / -1; margin: 0; font-size: 13px; }
.pad:active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.synth { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px 14px; margin-top: 12px; }
.synth label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); min-width: 0; }
.synth select { width: 100%; }
.synth input[type="range"] { width: 100%; accent-color: var(--accent); }
.keys { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
.keys button { height: 40px; background: #f2ecff10; color: var(--text); }
.keys button:active { background: var(--accent); color: var(--accent-ink); }
@media (max-width: 900px) {
  .synth { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .keys { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .pads { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .decks { grid-template-columns: minmax(0, 1fr); }
  .xfader { order: 3; }
  .lower { grid-template-columns: minmax(0, 1fr); }
  .knobs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-row { grid-template-columns: 56px repeat(16, minmax(0, 1fr)); gap: 2px; }
}
