:root {
  --ink: #eef4fb;
  --muted: #8e9bad;
  --faint: #596678;
  --panel: #0c111a;
  --panel-line: #1d2735;
  --accent: #69efc8;
  --background: #060910;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--background);
}

body {
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, select, input { font: inherit; }
button, select { color: inherit; }

.toy-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 318px;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: var(--background);
}

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: radial-gradient(circle at 50% 48%, rgba(25,36,52,.2), transparent 55%), var(--background);
}

.stage-header {
  position: absolute;
  z-index: 2;
  inset: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 30px;
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.stage-header h1 {
  margin: 0;
  color: rgba(239,245,252,.94);
  font-size: clamp(20px, 2.15vw, 31px);
  font-weight: 520;
  letter-spacing: -.045em;
}

.stage-header h1 i {
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
}

.stage-actions { display: flex; gap: 7px; pointer-events: auto; }

.quiet-button, .clear-button {
  border: 1px solid rgba(143,160,182,.22);
  border-radius: 8px;
  background: rgba(11,17,27,.72);
  color: #cbd6e3;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 140ms ease;
}

.quiet-button { padding: 8px 11px; backdrop-filter: blur(12px); }
.quiet-button:hover, .clear-button:hover { border-color: rgba(105,239,200,.5); color: #ecfff9; background: rgba(20,38,40,.72); }
.quiet-button:active, .clear-button:active, .drive-choice button:active { transform: translateY(1px); }

.simulation-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.simulation-canvas.is-grabbable { cursor: grab; }
.simulation-canvas.is-grabbable:active { cursor: grabbing; }

.control-panel {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-content: start;
  gap: 17px 14px;
  min-height: 0;
  padding: 27px 22px 20px;
  border-left: 1px solid var(--panel-line);
  overflow: auto;
  background: linear-gradient(180deg, rgba(20,28,40,.35), transparent 220px), var(--panel);
  scrollbar-width: thin;
  scrollbar-color: #263244 transparent;
}

.field-wide, .control-heading, .panel-footer { grid-column: 1 / -1; }

.control-heading {
  position: relative;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--panel-line);
}

.control-heading h2 { margin: 0; color: #f2f6fb; font-size: 21px; font-weight: 600; letter-spacing: -.035em; }
.control-heading > p:last-child { margin: 11px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field > span, .drive-choice legend { display: flex; justify-content: space-between; color: #9daabc; font-size: 10px; font-weight: 650; letter-spacing: .075em; text-transform: uppercase; }
.field output { color: #d4dde8; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 10px; font-weight: 500; letter-spacing: 0; }

.field select {
  width: 100%;
  height: 36px;
  padding: 0 32px 0 10px;
  border: 1px solid #263244;
  border-radius: 7px;
  outline: none;
  background: #101722;
  color: #e0e7f0;
  cursor: pointer;
  font-size: 12px;
}

.field select:focus-visible, .quiet-button:focus-visible, .clear-button:focus-visible, .drive-choice button:focus-visible, .field input:focus-visible { outline: 2px solid rgba(105,239,200,.85); outline-offset: 2px; }

.drive-choice { min-width: 0; margin: 0; padding: 0; border: 0; }
.drive-choice legend { margin-bottom: 8px; }
.drive-choice > div { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border: 1px solid #263244; border-radius: 8px; background: #090e16; }
.drive-choice button { min-height: 29px; padding: 0 8px; border: 0; border-radius: 5px; background: transparent; color: #7f8da0; cursor: pointer; font-size: 11px; font-weight: 600; transition: 140ms ease; }
.drive-choice button.selected { background: #1a2630; color: #cffff0; box-shadow: inset 0 0 0 1px rgba(105,239,200,.17); }

.field input[type="range"] { width: 100%; height: 16px; margin: 0; border: 0; outline: none; background: transparent; cursor: pointer; appearance: none; }
.field input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 999px; background: #283447; }
.field input[type="range"]::-webkit-slider-thumb { width: 12px; height: 12px; margin-top: -4.5px; border: 2px solid #0c111a; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px rgba(105,239,200,.35); appearance: none; }
.field input[type="range"]::-moz-range-track { height: 3px; border-radius: 999px; background: #283447; }
.field input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border: 2px solid #0c111a; border-radius: 50%; background: var(--accent); }

.clear-button { min-height: 35px; margin-top: 2px; background: #0f1621; }

.body-editor {
  margin: 0;
  border-top: 1px solid var(--panel-line);
  padding-top: 14px;
}

.body-editor summary {
  color: #9daabc;
  cursor: pointer;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .075em;
  list-style-position: outside;
  text-transform: uppercase;
}

.body-editor summary::marker { color: var(--accent); }

.body-editor-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.body-editor-row {
  display: grid;
  grid-template-columns: 22px 1fr 1fr;
  align-items: end;
  gap: 8px;
}

.body-editor-number {
  align-self: center;
  color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
}

.body-editor-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #738095;
  font-size: 8px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.body-editor-row input {
  width: 100%;
  min-width: 0;
  height: 29px;
  padding: 0 7px;
  border: 1px solid #263244;
  border-radius: 6px;
  outline: none;
  background: #101722;
  color: #dce5ef;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
}

.body-editor-row input:focus { border-color: rgba(105,239,200,.65); }

.panel-footer { display: flex; align-items: flex-end; justify-content: flex-end; align-self: end; margin-top: 3px; padding-top: 15px; border-top: 1px solid var(--panel-line); }
.panel-footer a { margin: 0; color: var(--faint); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 8px; line-height: 1.65; letter-spacing: .025em; }
.panel-footer a { flex: 0 0 auto; text-decoration: none; }
.panel-footer a:hover { color: var(--accent); }

@media (max-width: 780px) {
  html, body { overflow: auto; }
  .toy-shell { grid-template-columns: 1fr; grid-template-rows: minmax(340px, 58dvh) auto; height: auto; min-height: 100dvh; overflow: visible; }
  .stage { min-height: 340px; }
  .stage-header { padding: 18px; }
  .stage-actions { gap: 5px; }
  .quiet-button { padding: 7px 9px; }
  .control-panel { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px 16px; padding: 21px 18px 18px; border-top: 1px solid var(--panel-line); border-left: 0; overflow: visible; }
  .control-heading { padding-bottom: 14px; }
}

@media (max-width: 430px) {
  .stage-header h1 { font-size: 19px; }
  .eyebrow { font-size: 8px; }
  .stage-actions .quiet-button:first-child { display: none; }
}

@media (prefers-reduced-motion: reduce) { button { transition: none !important; } }
