:root {
  --bg: #070707;
  --panel: #111111;
  --panel-2: #171717;
  --border: #2b2b2b;
  --text: #f4f1ea;
  --muted: #b9b3a8;
  --accent: #8d5cff;
  --accent-2: #f2c15e;
  --danger: #f87171;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(141, 92, 255, 0.18), transparent 34rem),
    radial-gradient(circle at 88% 18%, rgba(242, 193, 94, 0.12), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.appShell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.stagePanel,
.controlPanel {
  border: 1px solid var(--border);
  background: rgba(17, 17, 17, 0.94);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.32);
}

.stagePanel {
  border-radius: 8px;
  padding: 18px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 14px;
}

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

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
  letter-spacing: 0;
}

p {
  margin: 8px 0 0;
  color: var(--muted);
}

.statusPill {
  min-width: 88px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 12px;
  background: #0c0c0c;
  color: var(--muted);
  text-align: center;
}

.statusPill.active {
  color: var(--text);
  border-color: rgba(141, 92, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(141, 92, 255, 0.13);
}

.canvasFrame {
  display: grid;
  place-items: center;
  min-height: 0;
  background: #000;
  border: 1px solid #1f1f1f;
  overflow: hidden;
}

canvas {
  width: min(100%, 74vh);
  max-height: 100%;
  aspect-ratio: 1128 / 1268;
  display: block;
}

.transport {
  display: grid;
  grid-template-columns: 1fr 1fr 1.3fr;
  gap: 10px;
}

button {
  border: 1px solid var(--border);
  background: #1a1a1a;
  color: var(--text);
  border-radius: 8px;
  padding: 13px 14px;
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.primaryBtn,
.exportBtn {
  border-color: transparent;
  background: linear-gradient(180deg, #a985ff, var(--accent));
}

.exportBtn {
  background: linear-gradient(180deg, #ffd681, var(--accent-2));
  color: #1d1300;
}

.meter {
  height: 30px;
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 5px;
  align-items: end;
}

.meter span {
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0.32;
  transition: height 80ms ease, opacity 80ms ease;
}

.controlPanel {
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  overflow: auto;
}

.controlGroup {
  display: grid;
  gap: 8px;
}

label,
.groupLabel {
  font-size: 13px;
  font-weight: 850;
  color: #eee8dd;
}

textarea,
select,
input[type="text"],
input[type="url"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #090909;
  color: var(--text);
  padding: 12px;
}

textarea {
  min-height: 170px;
  resize: vertical;
  line-height: 1.45;
}

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

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #090909;
}

.segmented label {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 12px;
  cursor: pointer;
}

.segmented label:has(input:checked) {
  background: rgba(141, 92, 255, 0.18);
  color: white;
}

.twoColumn {
  grid-template-columns: minmax(0, 1fr) 54px;
  align-items: center;
}

.twoColumn label {
  display: grid;
  gap: 6px;
}

output {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  color: var(--muted);
  text-align: center;
  background: #090909;
}

.hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
}

.hidden {
  display: none;
}

.statusBox {
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  color: var(--muted);
  background: #090909;
  line-height: 1.4;
}

.statusBox.error {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.6);
}

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

  canvas {
    width: min(100%, 68vh);
  }
}

@media (max-width: 640px) {
  .appShell {
    padding: 10px;
  }

  .stageHeader,
  .transport {
    grid-template-columns: 1fr;
    display: grid;
  }
}
