* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #0d0f12;
  --surface: #14171c;
  --surface-2: #1b1f26;
  --surface-3: #232831;
  --border: rgba(236, 239, 244, 0.08);
  --border-strong: rgba(236, 239, 244, 0.16);
  --text: #eceff4;
  --text-2: #9aa3b2;
  --muted: #636c7a;
  --accent: #e59a3c;
  --accent-ink: #0d0f12;
  --green: #38b272;
  --red: #d9534f;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
  min-height: 100%;
}

.hidden { display: none !important; }

.shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.status-dot.online { background: var(--green); }
.status-dot.offline { background: var(--red); }

.brand-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.brand-sep {
  width: 1px;
  height: 14px;
  background: var(--border-strong);
}

.brand-role {
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.mono-meta {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}

.status-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}
.status-text.live { color: var(--green); }

/* Buttons */
button, .btn-file {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  font-weight: 500;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid transparent;
  transition: background-color 0.14s ease, border-color 0.14s ease, transform 0.08s ease;
}
button:active, .btn-file:active { transform: scale(0.98); }

.btn-primary {
  background: var(--text);
  color: var(--accent-ink);
}
.btn-primary:hover { background: #ffffff; }
.btn-primary.playing {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-quiet {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.btn-quiet:hover { border-color: var(--border-strong); }
.btn-quiet.active {
  background: var(--surface-3);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger {
  background: rgba(217, 83, 79, 0.12);
  color: #f09592;
  border-color: rgba(217, 83, 79, 0.28);
}

.btn-xs { padding: 6px 10px; font-size: 12px; }
.btn-full { width: 100%; padding: 12px 16px; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* Picker */
.picker-wrap { max-width: 720px; margin: 28px auto; }
.picker-head { margin-bottom: 20px; }
.picker-head h1 { margin: 0 0 8px; font-size: 22px; font-weight: 600; }
.picker-head p { margin: 0; color: var(--text-2); }
.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.role-card {
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text);
}
.role-card:hover { border-color: var(--border-strong); background: var(--surface-2); }
.role-kicker { font-size: 12px; color: var(--accent); margin-bottom: 6px; }
.role-title { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.role-desc { font-size: 13px; color: var(--text-2); font-weight: 400; }

/* Media Panel */
.banner-warn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(229, 154, 60, 0.1);
  border: 1px solid rgba(229, 154, 60, 0.3);
  border-radius: 12px;
  margin-bottom: 12px;
  color: var(--text);
  font-size: 13px;
}

.media-top-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}

.code-display {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.code-digits {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 32px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.12em;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--accent);
  user-select: all;
}

.code-timer { font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; margin-bottom: 4px; }
.code-note { font-size: 12px; color: var(--muted); max-width: 240px; }

.visualizer {
  width: 100%;
  height: 72px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: block;
  margin-bottom: 12px;
}

.media-xfader-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.decks-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}

.deck-track-name {
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.deck-track-sub {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 10px;
}

.seek-row { margin-bottom: 10px; }

.deck-controls-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-play-sq { width: 42px; height: 36px; padding: 0; }
.deck-controls-row .mono-meta { margin-left: auto; }

.library-count {
  margin-left: 8px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.library-panel.dragover { border-color: var(--accent); }

.track-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 360px;
  overflow-y: auto;
}

.track-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid transparent;
}
.track-row.on-a { border-color: rgba(229, 154, 60, 0.35); }
.track-row.on-b { border-color: rgba(56, 178, 114, 0.35); }

.track-info { min-width: 0; flex: 1; }
.track-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-sub { font-size: 12px; color: var(--muted); }
.track-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* Join Screen */
.join-wrap { max-width: 420px; margin: 36px auto; }
.join-panel h1 { font-size: 20px; font-weight: 600; margin: 8px 0; }
.join-panel p { color: var(--text-2); margin: 0 0 16px; }
.code-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.16em;
  text-align: center;
  padding: 12px;
  margin-bottom: 12px;
  outline: none;
}
.code-input:focus { border-color: var(--accent); }
.error-box {
  background: rgba(217, 83, 79, 0.12);
  border: 1px solid rgba(217, 83, 79, 0.3);
  color: #f09592;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* DJ Console */
.dj-overview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.dj-deck-mini { padding: 12px; margin-bottom: 8px; }
.mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}
.deck-badge { font-size: 12px; font-weight: 600; color: var(--accent); }
.mini-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 8px;
}
.mini-progress {
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}
.mini-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
}
.mini-actions { display: flex; gap: 6px; }
.btn-play-mini { flex: 1; }

