/* ==========================================================================
   万物解构 · 观察台 UI Kit — shell & components
   Depends on tokens.css. Page-specific visuals belong in the page's own CSS.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. page frame
   -------------------------------------------------------------------------- */
body {
  display: flex;
  flex-direction: column;
}

.site-header {
  position: relative;
  z-index: 30;
  flex: 0 0 auto;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 12px clamp(12px, 2.2vw, 20px) 0;
  padding: 0 12px 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--header-bg);
  box-shadow: var(--header-shadow);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  padding: 7px;
  border: 1px solid var(--accent-line);
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  stroke-width: 1.15;
  transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.brand-sub {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.series-line {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
  white-space: nowrap;
}

.series-line i {
  width: 14px;
  height: 1px;
  background: var(--line-strong);
}

.series-line a {
  color: inherit;
  text-decoration: none;
}

.series-line a:hover {
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.header-spec {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 2px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--paper);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.header-spec span {
  color: var(--line-strong);
}

.header-actions .text-button {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--paper);
}

.header-tools .icon-button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.header-tools .icon-button svg {
  width: 14px;
  height: 14px;
}

/* Optional liquid-glass header skin: add data-glass="liquid" to .site-header.
   Pair it with a grid, model frame or other structured backdrop for the full effect. */
.site-header[data-glass="liquid"] {
  isolation: isolate;
  overflow: hidden;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.site-header[data-glass="liquid"]::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border: 1px double rgba(51, 51, 51, 0.1);
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.035);
  box-shadow:
    inset 2px -2px 1px -1px rgba(255, 255, 255, 0.9),
    inset -2px 2px 1px -1px rgba(255, 255, 255, 0.75),
    inset 6px -6px 1px -6px rgba(255, 255, 255, 0.5),
    inset -6px 6px 1px -6px rgba(255, 255, 255, 0.5),
    inset 0 0 2px rgba(0, 0, 0, 0.55),
    0 8px 20px rgba(20, 35, 55, 0.16);
  backdrop-filter: blur(2px) contrast(2.8) brightness(0.94) saturate(1.04);
  -webkit-backdrop-filter: blur(2px) contrast(2.8) brightness(0.94) saturate(1.04);
}

.site-header[data-glass="liquid"]::after {
  content: "";
  position: absolute;
  inset: 5px;
  z-index: 0;
  border: 1.5px solid rgba(0, 0, 0, 0.58);
  border-radius: inherit;
  background:
    radial-gradient(320px 70px at 0% 0%, rgba(255, 255, 255, 0.32), transparent 72%),
    radial-gradient(280px 60px at 100% 100%, rgba(255, 255, 255, 0.24), transparent 72%);
  filter: blur(3px);
  opacity: 0.52;
  pointer-events: none;
}

.site-header[data-glass="liquid"] > * {
  position: relative;
  z-index: 1;
}

body.dark .site-header[data-glass="liquid"]::before {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.045);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.34),
    inset 0 7px 12px -10px rgba(255, 255, 255, 0.12),
    inset 0 -11px 16px -12px rgba(0, 0, 0, 0.65),
    inset 0 0 3px rgba(0, 0, 0, 0.7),
    0 10px 26px rgba(0, 0, 0, 0.42);
}

body.dark .site-header[data-glass="liquid"]::after {
  border-color: rgba(0, 0, 0, 0.68);
}

/* --------------------------------------------------------------------------
   2. shell / workbench frame
   -------------------------------------------------------------------------- */
.shell {
  flex: 1 1 auto;
  min-height: 0;
  padding: 10px var(--shell-margin-x) var(--shell-margin);
  display: flex;
}

.workbench {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--frame-line);
  border-radius: var(--r-xl);
  background: var(--frame-bg);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  box-shadow: var(--shadow-lg);
  animation: shell-in 0.55s var(--ease) both;
}

@keyframes shell-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   3. view header
   -------------------------------------------------------------------------- */
.view-header {
  position: relative;
  z-index: 6;
  flex: 0 0 auto;
  height: var(--viewbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
}

.view-status {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  font-size: 11px;
  white-space: nowrap;
}

.live-dot {
  width: 5px;
  height: 5px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

#mode-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.view-code {
  margin-left: 10px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.03em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.view-switches {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* segmented control with a sliding thumb */
.segmented {
  --seg-count: 3;
  --seg-index: 0;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--seg-count), minmax(0, 1fr));
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper);
  isolation: isolate;
}

.segmented button {
  position: relative;
  z-index: 1;
  padding: 6px 14px;
  border-radius: var(--r-sm);
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.segmented button.active {
  color: var(--ink-strong);
}

.segmented-thumb {
  position: absolute;
  z-index: 0;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px - (var(--seg-count) - 1) * 2px) / var(--seg-count));
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transform: translateX(calc(var(--seg-index) * (100% + 2px)));
  transition: transform var(--dur-slow) var(--ease);
}

/* project pages can keep data-active in sync instead of setting --seg-index */
.segmented[data-active="assembled"] {
  --seg-index: 0;
}

.segmented[data-active="cutaway"] {
  --seg-index: 1;
}

.segmented[data-active="exploded"] {
  --seg-index: 2;
}

