:root {
  --bg: #0c0d12;
  --panel: #15171f;
  --panel-border: #2a2e3d;
  --text: #e8eaf2;
  --muted: #9a9fb3;
  --accent: #9fb4ff;
  --focus: #ffd479;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.4;
}

header, footer {
  padding: 1rem 1.25rem 0.5rem;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: normal;
  letter-spacing: 0.03em;
}

.subtitle, footer {
  color: var(--muted);
  margin: 0.25rem 0 0;
  max-width: 60rem;
}

footer {
  font-size: 0.9rem;
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20rem;
  gap: 1rem;
  padding: 0.5rem 1.25rem 1rem;
}

@media (max-width: 860px) {
  main {
    grid-template-columns: minmax(0, 1fr);
  }
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.toolbar-label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0.15rem 0 0.5rem;
}

.toolbar-label:first-child {
  margin-left: 0;
}

.bench-wrap {
  position: relative;
  width: 100%;
  height: min(70vh, 640px);
  min-height: 320px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  overflow: hidden;
  background: #07080b;
}

#bench {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

#bench.over-element {
  cursor: grab;
}

#bench.dragging {
  cursor: grabbing;
}

#bench:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.stage-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

.status {
  margin: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0.5rem 0 0;
}

kbd {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.85em;
  padding: 0 0.3em;
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  background: var(--panel);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

fieldset {
  margin: 0;
  padding: 0.75rem;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: var(--panel);
}

legend {
  padding: 0 0.35rem;
  color: var(--accent);
  font-weight: 600;
}

.param {
  margin-bottom: 0.6rem;
}

.param-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.param-head output, .readout {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.readout {
  margin: 0;
}

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

select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 0.25rem;
  font: inherit;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.4rem;
  font-size: 0.9rem;
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

button {
  font: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: #1f2330;
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
}

button:hover {
  background: #283043;
}

button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.swatch {
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  border-radius: 50%;
  vertical-align: -0.05em;
  margin-right: 0.3em;
}
