:root {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #182732;
  background: #f1f3f3;
  font-synthesis: none;
  --muted: #52616a;
  --line: #d9e0e2;
  --ink: #11252d;
  --teal: #126957;
  --mint: #72e7c5;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea { font: inherit; }
button, summary { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
:focus-visible { outline: 3px solid #258d7e; outline-offset: 3px; }

.topbar { background: #fff; border-bottom: 1px solid var(--line); }
.topbar-inner, main { max-width: 1584px; margin: auto; padding-inline: clamp(18px, 3vw, 40px); }
.topbar-inner {
  min-height: 64px;
  padding-block: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.identity { display: flex; align-items: center; gap: 15px; }
.identity strong { font-size: 22px; letter-spacing: -.8px; }
.identity span { border-left: 1px solid var(--line); padding-left: 15px; }
.identity span, .attribution { font-size: 13px; color: var(--muted); }

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 14px;
  margin-block: 24px 20px;
}
h1 { margin: 0; font-size: clamp(27px, 3vw, 40px); letter-spacing: -.04em; line-height: 1.1; }
.page-heading p { margin: 8px 0 0; color: var(--muted); font-size: 15px; }
.connection { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.connection::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #8a6935; flex: none; }
.connection[data-connected="true"]::before { background: #187861; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 366px); gap: 20px; align-items: start; }
.stage { overflow: hidden; border: 1px solid #263943; border-radius: 9px; background: #13232d; color: #e9f0f3; }
.stage-header, .stage-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  min-height: 51px;
  padding: 8px 16px;
}
.view-switch { display: flex; flex-wrap: wrap; gap: 3px; }
.view-switch button {
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #b6c7d0;
  font-size: 13px;
}
.view-switch button:hover { background: #233c49; color: #fff; }
.view-switch button[aria-pressed="true"] { background: #25414a; color: #f0fbf8; border-color: #446269; }
.scene-state { color: var(--mint); font-size: 12px; font-weight: 650; }
.scene-state[data-tone="reject"] { color: #ffabb5; }

#viewport {
  position: relative;
  height: clamp(400px, 56vh, 650px);
  overflow: hidden;
  isolation: isolate;
  background: #182934;
}
#viewport canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#scene-failure {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-content: center;
  padding: 30px;
  background: #172933;
  color: #fff;
}
.spatial-label, .scene-stamp, .scene-help {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  border: 1px solid #49616f;
  border-radius: 3px;
  padding: 5px 8px;
  background: #152730ee;
  color: #d7e2e9;
  font-size: 11px;
  white-space: nowrap;
}
.spatial-label { max-width: 144px; overflow: hidden; text-overflow: ellipsis; }
.spatial-label.path-label { color: #9af5db; border-color: #4e9485; }
.stage:has(.scene-state[data-tone="reject"]) .path-label { color: #ffb6bf; border-color: #b8707a; }
.scene-stamp { left: 13px; top: 13px; }
.scene-help { right: 13px; bottom: 13px; }
.operator-panel {
  position: absolute;
  top: 13px;
  right: 13px;
  z-index: 1;
  display: grid;
  gap: 7px;
  min-width: 154px;
  padding: 10px 12px;
  border: 1px solid #6d8694;
  border-radius: 5px;
  background: #172a35e8;
  color: #eef5f7;
  box-shadow: 0 4px 14px #172a353a;
  pointer-events: none;
}
.operator-panel strong { font-size: 13px; color: #a0e9d2; }
.operator-panel[data-tone="reject"] strong { color: #ffc1c8; }
.operator-panel span { display: flex; justify-content: space-between; gap: 14px; font-size: 11px; }
.operator-panel b { font-variant-numeric: tabular-nums; }
.view-reset { padding: 4px 7px; border: 1px solid #49616f; border-radius: 3px; color: #e9f0f3; background: transparent; text-decoration: none; }
.view-reset:hover { background: #25414a; }

#lens { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 30px 12px #0009; }
#lens::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; border-left: 2px solid #17212a; }

.stage-footer { border-top: 1px solid #31454f; color: #bfced5; font-size: 12px; }
.scene-toggles, .legend { display: flex; flex-wrap: wrap; align-items: center; gap: 9px 15px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend span::before { content: ""; width: 12px; height: 2px; background: var(--mint); }
.legend .legend-zone::before,
.stage:has(.scene-state[data-tone="reject"]) .legend-path::before { background: #ff99a5; }
.telemetry {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  border-top: 1px solid #31454f;
}
.telemetry > div { padding: 12px 16px; }
.telemetry > div + div { border-left: 1px solid #31454f; }
.telemetry dt { color: #b6c7d0; font-size: 12px; }
.telemetry dd { margin: 3px 0 0; font-size: 25px; font-weight: 640; font-variant-numeric: tabular-nums; }
.telemetry dd span { margin-left: 4px; font-size: 12px; font-weight: 500; color: #b6c7d0; }

.controls { background: #fff; border: 1px solid var(--line); border-radius: 9px; }
.control-section { padding: 16px 18px; }
.control-section + .control-section { border-top: 1px solid var(--line); }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
h2 { font-size: 17px; letter-spacing: -.02em; margin: 0; line-height: 1.2; }
.button, .presets button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 10px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.2;
}
.button:hover:enabled, .presets button:hover { border-color: #6f8b89; }
.button.primary { min-height: 40px; border-color: #126957; background: #126957; color: #fff; }
.button.primary:hover:enabled { background: #0e584a; }
.button.danger { border-color: #ddc4c7; color: #a03542; }
.button.danger:hover:enabled { background: #f9ecee; }
.button.full { width: 100%; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.presets button { padding-inline: 8px; }
.presets button[aria-pressed="true"] { border-color: #568c7e; background: #e7f2ed; color: #174e42; }
.field-label { display: block; margin-bottom: 5px; font-size: 13px; font-weight: 600; }
textarea {
  display: block;
  width: 100%;
  min-height: 54px;
  margin-bottom: 8px;
  padding: 8px 9px;
  border: 1px solid #bcc9cb;
  border-radius: 4px;
  resize: vertical;
  color: var(--ink);
  background: #f8faf9;
  font-size: 14px;
  line-height: 1.35;
}
.verdict {
  margin: 12px 0;
  border-left: 3px solid #9aaab0;
  background: #edf1f2;
  color: #253845;
  padding: 9px 11px;
}
.verdict.pass { border-color: #23876e; background: #e8f4ee; color: #174538; }
.verdict.reject { border-color: #b4515d; background: #faedef; color: #7d2833; }
.verdict strong { display: block; font-size: 15px; }
.verdict p { margin: 4px 0 0; font-size: 13px; line-height: 1.35; }
.check-label { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; line-height: 1.3; }
.check-label input { margin: 0; width: 16px; height: 16px; accent-color: #126957; flex: none; }
.confirmation { margin-bottom: 8px; }
.run-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 9px; }
progress { display: block; width: 100%; height: 6px; margin-top: 10px; border: 0; accent-color: var(--teal); }
.control-section:has(.verdict.reject) progress { accent-color: #a03542; }
.progress-text { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.disclosure { border-top: 1px solid var(--line); padding: 0 18px; }
summary { padding-block: 13px; font-size: 13px; font-weight: 650; }
summary span { float: right; font-weight: 500; color: var(--muted); }
.checks, .activity ol { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; align-items: flex-start; gap: 9px; border-top: 1px solid var(--line); padding-block: 7px; }
.checks strong, .checks small { display: block; line-height: 1.4; }
.checks strong { font-size: 13px; }
.checks small, .intent { color: var(--muted); font-size: 12px; }
.check-icon { color: #126957; font-size: 13px; }
.check-icon.fail { color: #a03542; }
.intent { margin: 6px 0 12px; line-height: 1.45; }
.intent strong { color: var(--ink); }
.intent p { margin: 4px 0 0; }
.sensor-controls { padding-bottom: 12px; font-size: 13px; }
.sensor-controls > label:not(.check-label) { display: flex; justify-content: space-between; margin-top: 5px; }
.sensor-controls input[type="range"] { width: 100%; accent-color: var(--teal); }
.sensor-controls .check-label { margin-top: 8px; flex-wrap: wrap; }
#vlm-status { color: var(--muted); font-size: 12px; }

.activity { margin-top: 14px; padding-inline: 16px; border: 1px solid var(--line); background: #fff; border-radius: 5px; color: var(--ink); }
.activity li { display: grid; grid-template-columns: 70px 84px 1fr; gap: 9px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.event-time, .event-type { color: var(--muted); font-variant-numeric: tabular-nums; }
footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 7px 14px; padding-block: 12px 16px; color: var(--muted); font-size: 12px; }
#toast { position: fixed; z-index: 3; bottom: 16px; right: 16px; max-width: min(430px, calc(100vw - 32px)); padding: 11px 14px; border-radius: 5px; background: #182f3b; color: #fff; font-size: 14px; }

@media (max-width: 860px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  #viewport { height: clamp(360px, 56vh, 560px); }
}
@media (max-width: 540px) {
  .topbar-inner, .page-heading { align-items: start; flex-direction: column; }
  .topbar-inner { gap: 5px; }
  .page-heading { margin-top: 18px; }
  .workspace { gap: 14px; }
  .stage-header, .stage-footer, .telemetry > div { padding-inline: 10px; }
  .view-switch button { padding-inline: 6px; font-size: 12px; }
  #viewport { height: 360px; }
  .operator-panel { top: auto; bottom: 48px; right: 10px; }
  .telemetry dd { font-size: 21px; }
  .telemetry dt { font-size: 11px; }
  .activity li { grid-template-columns: 65px 1fr; gap: 3px 8px; }
  .activity li > :last-child { grid-column: 1 / -1; }
}