/* --------------------------------------------------------------------------
   4. three-zone body
   -------------------------------------------------------------------------- */
.bench-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: var(--w-nav) minmax(0, 1fr) var(--w-inspector);
  gap: var(--gap);
  padding: var(--body-pad);
}

.panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--panel-line);
  border-radius: var(--r-lg);
  background: var(--panel-bg);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
}

/* --------------------------------------------------------------------------
   5. left navigation
   -------------------------------------------------------------------------- */
.side-panel {
  position: relative;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 13px 9px 9px;
  overflow: hidden;
}

.panel-heading {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 8px 9px;
}

#system-list {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 58%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.system-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 45px;
  padding: 8px 8px;
  margin-bottom: 2px;
  border-radius: 10px;
  text-align: left;
  color: var(--ink);
}

.system-index {
  width: 17px;
  flex: 0 0 auto;
  font-family: var(--font-serif);
  font-size: 10px;
  color: var(--faint);
}

.system-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.system-copy strong {
  overflow: hidden;
  color: inherit;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.system-copy small {
  overflow: hidden;
  color: var(--faint);
  font-size: 8px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.system-item > svg {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  color: var(--faint);
  opacity: 0;
  transition: opacity var(--dur-fast) ease, transform var(--dur-fast) var(--ease);
}

.system-item.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.system-item.active .system-index {
  color: var(--accent);
}

.system-item.active small {
  color: var(--accent);
  opacity: 0.72;
}

.system-item.active > svg {
  opacity: 1;
}

.side-divider {
  flex: 0 0 auto;
  height: 1px;
  margin: 8px 8px;
  background: var(--line);
}

.section-toggle {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 2px 8px 7px;
  text-align: left;
}

.section-toggle .eyebrow {
  color: var(--muted);
}

.section-toggle .tiny {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 8px;
}

.section-toggle > svg {
  width: 12px;
  height: 12px;
  color: var(--faint);
  transition: transform var(--dur) var(--ease);
}

.section-toggle[aria-expanded="false"] > svg {
  transform: rotate(-90deg);
}

#phase-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.phase-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 31px;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  text-align: left;
  color: var(--muted);
  font-size: 9.5px;
}

.phase-index {
  font-family: var(--font-serif);
  font-size: 9px;
  color: var(--faint);
}

.phase-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phase-time {
  font-family: var(--font-mono);
  font-size: 7.5px;
  color: var(--faint);
}

.phase-item.active {
  color: var(--ink);
  background: var(--hover);
}

.phase-item.active .phase-index {
  color: var(--accent);
}

.phase-item.complete {
  color: var(--faint);
}

.phase-item.complete .phase-index::after {
  content: "·";
  margin-left: 1px;
  color: var(--accent);
}

.sidebar-footer {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: auto;
  padding: 10px 8px 1px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 8px;
  line-height: 1.55;
}

.sidebar-footer .sidebar-mark {
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   6. viewport
   -------------------------------------------------------------------------- */
.viewport {
  position: relative;
  z-index: 1;
  overflow: hidden;
  border: 1px solid var(--panel-line);
  border-radius: var(--r-lg);
  background: var(--canvas-bg);
  isolation: isolate;
}

#canvas-host {
  position: absolute;
  inset: 0;
}

#canvas-host canvas {
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
}

.view-caption {
  position: absolute;
  z-index: 3;
  top: 21px;
  left: 23px;
  max-width: calc(100% - 190px);
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}

.view-caption .eyebrow {
  color: var(--muted);
}

.view-caption h2 {
  margin: 11px 0 8px;
  color: var(--ink-strong);
  font-family: var(--font-serif);
  font-size: clamp(34px, 3.6vw, 46px);
  font-weight: 400;
  letter-spacing: 0.015em;
  line-height: 0.98;
}

.view-caption h2 span {
  margin-left: 0.34em;
  color: var(--domain);
  font-size: 0.38em;
  letter-spacing: 0.06em;
  vertical-align: super;
}

.view-caption p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.05em;
}

.view-meta {
  position: absolute;
  z-index: 3;
  top: 19px;
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 9px;
  text-align: right;
  pointer-events: none;
}

.zoom-readout {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.zoom-readout span {
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.zoom-readout small,
.part-meta small {
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.06em;
}

.part-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

#part-count {
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* right tool dock */
.view-tools {
  position: absolute;
  z-index: 6;
  top: 50%;
  right: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 4px;
  border: 1px solid var(--panel-line);
  border-radius: var(--r-pill);
  background: var(--glass);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px) saturate(1.6);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  transform: translateY(-50%);
}

.view-tools .icon-button {
  width: 33px;
  height: 33px;
  border-radius: 50%;
}

.view-tools .icon-button svg {
  width: 15px;
  height: 15px;
}

.tool-divider {
  width: 19px;
  height: 1px;
  margin: 3px 0;
  background: var(--line);
}

/* vertical spread rail */
.explode-control {
  position: absolute;
  z-index: 6;
  top: 50%;
  left: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 46px;
  padding: 9px 3px 7px;
  border: 1px solid var(--panel-line);
  border-radius: 23px;
  background: var(--glass);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px) saturate(1.6);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  transform: translateY(-50%);
}

