:root {
  --bg: #07060c;
  --bg2: #0d0b16;
  --panel: #100d1c;
  --line: #241d3a;
  --txt: #d8d2ea;
  --dim: #7d749b;
  --accent: #00f0ff;
  --accent2: #ff2e88;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--txt);
  font: 13px/1.4 ui-sans-serif, "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
}

#app { display: flex; flex-direction: column; height: 100%; }

/* ---------------------------------------------------------------- header */
#bar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #141022, #0b0913);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.brand {
  font: 700 15px/1 ui-monospace, Consolas, monospace;
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(0, 240, 255, .45);
}
.brand span { color: var(--accent2); text-shadow: 0 0 12px rgba(255, 46, 136, .45); }

.actions { display: flex; align-items: center; gap: 6px; }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }

button, select {
  background: #191428;
  color: var(--txt);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 10px;
  font: inherit;
  cursor: pointer;
  transition: border-color .12s, color .12s;
}
button:hover, select:hover { border-color: var(--accent); color: #fff; }
button.primary { border-color: var(--accent2); color: #ffd7e8; }
button.primary:hover { background: #2a1024; }

#status { margin-left: auto; color: var(--dim); font: 11px/1 ui-monospace, Consolas, monospace; }

/* ---------------------------------------------------------------- layout */
main { display: flex; flex: 1 1 auto; min-height: 0; }

#stage {
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background:
    radial-gradient(1200px 600px at 50% 0%, #16112a 0%, transparent 70%),
    repeating-linear-gradient(45deg, #0a0812 0 12px, #0b0914 12px 24px);
  overflow: auto;
}
#stage.drag { outline: 2px dashed var(--accent); outline-offset: -12px; }

.viewport {
  max-width: 100%;
  max-height: 100%;
  display: flex;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .7), 0 0 0 1px var(--line);
}

canvas {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 130px);
  object-fit: contain;
  image-rendering: auto;
}

.hint {
  position: absolute; bottom: 10px; left: 0; right: 0;
  text-align: center; color: var(--dim); font-size: 11px;
  pointer-events: none;
}

/* ---------------------------------------------------------------- panel */
#panel {
  flex: 0 0 296px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.grp { border-bottom: 1px solid var(--line); }

.grp-head {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  background: #15112450;
  border: 0; border-radius: 0;
  padding: 9px 12px;
  font: 600 11px/1 ui-sans-serif, sans-serif;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}
.grp-head:hover { color: #fff; }
.grp-head i { font-style: normal; transition: transform .15s; color: var(--dim); }
.grp.collapsed .grp-head i { transform: rotate(-90deg); }
.grp.collapsed .grp-body { display: none; }

.grp-body { padding: 4px 12px 12px; }

.ctl { margin: 9px 0; }
.ctl-label { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 3px; }
.ctl-label span { color: var(--txt); font-size: 12px; }
.ctl-val { color: var(--accent2); font: 11px/1 ui-monospace, Consolas, monospace; font-weight: 400; }

.ctl select { width: 100%; }

.ctl.is-bool { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ctl.is-bool .ctl-label { flex: 1 1 auto; margin: 0; }

input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 3px;
  background: #2b2246;
  border-radius: 2px;
  outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(0, 240, 255, .6);
  cursor: pointer;
}
input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px; border: 0; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(0, 240, 255, .6);
  cursor: pointer;
}

input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent2); cursor: pointer; }

#panel::-webkit-scrollbar { width: 9px; }
#panel::-webkit-scrollbar-track { background: #0b0913; }
#panel::-webkit-scrollbar-thumb { background: #2b2246; border-radius: 5px; }
#panel::-webkit-scrollbar-thumb:hover { background: #3b3060; }

@media (max-width: 860px) {
  main { flex-direction: column; }
  #panel { flex: 0 0 auto; max-height: 45vh; border-left: 0; border-top: 1px solid var(--line); }
}
