:root {
  color-scheme: dark;
  --bg: #15181c;
  --panel: #1e2329;
  --ink: #dbe2ea;
  --muted: #97a3b1;
  --line: #353d47;
  --accent: #6ea8fe;
  --mocap: #f0a040;
  --nominal: #e57373;
}

* {
  box-sizing: border-box;
}

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

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 32px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  font-weight: 700;
}

h2 {
  font-size: 18px;
  font-weight: 650;
}

.run-meta {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.header-links {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.repo-link {
  color: var(--accent);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.repo-link:hover {
  text-decoration: underline;
}

.layout {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 32px 40px;
}

.controls {
  display: flex;
  align-items: end;
  gap: 20px;
  margin-bottom: 18px;
}

[hidden] {
  display: none !important;
}

label,
.control-label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

select,
button,
input[type="file"] {
  font: inherit;
}

select,
input[type="file"] {
  min-width: 320px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 12px;
}

input[type="file"] {
  display: flex;
  align-items: center;
  padding: 7px 10px;
}

button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: #9fb2d0;
}

.segmented {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.segmented button {
  min-width: 88px;
  height: 36px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: #e8f0fe;
  color: #174ea6;
  font-weight: 650;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
}

.metric span,
.panel-heading p {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  overflow: hidden;
  font-size: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.help-text {
  max-width: 860px;
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.panel {
  padding: 18px;
  margin-bottom: 18px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 14px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.panel-actions button {
  min-width: 96px;
  padding: 7px 10px;
  font-size: 12px;
}

.plot {
  min-height: 430px;
}

.plot svg {
  display: block;
  width: 100%;
  height: 430px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.plot svg.dragging {
  cursor: grabbing;
}

.playback-panel {
  padding-bottom: 14px;
}

.view-tabs {
  display: inline-flex;
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.view-tabs button {
  min-width: 128px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.view-tabs button.active {
  background: #eaf2ff;
  color: var(--accent);
}

.playback-view[hidden] {
  display: none;
}

.compact-heading {
  margin-top: 4px;
}

.playback-stage {
  position: relative;
}

.aircraft-playback {
  width: 100%;
  height: min(62vh, 640px);
  min-height: 420px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #262b31;
}

.aircraft-playback canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.playback-unavailable {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.control-hud {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: grid;
  width: min(500px, calc(100% - 28px));
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid rgba(152, 166, 186, 0.55);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.08);
  pointer-events: none;
}

.control-hud div {
  display: grid;
  grid-template-columns: 72px 18px minmax(0, 1fr) 18px 46px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.control-hud div:first-child {
  grid-template-columns: 72px minmax(0, 1fr) 46px;
}

.control-bar {
  position: relative;
  display: block;
  width: 100%;
  height: 16px;
  overflow: hidden;
  border: 1px solid #b8c6d8;
  border-radius: 999px;
  background: #e8eef6;
}

.control-bar.signed::after {
  content: "";
  position: absolute;
  top: -1px;
  bottom: -1px;
  left: 50%;
  width: 1px;
  background: rgba(65, 78, 98, 0.65);
}

.control-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: #1f6feb;
}

.control-fill.negative {
  background: #d97706;
}

.trim-button {
  width: 18px;
  min-width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #64748b;
  font-size: 10px;
  line-height: 1;
  pointer-events: auto;
}

.trim-button:hover,
.trim-button:focus-visible {
  color: #9ec5fe;
  background: rgba(110, 168, 254, 0.14);
}

.trim-marker {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  margin-left: -1px;
  border-radius: 999px;
  background: #f8fafc;
  opacity: 0.82;
}

.control-hud:not(.flight-active) .trim-button,
.control-hud:not(.flight-active) .trim-marker {
  display: none;
}

.control-hud:not(.flight-active) div:not(:first-child) {
  grid-template-columns: 72px minmax(0, 1fr) 46px;
}

.control-hud b {
  color: var(--ink);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.playback-controls {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.playback-controls .scrub-label {
  flex: 1 1 auto;
  min-width: 280px;
}

.playback-controls .segment-label {
  flex: 0 1 200px;
}

.playback-controls .speed-label {
  width: 120px;
}

.playback-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.flight-group {
  order: 1;
}

.model-picker {
  order: 2;
}

.scrub-label {
  order: 3;
}

#playback-predict {
  order: 5;
}

.playback-flight-status {
  order: 4;
  flex: 1 1 180px;
  min-width: 150px;
  max-width: 360px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playback-flight-status.error {
  color: #ffb4a9;
}

.selector-group {
  order: 6;
}

#flight-key-help {
  order: 7;
  margin-left: auto;
}

.playback-controls button {
  width: 42px;
  min-width: 42px;
  padding: 0;
  font-weight: 700;
}

.timeline-control {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 28px;
  gap: 4px;
  align-items: center;
  height: 38px;
  padding: 5px 7px;
  border: 1px solid #303741;
  border-radius: 3px;
  background: #2c3035;
}

.timeline-control button {
  width: 28px;
  min-width: 28px;
  height: 28px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: #f5f7fb;
  font-size: 13px;
  line-height: 1;
}

.timeline-control button:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: transparent;
}

.camera-label {
  width: 132px;
  min-width: 132px;
}

.camera-label select {
  width: 100%;
}

#flight-key-help {
  width: 28px;
  min-width: 28px;
  height: 34px;
  font-size: 14px;
  border-radius: 999px;
}

#playback-predict {
  width: auto;
  min-width: 0;
  padding: 0 14px;
  height: 34px;
  white-space: nowrap;
  font-weight: 600;
}

.model-picker {
  position: relative;
  display: grid;
  width: 220px;
  gap: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.model-title {
  display: none;
}

#playback-model-dd {
  position: relative;
}

#playback-model-dd summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 38px;
  padding: 0 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#playback-model-dd summary::after {
  content: "\25BE";
  margin-left: 8px;
  color: var(--muted);
}

.single-model-label {
  display: flex;
  align-items: center;
  height: 38px;
  min-width: 160px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 650;
}

.model-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 30;
  display: grid;
  gap: 2px;
  min-width: 360px;
  max-height: 300px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

.model-menu-head,
.model-menu-row {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) 44px 58px 62px;
  align-items: center;
  column-gap: 14px;
}

.model-menu-head {
  padding: 2px 6px 5px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.model-menu-row {
  padding: 5px 6px;
  border-radius: 4px;
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
}

.model-menu-head span:not(:first-child),
.model-menu-row > input,
.model-menu-row > button {
  justify-self: center;
}

.model-menu-row > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-menu-row:hover {
  background: rgba(110, 168, 254, 0.12);
}

.model-menu-row button {
  width: 52px;
  min-width: 52px;
  height: 28px;
  padding: 0;
  font-size: 12px;
  font-weight: 700;
}

.model-menu-row input[data-role="fly"] {
  width: 15px;
  height: 15px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid #7b8794;
  border-radius: 50%;
  background: #1f252c;
  cursor: pointer;
}

.model-menu-row input[data-role="fly"]:checked {
  border-color: #9ec5fe;
  background:
    radial-gradient(circle, #9ec5fe 0 38%, transparent 42%),
    #1f252c;
}

.model-menu-row input[data-role="fly"]:disabled {
  cursor: wait;
  opacity: 0.65;
}

#playback-model-menu button.active,
#playback-predict.active {
  border-color: #9ec5fe;
  background: #eaf2ff;
  color: var(--accent);
}

.sim-mode-action {
  display: none;
}

.sim-mode-panel {
  margin-top: 10px;
}

.autopilot-start-overlay {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  padding: 18px;
  pointer-events: none;
}

.autopilot-start-overlay[hidden] {
  display: none;
}

.autopilot-start-dialog {
  display: grid;
  width: min(360px, 100%);
  gap: 10px;
  padding: 16px;
  border: 1px solid #42638f;
  border-radius: 8px;
  background: rgba(10, 17, 27, 0.94);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.35);
  color: var(--ink);
  pointer-events: auto;
}

.autopilot-start-dialog span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.autopilot-start-dialog button {
  width: auto;
  min-width: 0;
  justify-self: start;
  padding: 0 14px;
}

.sim-mode-copy,
.waypoint-readout {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #1a1f24;
  color: var(--muted);
  font-size: 13px;
}

.sim-mode-copy b {
  color: var(--ink);
}

.autopilot-speed-readout {
  margin-left: auto;
  color: #33d17a;
  font-weight: 700;
  white-space: nowrap;
}

.autopilot-status-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px);
  gap: 8px;
  margin-top: 8px;
}

.waypoint-readout {
  color: #9ec5fe;
}

.lap-time-panel {
  min-height: 38px;
  max-height: 172px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #1a1f24;
}

.lap-time-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
}

.lap-time-heading span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.lap-time-list {
  display: grid;
  gap: 1px;
  max-height: 124px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.lap-time-list li {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 8px;
  padding: 7px 10px;
  background: #151a20;
  color: var(--muted);
  font-size: 12px;
}

.lap-time-list b {
  color: #9ec5fe;
  font-weight: 700;
}

.lap-time-list span:last-child {
  color: var(--ink);
}

.autopilot-rate-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.autopilot-rate-controls button {
  width: auto;
  min-width: 0;
  height: 30px;
  padding: 0 10px;
}

.autopilot-rate-controls button.active {
  background: #1f6feb;
  color: #fff;
}

.modelica-workbench {
  padding: 0;
  overflow: hidden;
}

.modelica-flight-panel {
  position: relative;
  border-top: 0;
  background: var(--panel-2);
}

.modelica-flight-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
}

.modelica-flight-toolbar button {
  width: auto;
  min-width: 0;
  padding: 0 12px;
}

.modelica-flight-toolbar button.busy {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.modelica-flight-toolbar button.busy::before {
  width: 12px;
  height: 12px;
  content: "";
  border: 2px solid rgba(220, 231, 245, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: modelica-spin 0.8s linear infinite;
}

.modelica-source-tabs {
  display: flex;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #111821;
}

.modelica-source-tabs button {
  height: 28px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
}

.modelica-source-tabs button.active {
  background: #1f6feb;
  color: #fff;
}

#modelica-flight-status {
  color: var(--muted);
  font-size: 0.85rem;
}

#modelica-flight-status.error {
  color: #ffb4a8;
}

.modelica-busy {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 8, 13, 0.72);
  color: var(--ink);
  cursor: wait;
}

.modelica-busy::before {
  content: "";
  position: absolute;
  width: min(420px, calc(100% - 48px));
  height: 112px;
  border: 1px solid #42638f;
  border-radius: 8px;
  background: rgba(10, 17, 27, 0.97);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.48);
}