.explode-control label {
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.explode-control output {
  color: var(--accent);
  font-family: var(--font-serif);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.explode-track {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 150px;
}

.explode-ticks {
  position: absolute;
  inset: 5px 0;
  width: 5px;
  pointer-events: none;
  background: repeating-linear-gradient(to top, var(--line-strong) 0 1px, transparent 1px 18.5px);
}

#explode-range {
  width: 5px;
  height: 142px;
  margin: 0;
  border: 0;
  border-radius: var(--r-pill);
  appearance: none;
  -webkit-appearance: none;
  background: var(--line-strong);
  cursor: ns-resize;
  writing-mode: vertical-lr;
  direction: rtl;
  touch-action: none;
}

#explode-range::-webkit-slider-thumb {
  width: 15px;
  height: 10px;
  border: 2px solid var(--surface);
  border-radius: 4px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--accent);
  box-shadow: 0 1px 5px rgba(36, 75, 130, 0.34);
}

#explode-range::-moz-range-thumb {
  width: 15px;
  height: 10px;
  border: 2px solid var(--surface);
  border-radius: 4px;
  background: var(--accent);
}

.explode-step {
  display: flex;
  align-items: center;
  gap: 2px;
}

.explode-step .mini-button {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.explode-reset {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: var(--faint);
}

.explode-reset svg {
  width: 12px;
  height: 12px;
}

/* selection chip */
.selection-chip {
  position: absolute;
  z-index: 8;
  left: 50%;
  bottom: 70px;
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: calc(100% - 110px);
  padding: 7px 9px 7px 14px;
  border: 1px solid var(--accent-line);
  border-radius: var(--r-pill);
  background: var(--glass-strong);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px) saturate(1.6);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  transform: translateX(-50%);
}

.selection-chip > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.selection-chip .tiny {
  flex: 0 0 auto;
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.selection-chip strong {
  overflow: hidden;
  max-width: 190px;
  color: var(--ink-strong);
  font-size: 10.5px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-chip .icon-button {
  width: 27px;
  height: 27px;
  border-radius: 50%;
}

.selection-chip .icon-button svg {
  width: 13px;
  height: 13px;
}

.focus-return {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 4px 5px 9px;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  font-size: 9px;
  white-space: nowrap;
}

.focus-return svg {
  width: 12px;
  height: 12px;
}

.selection-chip.has-focus {
  border-color: var(--accent);
}

.guide-toggle {
  position: absolute;
  z-index: 6;
  top: 16px;
  left: 50%;
  display: none;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  border: 1px solid var(--panel-line);
  border-radius: var(--r-pill);
  background: var(--glass);
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  transform: translateX(-50%);
}

.guide-toggle svg {
  width: 12px;
  height: 12px;
}

/* bottom-left legend + bottom-right view options */
.view-footer {
  position: absolute;
  z-index: 5;
  right: 15px;
  bottom: 13px;
  left: 15px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 11px;
  max-width: 62%;
  color: var(--muted);
  font-size: 9px;
  pointer-events: auto;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 0;
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.legend-item.active {
  color: var(--ink);
}

.line-key {
  width: 17px;
  height: 1.5px;
  border-radius: 2px;
  background: var(--domain);
}

.line-key.laser {
  background: var(--laser);
}

.legend-note {
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.03em;
}

.footer-tools {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  pointer-events: auto;
}

.small-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: 1px solid var(--panel-line);
  border-radius: var(--r-pill);
  background: var(--glass);
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
}

.small-button svg {
  width: 13px;
  height: 13px;
}

.small-button.active {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.orbit-hint {
  position: absolute;
  z-index: 2;
  bottom: 42px;
  left: 50%;
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.05em;
  white-space: nowrap;
  pointer-events: none;
  transform: translateX(-50%);
}

.scale-bar {
  position: absolute;
  z-index: 2;
  bottom: 56px;
  left: 19px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--faint);
  pointer-events: none;
}

.scale-bar span {
  width: 46px;
  height: 6px;
  border: 1px solid var(--faint);
  border-top: 0;
}

.scale-bar small {
  font-family: var(--font-mono);
  font-size: 8px;
}

.light-popover {
  position: absolute;
  z-index: 9;
  right: 15px;
  bottom: 68px;
  width: 232px;
  padding: 14px;
  border: 1px solid var(--panel-line);
  border-radius: var(--r-lg);
  background: var(--glass-strong);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
}

.light-popover h3 {
  margin: 0 0 9px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
}

.light-popover label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 9px;
}

.light-popover output {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 9px;
}

.light-popover input {
  width: 100%;
  margin: 3px 0 0;
}

.spread-labels {
  position: absolute;
  inset: 0;
  z-index: 4;
  overflow: hidden;
  pointer-events: none;
}

.spread-labels button {
  position: absolute;
  padding: 5px 8px;
  border: 1px solid var(--panel-line);
  border-radius: 7px;
  background: var(--glass);
  color: var(--accent);
  font-size: 9px;
  white-space: nowrap;
  pointer-events: auto;
  transform: translate(-50%, -100%);
}

#viewport.detail-view .view-caption,
#viewport.detail-view .view-meta {
  opacity: 0;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   7. inspector
   -------------------------------------------------------------------------- */
.inspector {
  position: relative;
  z-index: 4;
  display: flex;
  flex-direction: column;
  padding: 15px 18px 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.inspector > * {
  flex-shrink: 0;
}

.inspector-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 13px;
  color: var(--faint);
  font-size: 9px;
}

#run-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

#run-status i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--faint);
  transition: background-color var(--dur) ease, box-shadow var(--dur) ease;
}

