:root {
  --bg: #07080a;
  --panel: #0e1013;
  --line: #1e2228;
  --ink: #c8d0d8;
  --dim: #6b7682;
  --accent: #7ee787;
  --accent-dim: #2ea043;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- stage ---------- */

#stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at center, #0c0e12 0%, #050607 100%);
}

#out {
  max-width: 100%;
  max-height: 100%;
  image-rendering: pixelated;
  transition: filter 160ms ease;
}

#out.bloom { filter: drop-shadow(0 0 6px currentColor) brightness(1.08); }

#overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease;
}

#overlay.scanlines {
  opacity: 1;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.32) 3px,
    rgba(0, 0, 0, 0.32) 4px
  );
}

#overlay.vignette {
  opacity: 1;
  box-shadow: inset 0 0 18vmin 6vmin rgba(0, 0, 0, 0.85);
}

#overlay.scanlines.vignette {
  box-shadow: inset 0 0 18vmin 6vmin rgba(0, 0, 0, 0.85);
}

/* ---------- splash ---------- */

#splash {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 4px;
  text-align: center;
  padding: 24px;
  background: rgba(5, 6, 7, 0.82);
  backdrop-filter: blur(3px);
  z-index: 5;
}

#splash.gone { display: none; }

#splash-art {
  margin: 0 0 8px;
  font-size: 9px;
  line-height: 1.05;
  color: var(--accent-dim);
  white-space: pre;
}

#splash h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.35em;
  font-weight: 600;
  color: var(--accent);
}

#splash p {
  margin: 6px 0 14px;
  color: var(--dim);
  line-height: 1.6;
}

#splash .fineprint { font-size: 11px; margin-top: 16px; max-width: 34ch; }

/* ---------- hud ---------- */

#hud {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--dim);
  pointer-events: none;
  text-shadow: 0 1px 3px #000;
}

#toast {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: rgba(14, 16, 19, 0.95);
  color: var(--ink);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- panel ---------- */

#panel-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 20;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(14, 16, 19, 0.9);
  color: var(--ink);
  cursor: pointer;
}

#panel-toggle:hover { border-color: var(--accent-dim); color: var(--accent); }

#panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 15;
  width: 268px;
  height: 100%;
  padding: 14px 14px 20px;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--panel);
  transition: transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
  overscroll-behavior: contain;
}

#panel.hidden { transform: translateX(100%); }

#panel header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  padding-right: 40px;
}

.brand {
  font-size: 12px;
  letter-spacing: 0.3em;
  color: var(--accent);
}

.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f85149;
  animation: pulse 1.1s ease-in-out infinite;
}

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

#panel section {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

#panel section:last-of-type { border-bottom: 0; }

label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--dim);
  text-transform: uppercase;
}

output { color: var(--accent); text-transform: none; float: right; }

select, input[type="range"] { width: 100%; }

select {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #15181c;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  margin: 8px 0 2px;
  border-radius: 2px;
  background: var(--line);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.ramp-preview {
  margin: 8px 0 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #15181c;
  color: var(--dim);
  font-size: 11px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.swatches { display: flex; gap: 4px; margin-top: 8px; }

.swatches i {
  flex: 1;
  height: 14px;
  border-radius: 3px;
}

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

.toggles label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
}

.toggles input { accent-color: var(--accent-dim); margin: 0; }

.buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

button {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #15181c;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease;
}

button:hover { border-color: var(--accent-dim); color: var(--accent); }
button:active { transform: translateY(1px); }

button.primary {
  padding: 10px 22px;
  border-color: var(--accent-dim);
  background: var(--accent-dim);
  color: #04180a;
  font-weight: 600;
  letter-spacing: 0.05em;
}

button.primary:hover { background: var(--accent); border-color: var(--accent); color: #04180a; }

button.ghost { border-color: transparent; background: none; color: var(--dim); }
button.ghost:hover { color: var(--accent); }

button.recording { border-color: #f85149; color: #f85149; }

#panel footer { margin-top: 20px; font-size: 11px; color: var(--dim); }

#panel footer summary { cursor: pointer; padding: 4px 0; }

#panel footer dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 12px;
  margin: 8px 0 0;
}

#panel footer dt { color: var(--accent); }
#panel footer dd { margin: 0; }

#panel footer a { display: inline-block; margin-top: 12px; color: var(--dim); }
#panel footer a:hover { color: var(--accent); }

@media (max-width: 640px) {
  #panel {
    top: auto;
    bottom: 0;
    width: 100%;
    height: 62vh;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: var(--radius) var(--radius) 0 0;
  }
  #panel.hidden { transform: translateY(100%); }
  #hud { bottom: auto; top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
