:root {
  color-scheme: dark;
  --bg: #0c0f14;
  --bg-2: #050608;
  --panel: #0f1115;
  --panel-2: #0b0d10;
  --ink: #e8edf2;
  --muted: #9aa4af;
  --accent: #7fb3ff;
  --accent-2: #7fb3ff;
  --edge: #1f242c;
  --shadow: rgba(0, 0, 0, 0.65);
  --good: #6fcf97;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Consolas, "Courier New", monospace;
  color: var(--ink);
  background:
    radial-gradient(1200px 800px at 10% 10%, var(--bg), transparent),
    radial-gradient(900px 600px at 90% 0%, var(--bg-2), transparent),
    #000;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 24px 28px 8px 28px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
}

.title-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0;
  gap: 12px;
}

.title-text {
  display: flex;
  flex-direction: column;
}

.title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1.1;
}

.title-sub {
  margin-top: 0;
  font-size: 14px;
  line-height: 1.35;
  color: var(--muted);
}

.title-sub a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  border-bottom: none;
}

.title-sub a:hover {
  color: #a8ccff;
}

.github-star {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.github-star-note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
  white-space: nowrap;
}

.github-star-desktop {
  margin-left: auto;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.github-star-desktop .github-star-note {
  text-align: right;
}

.github-star-mobile {
  display: none;
  justify-content: flex-start;
  align-items: center;
  flex-direction: row;
  gap: 10px;
  padding: 2px 2px 0;
}

a {
  color: #7dd3fc;
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:visited {
  color: #7dd3fc;
}

a:hover {
  color: #a8ccff;
}

.page-indicator {
  display: none;
  position: sticky;
  top: 72px;
  z-index: 4;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  gap: 8px;
  padding: 8px 16px 12px 16px;
  margin-top: -8px;
}

.nav-btn {
  flex: 1 1 0;
  border: 1px solid var(--edge);
  background: rgba(8, 10, 12, 0.6);
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 999px;
  font: 400 12px Consolas, "Courier New", monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-btn.active {
  color: var(--ink);
  border-color: rgba(127, 179, 255, 0.8);
  background: rgba(16, 24, 36, 0.85);
  box-shadow: 0 0 0 1px rgba(127, 179, 255, 0.35);
}

.app {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1.2fr 0.8fr;
  gap: 20px;
  padding: 16px 24px 28px 24px;
  min-height: calc(100vh - 96px);
}

.col {
  min-width: 0;
}

.editor-col {
  display: none;
}

.settings-col, .plots-col, .outputs-col {
  display: flex;
}

.panel-col, .output-col {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
}

.main-col {
  width: 100%;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 16px;
  box-shadow: 0 12px 30px var(--shadow);
  overflow: hidden;
  animation: rise 420ms ease both;
}

.panel:nth-child(2) { animation-delay: 80ms; }
.panel:nth-child(3) { animation-delay: 160ms; }

.panel-title {
  padding: 10px 16px 4px;
  font-weight: 400;
  font-size: 14px;
  letter-spacing: 0.02em;
  background: transparent;
  border-bottom: none;
  color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-toggle {
  margin-left: auto;
  width: 22px;
  height: 22px;
  border: 1px solid var(--edge);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--ink);
  font: 700 12px/1 Consolas, "Courier New", monospace;
  padding: 0;
  cursor: pointer;
}

.panel-toggle:hover {
  border-color: var(--accent);
}

.panel.collapsed > :not(.panel-title) {
  display: none !important;
}

.panel-body {
  padding: 10px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.toggle {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.toggle input {
  accent-color: #38bdf8;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.flight-grid {
  grid-template-columns: 1fr;
}

.flight-conditions {
  --flight-label-width: 160px;
  --flight-col-gap: 2px;
  --flight-right-inset: 5px;
  gap: 8px;
  padding-right: 7px;
}

.flight-conditions .flight-grid {
  gap: 8px;
}

.flight-conditions > label.flight-row,
.flight-conditions .flight-grid > label.flight-row {
  display: grid;
  grid-template-columns: var(--flight-label-width) minmax(0, 1fr);
  column-gap: var(--flight-col-gap);
  align-items: center;
  padding-right: var(--flight-right-inset);
}

.flight-conditions > label.flight-row .label-text,
.flight-conditions .flight-grid > label.flight-row .label-text {
  grid-column: 1;
  justify-self: start;
  text-align: left;
  white-space: nowrap;
}

.flight-conditions > label.flight-row:not(.btn):not(.toggle) > input:not([type="checkbox"]):not([type="file"]):not([type="range"]),
.flight-conditions > label.flight-row:not(.btn):not(.toggle) > select,
.flight-conditions .flight-grid > label.flight-row:not(.btn):not(.toggle) > input:not([type="checkbox"]):not([type="file"]):not([type="range"]),
.flight-conditions .flight-grid > label.flight-row:not(.btn):not(.toggle) > select {
  grid-column: 2;
  justify-self: end;
  float: none;
  width: 100%;
  min-width: 0;
  max-width: none;
  margin-left: 0;
  margin-bottom: 0;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 14px;
}

label {
  font-size: 14px;
  color: var(--muted);
  display: block;
  line-height: 1.25;
}

label:not(.btn):not(.toggle) > input:not([type="checkbox"]):not([type="file"]):not([type="range"]),
label:not(.btn):not(.toggle) > select {
  float: right;
  margin-left: 10px;
  margin-bottom: 0;
  flex: none;
  min-width: 110px;
  width: 44%;
}

label:not(.btn):not(.toggle)::after {
  content: "";
  display: block;
  clear: both;
}

label.btn::after,
label.toggle::after {
  content: none;
}

label:not(.btn):not(.toggle) > textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
}

label sup,
label sub {
  font-size: 0.72em;
  line-height: 0;
  letter-spacing: 0;
}

label sup {
  vertical-align: super;
  margin-left: 0.02em;
}

label sub {
  vertical-align: sub;
  margin-left: 0.02em;
}

.row .btn,
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

input, textarea {
  background: var(--panel-2);
  border: 1px solid var(--edge);
  color: var(--ink);
  padding: 8px 10px;
  border-radius: 10px;
  font-family: inherit;
}

input:focus, textarea:focus {
  outline: 2px solid rgba(127, 179, 255, 0.3);
  border-color: var(--accent);
}

textarea.code {
  resize: vertical;
  min-height: 120px;
}

.file-editor {
  position: relative;
  border: 1px solid var(--edge);
  border-radius: 10px;
  background: var(--panel);
  overflow: hidden;
  --file-font-size: 13px;
}

.editor-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.editor-tab {
  background: var(--panel-2);
  border: 1px solid var(--edge);
  color: var(--muted);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.editor-tab.active {
  color: var(--ink);
  border-color: rgba(127, 179, 255, 0.85);
  box-shadow: 0 0 0 1px rgba(127, 179, 255, 0.35);
}

.file-highlight,
.file-editor textarea.code {
  margin: 0;
  width: 100%;
  min-height: 240px;
  padding: 8px 10px;
  font-family: Consolas, "Courier New", monospace;
  font-size: var(--file-font-size);
  line-height: 1.45;
  white-space: pre;
  overflow-wrap: normal;
  tab-size: 2;
}

.file-highlight {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  color: #f8f8f2;
  min-height: 0;
}

.file-editor textarea.code {
  position: relative;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: transparent;
  caret-color: #f8f8f2;
  z-index: 1;
  overflow: auto;
}

.file-editor textarea.code:focus {
  outline: none;
}

.file-editor:focus-within {
  box-shadow: 0 0 0 2px rgba(102, 217, 239, 0.28);
  border-color: #66d9ef;
}

.avl-token-comment { color: #75715e; }
.avl-token-keyword { color: #f92672; font-weight: 600; }
.avl-token-number { color: #ae81ff; }
.avl-token-string { color: #e6db74; }
.avl-token-operator { color: #f8f8f2; }

.btn {
  background: var(--panel-2);
  border: 1px solid var(--edge);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  appearance: none;
  -webkit-appearance: none;
  transition: transform 120ms ease, border 120ms ease;
}

.btn:hover { transform: translateY(-1px); border-color: var(--accent); }
.btn.primary { background: rgba(16, 24, 36, 0.9); color: var(--ink); border-color: rgba(127, 179, 255, 0.8); }
.btn.ghost { background: transparent; }

.file-meta {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

.aircraft-actions {
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
}

.aircraft-buttons {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: nowrap;
}

.aircraft-example-select {
  width: 124px;
  min-width: 124px;
  max-width: 124px;
  flex: 0 0 124px;
  height: 36px;
  box-sizing: border-box;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  padding-right: 28px;
}

.file-summary {
  margin-top: 8px;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  font-family: Consolas, "Courier New", monospace;
}

.file-aircraft-name {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  font-family: Consolas, "Courier New", monospace;
}

.file-aircraft-name:focus {
  outline: none;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.file-summary-lines {
  display: grid;
  gap: 2px;
  white-space: pre;
}

.file-summary-line {
  display: flex;
  gap: 18px;
  white-space: nowrap;
  flex-wrap: wrap;
}

.file-ref-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 6px 2px;
  align-items: center;
}

.file-ref-row {
  display: contents;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.25;
  white-space: nowrap;
}

.file-ref-row .label-text {
  justify-self: end;
  text-align: right;
}

.file-ref-row > input {
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 14px;
}

.file-summary strong {
  color: var(--ink);
  font-weight: 600;
}

.airfoil-files {
  margin-top: 10px;
  border: 1px solid var(--edge);
  border-radius: 10px;
  background: rgba(8, 10, 12, 0.35);
  padding: 10px;
}

.airfoil-files-title {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.airfoil-files-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.airfoil-file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.airfoil-file-name {
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.airfoil-file-status {
  color: var(--muted);
  font-size: 12px;
}

.airfoil-file-row.missing .airfoil-file-name,
.airfoil-file-row.missing .airfoil-file-status,
.airfoil-file-row.invalid .airfoil-file-name,
.airfoil-file-row.invalid .airfoil-file-status {
  color: #f87171;
}

.airfoil-file-row.loading .airfoil-file-status {
  color: #fbbf24;
}

.template-params-inline {
  margin-top: 10px;
}

.template-params-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-param-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.template-param-name {
  color: var(--ink);
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.template-param-slider {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  accent-color: #66d9ef;
}

.template-param-value {
  color: var(--ink);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  text-align: right;
  min-width: 42px;
  white-space: nowrap;
}

.subhead {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #7dd3fc;
  margin-top: 8px;
}

.main-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stage {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 18px;
  box-shadow: 0 30px 50px var(--shadow);
  overflow: hidden;
  position: relative;
  animation: rise 420ms ease both;
}

.stage-panel-body {
  padding: 0;
  position: relative;
}

.stage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px 10px;
}

.stage-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.viewer-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.viewer-btn {
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: rgba(15, 23, 42, 0.85);
  color: #e2e8f0;
  font-size: 0.75rem;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, color 160ms ease;
}

.viewer-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(56, 189, 248, 0.7);
  color: #f8fafc;
}

.viewer-btn.active {
  border-color: rgba(34, 211, 238, 0.9);
  color: #22d3ee;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.15);
}

.stage-title {
  font-weight: 600;
  font-size: 1.05rem;
}

.stage-sub {
  color: var(--muted);
  font-size: 0.85rem;
}

.pill {
  font-size: 0.75rem;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fcd34d;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.viewer {
  position: relative;
  height: clamp(240px, 44vh, 460px);
  touch-action: none;
  background: var(--panel);
}

.viewer-aircraft-name {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 5;
  max-width: calc(100% - 72px);
  padding: 4px 9px;
  border-radius: 8px;
  background: rgba(8, 10, 12, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--ink);
  font: 600 12px/1.2 Consolas, "Courier New", monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.viewer canvas {
  touch-action: none;
  background: var(--panel);
}

.viewer-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5;
}

.viewer-overlay-bottom {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: row;
  gap: 8px;
  z-index: 5;
}

.eigen-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5;
}

.viewer-hover-tip {
  position: absolute;
  z-index: 8;
  max-width: 320px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(7, 10, 16, 0.92);
  color: #e5e7eb;
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
  line-height: 1.25;
  pointer-events: none;
  white-space: nowrap;
}

.viewer-btn.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.viewer-btn.icon-btn.text-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 0.95rem/1 Consolas, "Courier New", monospace;
  letter-spacing: 0;
  text-transform: none;
}

.viewer-btn.icon-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.6;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.viewer-btn.icon-btn.active {
  border-color: rgba(34, 211, 238, 0.9);
  color: #22d3ee;
}

.plot {
  width: 100%;
  height: clamp(200px, 30vh, 320px);
  display: block;
  background: var(--panel);
}

.trefftz-plot {
  width: 100%;
  height: clamp(240px, 36vh, 384px);
  background: var(--panel);
  border-radius: 16px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
  overflow: hidden;
  position: relative;
  display: block;
}

.eigen-plot {
  width: 100%;
  height: clamp(240px, 36vh, 384px);
  background: var(--panel);
  border-radius: 16px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
  overflow: hidden;
  position: relative;
  display: block;
  touch-action: none;
}

.eigen-plot.pan-enabled {
  cursor: grab;
}

.eigen-plot.pan-enabled.is-panning {
  cursor: grabbing;
}

.trefftz-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: color-mix(in oklab, var(--panel) 22%, transparent);
  color: #e2e8f0;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  z-index: 3;
  pointer-events: none;
}

.trefftz-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(226, 232, 240, 0.35);
  border-top-color: #38bdf8;
  animation: spin 900ms linear infinite;
}

.trefftz-overlay-text {
  font-weight: 600;
}

.stage.trefftz-busy .trefftz-plot {
  opacity: 0.82;
  filter: none;
}

.stage.trefftz-busy .trefftz-overlay {
  display: flex;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.trefftz-legend {
  position: absolute;
  top: 6px;
  right: 6px;
  background: transparent;
  border-radius: 8px;
  padding: 4px 6px;
  display: grid;
  gap: 0;
  font: 16px Consolas, "Courier New", monospace;
  color: #9aa8b7;
}

.trefftz-axis-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font: 16px Consolas, "Courier New", monospace;
  color: #9aa8b7;
}

.trefftz-axis-label {
  position: absolute;
  opacity: 0.85;
  white-space: nowrap;
}

.trefftz-axis-label .katex,
.trefftz-legend-item .katex {
  font-size: 0.95em;
}

.trefftz-axis-label.x,
.trefftz-axis-label.y-left,
.trefftz-axis-label.y-right {
  transform: none;
}

.trefftz-ticks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font: 10px Consolas, "Courier New", monospace;
  color: #9aa8b7;
}

.trefftz-axis-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.trefftz-axis-line {
  position: absolute;
  background: rgba(255,255,255,0);
}

.trefftz-axis-line.left,
.trefftz-axis-line.right {
  width: 1px;
}

.trefftz-axis-line.bottom {
  height: 1px;
}

.trefftz-grid-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.trefftz-grid-line {
  position: absolute;
  background: rgba(255,255,255,0.08);
}

.trefftz-grid-line.h {
  height: 1px;
}

.trefftz-grid-line.v {
  width: 1px;
}

.trefftz-tick {
  position: absolute;
  white-space: nowrap;
  opacity: 0.9;
  height: 10px;
  line-height: 10px;
}

.trefftz-tick.left {
  transform: none;
}

.trefftz-tick.right {
  transform: none;
}

.trefftz-tick.bottom {
  transform: translate(-50%, 0);
}

.trefftz-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: -0.5em 0 0 0;
  padding: 0;
  line-height: 1;
}

.trefftz-legend-item:first-child {
  margin-top: 0;
}

.trefftz-legend-item .swatch.line {
  width: 14px;
  height: 10px;
  stroke-width: 1.2;
  fill: none;
  flex: 0 0 auto;
}

.trefftz-legend-item .swatch.line.clp line { stroke: #ef4444; }
.trefftz-legend-item .swatch.line.cl line { stroke: #fb923c; }
.trefftz-legend-item .swatch.line.cnc line { stroke: #22c55e; }
.trefftz-legend-item .swatch.line.dw line { stroke: #3b82f6; }

.trefftz-legend-item sub {
  font-size: 0.7em;
  line-height: 0;
  vertical-align: -0.3em;
}

.trefftz-legend-item .perp {
  font-size: 0.8em;
  margin-left: 2px;
}

.trefftz-legend-item .swatch {
  width: 12px;
  height: 2px;
  border-radius: 2px;
  display: inline-block;
}

.panel select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--edge);
  background: var(--panel-2);
  color: var(--ink);
  font: inherit;
}

.panel select.aircraft-example-select {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
}

.trefftz-plot .u-grid .u-gridline {
  stroke: rgba(255,255,255,0.08);
}

.output .kvs {
  display: grid;
  gap: 12px;
}

.total-forces-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  --forces-font-size: clamp(11px, 3.9cqi, 15px);
}

.total-forces-grid .force-cell {
  gap: 0;
}

.force-cell {
  display: flex;
  justify-content: flex-start;
  align-items: baseline;
  gap: 6px;
  min-height: 0;
  padding: 0;
  color: var(--muted);
  font-size: 14px;
  font-size: var(--forces-font-size);
  line-height: 1.25;
  white-space: nowrap;
}

.force-cell strong {
  color: var(--ink);
  font-size: 14px;
  font-size: var(--forces-font-size);
  font-weight: 600;
  font-family: Consolas, "Courier New", monospace;
  text-align: left;
  white-space: nowrap;
}

.force-control-name {
  display: inline-block;
  width: var(--control-name-width, auto);
  text-align: right;
  white-space: nowrap;
}

.force-kv-hidden {
  display: none;
}

.total-forces-grid .r1 { grid-row: 1; }
.total-forces-grid .r2 { grid-row: 2; }
.total-forces-grid .r3 { grid-row: 3; }
.total-forces-grid .r4 { grid-row: 4; }
.total-forces-grid .r5 { grid-row: 5; }
.total-forces-grid .c1 { grid-column: 1; }
.total-forces-grid .c2 { grid-column: 2; }
.total-forces-grid .c3 { grid-column: 3; }
.total-forces-grid .c4 { grid-column: 4; }

#outControlRows {
  display: contents;
}

.force-cell.control-row {
  grid-column: 1 / span 2;
  overflow: visible;
  z-index: 1;
}

.stability-grid {
  display: grid;
  grid-template-columns: 0.25fr repeat(5, minmax(0, 1fr));
  gap: 4px 12px;
  color: var(--muted);
  --deriv-font-size: clamp(9px, 3.2cqi, 14px);
  font-size: 14px;
  font-size: var(--deriv-font-size);
  line-height: 1.25;
}

.body-deriv-grid {
  display: grid;
  grid-template-columns: 0.25fr repeat(6, minmax(0, 1fr));
  gap: 4px 8px;
  color: var(--muted);
  --deriv-font-size: clamp(8.5px, 2.9cqi, 14px);
  font-size: 14px;
  font-size: var(--deriv-font-size);
  line-height: 1.25;
}

.surface-forces-grid {
  display: grid;
  grid-template-columns: var(--surface-name-col, minmax(90px, 1.0fr)) repeat(6, minmax(0, 1fr));
  gap: 4px 10px;
  color: var(--muted);
  --surface-font-size: clamp(8px, 2.8cqi, 14px);
  font-size: 14px;
  font-size: var(--surface-font-size);
  line-height: 1.25;
}

.hinge-grid {
  display: inline-grid;
  grid-template-columns: max-content max-content max-content;
  gap: 4px 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.25;
  max-width: 100%;
}

.hinge-grid .stability-num {
  min-width: 0;
}

.hinge-download-actions {
  margin: -4px 0 4px;
  gap: 8px;
}

.surface-forces-grid .stability-cell {
  min-width: 0;
}

.body-deriv-grid .stability-cell {
  min-width: 0;
}

.body-deriv-grid .stability-val {
  justify-content: flex-end;
}

.body-deriv-grid .stability-num {
  min-width: 0;
}

.surface-name-cell {
  overflow: hidden;
}

.surface-name-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.surface-forces-grid .stability-num {
  min-width: 0;
}

.surface-forces-grid .stability-cell strong {
  font-size: 14px;
  font-size: var(--surface-font-size, 14px);
}

.stability-cell {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-height: 0;
  padding: 0;
  white-space: nowrap;
}

.stability-head {
  color: var(--muted);
  font-weight: 500;
}

.stability-colhead {
  justify-content: center;
  text-align: center;
}

.stability-val {
  color: var(--ink);
}

.stability-cell strong {
  color: var(--ink);
  font-size: 14px;
  font-size: var(--deriv-font-size, 14px);
  font-weight: 600;
  font-family: Consolas, "Courier New", monospace;
  white-space: nowrap;
}

.stability-num {
  display: inline-block;
  min-width: 0;
  width: 100%;
  text-align: right;
  white-space: pre;
  font-variant-numeric: tabular-nums;
}

.stability-neutral {
  margin-top: 8px;
  color: var(--ink);
  font-size: 14px;
  font-size: var(--deriv-font-size, 14px);
  font-weight: 600;
  font-family: Consolas, "Courier New", monospace;
  white-space: nowrap;
}

.output .panel-body {
  max-height: 55vh;
  overflow: auto;
  container-type: inline-size;
}

.total-forces-panel > .panel-body {
  padding-left: 0;
  padding-right: 0;
}

.kv {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(22, 28, 41, 0.7);
  border: 1px solid var(--edge);
  font-size: 0.9rem;
}

.kv strong {
  color: var(--accent);
  font-weight: 600;
  font-family: Consolas, "Courier New", monospace;
}

.note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.debug-log {
  background: #0b0f17;
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 10px;
  height: 220px;
  overflow: auto;
  font-size: 0.78rem;
  color: #c7d2fe;
  font-family: Consolas, "Courier New", monospace;
  white-space: pre-wrap;
}

.mono-output {
  background: #0b0f17;
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 10px;
  max-height: 240px;
  overflow: auto;
  overflow-x: auto;
  font-size: 0.78rem;
  color: #d1d5f0;
  font-family: Consolas, "Courier New", monospace;
  white-space: pre;
}

.hidden {
  display: none !important;
}

.constraint-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.constraint-head {
  display: none !important;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 2px;
}

.constraint-row {
  display: grid;
  grid-template-columns: 1fr 1.35fr 0.95fr;
  gap: 0;
  align-items: stretch;
}

.constraint-cell {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  font-size: 14px;
  display: flex;
  align-items: center;
  min-height: 32px;
  color: var(--muted);
  line-height: 1.25;
}

.constraint-select,
.constraint-value {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--edge);
  border-radius: 8px;
  color: var(--ink);
  font-size: 14px;
  padding: 6px 8px;
  font-family: inherit;
  height: 32px;
  outline: none;
}

.constraint-row .constraint-cell:nth-child(3) {
  padding-left: 8px;
}

.constraint-select:focus,
.constraint-value:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(127, 179, 255, 0.25);
}

.constraint-row.dup .constraint-cell:first-child,
.constraint-select.dup,
.constraint-value.dup {
  border-color: rgba(248, 113, 113, 0.9);
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.35);
  color: #fecaca;
}

.run-cases-panel {
  gap: 10px;
}

.run-cases-actions {
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
}

.run-cases-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.run-case-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--edge);
  background: rgba(8, 10, 12, 0.35);
  cursor: pointer;
}

.run-case-item.active {
  border-color: rgba(127, 179, 255, 0.8);
  box-shadow: 0 0 0 1px rgba(127, 179, 255, 0.35);
}

.run-case-title {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-family: Consolas, "Courier New", monospace;
}

.run-case-title:focus {
  outline: none;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.run-case-color {
  width: 30px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.run-case-delete {
  min-width: 32px;
  padding: 4px 6px;
  line-height: 1;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.run-case-delete-icon {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.run-case-edit-actions {
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
}

.mass-props-panel {
  gap: 10px;
}

.mass-props-actions {
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
}

.mass-props-grid {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.mass-props-head {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
  white-space: nowrap;
}

.mass-props-head-empty {
  text-align: left;
}

.mass-props-grid > .label-text {
  justify-self: end;
  text-align: right;
  white-space: nowrap;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.25;
}

.mass-props-grid > input {
  width: 100%;
  min-width: 0;
  margin-left: 0 !important;
  float: none !important;
}

.mass-props-grid > input[readonly] {
  color: var(--muted);
}

@keyframes rise {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 1200px) {
  .stage-geo .viewer {
    height: clamp(240px, 50vh, 480px);
  }
}

@media (min-width: 901px) {
  #editorPanel .file-highlight,
  #editorPanel .file-editor textarea.code {
    min-height: 480px;
  }
}

@media (max-width: 900px) {
  .app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 0;
  }

  .title-text {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    flex-wrap: nowrap;
    gap: 4px;
    min-width: 0;
  }

  .github-star-desktop {
    display: none;
  }

  .github-star-mobile {
    display: inline-flex;
  }

  .github-star-mobile .github-star-note {
    text-align: left;
    white-space: normal;
    max-width: 190px;
  }

  .title-sub {
    margin-top: 0;
    max-width: none;
    padding: 6px 8px;
    border-radius: 10px;
    background: rgba(8, 10, 12, 0.55);
    font-size: 11px;
    line-height: 1.35;
    white-space: normal;
    overflow-wrap: anywhere;
    flex: 1 1 auto;
    min-width: 0;
  }

  .page-indicator {
    display: flex;
    top: 0;
    margin-top: 0;
    padding: 0 16px 12px 16px;
  }

  .app {
    grid-template-columns: none;
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: 16px;
    padding: 16px 16px 24px 16px;
    gap: 16px;
    min-height: calc(100vh - 120px);
    min-height: calc(100dvh - 120px);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .app::-webkit-scrollbar {
    display: none;
  }

  .col {
    flex: 0 0 100%;
    scroll-snap-align: start;
  }

  #editorCol {
    order: 0;
    display: flex;
    min-height: calc(100vh - 120px);
    min-height: calc(100dvh - 120px);
  }

  #settingsCol {
    order: 1;
  }

  #plotsCol {
    order: 2;
  }

  #outputsCol {
    order: 3;
  }

  #editorCol > .panel-col {
    gap: 0;
    min-height: 100%;
  }

  #editorPanel {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 100%;
  }

  #editorPanel > .panel-body {
    flex: 1 1 auto;
    min-height: 0;
    padding-bottom: 12px;
  }

  #editorPanel .file-editor {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
  }

  #editorPanel .file-highlight,
  #editorPanel .file-editor textarea.code {
    min-height: 100%;
    height: 100%;
  }
}