#run-status.running i {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.selected-part {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 0 0 9px;
  margin-bottom: 11px;
  border-bottom: 1px solid var(--line);
}

.selected-part > span {
  flex: 0 0 auto;
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.selected-part strong {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--ink-strong);
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.focus-clear {
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 1px solid var(--accent-line);
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 8px;
  white-space: nowrap;
}

#chapter-copy {
  max-height: 158px;
  overflow-y: auto;
  scrollbar-width: thin;
  padding-right: 2px;
  transition: max-height var(--dur) var(--ease);
}

.chapter-sub {
  margin: 0 0 7px;
  color: var(--muted);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 11px;
  line-height: 1.6;
}

.inspector h2 {
  margin: 0 0 8px;
  color: var(--ink-strong);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.005em;
  line-height: 1.5;
}

#chapter-body {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.9;
}

.chapter-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 9px 0 8px;
}

.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  color: var(--accent);
  font-size: 9px;
  text-align: left;
}

.text-button svg {
  width: 12px;
  height: 12px;
}

.text-button:disabled {
  color: var(--faint);
}

.guide-heading {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 9.5px;
}

.guide-filter {
  margin-left: auto;
  padding: 4px 8px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 8px;
  white-space: nowrap;
}

.guide-filter:not(.active) {
  background: var(--paper);
  color: var(--muted);
}

#observation-count {
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 7.5px;
  white-space: nowrap;
}

.observation-list {
  flex: 1 1 auto;
  min-height: 92px;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0 -3px 5px 0;
  padding-right: 3px;
}

.observation {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  min-height: 62px;
  margin-bottom: 5px;
  padding: 9px 8px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--row-bg);
  text-align: left;
}

.observation-index {
  min-width: 15px;
  padding-top: 1px;
  color: var(--faint);
  font-family: var(--font-serif);
  font-size: 9px;
}

.observation-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
}

.observation-copy strong {
  color: var(--ink);
  font-size: 10px;
  font-weight: 500;
  line-height: 1.45;
}

.observation-copy small {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 8.5px;
  line-height: 1.7;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.observation > svg {
  width: 10px;
  height: 10px;
  margin-top: 13px;
  color: var(--faint);
}

.observation.active {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.observation.active strong {
  color: var(--accent);
}

.detail-focus {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--accent);
  font-size: 9px;
  text-align: left;
}

.detail-focus:disabled {
  color: var(--faint);
}

.detail-focus svg {
  width: 11px;
  height: 11px;
}

.context-control {
  margin: 8px 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper);
}

.context-control label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 9px;
}

.context-control input {
  width: 100%;
  margin: 7px 0 2px;
}

.context-control output {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 9px;
}

.context-control .text-button {
  padding-top: 3px;
  font-size: 8px;
}

.micro-panel {
  margin-top: 3px;
  border-top: 1px solid var(--line);
}

.micro-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 0;
  color: var(--muted);
  font-size: 9px;
  text-align: left;
}

#field-progress {
  margin-left: auto;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 8px;
}

.micro-heading svg {
  width: 11px;
  height: 11px;
  transition: transform var(--dur) var(--ease);
}

.micro-heading[aria-expanded="true"] svg {
  transform: rotate(90deg);
}

#micro-body {
  padding-bottom: 8px;
}

#wafer-detail {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}

.micro-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 8px;
}

.micro-controls select {
  padding: 4px 6px;
  font-size: 8px;
}

.micro-note {
  margin: 6px 0 0;
  color: var(--faint);
  font-size: 7.5px;
  line-height: 1.65;
}

.live-readouts {
  display: flex;
  flex-direction: column;
  margin-top: 4px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
}

.live-readouts > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 8.5px;
  line-height: 1.9;
}

.live-readouts strong {
  color: var(--ink);
  font-weight: 500;
}

.evidence-button {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin-top: 5px;
  padding: 8px 0 2px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 8px;
  text-align: left;
}

.evidence-button svg {
  width: 11px;
  height: 11px;
}

/* --------------------------------------------------------------------------
   8. transport
   -------------------------------------------------------------------------- */
.transport {
  position: relative;
  z-index: 7;
  flex: 0 0 auto;
  min-height: var(--transport-h);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 18px;
  border-top: 1px solid var(--line);
  background: var(--transport-bg);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
}

.transport-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  height: 55px;
  min-width: 0;
}

.playback {
  display: flex;
  align-items: center;
  justify-self: start;
  gap: 8px;
  min-width: 0;
}

.phase-readout {
  justify-self: center;
}

.transport-actions {
  justify-self: end;
}

