/* BBTRON-5K — performance desk theme */
:root {
  --bg: #07080d;
  --bg2: #0c0e16;
  --panel: #10131f;
  --panel2: #151a2b;
  --line: #222a40;
  --ink: #e8edff;
  --dim: #8a93b4;
  --dimmer: #5a6484;
  --cyan: #00e5ff;
  --magenta: #ff3d7f;
  --amber: #ffb300;
  --green: #00ff9d;
  --red: #ff4056;
  --violet: #7c4dff;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 800px at 70% -10%, #131a2e 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
kbd {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 4px;
  padding: 1px 5px; font-size: 11px; color: var(--cyan);
}

#app { display: flex; flex-direction: column; height: 100vh; padding: 10px; gap: 10px; }

/* ---------- top bar ---------- */
#topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 12px;
}
.brand { font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.brand .logo { color: var(--cyan); text-shadow: 0 0 12px var(--cyan); }
.accent { color: var(--magenta); }
.group { display: flex; align-items: center; gap: 8px; }
.right-group { margin-left: auto; }

.btn {
  background: var(--panel2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 11px; font-family: var(--mono); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all .12s ease; white-space: nowrap;
}
.btn:hover { border-color: var(--cyan); color: #fff; box-shadow: 0 0 10px rgba(0,229,255,.25); }
.btn:active { transform: translateY(1px); }
.btn.big { padding: 9px 18px; font-size: 14px; }
.btn.tiny { padding: 4px 9px; }
.btn.small { padding: 5px 9px; font-size: 11px; }
.btn.toggle.active { background: var(--cyan); color: #001018; border-color: var(--cyan); box-shadow: 0 0 14px rgba(0,229,255,.5); }
.btn.danger { border-color: #5a2230; color: #ff9aa8; }
.btn.danger:hover { background: var(--red); color: #fff; border-color: var(--red); box-shadow: 0 0 12px rgba(255,64,86,.5); }
#playBtn.playing { background: var(--green); color: #002417; border-color: var(--green); box-shadow: 0 0 16px rgba(0,255,157,.5); }
.glow { animation: pulseGlow 1.8s ease-in-out infinite; }
@keyframes pulseGlow { 0%,100% { box-shadow: 0 0 10px rgba(0,229,255,.3);} 50% { box-shadow: 0 0 26px rgba(0,229,255,.7);} }

.bpm-box { display: flex; align-items: center; gap: 6px; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 3px 6px; }
.bpm-read { text-align: center; min-width: 52px; }
.bpm-read span { font-size: 18px; font-weight: 700; color: var(--cyan); }
.bpm-read small { display: block; font-size: 8px; color: var(--dim); letter-spacing: 1px; }
.bpm-box.locked { opacity: .6; }
.qsel { color: var(--dim); font-size: 11px; display: flex; align-items: center; gap: 4px; }
.qsel select { background: var(--panel2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 4px; font-family: var(--mono); }

.beatdots { display: flex; gap: 5px; }
.beatdots .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--panel2); border: 1px solid var(--line); }
.beatdots .dot.on { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.beatdots .dot.downbeat.on { background: var(--magenta); box-shadow: 0 0 8px var(--magenta); }

.meter-pair { display: flex; gap: 6px; }
.meter { display: flex; align-items: center; gap: 4px; font-size: 9px; color: var(--dim); }
.meter canvas { width: 60px; height: 12px; background: var(--bg2); border: 1px solid var(--line); border-radius: 3px; }

/* ---------- main layout ---------- */
main {
  flex: 1; display: grid; gap: 10px; min-height: 0;
  grid-template-columns: minmax(300px, 1fr) minmax(380px, 1.25fr);
  grid-template-rows: 1.5fr 1fr;
}
.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; min-height: 0;
}
.panel-title { font-size: 11px; letter-spacing: 2px; color: var(--dim); margin-bottom: 10px; text-transform: uppercase; }
.panel-title small { color: var(--dimmer); letter-spacing: 0; margin-left: 8px; font-size: 10px; }
#kaossSection { grid-row: 1 / span 2; }

/* ---------- kaoss ---------- */
.programs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.prog {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 7px;
  padding: 8px 4px; text-align: center; font-size: 11px; font-weight: 600; cursor: pointer;
  color: var(--dim); transition: all .12s;
}
.prog:hover { color: #fff; }
.prog.active { color: #001018; }
.pad-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
#xypad {
  width: 100%; aspect-ratio: 1 / 1; max-height: 100%;
  background: radial-gradient(circle at 50% 50%, #0a1020, #05070d);
  border: 1px solid var(--line); border-radius: 10px; cursor: crosshair;
  box-shadow: inset 0 0 40px rgba(0,0,0,.6);
}
.pad-controls { display: flex; align-items: center; gap: 10px; }
.hint { color: var(--dimmer); font-size: 10px; }

/* ---------- loop lanes ---------- */
.lanes { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; min-height: 0; }
.lane {
  display: grid; grid-template-columns: 34px 40px 1fr auto; align-items: center; gap: 8px;
  background: var(--bg2); border: 1px solid var(--line); border-left: 3px solid var(--line);
  border-radius: 8px; padding: 5px 8px; transition: border-color .15s;
}
.lane[data-state="recording"] { border-left-color: var(--red); animation: recPulse 1s infinite; }
.lane[data-state="overdub"] { border-left-color: var(--amber); }
.lane[data-state="playing"] { border-left-color: var(--green); }
.lane[data-state="armed"] { border-left-color: var(--cyan); animation: recPulse .5s infinite; }
@keyframes recPulse { 0%,100% { background: var(--bg2);} 50% { background: #1a1220;} }
.lane-num { font-size: 13px; font-weight: 700; color: var(--dim); text-align: center; }
.lane .rec {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 50%;
  width: 30px; height: 30px; color: var(--dim); cursor: pointer; font-size: 14px; line-height: 1;
}
.lane[data-state="recording"] .rec, .lane[data-state="armed"] .rec { color: var(--red); border-color: var(--red); }
.lane[data-state="playing"] .rec { color: var(--green); border-color: var(--green); }
.lane[data-state="overdub"] .rec { color: var(--amber); border-color: var(--amber); }
.lane .wave { width: 100%; min-width: 0; height: 36px; display: block; background: #06080f; border-radius: 4px; cursor: default; }
.lane[data-state="playing"] .wave, .lane[data-state="overdub"] .wave { cursor: pointer; }
.lane-ctl { display: flex; align-items: center; gap: 4px; }
.lane-ctl button { width: 24px; height: 24px; padding: 0; font-size: 11px; }
.lane-ctl .slice, .lane-ctl .smode { width: 26px; font-size: 10px; color: var(--dim); }
.lane-ctl .slice.active { background: var(--violet); color: #fff; border-color: var(--violet); }
.lane-ctl .smode.active { background: var(--cyan); color: #001018; border-color: var(--cyan); }
.lane-ctl .mute.active { background: var(--amber); color: #201400; border-color: var(--amber); }
.lane-ctl .solo.active { background: var(--cyan); color: #001018; border-color: var(--cyan); }
.lane-ctl .vol { width: 60px; accent-color: var(--cyan); }

/* ---------- pads ---------- */
.pad-tools { float: right; display: inline-flex; gap: 6px; }
.pad-tools .btn { padding: 3px 8px; font-size: 10px; }
#sampleBtn.active, #resampleBtn.active { background: var(--red); color: #fff; border-color: var(--red); animation: pulseGlow 1s infinite; }
.pads { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 1fr; gap: 8px; flex: 1; min-height: 0; }
.pad {
  background: linear-gradient(180deg, var(--panel2), var(--bg2));
  border: 1px solid var(--line); border-radius: 9px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--ink); font-weight: 700; font-size: 12px; transition: border-color .08s, box-shadow .08s, transform .08s;
  position: relative; overflow: hidden; touch-action: none;
}
.pad .padwave { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: .9; }
.pad:hover { border-color: var(--magenta); }
.pad.hit { border-color: var(--magenta); box-shadow: inset 0 0 24px rgba(255,61,127,.55), 0 0 18px rgba(255,61,127,.5); transform: scale(.97); }
.pad.recording { border-color: var(--red); box-shadow: inset 0 0 20px rgba(255,64,86,.4); animation: recPulse .7s infinite; }
.pad.dragover { border-color: var(--green); border-style: dashed; }
.pad .kh { position: absolute; top: 5px; left: 7px; font-size: 9px; color: var(--dim); font-weight: 600; z-index: 2; }
.pad .label { position: relative; z-index: 2; text-shadow: 0 1px 4px rgba(0,0,0,.8); }
.pad .empty { color: var(--dimmer); font-weight: 500; font-size: 10px; }

/* ---------- footer ---------- */
#status { display: flex; align-items: center; gap: 12px; padding: 6px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); font-size: 11px; }
.pill { background: var(--bg2); border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px; color: var(--dim); }
.pill.ok { color: var(--green); border-color: #1a4a35; }
.statusmsg { color: var(--cyan); }
.latency { margin-left: auto; color: var(--dimmer); }
#midiLearnBtn.active { background: var(--violet); color: #fff; border-color: var(--violet); animation: pulseGlow 1s infinite; }
.learnable { outline: 2px dashed var(--violet) !important; outline-offset: 2px; cursor: help !important; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(4,5,10,.86); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; z-index: 50; }
.overlay.hidden { display: none; }
.start-card { text-align: center; padding: 40px; }
.start-card h1 { font-size: 44px; margin: 8px 0; letter-spacing: 2px; }
.start-card p { color: var(--dim); }
.start-logo { font-size: 60px; color: var(--cyan); text-shadow: 0 0 30px var(--cyan); animation: pulseGlow 2s infinite; }
.tiny-note { font-size: 11px; color: var(--dimmer); margin-top: 20px; }
#help { flex-direction: column; align-items: center; color: var(--ink); }
.help-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 26px 34px; max-width: 640px; }
.help-card h2 { margin-top: 0; color: var(--cyan); }
.help-card table { width: 100%; border-collapse: collapse; font-size: 12px; }
.help-card td { padding: 4px 8px; border-bottom: 1px solid var(--line); }
.help-card td:first-child { color: var(--amber); white-space: nowrap; }
.help-card .close { margin-top: 16px; }

/* ---------- guided tour ---------- */
.tour-blocker.hidden, .tour-hl.hidden, .tour-card.hidden { display: none; }
.tour-blocker { position: fixed; inset: 0; z-index: 90; background: transparent; cursor: pointer; }
.tour-hl {
  position: fixed; z-index: 91; pointer-events: none; border-radius: 10px;
  border: 2px solid var(--cyan);
  box-shadow: 0 0 0 9999px rgba(3, 4, 9, 0.78), 0 0 22px rgba(0,229,255,.55);
  transition: left .28s ease, top .28s ease, width .28s ease, height .28s ease;
}
.tour-card {
  position: fixed; z-index: 92; background: var(--panel);
  border: 1px solid var(--cyan); border-radius: 12px; padding: 16px 18px;
  box-shadow: 0 8px 40px rgba(0,0,0,.6), 0 0 24px rgba(0,229,255,.15);
  transition: left .28s ease, top .28s ease;
}
.tour-card h3 { margin: 2px 0 8px; color: var(--cyan); font-size: 15px; padding-right: 22px; }
.tour-close {
  position: absolute; top: 8px; right: 10px; background: none; border: none;
  color: var(--dimmer); font-size: 16px; cursor: pointer; font-family: var(--mono); padding: 2px 6px;
}
.tour-close:hover { color: var(--red); }
.tour-keys { font-size: 9.5px; color: var(--dimmer); margin-top: 8px; text-align: right; }
.tour-card p { margin: 0 0 12px; font-size: 12.5px; line-height: 1.55; color: var(--ink); }
.tour-card p b { color: #fff; }
.tour-step { font-size: 10px; color: var(--dimmer); letter-spacing: 1px; }
.tour-nav { display: flex; align-items: center; gap: 6px; }
.tour-spacer { flex: 1; }
.tour-skip { color: var(--dimmer); border-color: transparent; }
.tour-next { background: var(--cyan); color: #001018; border-color: var(--cyan); }

/* ---------- help FAB ---------- */
#helpFab { position: fixed; right: 18px; bottom: 52px; z-index: 80; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#fabBtn {
  width: 44px; height: 44px; border-radius: 50%; font-size: 20px; font-weight: 700;
  background: var(--panel2); color: var(--cyan); border: 1px solid var(--cyan);
  cursor: pointer; box-shadow: 0 2px 16px rgba(0,229,255,.25); transition: all .15s;
  font-family: var(--mono);
}
#fabBtn:hover { background: var(--cyan); color: #001018; box-shadow: 0 0 22px rgba(0,229,255,.6); }
#fabMenu { display: flex; flex-direction: column; gap: 6px; }
#fabMenu.hidden { display: none; }
#fabMenu .btn { box-shadow: 0 4px 18px rgba(0,0,0,.5); }

/* ---------- lane hints ---------- */
.lane { position: relative; }
.lane-hint {
  position: absolute; left: 92px; right: 130px; top: 50%; transform: translateY(-50%);
  font-size: 10px; color: var(--dim); pointer-events: none; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; z-index: 3;
  text-shadow: 0 1px 4px rgba(0,0,0,.9);
}
.lane[data-state="recording"] .lane-hint, .lane[data-state="armed"] .lane-hint { color: var(--ink); }

/* ---------- capture-armed banner ---------- */
.arm-banner {
  background: var(--red); color: #fff; font-weight: 700; font-size: 11px;
  border-radius: 7px; padding: 6px 10px; margin-bottom: 8px; text-align: center;
  animation: armPulse .8s infinite;
}
.arm-banner.hidden { display: none; }
@keyframes armPulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

@media (max-width: 860px) {
  main { grid-template-columns: 1fr; grid-template-rows: auto auto auto; }
  #kaossSection { grid-row: auto; }
}
