:root {
  color-scheme: dark;
  --page: #0b1114;
  --panel: #10191d;
  --inset: #0e171b;
  --raised: #172329;
  --line: #28383e;
  --muted: #94a8af;
  --text: #e2ebed;
  --accent: #8dddcf;
  --active: #163733;
  --idle: #82909c;
  --move: #e76624;
  --inspect: #338ced;
  --feed: #00a888;
  --stage-color: #e76624;
  --box: #5e8c97;
  --free: #374c54;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; }
button, select, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button:disabled { opacity: .35; cursor: default; }
button, select { -webkit-tap-highlight-color: transparent; }
.topbar { height: 66px; padding: 0 23px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); background: #10181c; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-icon { width: 34px; height: 34px; padding: 7px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; border: 1px solid #315951; border-radius: 9px; background: #132a29; transform: rotate(-7deg); }
.brand-icon i { background: #77c8b9; border-radius: 1px; }
.brand-icon i:nth-child(3) { opacity: .35; }
.brand-icon i:nth-child(4) { opacity: .6; }
.brand strong, .brand div span { display: block; }
.brand strong { font-size: 15px; letter-spacing: .055em; }
.brand div span { margin-top: 3px; font-size: 11px; color: var(--muted); }
.views { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--inset); }
.view-tab { padding: 8px 14px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: 13px; white-space: nowrap; }
.view-tab[aria-pressed=true] { background: #26393e; color: var(--text); }
.view-tab:hover, .entity-tab:hover { color: var(--text); }
.view-symbol { margin-right: 3px; color: var(--accent); }
.day-badge { display: flex; align-items: center; gap: 7px; white-space: nowrap; font-size: 12px; color: var(--muted); }
.day-badge time { margin-left: 8px; font: 12px var(--mono); color: var(--text); }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.workspace { width: 100%; max-width: 1920px; margin: auto; padding: 16px 18px 18px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(286px, 315px); grid-template-rows: minmax(438px, 1fr) auto; gap: 14px; min-height: calc(100dvh - 66px); height: calc(100dvh - 66px); }
.spatial, .sidebar, .timeline { min-width: 0; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); }
.spatial { display: flex; flex-direction: column; overflow: hidden; }
.spatial-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding: 16px 17px 12px; }
.breadcrumb { color: var(--muted); font-size: 11px; display: flex; gap: 6px; align-items: center; min-height: 16px; }
.breadcrumb button { border: 0; background: transparent; padding: 0; color: var(--accent); }
h1 { margin: 4px 0 0; font-size: clamp(20px, 2.15vw, 31px); letter-spacing: .055em; line-height: 1.17; }
.scene-tools { display: flex; gap: 5px; }
.icon-btn, .quiet-btn { display: inline-grid; place-items: center; border: 1px solid var(--line); background: var(--inset); border-radius: 6px; font-size: 12px; color: var(--muted); min-height: 32px; padding: 0 10px; white-space: nowrap; }
.icon-btn:is(:hover,.active), .quiet-btn:hover { color: var(--text); border-color: #557378; }
.icon-btn.active { color: var(--accent); background: var(--active); }
.spatial-controls { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 17px 10px; }
.spatial-controls label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
select { min-height: 31px; color: var(--text); border: 1px solid var(--line); background: var(--inset); border-radius: 6px; padding: 3px 7px; }
.view-stage { position: relative; flex: 1; min-height: 230px; overflow: hidden; margin: 0 10px; border: 1px solid #283940; border-radius: 8px; background: radial-gradient(ellipse at 46% 42%, #203136, #0d1519 82%); }
.view-stage::before { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .26; background-image: linear-gradient(#3b555a 1px, transparent 1px), linear-gradient(90deg, #3b555a 1px, transparent 1px); background-size: 24px 24px; mask-image: radial-gradient(ellipse, transparent 16%, black); }
.viewport, .scene-labels { position: absolute; inset: 0; }
.viewport canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; cursor: grab; }
.viewport canvas:active { cursor: grabbing; }
.scene-labels { overflow: hidden; pointer-events: none; }
.scene-tag { position: absolute; left: 0; top: 0; z-index: 1; padding: 2px 4px; line-height: 1.2; background: #16262e; color: #deebef; border: 1px solid #52737a; border-radius: 3px; font: 10px var(--mono); white-space: nowrap; }
button.scene-tag { pointer-events: auto; }
.scene-tag.robot { z-index: 2; background: #14242ceb; font-size: 9px; padding: 2px 3px; }
.scene-tag.chosen, .scene-tag:hover { z-index: 3; color: #111b1b; background: var(--accent); }
.scene-tag.station { background: #d1dde0; color: #19282f; border-color: #8fa8ab; }
.scene-tag.axis, .scene-tag.zone { color: #b7c9cd; background: none; border: 0; font-size: 10px; }
.scene-tag.zone { color: #e2ebed; font-family: inherit; }
.spatial-notice { position: absolute; z-index: 5; top: 10px; left: 10px; padding: 8px 12px; border-radius: 5px; border: 1px solid var(--line); background: var(--inset); color: var(--text); font-size: 12px; }
.spatial-foot { min-height: 44px; padding: 9px 15px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 7px 12px; font-size: 11px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; color: var(--muted); }
.swatch { width: 9px; height: 9px; border-radius: 2px; display: inline-block; flex: none; background: var(--swatch, var(--idle)); }
.spatial-hint { color: var(--muted); font-size: 11px; }
.spatial-table { position: absolute; inset: 0; overflow: auto; background: var(--inset); }
.spatial-table table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
.spatial-table th, .spatial-table td { padding: 7px 12px; border-bottom: 1px solid var(--line); }
.spatial-table th { position: sticky; top: 0; background: var(--raised); color: var(--muted); z-index: 1; }
.spatial-table td button { border: 0; padding: 3px 0; background: transparent; color: var(--accent); font-family: var(--mono); }
.spatial-table td:not(:first-child) { font-variant-numeric: tabular-nums; }
.sidebar { display: flex; flex-direction: column; overflow: hidden; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; min-height: 51px; padding: 12px 14px; gap: 6px; }
h2 { font-size: 15px; letter-spacing: .025em; margin: 0; }
.entity-tabs { margin: 0 12px 9px; padding: 4px; display: flex; gap: 4px; border: 1px solid var(--line); border-radius: 7px; background: var(--inset); }
.entity-tab { border: 0; padding: 7px 4px; border-radius: 5px; color: var(--muted); background: transparent; flex: 1; font-size: 12px; }
.entity-tab[aria-pressed=true] { color: var(--text); background: #26393e; }
.entity-tab span { margin-left: 5px; font: 11px var(--mono); color: var(--accent); }
.entity-scroll { overflow: auto; flex: 1; min-height: 0; scrollbar-width: thin; scrollbar-color: #385057 transparent; }
#entity-list, #entity-detail { padding: 0 12px 12px; }
.entity-row { width: 100%; display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 8px; min-height: 48px; padding: 6px 7px; text-align: left; border: 1px solid transparent; border-bottom-color: var(--line); background: transparent; }
.entity-row:hover { border-color: #43636a; background: var(--raised); border-radius: 6px; }
.equip-icon { display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid #345159; border-radius: 5px; color: var(--accent); background: #17282c; font: 15px var(--mono); }
.entity-id { font: 600 13px var(--mono); }
.entity-name { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.state { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.state .swatch { width: 6px; height: 6px; border-radius: 50%; }
.state.busy { color: var(--text); }
.detail-card { border-radius: 8px; background: var(--inset); border: 1px solid var(--line); padding: 11px; margin: 0 0 10px; }
.detail-card h3, .history-head h3 { margin: 0; font-size: 13px; }
.detail-card p { font-size: 12px; line-height: 1.55; margin: 6px 0; color: var(--muted); overflow-wrap: anywhere; }
.detail-card strong { color: var(--text); }
.info-fields { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 8px; margin: 10px 0 0; font-size: 11px; line-height: 1.5; }
.info-fields dt { color: var(--muted); }
.info-fields dd { margin: 0; overflow-wrap: anywhere; }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 5px; margin: 13px 0 6px; }
.history-nav { display: flex; align-items: center; gap: 4px; font: 10px var(--mono); color: var(--muted); }
.history-nav button { min-height: 25px; padding: 0 7px; }
.history-row { width: 100%; display: grid; gap: 7px; grid-template-columns: 65px 1fr; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: transparent; border-radius: 3px; padding: 7px 4px; font-size: 11px; line-height: 1.48; }
.history-row:hover, .history-row[aria-current=true] { background: var(--active); }
.history-row time { font: 10px var(--mono); color: var(--accent); padding-top: 3px; }
.history-row small { display: block; color: var(--muted); overflow-wrap: anywhere; }
.empty-note { color: var(--muted); font-size: 12px; }
.inline-btn { color: var(--accent); margin: 6px 4px 0 0; }
.timeline { grid-column: 1 / -1; padding: 10px 15px 9px; }
.timeline-top, .transport, .time-display, .timeline-caption { display: flex; align-items: center; gap: 10px; }
.timeline-top { gap: 16px; }
.time-display { align-items: baseline; }
.time-display time { color: var(--accent); font: 600 clamp(19px, 2.9vw, 31px) var(--mono); letter-spacing: .025em; }
.time-display span, .timeline-caption { color: var(--muted); font-size: 11px; white-space: nowrap; }
.transport { gap: 5px; }
.control { min-width: 30px; padding: 0 6px; font-size: 17px; }
.play-btn { width: 38px; height: 32px; border: 0; border-radius: 6px; background: var(--accent); color: #102420; }
.play-btn:hover { background: #a7eee0; }
.speed select { font: 12px var(--mono); padding: 1px 5px; }
.timeline-caption { margin-left: auto; gap: 6px; }
.timeline-caption span:first-child { color: var(--text); }
.scrubber { position: relative; margin: 8px 0 5px; }
.activity-band { height: 23px; display: grid; align-items: end; gap: 2px; margin: 0 7px -8px; padding-bottom: 3px; border-bottom: 1px solid var(--line); cursor: pointer; }
.activity-bin { display: block; border-radius: 2px 2px 0 0; height: var(--level); background: #508c85; }
.activity-bin:where(.passed) { background: #8dddcf; }
.band-tooltip { position: absolute; z-index: 6; bottom: 100%; max-width: 230px; transform: translateX(-50%); padding: 6px 8px; font-size: 11px; white-space: nowrap; background: #10191d; border: 1px solid #526970; border-radius: 5px; pointer-events: none; }
#seek { display: block; position: relative; width: 100%; height: 20px; margin: 0; appearance: none; background: transparent; cursor: ew-resize; }
#seek::-webkit-slider-runnable-track { height: 4px; background: linear-gradient(to right, #87daca var(--progress, 0%), #395158 var(--progress, 0%)); border-radius: 4px; }
#seek::-webkit-slider-thumb { appearance: none; width: 14px; height: 14px; margin-top: -5px; background: #a8eee0; border: 2px solid #172a2d; border-radius: 50%; }
#seek::-moz-range-track { height: 4px; background: #395158; border-radius: 4px; }
#seek::-moz-range-progress { height: 4px; background: #87daca; border-radius: 4px; }
#seek::-moz-range-thumb { width: 11px; height: 11px; background: #a8eee0; border: 2px solid #172a2d; border-radius: 50%; }
.time-ruler { position: relative; height: 18px; margin: 0 7px; }
.time-ruler button { position: absolute; transform: translateX(-50%); color: var(--muted); background: transparent; border: 0; padding: 3px 0; font: 10px var(--mono); }
.time-ruler button:first-child { transform: translateX(-7px); }
.time-ruler button:last-child { transform: translateX(calc(-100% + 7px)); }
.time-ruler button:hover { color: var(--accent); }
.metrics { display: flex; flex-wrap: wrap; gap: 5px 20px; margin-top: 5px; padding-top: 6px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.metric strong { margin-right: 4px; font: 600 12px var(--mono); color: var(--text); }
@media (max-height: 718px) and (min-width: 801px) { .workspace { height: auto; } }
@media (max-width: 800px) {
  .workspace { height: auto; padding: 10px; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; gap: 10px; }
  .spatial { min-height: min(575px, 74dvh); }
  .sidebar { min-height: 250px; max-height: 440px; }
  .timeline { grid-column: auto; grid-row: 2; position: sticky; bottom: 0; z-index: 10; }
  .topbar { padding: 0 12px; }
  .day-badge span:not(.status-dot) { display: none; }
  .day-badge time { margin-left: 1px; }
}
@media (max-width: 515px) {
  .topbar { height: auto; padding: 9px 12px; flex-wrap: wrap; }
  .views { order: 3; width: 100%; }
  .view-tab { flex: 1; padding: 6px; }
  .topbar .brand div span { font-size: 10px; }
  .spatial { min-height: 440px; }
  .spatial-head { padding: 10px 10px 8px; }
  .spatial-controls { padding: 0 10px 8px; }
  .scene-tools { gap: 3px; }
  .icon-btn { padding: 0 6px; }
  .spatial-foot { padding: 8px 10px; }
  .time-display span, .timeline-caption span:last-child { display: none; }
  .timeline { padding: 8px 9px; }
  .timeline-top { gap: 8px; }
  .time-ruler button:nth-child(2n+2):not(:last-child) { display: none; }
  .spatial-table td, .spatial-table th { padding: 6px 5px; font-size: 11px; }
}
@media (forced-colors: active) { .legend-item .swatch { border: 1px solid CanvasText; } }