.play-button {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  background: var(--play-bg);
  color: var(--play-ink);
  box-shadow: 0 4px 12px rgba(20, 35, 55, 0.16);
}

.play-button svg {
  width: 14px;
  height: 14px;
}

.step-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 7px;
  border-radius: var(--r-sm);
  color: var(--muted);
  font-size: 9.5px;
  white-space: nowrap;
}

.step-button svg {
  width: 13px;
  height: 13px;
}

.playback .icon-button {
  width: 31px;
  height: 31px;
}

.speed-control {
  display: flex;
  gap: 1px;
  margin-left: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
}

.speed-button {
  min-width: 32px;
  padding: 4px 6px;
  border-radius: 7px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.speed-button.active {
  background: var(--surface);
  color: var(--ink-strong);
  box-shadow: var(--shadow-sm);
}

.phase-readout {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 11px;
  min-width: 0;
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

#phase-name {
  overflow: hidden;
  max-width: 240px;
  color: var(--ink);
  font-size: 9.5px;
  text-overflow: ellipsis;
}

#time-readout {
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.transport-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.time-note {
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.timeline-label {
  display: block;
  padding: 0 0 9px;
}

#timeline {
  width: 100%;
  height: 13px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}

#timeline::-webkit-slider-runnable-track {
  height: 2.5px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--progress, 0%), var(--line) var(--progress, 0%));
}

#timeline::-webkit-slider-thumb {
  width: 10px;
  height: 10px;
  margin-top: -3.75px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--accent);
  box-shadow: 0 1px 5px rgba(20, 35, 55, 0.22);
}

#timeline::-moz-range-track {
  height: 2.5px;
  border-radius: 2px;
  background: var(--line);
}

#timeline::-moz-range-progress {
  height: 2.5px;
  border-radius: 2px;
  background: var(--accent);
}

#timeline::-moz-range-thumb {
  width: 8px;
  height: 8px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
}

/* --------------------------------------------------------------------------
   9. buttons shared by every zone
   -------------------------------------------------------------------------- */
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 33px;
  height: 33px;
  border-radius: 50%;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.icon-button svg {
  width: 16px;
  height: 16px;
}

.icon-button.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.header-actions .text-button {
  justify-content: flex-start;
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.header-actions .text-button:hover {
  color: var(--ink);
}

.mobile-button {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .icon-button:hover:not(:disabled) {
    color: var(--accent);
    background: var(--hover);
  }

  .system-item:hover {
    background: var(--hover);
  }

  .system-item:hover > svg {
    opacity: 1;
  }

  .system-item.active:hover {
    background: var(--accent-soft);
  }

  .phase-item:hover {
    color: var(--ink);
    background: var(--hover);
  }

  .observation:hover {
    border-color: var(--line-strong);
  }

  .speed-button:hover {
    color: var(--ink);
  }

  .step-button:hover,
  .text-button:hover:not(:disabled),
  .evidence-button:hover,
  .footer-tools .small-button:hover,
  .guide-toggle:hover {
    color: var(--ink);
  }

  .play-button:hover {
    background: color-mix(in srgb, var(--play-bg) 86%, var(--accent));
    transform: scale(1.04);
  }

  .small-button.active:hover {
    color: var(--accent-strong);
  }

  .focus-clear:hover {
    background: var(--accent);
    color: var(--surface);
  }
}

/* --------------------------------------------------------------------------
   10. drawers, sheets, dialogs
   -------------------------------------------------------------------------- */
.drawer-backdrop {
  position: absolute;
  inset: 0;
  z-index: 45;
  background: var(--scrim);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

dialog.sheet {
  border: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  box-shadow: none;
}

dialog.sheet::backdrop {
  background: rgba(20, 30, 45, 0.34);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

#sources-dialog {
  width: min(460px, 100vw);
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0 0 0 auto;
  border: 1px solid var(--panel-line);
  border-radius: 24px 0 0 24px;
  background: var(--surface);
  box-shadow: -18px 0 70px rgba(15, 25, 40, 0.18);
  overflow: hidden;
}

#sources-dialog[open] {
  animation: sheet-in var(--dur-slow) var(--ease) both;
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateX(28px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

#document-dialog {
  width: min(820px, calc(100vw - 48px));
  max-height: 86dvh;
  margin: auto;
  border: 1px solid var(--panel-line);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: 0 30px 100px rgba(15, 25, 40, 0.28);
  overflow: hidden;
}

#document-dialog[open] {
  animation: reader-in var(--dur) var(--ease) both;
}

@keyframes reader-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin: 7px 0 0;
  color: var(--ink-strong);
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.25;
}

.dialog-header .eyebrow {
  color: var(--muted);
}

.dialog-body {
  padding: 4px 24px 24px;
  overflow-y: auto;
  max-height: calc(100dvh - 108px);
}

#document-dialog .dialog-body {
  max-height: calc(86dvh - 92px);
}

.source-intro {
  margin: 6px 0 0;
  padding: 8px 0 15px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.95;
}

.source-entry {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.source-entry a {
  color: var(--accent);
  font-size: 11px;
  line-height: 1.6;
  text-decoration: none;
}

.source-entry a:hover {
  text-decoration: underline;
}

.source-entry p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.65;
}