.modelica-busy > * {
  position: relative;
  z-index: 1;
}

.modelica-busy[hidden] {
  display: none;
}

.modelica-spinner {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  background:
    radial-gradient(farthest-side, #101821 64%, transparent 66%),
    conic-gradient(from 0deg, #7dd3fc, #5c7cfa, #33d17a, transparent 82%);
  animation: modelica-spin 0.8s linear infinite;
}

.modelica-busy-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.modelica-busy-copy strong {
  font-size: 0.86rem;
}

.modelica-busy-copy span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

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

.modelica-diagnostics-panel {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  background: #101821;
}

.modelica-diagnostics-panel[hidden] {
  display: none;
}

.modelica-log-panel {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  background: #0f1720;
}

.modelica-log-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-size: 0.82rem;
}

.modelica-log-heading span {
  color: var(--muted);
  font-size: 0.76rem;
}

.modelica-log-list {
  display: grid;
  gap: 4px;
  max-height: 132px;
  overflow: auto;
  padding-right: 4px;
}

.modelica-log-row {
  display: grid;
  grid-template-columns: 86px 62px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  min-height: 24px;
  padding: 4px 6px;
  border: 1px solid #223244;
  border-radius: 5px;
  background: #111b26;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.35;
}

.modelica-log-row.error {
  border-color: #6d342f;
  color: #ffb4a8;
}

.modelica-log-row.step {
  border-color: #26465a;
  color: #9adcf6;
}

.modelica-log-level {
  color: var(--ink);
  text-transform: uppercase;
}

.modelica-log-message {
  min-width: 0;
  overflow-wrap: anywhere;
}

.diagnostic-heading {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  color: var(--ink);
  font-size: 0.82rem;
}

.diagnostic-heading span {
  color: var(--muted);
}

.diagnostic-list {
  display: grid;
  gap: 6px;
}

.diagnostic-row {
  display: grid;
  grid-template-columns: 72px 108px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  width: 100%;
  min-height: 34px;
  height: auto;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #18202a;
  text-align: left;
}

.diagnostic-row.error {
  border-color: #8f3d3d;
  background: #241919;
}

.diagnostic-row.warning {
  border-color: #8a6a22;
  background: #241f14;
}

.diagnostic-row:hover,
.diagnostic-row:focus-visible {
  border-color: #6ba3ff;
}

.diagnostic-severity {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
  text-transform: uppercase;
}

.diagnostic-row.error .diagnostic-severity {
  color: #ffb4a8;
}

.diagnostic-row.warning .diagnostic-severity {
  color: #ffd166;
}

.diagnostic-location {
  color: #9ec5fe;
  font-size: 0.76rem;
  white-space: nowrap;
}

.diagnostic-message {
  color: var(--ink);
  font-size: 0.76rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.compile-error {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #8f3d3d;
  border-radius: 6px;
  background: #241919;
  color: #ffb4a8;
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}

.modelica-metrics-output {
  border-top: 1px solid var(--line);
  padding: 12px 14px;
  background: #07111d;
  color: #dce7f5;
  font-size: 0.82rem;
}

.modelica-metrics-output h3 {
  margin: 0 0 4px;
  font-size: 0.9rem;
  color: #e7f0fb;
}

.modelica-metrics-output .metrics-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 0 0 12px;
  color: var(--muted);
}

.modelica-metrics-output .metrics-highlights strong {
  color: #9fd0ff;
  font-variant-numeric: tabular-nums;
}

.modelica-metrics-output .metrics-block {
  margin: 0 0 14px;
}

.modelica-metrics-output .metrics-block:last-child {
  margin-bottom: 0;
}

.modelica-metrics-output table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.modelica-metrics-output th,
.modelica-metrics-output td {
  padding: 3px 8px;
  text-align: right;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}

.modelica-metrics-output th:first-child,
.modelica-metrics-output td:first-child {
  text-align: left;
}

.modelica-metrics-output th {
  color: var(--muted);
  font-weight: 600;
}

.modelica-metrics-output tr.measured td {
  color: var(--mocap);
}

.modelica-metrics-output tr.measured td:first-child {
  font-weight: 600;
}

.modelica-metrics-output .metrics-tag {
  margin-left: 8px;
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  vertical-align: middle;
}

.modelica-metrics-output .metrics-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.modelica-flight-source {
  display: block;
  width: 100%;
  min-height: 280px;
  max-height: 46vh;
  resize: vertical;
  border: 0;
  border-top: 1px solid var(--line);
  padding: 14px;
  background: #07111d;
  color: #dce7f5;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  outline: none;
}

.modelica-flight-editor {
  display: none;
  width: 100%;
  height: min(460px, 46vh);
  min-height: 280px;
  border-top: 1px solid var(--line);
  background: #07111d;
}

.modelica-flight-panel.monaco-ready .modelica-flight-editor {
  display: block;
}

.modelica-flight-panel.monaco-ready .modelica-flight-source {
  display: none;
}

.scrub-label,
.speed-label,
.segment-label {
  min-width: 0;
}

.playback-controls input[type="range"],
.playback-controls select {
  width: 100%;
  min-width: 0;
}

.playback-controls input[type="range"] {
  height: 38px;
}

.axis-label,
.tick {
  fill: var(--muted);
  font-size: 12px;
}

.best-point-label {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 650;
}

.known-label {
  fill: var(--nominal);
  font-size: 42px;
  font-weight: 700;
  opacity: 0.08;
  text-transform: uppercase;
}

.unknown-label {
  fill: #687587;
  font-size: 42px;
  font-weight: 700;
  opacity: 0.1;
  text-transform: uppercase;
}

.select-rect {
  fill: rgba(110, 168, 254, 0.12);
  stroke: var(--accent);
  stroke-width: 1;
  stroke-dasharray: 4 3;
  pointer-events: none;
}

.nominal-line {
  stroke: var(--nominal);
  stroke-width: 1.8;
  stroke-dasharray: 8 6;
}

.tradeoff-point {
  cursor: pointer;
}

.tradeoff-point.no-trace {
  cursor: default;
}

.no-trace-row {
  color: var(--muted);
  cursor: default;
}

.plot-hint {
  fill: var(--muted);
  font-size: 12px;
}

.grid-line {
  stroke: var(--line);
  stroke-width: 1;
}

.axis-line {
  stroke: #5d6a79;
  stroke-width: 1.1;
}

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

.timeseries-grid svg {
  width: 100%;
  min-height: 170px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
}

.series-title {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 650;
}

.truth-series,
.method-series {
  fill: none;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.truth-series {
  stroke: #e4eaf2;
  stroke-width: 1.7;
}

.method-series {
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}

.two-column,
.grid-main {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 18px;
}

.side-stack {
  display: grid;
  align-content: start;
  gap: 18px;
}

.table-wrap {
  overflow-x: auto;
}

.table-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.definition-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.definition-list div {
  display: grid;
  grid-template-columns: minmax(120px, 0.22fr) minmax(0, 1fr);
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.definition-list div:first-child {
  padding-top: 0;
  border-top: 0;
}

.definition-list dt {
  color: var(--ink);
  font-weight: 700;
}

.definition-list dd {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

td.numeric {
  font-variant-numeric: tabular-nums;
}

tbody tr {
  cursor: pointer;
}

.selected-method-row {
  background: #e8f0fe;
  font-weight: 650;
}

.maneuver-list {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px 16px;
  margin: 0;
  font-size: 14px;
}

.maneuver-list dt {
  color: var(--muted);
}

.maneuver-list dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.upload-form {
  display: grid;
  gap: 12px;
}

.upload-form select,
.upload-form input[type="file"] {
  min-width: 0;
  width: 100%;
}

.upload-form button {
  justify-self: start;
  padding: 0 18px;
  background: #1f6feb;
  color: #ffffff;
  border-color: #1f6feb;
  font-weight: 650;
}

.upload-status {
  color: var(--muted);
  font-size: 13px;
}

.action-progress {
  width: 100%;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ebf2;
}

.action-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 160ms ease;
}

.command-output {
  min-height: 58px;
  overflow-x: auto;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f2f5f9;
  color: #253040;
  font-size: 12px;
  white-space: pre-wrap;
}

@media (max-width: 900px) {
  .app-header,
  .controls {
    align-items: stretch;
    flex-direction: column;
  }

  .run-meta {
    text-align: left;
  }

  .header-links {
    justify-items: start;
  }

  .summary-grid,
  .two-column,
  .grid-main,
  .timeseries-grid {
    grid-template-columns: 1fr;
  }

  select,
  input[type="file"] {
    min-width: 0;
    width: 100%;
  }

  .panel-heading,
  .definition-list div {
    display: grid;
    grid-template-columns: 1fr;
  }

  .panel-actions {
    justify-content: flex-start;
  }

  .speed-label {
    grid-column: 1 / -1;
  }

  .segment-label {
    grid-column: 1 / -1;
  }
}

/* Flight explorer */
.explorer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.explorer-methods label {
  margin-right: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.explorer-legend span {
  margin-right: 0.7rem;
  font-size: 0.85rem;
  color: #444;
}
.explorer-legend i {
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-right: 0.3em;
  border-radius: 2px;
}
.explorer-timeline,
.explorer-chart {
  width: 100%;
  margin-bottom: 0.4rem;
}
.explorer-badge {
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  font-size: 0.75rem;
  color: #fff;
}
.explorer-badge.train { background: #444; }
.explorer-badge.validation { background: #d62728; }

/* Dark is the default theme; these override the hardcoded light surfaces. */
button:hover {
  border-color: #4a5868;
}
.segmented button.active,
.view-tabs button.active,
#playback-model-menu button.active,
#playback-predict.active,
.selected-method-row {
  background: #243043;
  color: #9ec5fe;
}
.segmented button.active,
.view-tabs button.active,
#playback-model-menu button.active,
#playback-predict.active {
  border-color: #3d5a85;
}
.view-tabs {
  background: var(--panel);
}
.control-hud {
  background: rgba(30, 35, 41, 0.92);
  color: var(--ink);
}
.control-bar {
  background: #2c333c;
}
.timeseries-grid svg {
  background: #1a1f24;
}
svg text {
  fill: #aab4bf;
}



.splits-chart {
  display: grid;
  gap: 10px;
  padding: 6px 0 2px;
}

.splits-row {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.splits-name {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.splits-lane {
  position: relative;
  height: 32px;
}

.splits-bar {
  position: absolute;
  inset: 6px 0;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.splits-window {
  position: absolute;
  top: 0;
  height: 5px;
  border-radius: 2px;
}

.splits-window.splits-below {
  top: auto;
  bottom: 0;
}

.splits-train,
.splits-train-key {
  background: #3fb950;
}

.splits-validation,
.splits-validation-key {
  background: #f85149;
}

.splits-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.splits-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.splits-legend i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.splits-notes {
  max-width: 980px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.splits-notes p {
  margin: 0 0 10px;
}

#animation-view:fullscreen {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #262b31;
}

#animation-view:fullscreen .playback-stage {
  flex: 1;
  min-height: 0;
}

#animation-view:fullscreen .aircraft-playback {
  height: 100%;
  border: none;
  border-radius: 0;
}

#animation-view:fullscreen .playback-controls {
  flex-wrap: nowrap;
  padding: 0.6rem 1rem;
  background: #1a1f24;
}

@media (max-width: 1100px) {
  .playback-controls {
    flex-wrap: wrap;
  }

  .playback-controls .scrub-label {
    flex-basis: 100%;
    order: 10;
  }
}

/* Segmentation-colored playback scrubber */
#playback-scrub {
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 0;
  border: 0;
  background: #777;
}

#playback-scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 5px;
  height: 18px;
  border-radius: 1px;
  background: #f1f5f9;
  border: 1px solid #0d1117;
  cursor: pointer;
}

#playback-scrub::-moz-range-thumb {
  width: 5px;
  height: 18px;
  border-radius: 1px;
  background: #f1f5f9;
  border: 1px solid #0d1117;
  cursor: pointer;
}


.explorer-status {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}


/* Summary metrics live beside the Maneuver panel in the side stack. */
.side-stack .summary-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 0;
}


/* Qualisys-style trail window on the time bar */
.scrub-wrap {
  position: relative;
}

#trail-window {
  position: absolute;
  top: 1px;
  height: 12px;
  border: 1px solid rgba(241, 245, 249, 0.75);
  border-radius: 4px;
  pointer-events: none;
}

