:root {
  --default-purple: #6c47ff;
  --default-red: color(display-p3 1 0.25 0.39); /* #ff1b5f */
  --default-green: color(display-p3 0.3 1 0.7); /* #00ffac */
  --default-yellow: color(display-p3 1 0.7 0.18); /* #ffae00 */

  --txt-primary: hsl(240, 20%, 80%);
  --txt-secondary: hsl(240, 10%, 50%);
  --txt-light: hsl(240, 15%, 25%);

  --background: #111117;

  --panel-bg: rgba(17, 17, 23, 0.78);
  --panel-border: hsla(240, 15%, 30%, 0.55);
  --row-bg: hsla(240, 15%, 55%, 0.07);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--background);
  color: var(--txt-primary);
  font-family: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

/* ---------- loading ---------- */

#loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--background);
  color: var(--txt-secondary);
  z-index: 20;
  transition: opacity 0.5s ease;
}
#loading.done { opacity: 0; pointer-events: none; }

.logo-mark {
  width: 30px;
  height: 30px;
  background: var(--default-purple);
  -webkit-mask: url(../assets/logo.svg) center / contain no-repeat;
  mask: url(../assets/logo.svg) center / contain no-repeat;
  flex: 0 0 auto;
}
/* ---------- panel ---------- */

#panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 312px;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border-left: 1px solid var(--panel-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 10;
  overflow: hidden;
}

#panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--panel-border);
}
#panel-head h1 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.1;
  color: #fff;
}
#panel-head h1 span {
  color: #fff;
  font-weight: 400;
}
#panel-head .logo-mark { background: #fff; }
#panel-head .sub {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--txt-secondary);
}

/* ---------- controls ---------- */

#controls {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--txt-light) transparent;
}
#controls::-webkit-scrollbar { width: 6px; }
#controls::-webkit-scrollbar-thumb { background: var(--txt-light); border-radius: 3px; }

details.group { border-bottom: 1px solid hsla(240, 15%, 30%, 0.3); }
details.group:last-child { border-bottom: none; }

details.group summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 20px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
}
details.group summary::-webkit-details-marker { display: none; }
details.group summary .sec-ico {
  width: 14px;
  text-align: center;
  font-size: 11px;
  color: #fff;
  flex: 0 0 auto;
}
details.group summary .chev {
  margin-left: auto;
  color: var(--txt-secondary);
  font-size: 12px;
}
details.group summary .chev .fa-angle-up { display: none; }
details.group[open] summary .chev .fa-angle-up { display: inline-block; }
details.group[open] summary .chev .fa-angle-down { display: none; }

.group-body { padding: 0px 20px 20px 20px; display: flex; flex-direction: column; gap: 9px; }

/* rows */
.ctl { display: flex; flex-direction: column; gap: 5px; }
.ctl label { color: var(--txt-secondary); }
.ctl .row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.ctl .val {
  color: var(--txt-primary);
  font-variant-numeric: tabular-nums;
  background: hsla(240, 15%, 60%, 0.18);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
}

/* sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--default-purple) 0%,
    var(--default-purple) var(--fill, 50%),
    hsla(240, 15%, 40%, 0.35) var(--fill, 50%)
  );
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  border: none;
  margin-top: -5px;
  transition: transform 0.1s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }
input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: hsla(240, 15%, 40%, 0.35);
}
input[type="range"]::-moz-range-progress {
  height: 3px;
  border-radius: 2px;
  background: var(--default-purple);
}
input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  border: none;
}

/* toggles */
.ctl.check {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0;
}
.switch {
  position: relative;
  width: 32px;
  height: 18px;
  flex: 0 0 auto;
}
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; z-index: 1; }
.switch .track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: hsla(240, 15%, 40%, 0.35);
  transition: background 0.15s;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--txt-primary);
  transition: transform 0.15s;
}
.switch input:checked + .track { background: var(--default-purple); }
.switch input:checked + .track::after { transform: translateX(14px); background: #fff; }

/* color swatches */
.swatches { display: flex; align-items: center; gap: 7px; }
.swatches button {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s, border-color 0.12s;
}
.swatches button:hover { transform: scale(1.15); }
.swatches button.active {
  border-color: #fff;
  box-shadow: inset 0 0 0 1px var(--background);
}
.swatches input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 0;
  cursor: pointer;
  margin-left: auto;
  transition: transform 0.12s, border-color 0.12s;
}
.swatches input[type="color"]:hover { transform: scale(1.15); }
.swatches input[type="color"].active {
  border-color: #fff;
  box-shadow: inset 0 0 0 1px var(--background);
}
/* the element's own background (set from JS) is the visible color,
   exactly like the preset buttons — hide the native inner swatch */
.swatches input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.swatches input[type="color"]::-webkit-color-swatch { opacity: 0; }
.swatches input[type="color"]::-moz-color-swatch { opacity: 0; }

/* action buttons */
.ctl button.action {
  font: inherit;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--txt-primary);
  background: var(--row-bg);
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  padding: 7px 10px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.ctl button.action:hover { border-color: var(--default-purple); color: #fff; }

@media (max-width: 640px) {
  #panel { width: min(312px, calc(100vw - 28px)); }
}
