:root {
  --bg: #0d1117;
  --panel: #151b23;
  --panel-2: #1b232d;
  --line: #262f3b;
  --text: #dfe6ef;
  --dim: #8a97a8;
  --accent: #4fa3d1;
  --accent-2: #2d7fb0;
  --warn: #d99b3f;
  --bar-h: 52px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

/* ---------- top bar ---------- */

.bar {
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.bar h1 {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: .2px;
  margin: 0 6px 0 0;
  white-space: nowrap;
}
.spacer { flex: 1; }

.btn, .preset, .icon-btn {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 11px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover, .preset:hover, .icon-btn:hover { border-color: #3a4756; background: #212b37; }
.btn.primary {
  background: var(--accent-2);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn.primary:hover { background: var(--accent); }
.icon-btn { padding: 6px 10px; line-height: 1; }
.preset { max-width: 190px; }

/* ---------- layout ---------- */

main {
  display: flex;
  height: calc(100% - var(--bar-h));
}

#sidebar {
  width: 336px;
  flex: 0 0 336px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  overscroll-behavior: contain;
  transition: margin-left .2s ease;
}
body.sidebar-hidden #sidebar { margin-left: -336px; }

#stage { position: relative; flex: 1; min-width: 0; }
#view { display: block; width: 100%; height: 100%; touch-action: none; }

/* ---------- parameter groups ---------- */

.group { border-bottom: 1px solid var(--line); }
.group-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 11px 14px;
  cursor: pointer;
  text-align: left;
}
.group-head:hover { background: var(--panel-2); }
.chev { color: var(--dim); transform: rotate(90deg); transition: transform .15s; }
.group.collapsed .chev { transform: rotate(0deg); }
.group.collapsed .group-body { display: none; }
.group-body { padding: 2px 14px 14px; }

.ctl { margin: 12px 0; }
.ctl-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ctl-label { color: var(--text); font-size: 12.5px; }
.ctl-unit { color: var(--dim); font-size: 11px; }
.ctl-line { display: flex; align-items: center; gap: 9px; margin-top: 5px; }

.ctl-range { flex: 1; min-width: 0; accent-color: var(--accent); height: 18px; }
.ctl-num, .ctl-select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  font: inherit;
  padding: 4px 6px;
}
.ctl-num { width: 72px; text-align: right; }
.ctl-select { width: 100%; margin-top: 5px; }
.ctl-help { color: var(--dim); font-size: 11px; margin-top: 4px; }

.foot { color: var(--dim); font-size: 11px; padding: 14px; margin: 0; }

/* ---------- viewport overlays ---------- */

.viewtools {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.chip {
  font: inherit;
  font-size: 12px;
  color: var(--dim);
  background: rgba(21, 27, 35, .82);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.chip:hover { color: var(--text); }
.chip.on { color: #fff; background: var(--accent-2); border-color: var(--accent); }

.stats {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: rgba(21, 27, 35, .86);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 260px;
  backdrop-filter: blur(6px);
}
.stat { display: flex; justify-content: space-between; gap: 18px; padding: 2px 0; }
.stat-k { color: var(--dim); font-size: 11.5px; }
.stat-v { font-variant-numeric: tabular-nums; font-size: 11.5px; }

.warnings {
  position: absolute;
  left: 12px;
  top: 12px;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.warn {
  background: rgba(58, 44, 20, .9);
  border: 1px solid #6b5220;
  color: #f0cd91;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 11.5px;
  backdrop-filter: blur(6px);
}

.hint {
  position: absolute;
  right: 12px;
  bottom: 12px;
  color: #5d6b7c;
  font-size: 11px;
  pointer-events: none;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 12px);
  background: var(--accent-2);
  color: #fff;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- narrow screens ---------- */

@media (max-width: 780px) {
  main { flex-direction: column; }
  #sidebar {
    width: 100%;
    flex: 0 0 46%;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    order: 2;
  }
  body.sidebar-hidden #sidebar { display: none; margin-left: 0; }
  #stage { order: 1; flex: 1; }
  .stats { min-width: 0; font-size: 11px; right: 12px; }
  .bar h1 { display: none; }
  .hint { display: none; }
}