#trail-past-handle,
#trail-future-handle {
  position: absolute;
  top: -7px;
  width: 10px;
  height: 8px;
  cursor: ew-resize;
  touch-action: none;
}

#trail-past-handle::after,
#trail-future-handle::after {
  content: "";
  display: block;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid #cbd5e1;
}

/* Model inspector: picker above a full-width detail card; the card's
   internal parameter groups spread across the width on their own grid. */
.models-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}

.model-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.model-table td {
  padding: 1px 6px;
  border-bottom: 1px solid #262b31;
}

.model-table td:last-child {
  text-align: right;
}

.model-note,
.model-terms {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.scrub-legend {
  display: flex;
  gap: 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.scrub-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.scrub-legend i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

#model-inspect-select {
  min-width: 280px;
}

.model-detail {
  width: 100%;
  box-sizing: border-box;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1a1f24;
}

.model-detail h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.model-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px 28px;
  margin: 8px 0;
}

.method-info {
  margin: 4px 0 10px;
  padding: 8px 10px;
  border-left: 3px solid var(--accent);
  background: rgba(110, 168, 254, 0.07);
  border-radius: 4px;
}

.method-info .model-note:last-child {
  margin-bottom: 0;
}

.modelica-source {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.modelica-source > summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}

.modelica-code {
  max-height: 320px;
  overflow: auto;
  margin: 6px 0 12px;
  padding: 10px 12px;
  background: #11151a;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink);
  white-space: pre;
}

.mo-download {
  color: var(--accent);
  font-size: 12px;
}
