:root {
  --bg: #0e1015;
  --panel: #161a22;
  --panel2: #1d222c;
  --fg: #dfe3ea;
  --muted: #8a93a3;
  --accent: #6cc4ff;
  --warn: #ffb454;
  --bad: #ff6b6b;
  --ok: #7bd88f;
  --line: #2a303c;
}
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font:
    13px/1.35 system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    sans-serif;
}
button,
select,
input {
  font: inherit;
  color: inherit;
}
button {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px 8px;
  cursor: pointer;
}
button:hover {
  border-color: var(--accent);
}
button.active {
  background: var(--accent);
  color: #05060a;
  border-color: var(--accent);
}
select,
input[type='number'] {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 4px;
}
label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
h3 {
  margin: 10px 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
/* layout: the two side columns are resizable through the gutters (Gutters.js writes --tools-w / --side-w) */
#app {
  display: grid;
  height: 100vh;
  grid-template-rows: 44px minmax(0, 1fr);
  grid-template-columns: var(--tools-w, 220px) 6px minmax(0, 1fr) 6px var(--side-w, 360px);
  grid-template-areas: 'tb tb tb tb tb' 'tools lg stage rg side';
}
.gutter {
  cursor: col-resize;
  background: var(--panel);
  touch-action: none;
}
.gutter[data-dir='left'] {
  grid-area: lg;
  border-right: 1px solid var(--line);
}
.gutter[data-dir='right'] {
  grid-area: rg;
  border-left: 1px solid var(--line);
}
.gutter:hover,
.gutter.drag {
  background: var(--accent);
}
#toolbar {
  grid-area: tb;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
#toolbar .modes,
#toolbar .transport,
#toolbar .actions {
  display: flex;
  gap: 4px;
}
#toolbar .spacer {
  flex: 1;
}
#toolbar .actions [data-act='settings'] {
  border-color: var(--accent);
}
#toolbar .score {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--panel2);
}
#toolbar .score.invalid {
  text-decoration: line-through;
  color: var(--bad);
}
#toolbar .score.settling {
  color: var(--warn);
}
#toolbar .score small {
  color: var(--muted);
  font-weight: 400;
  margin-left: 6px;
}
#tools {
  grid-area: tools;
  min-width: 0;
  overflow: auto;
  padding: 8px;
  background: var(--panel);
}
#tools .row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0;
}
#tools label {
  display: flex;
  margin: 6px 0;
  justify-content: space-between;
}
#tools .ink .bar {
  height: 8px;
  background: var(--panel2);
  border-radius: 4px;
  overflow: hidden;
  margin: 4px 0;
}
#tools .ink .fill {
  height: 100%;
  background: var(--accent);
  width: 0;
}
#tools .ink.over .fill {
  background: var(--bad);
}
#tools .hint {
  color: var(--muted);
  font-size: 11px;
  margin-top: 8px;
}
#tools > div[hidden] {
  display: none;
}
#tools .hint[data-v='rigdesc'] {
  margin-top: 2px;
}
#stage {
  grid-area: stage;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #05060a;
  overflow: hidden;
  min-width: 0;
}
#gl {
  width: 100%;
  max-height: 100%;
  aspect-ratio: 2 / 1;
  display: block;
  cursor: crosshair;
  outline: none;
}
#hud {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(14, 16, 21, 0.75);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
}
#hud .lock {
  color: var(--warn);
}
#hud .warn {
  color: var(--bad);
}
#hud [hidden] {
  display: none;
}
#hud .scope {
  display: none;
  gap: 6px;
  align-items: center;
}
#hud.scope-on .scope {
  display: inline-flex;
}
#hud .scope input[type='range'] {
  width: 70px;
}
/* right panel: collapsible sections, always-visible thin scrollbar */
#side {
  grid-area: side;
  min-width: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
  background: var(--panel);
  padding: 8px;
}
#side,
#tools {
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
#side::-webkit-scrollbar,
#tools::-webkit-scrollbar {
  width: 8px;
}
#side::-webkit-scrollbar-thumb,
#tools::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}
#side [hidden] {
  display: none;
}
#side details {
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
#side summary {
  cursor: pointer;
  list-style: none;
  margin: 6px 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  user-select: none;
  display: flex;
  gap: 6px;
  align-items: center;
}
#side summary::-webkit-details-marker {
  display: none;
}
#side summary::before {
  content: '▾';
  font-size: 10px;
  width: 10px;
}
#side details:not([open]) summary::before {
  content: '▸';
}
#side summary small {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
#side .big {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
#side .big.invalid {
  text-decoration: line-through;
  color: var(--bad);
}
#side .big.settling {
  color: var(--warn);
}
#side .job {
  color: var(--accent);
  font-size: 11px;
  margin-top: 4px;
}
#side .hint {
  color: var(--muted);
  font-size: 11px;
}
#side table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
#side td {
  padding: 1px 2px;
}
#side td:first-child {
  color: var(--muted);
  cursor: help;
}
#side td:last-child {
  text-align: right;
}
#side canvas.chart {
  width: 100%;
  height: 110px;
  display: block;
  margin-top: 4px;
}
#side canvas.small {
  height: 80px;
}
#side .grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
#side .parts div {
  display: flex;
  justify-content: space-between;
}
#side .flags span {
  display: inline-block;
  margin-right: 4px;
  padding: 0 4px;
  border-radius: 3px;
  background: var(--panel2);
  color: var(--warn);
  font-size: 11px;
}
#side .solver {
  color: var(--muted);
  font-size: 11px;
  word-break: break-all;
}
/* airfoil rig readout: one card per body / spring, atomic label+value cells with tooltips */
#side .card {
  background: var(--panel2);
  border-radius: 4px;
  padding: 6px 8px;
  margin: 6px 0;
}
#side .card .title {
  font-weight: 600;
  margin-bottom: 4px;
  cursor: help;
}
#side .card .kvs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 3px 8px;
}
#side .card .kv {
  display: flex;
  flex-direction: column;
  cursor: help;
  min-width: 0;
}
#side .card .kv b {
  font-weight: 400;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}
