:root {
  --bg: #0b0c10;
  --bg-2: #12141b;
  --panel: rgba(16, 18, 24, 0.92);
  --line: rgba(255, 214, 160, 0.14);
  --text: #f4eee4;
  --muted: #9a9084;
  --accent: #ff8a2a;
  --accent-2: #ffd29a;
  --hit: #ffe7b8;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --sans: "Sora", "Segoe UI", sans-serif;
  --display: "Oswald", "Sora", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1200px 700px at 50% 18%, #1c1712 0%, var(--bg) 58%);
  color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
}
button, input, select { font-family: inherit; }

body:not(.is-open) .app,
body:not(.is-open) .overlay,
body:not(.is-open) .toast {
  display: none !important;
}

#gate {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: radial-gradient(900px 520px at 50% 20%, #1c1712 0%, #0b0c10 62%);
}
body.is-open #gate { display: none; }

.gate-card {
  width: min(420px, 92vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px 24px 22px;
  text-align: center;
}
.gate-card h1 {
  margin: 12px 0 6px;
  font-family: var(--display);
  letter-spacing: 0.12em;
  font-size: 28px;
}
.gate-card p {
  color: var(--muted);
  margin: 0 0 18px;
  font-size: 14px;
}
.gate-card input[type="password"] {
  width: 100%;
  background: #0f1117;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px;
}
.gate-card button {
  margin-top: 12px;
  width: 100%;
  background: linear-gradient(180deg, #ff9a3c, #e36a12);
  color: #1a1008;
  border: 0;
  border-radius: 10px;
  padding: 12px 14px;
  font-weight: 700;
  cursor: pointer;
}
.gate-card button:disabled { opacity: .55; cursor: wait; }
#gateError { min-height: 20px; margin: 10px 0 0; color: #ff8d8d; font-size: 13px; }
#gate.shake .gate-card { animation: gateShake .35s ease; }
@keyframes gateShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.app {
  height: 100vh;
  display: grid;
  grid-template-rows: 64px 1fr 72px;
}

.topbar, .dock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: linear-gradient(180deg, rgba(0,0,0,.35), transparent);
  border-bottom: 1px solid var(--line);
}
.dock {
  border-bottom: 0;
  border-top: 1px solid var(--line);
  background: rgba(8, 9, 12, 0.88);
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: conic-gradient(from 210deg, #ff6a00, #ffd27a, #ff6a00);
  display: grid;
  place-items: center;
  color: #1a1008;
  font-weight: 700;
}
.brand h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: 0.12em;
  font-weight: 600;
}
.brand small {
  display: block;
  color: var(--muted);
  letter-spacing: 0.18em;
  font-size: 9px;
  text-transform: uppercase;
}

.status {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}
.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255,255,255,.03);
}
.pill.on { color: #9dffb0; border-color: rgba(157,255,176,.3); }

.stage {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.stage::before {
  content: "";
  position: absolute;
  inset: auto 10% 4% 10%;
  height: 90px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.55), transparent 70%);
  filter: blur(8px);
  pointer-events: none;
}

.kit-wrap {
  width: min(1280px, 96vw);
  height: min(78vh, 820px);
  position: relative;
}
svg.kit {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 18px 24px rgba(0,0,0,.45));
}
.piece { cursor: pointer; }
.piece .shell { transition: filter .12s ease, transform .08s ease; }
.piece.hit .head-hit { opacity: 1; }
.head-hit {
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}
.key-tag {
  font-family: var(--display);
  font-size: 18px;
  fill: #fff6e8;
  paint-order: stroke;
  stroke: rgba(0,0,0,.65);
  stroke-width: 4px;
  pointer-events: none;
}
.key-tag.dual { fill: var(--accent-2); }
.labels-off .key-tag { display: none; }

.hint {
  position: absolute;
  left: 24px;
  bottom: 18px;
  color: var(--muted);
  font-size: 12px;
  max-width: 320px;
  line-height: 1.45;
}

