:root {
  --bg: #121318;
  --surface: #1b1d24;
  --surface-2: #232630;
  --surface-3: #2d313d;
  --line: #393d49;
  --text: #f7f3ed;
  --muted: #aaaeb9;
  --accent: #ff5a36;
  --accent-2: #21c7a8;
  --warn: #ffd166;
  --danger: #ff3b5c;
  --blue: #58a6ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  background:
    radial-gradient(circle at 28% -12%, rgba(255, 90, 54, 0.18), transparent 32rem),
    linear-gradient(140deg, #121318 0%, #16181f 54%, #101116 100%);
}

.rail {
  border-right: 1px solid var(--line);
  background: rgba(22, 24, 31, 0.94);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px 12px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #101218;
  border: 1px solid rgba(255, 90, 54, 0.45);
  box-shadow: 0 12px 28px rgba(255, 90, 54, 0.22);
  margin-bottom: 14px;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.rail-button,
.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
}

.rail-button.active,
.rail-button:hover,
.icon-button:hover {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
}

.workspace {
  padding: 18px;
  min-width: 0;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: center;
  gap: 16px;
  min-height: 72px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 29, 36, 0.84);
  box-shadow: var(--shadow);
}

.session-title {
  display: grid;
  gap: 4px;
}

.session-title label,
.metric-label,
.eyebrow {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.session-title input {
  min-width: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: clamp(1.15rem, 2vw, 1.7rem);
  font-weight: 750;
}

.transport {
  display: flex;
  align-items: center;
  gap: 10px;
}

.record-button,
.live-button,
.secondary-button,
.mini-button,
.chat-form button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-2);
  padding: 0 14px;
  font-weight: 700;
}

.record-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--danger);
  border-color: rgba(255, 255, 255, 0.14);
}

.record-button span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
}

.record-button.recording span {
  animation: pulse 1s ease-in-out infinite;
}

.live-button.live {
  background: var(--accent-2);
  color: #06231d;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(78px, 1fr));
  gap: 10px;
}

.status-strip div {
  min-width: 0;
  padding: 8px 10px;
  background: #15171d;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-strip strong {
  display: block;
  font-variant-numeric: tabular-nums;
}

.studio-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.85fr);
  grid-template-areas:
    "deck soundboard"
    "deck mixer"
    "playlist mixer"
    "chat notes";
  gap: 18px;
}

.deck,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 29, 36, 0.9);
  box-shadow: var(--shadow);
}

.deck {
  grid-area: deck;
  padding: 18px;
  min-width: 0;
}

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

.deck h1,
.panel h2 {
  margin: 0;
}

.deck h1 {
  font-size: clamp(1.9rem, 4vw, 3.7rem);
}

.panel h2 {
  font-size: 1rem;
}

.on-air,
.pill {
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  font-weight: 800;
}

.on-air.live {
  color: #06231d;
  background: var(--accent-2);
}

#waveform {
  width: 100%;
  height: clamp(190px, 28vw, 280px);
  display: block;
  margin: 18px 0 12px;
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    #101218;
  background-size: 100% 25%, 7% 100%;
}

.timeline {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.deck-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr)) auto;
  align-items: end;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.stream-link-box {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #15171d;
}

.stream-link-box > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stream-label,
.stream-link-box p {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

#streamStatus {
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 0.75rem;
}

.stream-link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.stream-link-row input {
  min-width: 0;
  min-height: 42px;
  color: var(--text);
  background: #101218;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  outline: 0;
}

.stream-link-box p {
  margin: 0;
  line-height: 1.35;
}

.device-grid label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.device-grid label span,
.device-status {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.device-grid select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  color: var(--text);
  background: #12141a;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  outline: 0;
}

.device-status {
  grid-column: 1 / -1;
  min-height: 18px;
}

.secondary-button:disabled {
  color: #777c88;
  cursor: not-allowed;
}

.listener-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.listener-shell {
  width: min(560px, 100%);
  display: grid;
  gap: 16px;
  justify-items: center;
  text-align: center;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 29, 36, 0.92);
  box-shadow: var(--shadow);
}

.listener-shell img {
  width: 116px;
  height: 116px;
  border-radius: 8px;
}

.listener-shell h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 3rem);
}

.listener-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #15171d;
  color: var(--muted);
}

.listener-status span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 5px rgba(33, 199, 168, 0.14);
}

.listener-shell audio {
  width: 100%;
}

#listenerMeta {
  margin: 0;
  color: var(--muted);
}

.panel {
  padding: 14px;
  min-width: 0;
}

.soundboard {
  grid-area: soundboard;
}

.mixer {
  grid-area: mixer;
}

.playlist {
  grid-area: playlist;
}

