:root {
  --bg: #07080c;
  --panel: rgba(20, 22, 30, 0.82);
  --panel-solid: #14161e;
  --stroke: rgba(255, 255, 255, 0.10);
  --text: #e8ecf4;
  --muted: #8b93a7;
  --accent: #6ee7ff;
  --accent-2: #ff79c6;
  --good: #7CFFB2;
  --radius: 12px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: none;
}

/* ---- Stage / canvases ---- */
#stage { position: fixed; inset: 0; }
#paintSynth, #paintFx, #overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#paintSynth, #paintFx { background: #000; z-index: 1; }
#paintFx { display: none; }            /* shown only in FX view */
#overlay { z-index: 2; cursor: crosshair; }

/* ---- Toolbar ---- */
#toolbar {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  background: var(--panel);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: calc(100vw - 28px);
  flex-wrap: wrap;
  justify-content: center;
}

.brand { display: flex; align-items: center; gap: 8px; padding-right: 6px; }
.brand .logo { color: var(--accent); font-size: 20px; line-height: 1; }
.brand .name { font-weight: 650; letter-spacing: 0.2px; font-size: 15px; }

.group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-left: 1px solid var(--stroke);
  position: relative;
}
.group[data-label]::before {
  content: attr(data-label);
  position: absolute;
  top: -16px;
  left: 8px;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

button, select, input[type="range"] { font-family: inherit; color: var(--text); }

#toolbar button {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 9px;
  padding: 7px 10px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.06s;
  line-height: 1;
}
#toolbar button:hover { background: rgba(255, 255, 255, 0.10); }
#toolbar button:active { transform: translateY(1px); }
#toolbar button.active {
  background: rgba(110, 231, 255, 0.16);
  border-color: rgba(110, 231, 255, 0.5);
  color: #d7faff;
}
#toolbar button.primary {
  background: linear-gradient(180deg, var(--accent), #36c6e0);
  color: #042027;
  font-weight: 650;
  border: none;
}
#toolbar button.primary.on {
  background: linear-gradient(180deg, var(--accent-2), #d65aa6);
  color: #2a0a1d;
}

.readout {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--muted);
  min-width: 26px;
  text-align: right;
}

select {
  background: var(--panel-solid);
  border: 1px solid var(--stroke);
  border-radius: 9px;
  padding: 6px 8px;
  font-size: 13px;
  cursor: pointer;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 96px;
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.16);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #0a1418;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #0a1418;
}

/* ---- HUD ---- */
#hud {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 9;
  background: var(--panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12px;
  min-width: 160px;
  box-shadow: var(--shadow);
}
.hud-row { display: flex; justify-content: space-between; gap: 16px; padding: 2px 0; }
.hud-row .k { color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; font-size: 10px; align-self: center; }
.hud-row .v { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent); }

/* ---- Help overlay ---- */
#help {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(4, 6, 10, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
#help.hidden { display: none; }
.help-card {
  width: min(560px, 92vw);
  background: var(--panel-solid);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 28px 30px;
  box-shadow: var(--shadow);
}
.help-card h1 { margin: 0 0 8px; font-size: 26px; }
.help-card .lead { color: #cfd6e6; line-height: 1.5; margin: 0 0 14px; }
.help-card ul { margin: 0 0 14px; padding-left: 18px; line-height: 1.7; color: #c2cadb; }
.help-card li b { color: var(--text); }
.help-card .tip { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.help-card em { color: var(--accent); font-style: normal; }
.help-card .primary {
  background: linear-gradient(180deg, var(--accent), #36c6e0);
  color: #042027;
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
}
.help-card .primary:hover { filter: brightness(1.05); }

@media (max-width: 720px) {
  .group[data-label]::before { display: none; }
  .brand .name { display: none; }
}