.source-entry svg {
  width: 13px;
  height: 13px;
  margin-top: 3px;
  color: var(--faint);
}

.reference-photo {
  margin: 16px 0 10px;
}

.reference-photo img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.reference-photo figcaption {
  margin-top: 7px;
  color: var(--faint);
  font-size: 9px;
}

.local-doc-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 16px;
  margin: 15px 0 4px;
}

.local-doc-links a {
  color: var(--accent);
  font-size: 9px;
  line-height: 1.7;
  text-decoration: none;
}

.local-doc-links a:hover {
  text-decoration: underline;
}

.dialog-body h3 {
  margin: 22px 0 9px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.dialog-body ul {
  margin: 0;
  padding-left: 17px;
}

.dialog-body li {
  margin: 7px 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.8;
}

.crosswalk-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 9px;
  line-height: 1.7;
}

.crosswalk-row span:first-child {
  color: var(--ink);
  white-space: nowrap;
}

.license-note {
  color: var(--faint);
  font-size: 9px;
  line-height: 1.8;
}

.dialog-close {
  flex: 0 0 auto;
}

/* markdown reader */
.document-body {
  color: var(--ink);
  font-size: 12px;
  line-height: 1.9;
}

.document-body h1 {
  margin: 18px 0 14px;
  font-family: var(--font-serif);
  font-size: 25px;
  font-weight: 400;
}

.document-body h2 {
  margin: 22px 0 10px;
  font-size: 18px;
  font-weight: 500;
}

.document-body h3 {
  margin: 18px 0 8px;
  font-size: 14px;
  font-weight: 600;
}

.document-body p,
.document-body li {
  color: var(--muted);
}

.document-body table {
  width: 100%;
  margin: 14px 0;
  border-collapse: collapse;
  font-size: 10px;
}

.document-body th,
.document-body td {
  padding: 7px 8px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.document-body th {
  background: var(--paper);
  color: var(--ink);
  font-weight: 500;
}

.document-body pre {
  overflow: auto;
  padding: 12px;
  border-radius: 10px;
  background: var(--paper);
  font-size: 10px;
}

.document-body a {
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   11. loader & toast
   -------------------------------------------------------------------------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 50% 36%, var(--bg-glow), transparent 64%),
    var(--bg);
  transition: opacity 0.5s var(--ease), visibility 0.5s;
}

.loader.finished {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(420px, 88vw);
  text-align: center;
}

.loader-mark {
  width: 118px;
  height: 118px;
  margin-bottom: 16px;
  color: var(--muted);
}

.loader-mark svg {
  width: 100%;
  height: 100%;
  stroke-width: 0.7;
  animation: loader-turn 9s linear infinite;
}

.loader-mark .loader-dot {
  fill: var(--accent);
  stroke: none;
}

@keyframes loader-turn {
  to {
    transform: rotate(360deg);
  }
}

.loader-kicker {
  margin: 0;
  color: var(--faint);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.loader-title {
  margin: 5px 0 0;
  color: var(--ink-strong);
  font-family: var(--font-serif);
  font-size: 27px;
  font-weight: 400;
  letter-spacing: 0.1em;
}

.loader-status {
  min-height: 16px;
  margin: 7px 0 12px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.loader-line {
  position: relative;
  width: 100%;
  height: 2px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--line);
}

.loader-line::after {
  content: "";
  display: block;
  width: 38%;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--line-strong), var(--accent));
  animation: loader-sweep 1.6s ease-in-out infinite;
}

@keyframes loader-sweep {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(280%);
  }
}

.loader.finished .loader-line::after,
.loader.error .loader-line::after {
  animation: none;
}

.loader.error .loader-status {
  max-width: 300px;
  color: var(--warn);
  line-height: 1.8;
}

.loader-retry {
  margin-top: 14px;
  padding: 7px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  color: var(--ink);
  font-size: 9px;
  letter-spacing: 0.04em;
}

.loader.error .loader-mark {
  color: var(--warn);
}

.notice {
  position: fixed;
  z-index: 110;
  bottom: calc(var(--transport-h) + 18px);
  left: 50%;
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 16px;
  border: 1px solid var(--panel-line);
  border-radius: var(--r-pill);
  background: var(--glass-strong);
  box-shadow: var(--shadow-md);
  color: var(--ink);
  font-size: 10px;
  line-height: 1.6;
  text-align: center;
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  transform: translateX(-50%);
}

/* --------------------------------------------------------------------------
   12. responsive
   -------------------------------------------------------------------------- */
@media (min-width: 1600px) {
  :root {
    --w-nav: 196px;
    --w-inspector: 296px;
  }

  .system-item {
    min-height: 48px;
  }

  .inspector {
    padding: 18px 21px 12px;
  }
}

@media (max-width: 1280px) {
  :root {
    --w-nav: 168px;
    --w-inspector: 264px;
  }

  .system-copy strong {
    font-size: 10px;
  }

  .brand-sub {
    font-size: 12px;
  }
}