.dock-group { display: flex; gap: 8px; align-items: center; }
.dock button, .icon-btn {
  background: #171920;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}
.dock button.active, .icon-btn.active {
  background: linear-gradient(180deg, #ff9a3c, #e36a12);
  color: #1a1008;
  border-color: transparent;
  font-weight: 700;
}

.sliders {
  display: flex;
  gap: 18px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}
.sliders label { display: grid; gap: 4px; min-width: 140px; }
input[type="range"] {
  appearance: none;
  height: 4px;
  background: #2a2d36;
  border-radius: 99px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.overlay {
  position: fixed;
  inset: 64px 0 96px 0;
  background: rgba(4,5,8,.55);
  display: none;
  z-index: 20;
}
.topbar, .dock { position: relative; z-index: 30; }
.overlay.open { display: block; }
.panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(920px, 94vw);
  max-height: 84vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 22px;
}
.panel h2 {
  margin: 0 0 6px;
  font-family: var(--display);
  letter-spacing: 0.08em;
}
.panel p.lead { color: var(--muted); margin: 0 0 18px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255,255,255,.03);
  cursor: pointer;
}
.card:hover, .card.selected { border-color: var(--accent); }
.card h3 { margin: 0 0 6px; font-size: 16px; }
.card p { margin: 0; color: var(--muted); font-size: 12px; }

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.row input[type="text"] {
  flex: 1;
  min-width: 160px;
  background: #0f1117;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
}

.keys-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.keys-table th, .keys-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
}
.keys-table kbd {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  border-radius: 6px;
  background: #0f1117;
  border: 1px solid var(--line);
  font-family: var(--display);
}
.listen {
  outline: 2px solid var(--accent);
  background: rgba(255,138,42,.12);
}

.vol-grid {
  display: grid;
  grid-template-columns: 140px 1fr 48px;
  gap: 8px 12px;
  align-items: center;
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 92px;
  background: #171920;
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 10px;
  display: none;
  z-index: 30;
}
.toast.show { display: block; }

.chk, .sliders .chk {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  min-width: auto;
}
.rev-box {
  min-width: 190px;
}
.rev-box .chk {
  min-width: auto;
}
.panel-wide {
  width: min(1180px, 98vw);
}
.mixer-board {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 10px;
}
.mix-strip {
  flex: 0 0 94px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 7px 10px;
  display: grid;
  justify-items: center;
  gap: 5px;
}
.mix-sep {
  flex: 0 0 6px;
  align-self: stretch;
  margin: 8px 4px;
  border-radius: 99px;
  background: rgba(255, 138, 42, 0.35);
}
.mix-name {
  font-size: 11px;
  text-align: center;
  line-height: 1.2;
  min-height: 28px;
}
.eq-visual, .comp-visual {
  width: 68px;
  height: 36px;
  display: block;
}
.comp-visual { height: 28px; }
.eq-sliders {
  display: grid;
  gap: 2px;
  width: 100%;
  font-size: 9px;
  color: var(--muted);
}
.eq-sliders label, .mix-strip .tiny {
  display: grid;
  gap: 1px;
  width: 100%;
  font-size: 9px;
  color: var(--muted);
}
.mix-strip .tiny.chk {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text);
}
.mix-strip input[type="range"] {
  width: 100%;
}
.mix-strip .fader {
  width: 6px;
  height: 88px;
  writing-mode: vertical-lr;
  direction: rtl;
  appearance: none;
  background: #2a2d36;
}
.mix-gain {
  font-size: 11px;
  color: var(--accent-2);
}
.overlay { inset: 64px 0 118px 0; }

.topbar { gap: 12px; flex-wrap: wrap; height: auto; min-height: 64px; padding: 10px 22px; }
.dock { flex-wrap: wrap; min-height: 72px; height: auto; padding: 10px 16px; }
.sliders { flex-wrap: wrap; }

@media (max-width: 860px) {
  .brand small, .hint { display: none; }
  .app { grid-template-rows: auto 1fr auto; }
  .sliders label { min-width: 110px; }
}
