:root {
  --bg: #07050b;
  --panel: #0f0b16;
  --line: #2a1f38;
  --text: #e9e3f2;
  --dim: #8b7f9c;
  --hot: #ff2a6d;
  --violet: #9b5cff;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 "JetBrains Mono", ui-monospace, Consolas, monospace;
}

.app {
  display: grid;
  grid-template-columns: 1fr 340px;
  height: 100vh;
}

.stage-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  min-width: 0;
  min-height: 0;
}

#stage {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 32px);
  border-radius: 10px;
  box-shadow: 0 0 0 1px var(--line), 0 20px 60px rgba(155, 92, 255, 0.12);
}

.panel {
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 18px 18px 28px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.brand h1 span { color: var(--hot); }

.group {
  border-top: 1px solid var(--line);
  padding: 14px 0;
  display: grid;
  gap: 10px;
}

.lbl { color: var(--dim); }

input, select, button {
  font: inherit;
  color: var(--text);
}

input:not([type]), input[type="number"], select {
  width: 100%;
  background: #160f20;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  outline: none;
}

input:focus, select:focus { border-color: var(--violet); }

.expr {
  font-size: 16px !important;
  font-weight: 700;
  padding: 10px 11px !important;
}

.expr.bad { border-color: var(--hot) !important; }

.err { color: var(--hot); min-height: 1em; margin-top: -4px; font-size: 12px; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

label { display: grid; gap: 4px; color: var(--dim); }

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

.toggles { display: flex; gap: 16px; }
.toggles label { display: flex; align-items: center; gap: 6px; color: var(--text); cursor: pointer; }
input[type="checkbox"] { accent-color: var(--hot); width: 15px; height: 15px; }

.slider { grid-template-columns: 64px 1fr; align-items: center; }
input[type="range"] { accent-color: var(--hot); width: 100%; }

button { cursor: pointer; border: none; }

.play {
  background: var(--hot);
  color: #fff;
  font-weight: 800;
  padding: 9px 16px;
  border-radius: 999px;
  letter-spacing: 0.06em;
  box-shadow: 0 0 24px rgba(255, 42, 109, 0.45);
}

.play.on { background: #2a1f38; box-shadow: none; }

.seg {
  display: flex;
  background: #160f20;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
}

.seg button {
  flex: 1;
  background: transparent;
  color: var(--dim);
  padding: 7px;
  border-radius: 6px;
}

.seg button.on { background: var(--violet); color: #fff; }

.rec {
  background: #2b0d18;
  color: var(--hot);
  border: 1px solid #5a1630;
  border-radius: 8px;
  padding: 9px;
  font-weight: 700;
}

.rec.ghost { background: transparent; }

.share {
  background: #1d1428;
  color: var(--text);
  border: 1px solid var(--violet);
  border-radius: 8px;
  padding: 9px;
  font-weight: 700;
}

.share:hover { background: #2a1d3b; }

#shareLink { font-size: 11px; color: var(--dim); }
.rec.live { background: var(--hot); color: #fff; animation: pulse 1s infinite; }

@keyframes pulse { 50% { opacity: 0.6; } }

.hint { color: var(--dim); font-size: 12px; min-height: 1em; }

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--dim);
}

.small {
  background: #1d1428;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 9px;
}

.small:disabled { opacity: 0.4; cursor: default; }

.layers { display: grid; gap: 10px; }

.layer {
  border: 1px solid var(--line);
  border-left: 3px solid var(--c);
  border-radius: 8px;
  padding: 9px;
  display: grid;
  gap: 8px;
  background: #130e1b;
}

.layer.muted { opacity: 0.5; }

.lrow { display: flex; gap: 7px; align-items: center; }

.lrow .expr { flex: 1; min-width: 0; font-size: 14px !important; padding: 8px 9px !important; }

.dot {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 10px var(--c);
}

.layer.muted .dot { background: transparent; box-shadow: inset 0 0 0 2px var(--c); }

.del { background: transparent; color: var(--dim); padding: 4px 6px; }
.del:hover { color: var(--hot); }

.lgrid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 7px;
  font-size: 11px;
}

.lgrid select { padding: 5px 6px; font-size: 12px; }
.lgrid .vol { grid-column: span 2; }

.layer .err { margin-top: -4px; }
.layer .err:empty { display: none; }

.help { color: var(--dim); font-size: 12px; }
.help summary { cursor: pointer; }
.help p { margin: 6px 0; }
code { color: var(--text); }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; height: auto; }
  .stage-wrap { padding: 16px 16px 0; }
  #stage { max-height: 70vh; }
  .panel { border-left: none; padding: 16px; }
}