@media (max-width: 1100px) {
  :root {
    --w-nav: 156px;
    --w-inspector: 248px;
  }

  .header-spec {
    display: none;
  }

  .brand-sub {
    display: none;
  }

  .view-caption h2 {
    font-size: 36px;
  }

  .orbit-hint {
    display: none;
  }

  #chapter-copy {
    max-height: 136px;
  }

  .observation {
    min-height: 58px;
  }

  .time-note {
    display: none;
  }
}

/* tablet: inspector becomes a drawer, navigation stays */
@media (max-width: 1080px) {
  .bench-body {
    grid-template-columns: var(--w-nav) minmax(0, 1fr);
  }

  .inspector {
    position: absolute;
    z-index: 46;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(336px, 88%);
    border: 1px solid var(--panel-line);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    visibility: hidden;
    pointer-events: none;
    transform: translateX(104%);
    transition: transform var(--dur-slow) var(--ease-drawer), visibility 0s var(--dur-slow);
  }

  .inspector.open {
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition: transform var(--dur-slow) var(--ease-drawer), visibility 0s;
  }

  .inspector .mobile-button,
  .transport .mobile-button {
    display: inline-grid;
  }

  .inspector-top .mobile-button {
    margin-left: 4px;
    order: 3;
  }

  #run-status {
    margin-left: auto;
  }

  .system-panel .mobile-button {
    display: none;
  }

  .guide-toggle {
    display: inline-flex;
  }

  .view-code {
    display: none;
  }

  .observation-list {
    min-height: 140px;
  }

  .selection-chip {
    bottom: 68px;
  }
}

/* phone: navigation and inspector become sheets */
@media (max-width: 720px) {
  :root {
    --header-h: 54px;
    --viewbar-h: 44px;
    --transport-h: 104px;
    --shell-margin: 8px;
    --shell-margin-x: 8px;
    --body-pad: 8px;
    --r-xl: 18px;
    --r-lg: 15px;
  }

  .site-header {
    margin: 8px 8px 0;
    padding: 0 8px 0 10px;
    border-radius: 16px;
    gap: 8px;
  }

  .shell {
    padding: 6px 8px 8px;
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
    padding: 6px;
    border-radius: 9px;
  }

  .brand h1 {
    font-size: 13px;
  }

  .brand-sub,
  .series-line {
    display: none;
  }

  .header-actions {
    gap: 4px;
  }

  .header-actions .text-button {
    padding: 5px 8px;
    font-size: 8.5px;
  }

  .header-tools .icon-button {
    width: 26px;
    height: 26px;
  }

  .view-header {
    padding: 0 8px;
    gap: 6px;
  }

  .view-header .mobile-button {
    display: inline-grid;
    width: 29px;
    height: 29px;
  }

  .view-status {
    gap: 6px;
    font-size: 10px;
  }

  .view-status .view-code {
    display: none;
  }

  .segmented {
    border-radius: 9px;
    padding: 2px;
  }

  .segmented button {
    padding: 6px 10px;
    font-size: 9.5px;
  }

  .segmented-thumb {
    top: 2px;
    bottom: 2px;
    left: 2px;
    width: calc((100% - 4px - (var(--seg-count) - 1) * 2px) / var(--seg-count));
  }

  .bench-body {
    display: block;
    padding: 6px;
  }

  .viewport {
    width: 100%;
    height: 100%;
  }

  .system-panel {
    position: absolute;
    z-index: 46;
    top: 0;
    bottom: 0;
    left: 0;
    display: flex;
    width: min(290px, 86%);
    border: 1px solid var(--panel-line);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-104%);
    transition: transform var(--dur-slow) var(--ease-drawer), visibility 0s var(--dur-slow);
  }

  .system-panel.open {
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition: transform var(--dur-slow) var(--ease-drawer), visibility 0s;
  }

  .system-panel .mobile-button {
    display: inline-grid;
  }

  .inspector {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: min(86%, 630px);
    padding: 15px 16px calc(10px + env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    transform: translateY(105%);
  }

  .inspector.open {
    transform: none;
  }

  .inspector::before {
    content: "";
    display: block;
    width: 34px;
    height: 3px;
    margin: -4px auto 10px;
    border-radius: 3px;
    background: var(--line-strong);
  }

  .view-caption {
    top: 16px;
    left: 16px;
    max-width: calc(100% - 128px);
  }

  .view-caption h2 {
    margin: 8px 0 6px;
    font-size: 31px;
  }

  .view-caption p {
    font-size: 8.5px;
  }

  .view-meta {
    top: 15px;
    right: 14px;
    gap: 6px;
  }

  .zoom-readout span {
    font-size: 14px;
  }

  #part-count {
    font-size: 11px;
  }

  .view-tools {
    top: auto;
    right: auto;
    bottom: 76px;
    left: 50%;
    flex-direction: row;
    padding: 3px;
    transform: translateX(-50%);
  }

  .view-tools .icon-button {
    width: 35px;
    height: 36px;
  }

  .view-tools .tool-divider {
    width: 1px;
    height: 19px;
    margin: 0 2px;
  }

  .explode-control {
    top: 47%;
    left: 9px;
    width: 44px;
  }

  .explode-track {
    height: 106px;
  }

  #explode-range {
    height: 98px;
  }

  .explode-step {
    display: none;
  }

  .view-footer {
    right: 12px;
    bottom: 9px;
    left: 12px;
    align-items: flex-end;
  }

  .legend {
    max-width: 55%;
    gap: 2px 9px;
  }

  .legend-note {
    display: none;
  }

  .footer-tools {
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
  }

  .small-button {
    padding: 6px 8px;
    font-size: 8.5px;
  }

  .light-popover {
    right: 12px;
    bottom: 116px;
    width: min(238px, calc(100vw - 24px));
  }

  .selection-chip {
    bottom: 126px;
    max-width: calc(100% - 24px);
    padding: 6px 7px 6px 11px;
  }

  .selection-chip > div {
    gap: 6px;
  }

  .selection-chip strong {
    max-width: 112px;
    font-size: 9.5px;
  }

  .selection-chip .icon-button {
    width: 26px;
    height: 26px;
  }

  .focus-return {
    padding-left: 6px;
    font-size: 8px;
  }

  .scale-bar,
  .orbit-hint {
    display: none;
  }

  .guide-toggle {
    top: 13px;
    padding: 6px 8px;
    font-size: 8px;
  }

  .transport {
    padding: 0 10px;
  }

  .transport-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: auto;
    flex-wrap: wrap;
    gap: 3px 6px;
    padding: 7px 0 0;
  }

  .phase-readout,
  .transport-actions {
    justify-self: auto;
  }

  .playback {
    flex: 1 1 auto;
    gap: 4px;
  }

  .play-button {
    width: 33px;
    height: 33px;
  }

  .playback #replay {
    display: none;
  }

  .step-button {
    padding: 6px 4px;
  }

  .speed-control {
    margin-left: 0;
  }

  .speed-button {
    min-width: 29px;
    padding: 4px 4px;
    font-size: 8px;
  }

  .phase-readout {
    order: 3;
    width: 100%;
    justify-content: center;
    gap: 8px;
    padding-bottom: 2px;
    font-size: 8.5px;
  }

  #phase-name {
    max-width: 58vw;
    font-size: 9px;
  }

  .transport-actions .time-note {
    display: none;
  }

  .transport-actions .small-button {
    padding: 6px 9px;
  }

  .timeline-label {
    padding-bottom: 7px;
  }

  .dialog-header {
    padding: 18px 18px 13px;
  }

  .dialog-header h2 {
    font-size: 21px;
  }

  .dialog-body {
    padding: 4px 18px 20px;
  }

  #sources-dialog {
    width: 100%;
    height: 90dvh;
    margin: auto 0 0;
    border-radius: 20px 20px 0 0;
  }

  #sources-dialog[open] {
    animation: sheet-up var(--dur-slow) var(--ease) both;
  }

  @keyframes sheet-up {
    from {
      opacity: 0;
      transform: translateY(26px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  #document-dialog {
    width: calc(100vw - 20px);
    max-height: 90dvh;
  }

  #document-dialog .dialog-body {
    max-height: calc(90dvh - 88px);
  }

  .notice {
    bottom: calc(var(--transport-h) + 10px);
    font-size: 9px;
  }

  .loader-title {
    font-size: 23px;
  }

  .loader-mark {
    width: 100px;
    height: 100px;
  }
}