.chat {
  grid-area: chat;
}

.notes {
  grid-area: notes;
}

.mini-button {
  min-height: 32px;
  padding: 0 10px;
  color: var(--muted);
}

.pad-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.pad {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: linear-gradient(160deg, var(--surface-3), #181a21);
  font-weight: 800;
}

.pad.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 4px rgba(255, 90, 54, 0.1);
}

.channels {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.ducking-box,
.autodj-box {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #15171d;
}

.ducking-box label,
.autodj-box label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.ducking-box label span,
.autodj-box label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.switch-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
}

.switch-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-2);
}

.switch-row span {
  color: var(--text) !important;
  font-size: 0.92rem !important;
}

#duckingState,
#autoDjStatus,
#autoDjFadeValue {
  min-width: 68px;
  text-align: center;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 0.75rem;
}

#autoDjFadeValue {
  min-width: 42px;
}

#duckingState.active {
  color: #06231d;
  background: var(--accent-2);
  border-color: transparent;
}

.channel {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #171920;
}

.ducking-active .channel[data-channel="3"],
.ducking-active .channel[data-channel="4"] {
  border-color: rgba(33, 199, 168, 0.62);
}

.channel-name {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.channel-name strong {
  overflow: hidden;
  text-overflow: ellipsis;
}

.meter {
  height: 8px;
  background: #0d0f14;
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid #2c303a;
}

.meter span {
  display: block;
  height: 100%;
  width: 42%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--warn), var(--danger));
}

.mute {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-2);
}

.mute.muted {
  color: #fff;
  background: var(--danger);
}

.track-list,
.chat-log {
  margin: 14px 0 0;
  padding: 0;
}

.playlist-dropzone {
  display: grid;
  gap: 4px;
  place-items: center;
  min-height: 92px;
  margin-top: 14px;
  padding: 14px;
  border: 1px dashed rgba(33, 199, 168, 0.72);
  border-radius: 8px;
  background: rgba(33, 199, 168, 0.06);
  color: var(--text);
  text-align: center;
  outline: 0;
}

.playlist-dropzone span {
  color: var(--muted);
  font-size: 0.82rem;
}

.playlist-dropzone.drag-over,
.playlist-dropzone:focus-visible {
  border-color: var(--accent);
  background: rgba(255, 90, 54, 0.1);
  box-shadow: 0 0 0 4px rgba(255, 90, 54, 0.08);
}

.track-list {
  list-style: none;
  display: grid;
  gap: 8px;
}

.track-list li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 9px;
  border-radius: 8px;
  background: #171920;
  border: 1px solid var(--line);
}

.track-list li.playing {
  border-color: var(--accent-2);
  box-shadow: inset 0 0 0 1px rgba(33, 199, 168, 0.5);
}

.track-list button {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--surface-2);
}

.track-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.chat-log {
  display: grid;
  gap: 10px;
  max-height: 234px;
  overflow: auto;
}

.message {
  padding: 10px;
  border-radius: 8px;
  background: #171920;
  border: 1px solid var(--line);
}

.message strong {
  display: block;
  margin-bottom: 3px;
}

.message p {
  margin: 0;
  color: var(--muted);
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
}

.chat-form input,
.notes textarea {
  min-width: 0;
  color: var(--text);
  background: #12141a;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
}

.chat-form input {
  min-height: 42px;
  padding: 0 11px;
}

.notes textarea {
  width: 100%;
  min-height: 172px;
  resize: vertical;
  margin-top: 14px;
  padding: 12px;
  line-height: 1.45;
}

.markers {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.marker {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  color: var(--muted);
  background: #171920;
  font-size: 0.82rem;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.7);
    opacity: 0.58;
  }
}

@media (max-width: 1040px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .transport,
  .status-strip {
    justify-self: stretch;
  }

  .transport {
    flex-wrap: wrap;
  }

  .studio-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "deck"
      "mixer"
      "soundboard"
      "playlist"
      "chat"
      "notes";
  }

  .device-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stream-link-row {
    grid-template-columns: 1fr 1fr;
  }

  .stream-link-row input {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: sticky;
    top: 0;
    z-index: 3;
    min-height: 62px;
    flex-direction: row;
    justify-content: center;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand-mark {
    margin: 0 6px 0 0;
  }

  .workspace {
    padding: 12px;
  }

  .status-strip,
  .pad-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .channel {
    grid-template-columns: 1fr 40px;
  }

  .channel input,
  .meter {
    grid-column: 1 / -1;
  }

  .chat-form {
    grid-template-columns: 1fr;
  }

  .device-grid {
    grid-template-columns: 1fr;
  }

  .stream-link-row {
    grid-template-columns: 1fr;
  }
}