#side .card .kv span {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#side .card .kv.warn span {
  color: var(--warn);
}
.badge {
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--panel2);
  font-size: 11px;
}
.badge.settle {
  color: var(--warn);
}
.badge.settle.ok {
  color: var(--ok);
}
.badge.warn {
  color: var(--bad);
}
#notify {
  position: fixed;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
  max-width: 460px;
}
#notify .toast {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  padding: 6px 10px;
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
#notify .toast.warn {
  border-left-color: var(--warn);
}
#notify .toast.bad {
  border-left-color: var(--bad);
}
#notify .toast.pop {
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}
#notify .toast.pop .pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  margin-bottom: 4px;
}
#notify .toast.pop .pop-head button {
  padding: 0 6px;
  line-height: 1.4;
}
#notify .toast h4 {
  margin: 0;
  font-size: 12px;
}
#notify .toast pre {
  white-space: pre-wrap;
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  overflow: auto;
}
/* settings dialog: every parameter with room for a description; the depth slider spans both columns */
dialog.settings {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0;
  width: min(960px, 94vw);
  max-height: 90vh;
}
dialog.settings::backdrop {
  background: rgba(0, 0, 0, 0.6);
}
dialog.settings form {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  margin: 0;
}
dialog.settings header,
dialog.settings footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
}
dialog.settings header {
  border-bottom: 1px solid var(--line);
}
dialog.settings footer {
  border-top: 1px solid var(--line);
}
dialog.settings header h2 {
  margin: 0;
  font-size: 15px;
}
dialog.settings header .hint {
  flex: 1;
  color: var(--muted);
  font-size: 11px;
}
dialog.settings footer .status {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
dialog.settings .body {
  overflow: auto;
  padding: 6px 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}
dialog.settings .body section {
  min-width: 0;
}
dialog.settings .body section.wide {
  grid-column: 1 / -1;
}
dialog.settings .row {
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
dialog.settings .row label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
dialog.settings .row .name code {
  margin-left: 6px;
  color: var(--muted);
  font-size: 11px;
}
dialog.settings .row .desc {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}
dialog.settings .row.depth .H {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 8px 0 4px;
}
dialog.settings .row.depth .H input[type='range'] {
  flex: 1;
}
dialog.settings .row.depth output {
  min-width: 56px;
  font-variant-numeric: tabular-nums;
}
dialog.settings canvas.markers {
  width: 100%;
  height: 18px;
  display: block;
}
dialog.settings input[type='number'] {
  width: 110px;
}
@media (max-width: 720px) {
  dialog.settings .body {
    grid-template-columns: 1fr;
  }
}
.fatal {
  color: var(--bad);
  padding: 16px;
  white-space: pre-wrap;
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
