:root {
  color-scheme: dark;
  --bg: #111315;
  --panel: #1b2024;
  --panel-strong: #22292f;
  --text: #f4f1e8;
  --muted: #9da7ad;
  --line: #3a4248;
  --accent: #f2b84b;
  --accent-2: #47c1b2;
  --danger: #ee5f63;
  --button: #e7e0cf;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 24% 18%, rgba(71, 193, 178, 0.16), transparent 32rem),
    linear-gradient(145deg, #111315 0%, #171b1f 54%, #101214 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
audio {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  width: 100vw;
  height: 100vh;
  padding: 18px;
}

.stage-panel,
.control-panel {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(27, 32, 36, 0.78);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

.stage-panel {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
}

#stage {
  width: 100%;
  height: 100%;
  display: block;
}

.meter-strip {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  pointer-events: none;
}

.meter {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background: rgba(10, 12, 14, 0.52);
}

.meter span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  text-transform: uppercase;
}

.meter i {
  width: 0%;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--danger));
  transition: width 60ms linear;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  border-radius: 8px;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 27px;
  line-height: 1.05;
  letter-spacing: 0;
}

.sync-state {
  min-width: 72px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.sync-state.live {
  border-color: rgba(71, 193, 178, 0.6);
  color: var(--accent-2);
}

.file-picker {
  display: grid;
  place-items: center;
  min-height: 54px;
  border: 1px dashed rgba(242, 184, 75, 0.56);
  border-radius: 8px;
  background: rgba(242, 184, 75, 0.08);
  color: var(--button);
  cursor: pointer;
}

.file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-picker span {
  max-width: 100%;
  overflow: hidden;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

audio {
  width: 100%;
  min-width: 0;
  min-height: 44px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

button {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background: var(--button);
  color: #171310;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.05);
}

#resetButton,
.mode-tabs button,
.source-tabs button {
  background: var(--panel-strong);
  color: var(--text);
}

.control-grid {
  display: grid;
  gap: 12px;
}

.control-grid label {
  display: grid;
  gap: 7px;
}

.control-grid span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.readout {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.readout div {
  display: grid;
  gap: 6px;
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}

.readout span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.readout strong {
  font-size: 18px;
}

.mode-tabs,
.source-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.mode-tabs button,
.source-tabs button {
  min-height: 36px;
  border: 0;
}

.mode-tabs button.active,
.source-tabs button.active {
  background: var(--accent-2);
  color: #071311;
}

@media (max-width: 900px) {
  body {
    overflow: auto;
    overflow-x: hidden;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .stage-panel {
    min-height: 58vh;
  }

  .control-panel {
    overflow: visible;
  }
}

@media (max-width: 560px) {
  .app-shell {
    gap: 12px;
    padding: 8px;
  }

  .control-panel {
    padding: 12px;
  }

  .meter-strip,
  .readout,
  .button-row,
  .mode-tabs,
  .source-tabs {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }
}
