:root {
  --bg: #0a0a0c;
  --panel: #16171b;
  --panel-2: #1d1f25;
  --panel-3: #23262e;
  --line: #2c3038;
  --line-2: #3a3f4a;
  --text: #e9ecf2;
  --muted: #868d9c;
  --dim: #7c8290;
  --red: #ff3b30;
  --orange: #ff9f0a;
  --yellow: #ffd60a;
  --green: #30d158;
  --blue: #0a84ff;
  --cyan: #40e0ff;
  --purple: #bf5af2;
  --metal: linear-gradient(180deg, #2a2d35 0%, #1a1c22 100%);
  --radius: 10px;
  --mono: "SF Mono", ui-monospace, "Roboto Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: #060608;
  color: var(--text);
  font-family: -apple-system, "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font-family: inherit; }

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1400px 700px at 50% -20%, #1a1d24 0%, #060608 60%);
}

/* ===== Top bar ===== */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 18px;
  background: linear-gradient(180deg, #1c1e24, #121317);
  border-bottom: 1px solid #000;
  box-shadow: 0 1px 0 #2a2d35 inset, 0 4px 18px rgba(0,0,0,.5);
  position: sticky; top: 0; z-index: 60;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand .logo {
  font-weight: 800; font-size: 20px; letter-spacing: .12em;
  background: linear-gradient(180deg, #fff, #9aa0ad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand .model { font-size: 12px; color: var(--muted); letter-spacing: .18em; font-family: var(--mono); }
.brand .tag { font-size: 10px; color: var(--dim); letter-spacing: .1em; }
.topbar .spacer { flex: 1; }
.status-pill {
  font-size: 11px; color: var(--muted); border: 1px solid var(--line);
  padding: 5px 11px; border-radius: 999px; display: flex; align-items: center; gap: 7px;
  font-family: var(--mono);
}
.status-pill .led { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-pill.off .led { background: var(--red); box-shadow: 0 0 8px var(--red); }

.power-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--metal); border: 1px solid var(--line-2); color: var(--text);
  padding: 8px 16px; border-radius: 9px; cursor: pointer; font-size: 13px; font-weight: 600;
  box-shadow: 0 1px 0 #444a57 inset, 0 2px 6px rgba(0,0,0,.4);
}
.power-btn:hover { filter: brightness(1.12); }
.power-btn .pdot { width: 9px; height: 9px; border-radius: 50%; background: #555; }
.power-btn.on .pdot { background: var(--green); box-shadow: 0 0 10px var(--green); }

.rec-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--metal); border: 1px solid var(--line-2); color: var(--text);
  padding: 8px 16px; border-radius: 9px; cursor: pointer; font-size: 13px; font-weight: 600;
  box-shadow: 0 1px 0 #444a57 inset, 0 2px 6px rgba(0,0,0,.4);
}
.rec-btn:hover { filter: brightness(1.12); }
.rec-btn .rdot { width: 9px; height: 9px; border-radius: 50%; background: #555; }
.rec-btn.recording { border-color: var(--red); }
.rec-btn.recording .rdot { background: var(--red); box-shadow: 0 0 10px var(--red); animation: recpulse 1s ease-in-out infinite; }
@keyframes recpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ===== Mixer deck layout ===== */
.mixer {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0,1fr) 300px;
  gap: 0;
  padding: 14px;
  max-width: 1720px;
  width: 100%;
  margin: 0 auto;
}
.decks-area {
  display: flex; flex-direction: column; gap: 14px; min-width: 0;
}
.channels {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}
.channel {
  background: linear-gradient(180deg, #191b21 0%, #121318 100%);
  border: 1px solid #000;
  border-radius: var(--radius);
  box-shadow: 0 1px 0 #2a2d35 inset, 0 3px 10px rgba(0,0,0,.4);
  padding: 10px 8px 12px;
  display: flex; flex-direction: column; gap: 9px;
  position: relative;
  min-width: 0;
}
.channel.loaded { border-color: #2e3440; }
.channel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
}
.ch-num {
  font-family: var(--mono); font-weight: 700; font-size: 15px;
  color: #cfd4de; width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: #0d0e12; border: 1px solid var(--line-2);
  box-shadow: 0 0 0 1px #000 inset;
}
.ch-num.on { color: #fff; border-color: var(--cyan); box-shadow: 0 0 12px rgba(64,224,255,.4); }
.ch-assign {
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 6px; cursor: pointer; user-select: none;
  background: #0d0e12; border: 1px solid var(--line-2); color: var(--dim);
}
.ch-assign.A { color: var(--cyan); border-color: #1d4a57; }
.ch-assign.B { color: var(--orange); border-color: #553a12; }

.ch-title {
  font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; min-height: 14px; text-align: center;
  font-family: var(--mono);
}
.ch-load {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px dashed var(--line-2); border-radius: 8px; padding: 7px;
  cursor: pointer; font-size: 11.5px; color: var(--muted); background: #0c0d11;
}
.ch-load:hover { border-color: var(--cyan); color: var(--text); }
.ch-load input { display: none; }
.ch-load.loaded { border-style: solid; border-color: #2c313b; color: var(--text); }

.ch-transport {
  display: flex; gap: 5px;
}
.tbtn {
  flex: 1; background: var(--metal); border: 1px solid var(--line-2); color: var(--text);
  border-radius: 7px; padding: 7px 0; cursor: pointer; font-size: 13px;
  box-shadow: 0 1px 0 #3a3f4a inset;
}
.tbtn:hover { filter: brightness(1.15); }
.tbtn:active { transform: translateY(1px); }
.tbtn.play.on { background: linear-gradient(180deg,#1f6b2e,#144a20); border-color: var(--green); color: #b8ffc8; box-shadow: 0 0 10px rgba(48,209,88,.35); }
.tbtn.cue.on { background: linear-gradient(180deg,#6b5a10,#4a3e0a); border-color: var(--yellow); color: #fff3b0; }
.tbtn.loop.on { background: linear-gradient(180deg,#0a4a6b,#083a52); border-color: var(--cyan); color: #b0f0ff; }

.ch-time {
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  display: flex; justify-content: space-between; padding: 0 2px;
}
.ch-progress {
  height: 4px; background: #0a0b0e; border-radius: 999px; overflow: hidden; cursor: pointer;
}
.ch-progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--blue)); }

.ch-knobs {
  display: flex; justify-content: space-around; gap: 2px;
}
.ch-knobs.eq4 { gap: 0; }
.ch-sends {
  display: flex; justify-content: space-around; gap: 0;
  padding-top: 4px; border-top: 1px solid #1f232b; margin-top: 2px;
}
.knob-wrap { display: flex; flex-direction: column; align-items: center; gap: 2px; touch-action: none; }
.knob-svg { cursor: ns-resize; filter: drop-shadow(0 2px 3px rgba(0,0,0,.5)); }
.knob-label { font-size: 9px; color: var(--dim); font-family: var(--mono); letter-spacing: .05em; text-transform: uppercase; }

.ch-filter {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.filter-scale { display: flex; justify-content: space-between; width: 100%; font-size: 9px; color: var(--dim); font-family: var(--mono); }

.ch-fader-row { display: flex; gap: 6px; align-items: stretch; justify-content: center; padding-top: 2px; }
.vfader {
  position: relative; width: 34px; display: flex; flex-direction: column;
  align-items: center; touch-action: none; padding: 2px 0;
}
.vfader-track {
  position: absolute; top: 0; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 6px; background: #0a0b0e; border-radius: 999px;
  border: 1px solid #000; box-shadow: 0 0 0 1px #262a32 inset;
  overflow: hidden;
}
.vfader-fill { position: absolute; bottom: 0; left: 0; right: 0; width: 100%; opacity: .85; }
.vfader-cap {
  position: absolute; left: 50%; transform: translateX(-50%);
  width: 30px; height: 18px; border-radius: 4px;
  background: linear-gradient(180deg, #4a4f5a, #2a2d35);
  border: 1px solid #0a0b0e; box-shadow: 0 1px 0 #5a606d inset, 0 2px 5px rgba(0,0,0,.6);
  cursor: ns-resize; z-index: 2;
}
.vfader-cap::after { content: ""; position: absolute; left: 4px; right: 4px; top: 50%; height: 1px; background: #cfd4de; transform: translateY(-50%); }
.vfader-scale {
  position: absolute; right: -2px; top: 0; bottom: 0; display: flex;
  flex-direction: column; justify-content: space-between; font-size: 8px; color: var(--dim);
  font-family: var(--mono); pointer-events: none;
}

.meter-v {
  width: 8px; display: flex; flex-direction: column; gap: 2px; padding: 2px 0;
  background: #0a0b0e; border-radius: 4px; border: 1px solid #000;
}
.meter-v .meter-seg { flex: 1; border-radius: 1px; background: #232833; min-height: 3px; }
.meter-h { display: flex; gap: 2px; height: 10px; background: #0a0b0e; border-radius: 4px; padding: 1px; border: 1px solid #000; }
.meter-h .meter-seg { flex: 1; border-radius: 1px; background: #232833; }

/* ===== Center / master section ===== */
.bottom-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) 250px;
  gap: 14px;
}
.crossfader-panel, .master-panel {
  background: linear-gradient(180deg, #191b21 0%, #121318 100%);
  border: 1px solid #000; border-radius: var(--radius);
  box-shadow: 0 1px 0 #2a2d35 inset, 0 3px 10px rgba(0,0,0,.4);
  padding: 14px 18px;
}
.panel-label { font-size: 10px; color: var(--dim); letter-spacing: .18em; text-transform: uppercase; font-family: var(--mono); margin-bottom: 10px; }

.hfader { position: relative; touch-action: none; padding: 6px 0; }
.hfader-track {
  position: relative; height: 14px; background: #0a0b0e; border-radius: 999px;
  border: 1px solid #000; box-shadow: 0 0 0 1px #262a32 inset;
}
.hfader-cap {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 32px; height: 30px; border-radius: 6px;
  background: linear-gradient(180deg, #4a4f5a, #2a2d35);
  border: 1px solid #0a0b0e; box-shadow: 0 1px 0 #5a606d inset, 0 3px 7px rgba(0,0,0,.6);
  cursor: ew-resize;
}
.hfader-cap::after { content: ""; position: absolute; top: 5px; bottom: 5px; left: 50%; width: 1px; background: #cfd4de; transform: translateX(-50%); }
.cross-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--dim); font-family: var(--mono); margin-top: 6px; }

.cross-extras { display: flex; gap: 14px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.curve-select { display: flex; gap: 6px; align-items: center; }
.curve-select .panel-label { margin: 0; }
.curve-btn {
  background: var(--metal); border: 1px solid var(--line-2); color: var(--muted);
  border-radius: 6px; padding: 5px 10px; font-size: 11px; cursor: pointer; font-family: var(--mono);
}
.curve-btn.on { color: var(--text); border-color: var(--cyan); box-shadow: 0 0 8px rgba(64,224,255,.3); }

/* Master panel */
.master-panel { display: flex; flex-direction: column; gap: 12px; }
.master-meters { display: flex; gap: 6px; justify-content: center; align-items: flex-end; height: 120px; }
.master-meters .meter-v { width: 12px; height: 100%; }
.clip-label { text-align: center; font-family: var(--mono); font-size: 9px; letter-spacing: .18em; color: #3a2020; margin-top: 4px; transition: color .1s, text-shadow .1s; }
.clip-label.on { color: #ef4444; text-shadow: 0 0 6px #ef4444; }
.master-knobs { display: flex; justify-content: space-around; }

/* ===== FX panels ===== */
.fx-area {
  display: flex; flex-direction: column; gap: 14px;
}
.fx-inline {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 14px;
}
.fx-inline .fx-panel { height: 100%; }
.bottom-left { display: flex; flex-direction: column; gap: 14px; }
.beatfx-wrap { display: block; }
.beatfx-wrap .fx-panel { flex-direction: row; flex-wrap: wrap; align-items: flex-start; gap: 16px; }
.beatfx-wrap .beatfx-grid { flex: 1 1 420px; }
.beatfx-wrap .beat-rate { flex: 0 0 auto; }
.beat-rate-col { display: flex; flex-direction: column; gap: 6px; }
.beatfx-wrap .beatfx-depth { flex: 1 1 100%; }
.beatfx-wrap .fx-head { flex: 1 1 100%; }
.beatfx-wrap > .fx-panel > .fx-sub { flex: 0 0 auto; align-self: center; }
.fx-panel {
  background: linear-gradient(180deg, #191b21 0%, #111217 100%);
  border: 1px solid #000; border-radius: var(--radius);
  box-shadow: 0 1px 0 #2a2d35 inset, 0 3px 10px rgba(0,0,0,.4);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.fx-head { display: flex; align-items: center; justify-content: space-between; }
.fx-title { font-size: 12px; font-weight: 700; letter-spacing: .12em; color: #cfd4de; font-family: var(--mono); }
.fx-sub { font-size: 10px; color: var(--dim); }

.beatfx-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.beatfx-btn {
  background: var(--metal); border: 1px solid var(--line-2); color: var(--muted);
  border-radius: 7px; padding: 8px 4px; font-size: 10.5px; cursor: pointer;
  font-family: var(--mono); letter-spacing: .02em; transition: all .12s;
  box-shadow: 0 1px 0 #3a3f4a inset;
}
.beatfx-btn:hover { color: var(--text); filter: brightness(1.12); }
.beatfx-btn.on {
  color: #0a0a0c; font-weight: 700;
  background: linear-gradient(180deg, var(--cyan), #1a9fc0);
  border-color: var(--cyan); box-shadow: 0 0 12px rgba(64,224,255,.5);
}
.beatfx-depth { display: flex; align-items: center; gap: 10px; }
.beatfx-depth .knob-wrap { flex-shrink: 0; }
.beat-rate {
  display: flex; gap: 4px; flex-wrap: wrap;
}
.rate-btn {
  background: #0d0e12; border: 1px solid var(--line-2); color: var(--dim);
  border-radius: 5px; padding: 4px 7px; font-size: 9.5px; cursor: pointer; font-family: var(--mono);
}
.rate-btn.on { color: var(--cyan); border-color: #1d4a57; }

.sendfx-row {
  display: flex; flex-direction: column; gap: 8px;
}
.sendfx-item {
  display: flex; align-items: center; gap: 8px;
  background: #0d0e12; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px;
}
.sendfx-name { font-size: 10.5px; font-family: var(--mono); color: var(--muted); width: 62px; flex-shrink: 0; }
.sendfx-item input[type=range] { flex: 1; accent-color: var(--purple); height: 4px; }
.sendfx-val { font-size: 9.5px; font-family: var(--mono); color: var(--dim); width: 26px; text-align: right; }

/* ===== Library / drawer ===== */
.library {
  background: linear-gradient(180deg, #191b21 0%, #121318 100%);
  border: 1px solid #000; border-radius: var(--radius);
  box-shadow: 0 1px 0 #2a2d35 inset, 0 3px 10px rgba(0,0,0,.4);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  max-height: calc(100vh - 90px);
  position: sticky; top: 70px;
}
.lib-head { display: flex; align-items: center; justify-content: space-between; }
.lib-title { font-size: 12px; font-weight: 700; letter-spacing: .1em; color: #cfd4de; font-family: var(--mono); }
.lib-tracks { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; flex: 1; }
.lib-track {
  display: flex; align-items: center; gap: 9px;
  background: #0d0e12; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; cursor: pointer; transition: all .12s;
}
.lib-track:hover { border-color: var(--cyan); background: #11151c; }
.lib-track .lt-icon { font-size: 15px; width: 20px; text-align: center; }
.lib-track .lt-body { flex: 1; min-width: 0; }
.lib-track .lt-name { font-size: 11.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-track .lt-meta { font-size: 9.5px; color: var(--dim); font-family: var(--mono); margin-top: 1px; }
.lib-track.loading { opacity: .5; pointer-events: none; }
.lib-upload {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px dashed var(--line-2); border-radius: 8px; padding: 11px;
  cursor: pointer; font-size: 12px; color: var(--muted); background: #0c0d11;
}
.lib-upload:hover { border-color: var(--cyan); color: var(--text); }
.lib-upload input { display: none; }
.lib-hint { font-size: 10px; color: var(--dim); line-height: 1.5; }
.lib-onboard { padding: 10px 12px; margin-bottom: 10px; border: 1px solid var(--line-2); border-radius: 8px; background: rgba(64,224,255,.05); }
.lib-onboard-title { font-size: 12px; font-weight: 700; color: var(--cyan); margin-bottom: 6px; letter-spacing: .04em; }
.lib-onboard-step { font-size: 11px; color: var(--text); line-height: 1.7; }

/* demo synth buttons */
.demo-row { display: flex; flex-direction: column; gap: 6px; }
.demo-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--metal); border: 1px solid var(--line-2); color: var(--text);
  border-radius: 8px; padding: 8px 10px; cursor: pointer; font-size: 11.5px;
  box-shadow: 0 1px 0 #3a3f4a inset; text-align: left;
}
.demo-btn:hover { filter: brightness(1.12); }
.demo-btn .db-ic { width: 18px; text-align: center; }
.demo-btn .db-meta { margin-left: auto; font-size: 9px; color: var(--dim); font-family: var(--mono); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: #1d1f25; border: 1px solid var(--line-2); color: var(--text);
  padding: 11px 18px; border-radius: 9px; font-size: 13px; opacity: 0; pointer-events: none;
  transition: all .25s; z-index: 200; box-shadow: 0 10px 40px rgba(0,0,0,.6); max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* responsive */
@media (max-width: 1280px) {
  .mixer { grid-template-columns: minmax(0, 1fr); }
  .library { position: static; max-height: 320px; order: -1; }
  .fx-inline { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .channels { grid-template-columns: repeat(3, 1fr); }
  .bottom-row { grid-template-columns: 1fr; }
  .fx-inline { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .channels { grid-template-columns: repeat(2, 1fr); }
  .brand .tag { display: none; }
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px; }
  .topbar .spacer { display: none; }
  .brand { flex: 1 1 auto; min-width: 0; }
  .brand .logo { font-size: 16px; }
  .status-pill { padding: 4px 9px; }
  .power-btn { padding: 7px 12px; }
  .power-btn, .rec-btn { min-height: 44px; }
  .lib-upload { min-height: 44px; }
  .vfader { overflow: visible; }
  .rate-btn { min-height: 44px; min-width: 44px; padding: 8px 10px; font-size: 11px; }
  .beatfx-btn { min-height: 44px; padding: 12px 4px; }
  .curve-btn { min-height: 44px; padding: 12px 10px; }
  .library { max-height: 150px; min-width: 0; }
  .decks-area, .channels { min-width: 0; }
  .knob-wrap { min-width: 44px; min-height: 44px; justify-content: center; }
  .tbtn { min-height: 44px; }
  .vfader { min-width: 44px; }
  .vfader-cap { width: 40px; }
  .hfader { min-height: 44px; padding: 9px 0; }
  .sendfx-item input[type=range] { height: 44px; }
  .sendfx-item { min-height: 44px; }
  .beatfx-depth input[type=range] { height: 44px; }
}

/* Keyboard focus visibility */
.knob-wrap:focus-visible,
.vfader:focus-visible,
.hfader:focus-visible,
input[type=range]:focus-visible,
button:focus-visible {
  outline: 2px solid #40e0ff;
  outline-offset: 2px;
  border-radius: 6px;
}