@media (max-width: 430px) {
  :root {
    --header-h: 52px;
    --transport-h: 100px;
  }

  .site-header {
    margin: 8px 8px 0;
    padding: 0 6px 0 8px;
    border-radius: 15px;
  }

  .header-actions .text-button {
    display: inline-flex;
    padding: 4px 7px;
    font-size: 7.5px;
  }

  .header-tools {
    gap: 0;
    padding: 1px;
  }

  .header-tools .icon-button {
    width: 25px;
    height: 25px;
  }

  .brand h1 {
    font-size: 12px;
  }

  .view-caption h2 {
    font-size: 28px;
  }

  .selection-chip {
    bottom: 122px;
  }

  .legend {
    max-width: 50%;
    font-size: 8px;
  }

  .legend-item {
    font-size: 8px;
  }

  .line-key {
    width: 13px;
  }

  .step-button span {
    display: none;
  }

  .speed-button {
    min-width: 27px;
  }

  .footer-tools .small-button span {
    display: none;
  }

  .footer-tools .small-button {
    padding: 6px;
  }
}

@media (max-height: 780px) and (min-width: 721px) {
  .inspector {
    padding-top: 12px;
  }

  .inspector-top {
    margin-bottom: 10px;
  }

  #chapter-copy {
    max-height: 116px;
  }

  .chapter-sub {
    display: none;
  }

  .inspector h2 {
    font-size: 15px;
    margin-bottom: 6px;
  }

  #chapter-body {
    font-size: 9px;
    line-height: 1.8;
  }

  .observation {
    min-height: 54px;
  }

  .micro-note {
    display: none;
  }
}

@media (max-height: 680px) and (min-width: 721px) {
  .system-item {
    min-height: 40px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .phase-item {
    min-height: 27px;
  }

  .sidebar-footer {
    display: none;
  }

  #chapter-copy {
    max-height: 92px;
  }

  .live-readouts {
    display: none;
  }

  .micro-panel {
    display: none;
  }
}