.xfader-panel { padding: 10px 14px; margin-bottom: 12px; }
.xfader-row { display: flex; align-items: center; gap: 10px; }
.xfader-slider { flex: 1; }

.dj-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.dj-tab {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 10px 6px;
  font-size: 12px;
}
.dj-tab.active {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--text);
}
.dj-tab-panel { display: none; }
.dj-tab-panel.active { display: block; }

/* Jog Wheel */
.deck-workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.jog-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.jog-platter {
  position: relative;
  width: 196px;
  height: 196px;
  border-radius: 50%;
  background: radial-gradient(circle at center, #1b1f26 0%, #111318 42%, #0a0b0e 100%);
  border: 1px solid var(--border-strong);
  touch-action: none;
  cursor: grab;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.jog-platter:active { cursor: grabbing; }

.jog-grooves {
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 1px solid rgba(236, 239, 244, 0.06);
  box-shadow: inset 0 0 0 14px rgba(255, 255, 255, 0.015), inset 0 0 0 28px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.jog-marker {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  pointer-events: none;
}
.jog-marker::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 50%;
  width: 4px;
  height: 16px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--accent);
}

.jog-center {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.jog-center-time {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.jog-center-pitch {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.deck-transport-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

/* Rotary Knobs */
.knobs-grid-5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.knobs-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.knob-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.knob-wrap {
  width: 64px;
  height: 64px;
  position: relative;
  touch-action: none;
  cursor: ns-resize;
  user-select: none;
}
.knob-svg { width: 64px; height: 64px; display: block; }
.knob-cap {
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  pointer-events: none;
}
.knob-pointer {
  position: absolute;
  top: 4px;
  left: 50%;
  width: 2px;
  height: 11px;
  margin-left: -1px;
  background: var(--text);
  border-radius: 1px;
}
.knob-label { font-size: 12px; color: var(--text-2); text-align: center; }
.knob-val {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.kill-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.kill-btn.active {
  background: rgba(217, 83, 79, 0.18);
  border-color: var(--red);
  color: #f09592;
}

.faders-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.fader-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.fader-box-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-2);
}

/* Range sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--text);
  border: 1px solid var(--border-strong);
  cursor: pointer;
}

/* FX & Switches */
.fx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.fx-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fx-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 500;
}
.fx-note { font-size: 12px; color: var(--muted); }

.hw-switch {
  -webkit-appearance: none;
  appearance: none;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  position: relative;
  cursor: pointer;
}
.hw-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-2);
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.hw-switch:checked { border-color: var(--accent); }
.hw-switch:checked::after {
  transform: translateX(18px);
  background: var(--accent);
}

/* Sampler Pads */
.sampler-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.pad-btn {
  padding: 16px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
}
.pad-btn:active {
  background: var(--surface-3);
  border-color: var(--accent);
  color: var(--accent);
}

.search-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 10px;
  outline: none;
}
.search-input:focus { border-color: var(--accent); }

@media (max-width: 640px) {
  .knobs-grid-5 { grid-template-columns: repeat(3, 1fr); }
  .faders-split { grid-template-columns: 1fr; }
  .sampler-grid { grid-template-columns: repeat(2, 1fr); }
  .dj-tab { font-size: 11px; padding: 9px 4px; }
}
