/* Component styling. Theme and scale values live in token.css. */
:root {
  font-family: var(--font-family);
  font-size: 100%;
  color: var(--color-text);
  background: var(--color-canvas);
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  overflow: hidden;
  line-height: var(--leading-normal);
}
button, select, input {
  font: inherit;
}
button {
  color: inherit;
  cursor: pointer;
}
button:disabled {
  cursor: default;
  opacity: var(--disabled-opacity);
}
button, input, select {
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--focus-offset);
}
/* The 3D view takes focus on every click for its keyboard shortcuts; it draws no outline. */
canvas:focus {
  outline: none;
}
button:focus:not(:focus-visible) {
  outline: none;
}
[hidden] {
  display: none !important;
}
svg {
  width: var(--icon-size);
  height: var(--icon-size);
  fill: none;
  stroke: currentColor;
  stroke-width: var(--icon-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
h2 {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
}
.model-stats {
  margin: var(--space-3) 0 0;
  font-size: var(--text-xs);
  line-height: var(--leading-normal);
  color: var(--color-text-muted);
}

/* ── Frame: sidebar beside the 3D stage ── */
#viewer {
  position: relative;
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background: var(--color-canvas);
}
.stage {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  container: stage / inline-size;
}
#scene {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.stage-title {
  display: none;
}

/* ── Sidebar: model tree and places, floating at the top left ── */
.sidebar {
  position: absolute;
  z-index: 5;
  top: var(--inset-top);
  left: var(--inset-left);
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  /* As tall as its content, ending above the dock (44 px buttons plus padding). */
  max-height: calc(100% - var(--inset-top) - var(--inset-bottom) - var(--control-size) - var(--space-6));
  overflow: hidden;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--color-overlay-soft);
  box-shadow: var(--shadow-control);
}
/* Collapsed, only the header remains, level with the toolbar. */
#viewer.sidebar-collapsed .sidebar-body {
  display: none;
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  cursor: pointer;
}
.building-mark {
  width: 22px;
  height: 22px;
  stroke-width: 1.2;
  color: var(--color-text-secondary);
}
.sidebar-header h1 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 1.0625rem;
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
}
.ghost-button:hover {
  background: var(--color-overlay-pressed);
  color: var(--color-text);
}
.ghost-button svg {
  width: var(--icon-size-small);
  height: var(--icon-size-small);
}
.sidebar-toggle svg {
  transform: rotate(-90deg);
  transition: transform var(--duration-fast) var(--ease-standard);
}
.sidebar-toggle[aria-expanded=false] svg {
  transform: rotate(90deg);
}
.sheet-summary, #sheet-close {
  display: none;
}
.sidebar-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.sidebar-tabbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin: 0 var(--space-4);
  border-bottom: var(--border-width) solid var(--color-border);
}
.sidebar-tabs {
  flex: 1;
  display: flex;
  gap: var(--space-4);
}
.sidebar-tabs [role=tab] {
  min-height: 36px;
  margin-bottom: -1px;
  padding: 0 var(--space-half);
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.sidebar-tabs [role=tab]:hover {
  color: var(--color-text);
}
.sidebar-tabs [aria-selected=true] {
  border-bottom-color: var(--color-text);
  color: var(--color-text);
}
.tab-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.filter-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-3) var(--space-4) var(--space-1h);
  padding: 0 var(--space-1h) 0 10px;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-inner);
  background: var(--color-field);
}
.filter-field:focus-within {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: 1px;
}
.filter-field > svg {
  width: var(--icon-size-small);
  height: var(--icon-size-small);
  color: var(--color-text-muted);
}
.filter-field input {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--color-text);
  font-size: var(--text-sm);
}
.filter-field input:focus-visible {
  outline: none;
}
.filter-field input::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}
.filter-field input::-webkit-search-cancel-button {
  display: none;
}
.filter-field .ghost-button {
  width: 28px;
  height: 28px;
}
.filter-field .ghost-button svg {
  width: 14px;
  height: 14px;
}
.tree-status {
  margin: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.model-tree {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0 var(--space-2) var(--space-2);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  scrollbar-width: thin;
}
.tree-row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  height: var(--tree-row);
  padding: 0 var(--space-1) 0 calc(6px + var(--depth, 0) * var(--tree-indent));
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--color-text);
}
.tree-row:hover {
  background: var(--color-overlay-hover);
}
.tree-row.focus {
  background: var(--color-surface-hover);
}
.tree-row.selected {
  background: var(--color-surface-selected);
  color: var(--color-text-inverse);
}
.tree-row.is-hidden:not(.selected) {
  color: var(--color-text-muted);
}
.tree-row.is-hidden:not(.selected) .tree-label {
  opacity: .6;
}
.tree-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: inherit;
}
.tree-chevron.empty {
  visibility: hidden;
}
.tree-chevron svg {
  width: 12px;
  height: 12px;
  transition: transform var(--duration-fast) var(--ease-standard);
}
.tree-row[data-open=true] > .tree-chevron svg {
  transform: rotate(90deg);
}
.tree-label {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}
.tree-label:focus-visible, .tree-more:focus-visible {
  outline-offset: -2px;
  border-radius: var(--radius-row);
}
.tree-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.is-storey .tree-name {
  font-weight: var(--weight-semibold);
}
.tree-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-half);
  flex: none;
  width: 0;
  overflow: hidden;
}
.tree-row:hover .tree-actions, .tree-row:focus-within .tree-actions {
  width: 82px;
}
/* Hidden and isolated rows keep their state button in view. */
.tree-row.pinned .tree-actions {
  width: auto;
}
.tree-row.pinned:not(:hover):not(:focus-within) .tree-actions > :not([aria-pressed=true]) {
  display: none;
}
.tree-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-row);
  background: transparent;
  color: inherit;
}
.tree-actions button:hover {
  background: var(--color-overlay-pressed);
}
.tree-actions [data-action=isolate][aria-pressed=true] {
  background: var(--color-selection-soft);
}
.tree-actions svg {
  width: 14px;
  height: 14px;
}
.tree-more {
  height: 100%;
  padding: 0 var(--space-1);
  border: 0;
  background: transparent;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}
.tree-more:hover {
  color: var(--color-text);
}
.visibility-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 10px var(--space-4);
  border-top: var(--border-width) solid var(--color-border);
}
.visibility-footer span {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.text-button {
  padding: var(--space-1h) var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.text-button:hover {
  background: var(--color-overlay-pressed);
}
.places-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-2) var(--space-2) var(--space-4);
  scrollbar-width: thin;
}
.places-heading {
  margin: var(--space-3) var(--space-2) var(--space-1);
}
.places-heading:first-child {
  margin-top: var(--space-1);
}
.place-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: var(--control-size-compact);
  padding: 0 var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text);
  font-size: var(--text-sm);
  text-align: left;
}
.place-row:hover:not(:disabled) {
  background: var(--color-overlay-hover);
}
.place-row svg {
  width: var(--icon-size-small);
  height: var(--icon-size-small);
  color: var(--color-text-muted);
}
.place-row span {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Floating controls on the stage ── */
/* The top bar, its toolbars, dropdowns and the help panel are shared with the gallery and the
   splat viewers in app-tools.css; the rules below are the viewer's own. */
.camera-rail, .nav-modes, .dock {
  border: var(--border-width) solid var(--color-border);
  background: var(--color-overlay-soft);
  box-shadow: var(--shadow-dock);
  backdrop-filter: blur(var(--blur-panel));
}
/* Scene settings sit centred in the top bar. */
.scene-tools {
  grid-column: 2;
}
.lighting-toggle.daylight-active .lighting-icon {
  color: var(--color-daylight);
}
.surroundings-toggle.surroundings-hidden > svg {
  opacity: .5;
}
.compact-only {
  display: none !important;
}

.surroundings-panel {
  padding: var(--space-3) var(--space-4);
}
.switch-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: var(--control-size-compact);
  font-size: var(--text-base);
  cursor: pointer;
}
.switch-row.dimmed {
  opacity: var(--disabled-opacity);
}
.switch-row input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.switch-row:has(input:disabled) {
  cursor: default;
  opacity: var(--disabled-opacity);
}
.switch {
  flex: none;
  width: var(--switch-width);
  height: var(--switch-height);
  border-radius: var(--radius-pill);
  background: var(--color-switch-off);
  transition: background var(--duration-fast) var(--ease-standard);
  pointer-events: none;
}
.switch::after {
  content: '';
  display: block;
  width: var(--switch-knob);
  height: var(--switch-knob);
  margin: var(--switch-gap);
  border-radius: 50%;
  background: var(--color-switch-knob);
  transition: transform var(--duration-fast) var(--ease-standard);
}
input:checked + .switch {
  background: var(--color-surface-selected);
}
#daylight:checked + .switch {
  background: var(--color-daylight);
}
input:checked + .switch::after {
  transform: translateX(var(--switch-travel));
  background: var(--color-text-inverse);
}
.switch-row:has(input:focus-visible) {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--focus-offset);
  border-radius: var(--radius-xs);
}
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin-top: var(--space-1);
}
.field-grid label {
  display: grid;
  gap: var(--space-1h);
  min-width: 0;
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}
.field-grid input {
  width: 100%;
  min-width: 0;
  min-height: var(--control-size-compact);
  padding: 0 10px;
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  color: var(--color-text);
  color-scheme: dark;
  font-size: .9375rem;
}
.field-grid input[aria-invalid=true] {
  border-color: var(--color-warning);
}
.sun-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.sun-row .panel-note {
  margin: 0;
}
.small-button {
  min-height: 32px;
  padding: 0 10px;
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-overlay-hover);
  color: var(--color-text);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.small-button:hover {
  background: var(--color-overlay-pressed);
}
.panel-divider {
  height: 1px;
  margin: var(--space-2) 0;
  background: var(--color-border);
}
.range-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-1);
  font-size: var(--text-base);
}
output {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}
input[type=range] {
  display: block;
  width: 100%;
  height: 32px;
  margin: 0;
  accent-color: var(--color-text);
  cursor: pointer;
}
.quiet-button {
  width: 100%;
  min-height: 36px;
  margin-top: var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
}
.quiet-button:hover {
  background: var(--color-overlay-hover);
  color: var(--color-text);
}

/* The More menu: items, a note, a divider and the link field for copying by hand. */
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: var(--control-size-compact);
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--color-text);
  font-size: var(--text-base);
  text-align: left;
  text-decoration: none;
}
.menu-item:hover:not(:disabled) {
  background: var(--color-overlay-pressed);
}
.menu-item svg {
  width: 18px;
  height: 18px;
}
.menu-item > span:first-of-type {
  flex: 1;
}
.menu-item .menu-chevron {
  width: 14px;
  height: 14px;
  color: var(--color-text-muted);
  transform: rotate(90deg);
  transition: transform var(--duration-fast) var(--ease-standard);
}
.menu-item[aria-expanded=true] .menu-chevron {
  transform: rotate(-90deg);
}
.menu-divider {
  display: block;
  height: 1px;
  margin: var(--space-1) var(--space-1h);
  background: var(--color-border);
}
.menu-note {
  margin: 0 10px var(--space-1h);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.menu-input {
  display: block;
  width: calc(100% - 20px);
  min-height: 36px;
  margin: 0 10px var(--space-1h);
  padding: 0 var(--space-2);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  color: var(--color-text);
  font-size: var(--text-xs);
}

/* Bottom controls: centred view dock, navigation switch at the right. */
.navigation-hint {
  position: absolute;
  right: var(--inset-right);
  bottom: calc(var(--inset-bottom) + var(--control-size-compact) + var(--space-2) + 2px + var(--space-2));
  max-width: 40%;
  margin: 0 var(--space-half) 0 0;
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  text-align: right;
  text-shadow: var(--shadow-text);
  pointer-events: none;
}
/* Camera: Home, zoom in and zoom out, stacked at the right edge and vertically centred. */
.camera-rail {
  position: absolute;
  z-index: 2;
  top: 50%;
  right: var(--inset-right);
  display: flex;
  flex-direction: column;
  gap: var(--space-half);
  padding: var(--space-1);
  border-radius: var(--radius-toolbar);
  transform: translateY(-50%);
}
.camera-rail button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-size-compact);
  height: var(--control-size-compact);
  padding: 0;
  border: 0;
  border-radius: var(--radius-inner);
  background: transparent;
  color: var(--color-text);
}
.camera-rail button:hover:not(:disabled) {
  background: var(--color-overlay-pressed);
}
.controls {
  position: absolute;
  z-index: 2;
  left: var(--inset-left);
  right: var(--inset-right);
  bottom: var(--inset-bottom);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}
.controls > * {
  pointer-events: auto;
}
.dock {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1h);
  border-radius: var(--radius-dock);
}
.dock [data-mode] {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-size);
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--dock-label-size);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard);
}
.dock [data-mode]:hover:not(:disabled):not([aria-pressed=true]), .nav-modes button:hover:not(:disabled):not([aria-pressed=true]) {
  background: var(--color-overlay-pressed);
  color: var(--color-text);
}
.dock [aria-pressed=true], .nav-modes [aria-pressed=true] {
  background: var(--color-surface-selected);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-selected);
}
.label-short {
  display: none;
}
.nav-modes {
  position: absolute;
  right: 0;
  bottom: 0;
  display: flex;
  gap: var(--space-half);
  padding: var(--space-1);
  border-radius: var(--radius-toolbar);
}
.nav-modes button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--control-size);
  height: var(--control-size-compact);
  padding: 0;
  border: 0;
  border-radius: var(--radius-inner);
  background: transparent;
  color: var(--color-text-secondary);
}
/* Narrower stages keep the top bar clear of the sidebar: the gallery link drops its label
   first, then Lighting and Surroundings. Labels stay available to screen readers. */
@container stage (max-width: 1279px) {
  .gallery-link {
    justify-content: center;
    width: var(--control-size-compact);
    padding: 0;
  }
  .gallery-link .toolbar-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
@container stage (max-width: 999px) {
  .scene-tools .toolbar-button {
    justify-content: center;
    width: var(--control-size-compact);
    padding: 0;
  }
  .scene-tools .toolbar-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
/* A narrow stage keeps the dock clear of the navigation switch with icon-only views. */
@container stage (max-width: 780px) {
  .dock [data-mode] {
    padding: 0 var(--space-3);
  }
  .dock [data-mode] span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* ── Inspector: anchored beside the picked element ── */
.pick-marker {
  position: absolute;
  z-index: 3;
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-selection);
  background: var(--color-selection-fill);
  box-shadow: var(--shadow-crosshair);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.inspector {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  width: var(--inspector-width);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-dropdown);
  background: var(--color-overlay-panel);
  backdrop-filter: blur(var(--blur-panel));
  box-shadow: var(--shadow-panel);
}
.inspector::before {
  content: '';
  position: absolute;
  top: calc(var(--arrow-y, 40px) - 6px);
  width: 12px;
  height: 12px;
  border: solid var(--color-border-strong);
  border-width: 0 0 1px 1px;
  background: var(--color-surface);
}
.inspector[data-side=right]::before {
  left: -7px;
  transform: rotate(45deg);
}
.inspector[data-side=left]::before {
  right: -7px;
  transform: rotate(-135deg);
}
.inspector[data-side=none]::before {
  display: none;
}
.inspector-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: 14px var(--space-2) var(--space-3) var(--space-4);
}
.selection-swatch {
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 7px;
  background: var(--color-selection);
}
.inspector-title {
  flex: 1;
  min-width: 0;
}
.inspector-title h2 {
  font-size: .9375rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.inspector-title p {
  margin: var(--space-half) 0 0;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
#close-inspector {
  margin-top: -4px;
}
.inspector-warning {
  margin: -4px var(--space-4) var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-warning);
}
.inspector-facts {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: var(--space-1) var(--space-3);
  margin: 0;
  padding: 0 var(--space-4) var(--space-3);
  font-size: var(--text-sm);
  line-height: 1.45;
}
.inspector-facts:empty {
  display: none;
}
.inspector-facts dt {
  color: var(--color-text-muted);
}
.inspector-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.inspector-actions {
  display: flex;
  gap: var(--space-half);
  padding: var(--space-1h);
  border-top: var(--border-width) solid var(--color-border);
}
.inspector-actions button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1h);
  min-height: 36px;
  padding: 0 var(--space-1);
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}
.inspector-actions button:hover:not(:disabled) {
  background: var(--color-overlay-pressed);
}
.inspector-actions svg {
  width: 14px;
  height: 14px;
}
.inspector-details {
  max-height: min(40dvh, 360px);
  padding: 0 var(--space-4);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-top: var(--border-width) solid var(--color-border);
  border-radius: 0 0 var(--radius-dropdown) var(--radius-dropdown);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  line-height: var(--leading-normal);
  scrollbar-width: thin;
}
.inspector-details summary {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: var(--space-1h);
  min-height: 34px;
  background: var(--color-surface);
  list-style: none;
  cursor: pointer;
}
.inspector-details summary::-webkit-details-marker {
  display: none;
}
.inspector-details summary::before {
  content: '';
  border-left: 5px solid currentColor;
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
  transition: transform var(--duration-fast) var(--ease-standard);
}
.inspector-details[open] summary::before {
  transform: rotate(90deg);
}
.inspector-details summary:hover {
  color: var(--color-text);
}
/* Details reuse the summary grid, with a wider label column for longer names. */
.inspector-details .detail-facts {
  grid-template-columns: 88px 1fr;
  padding: var(--space-1) 0 var(--space-3);
  color: var(--color-text);
}
.inspector-facts .inferred {
  color: var(--color-evidence);
  font-size: var(--text-2xs);
  cursor: help;
}
.inspector-facts .code {
  font: var(--text-2xs) / var(--leading-normal) ui-monospace, monospace;
  color: var(--color-text-secondary);
}
.detail-sources {
  padding-bottom: var(--space-3);
}
.detail-sources .eyebrow {
  margin: 0 0 var(--space-1h);
}
.detail-sources ul {
  display: grid;
  gap: var(--space-1h);
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-wrap: anywhere;
}

/* ── Loading, walking and notices ── */
.primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
  min-height: var(--control-size-large);
  margin-top: var(--space-5);
  padding: var(--space-3) var(--space-5);
  border: 0;
  border-radius: var(--radius-control);
  background: var(--color-surface-selected);
  color: var(--color-text-inverse);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
}
.primary-button:hover:not(:disabled) {
  background: var(--color-text);
}
/* Walk and Fly keep every control in view: the pad sits in the bottom-left corner and its
   actions above the navigation switch, in place of the navigation hint. */
.touch-walk {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.touch-walk button {
  min-width: var(--control-size-large);
  min-height: var(--control-size-large);
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.move-pad {
  position: absolute;
  left: var(--inset-left);
  bottom: var(--inset-bottom);
  display: grid;
  grid-template: repeat(2, 48px) / repeat(3, 48px);
  gap: var(--space-1);
}
.move-pad button {
  border: var(--border-width) solid var(--color-border-hover);
  border-radius: var(--radius-control);
  background: var(--color-overlay-control);
  color: var(--color-text);
  font-size: var(--text-2xl);
}
.move-forward { grid-area: 1 / 2; }
.move-left { grid-area: 2 / 1; }
.move-back { grid-area: 2 / 2; }
.move-right { grid-area: 2 / 3; }
.touch-walk-actions {
  position: absolute;
  right: var(--inset-right);
  bottom: calc(var(--inset-bottom) + var(--control-size-compact) + var(--space-2) + 2px + var(--space-2));
  display: grid;
  justify-items: end;
  gap: var(--space-2);
}
.touch-walk-actions p {
  max-width: 115px;
  margin: 0;
  font-size: var(--text-xs);
  color: var(--color-text);
  text-align: right;
  text-shadow: var(--shadow-text);
}
#touch-fly {
  display: grid;
  gap: var(--space-1h);
}
.touch-walk button.held {
  background: var(--color-surface-selected);
  color: var(--color-text-inverse);
}
body.touch-walking .navigation-hint {
  display: none;
}
.notice {
  position: absolute;
  z-index: var(--layer-notice);
  left: 50%;
  bottom: calc(var(--inset-bottom) + 72px);
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - var(--inset-left) - var(--inset-right)));
  padding: 10px 18px;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-overlay-panel);
  box-shadow: var(--shadow-dock);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  text-align: center;
  pointer-events: none;
}

/* ── Phones: one dock and a bottom sheet for the model ── */
#viewer.compact {
  display: block;
}
#viewer.compact .stage {
  position: absolute;
  inset: 0;
}
#viewer.compact .stage::before {
  content: '';
  position: absolute;
  z-index: 1;
  inset: 0 0 auto;
  height: 120px;
  background: var(--header-scrim);
  pointer-events: none;
}
#viewer.compact .stage-title {
  position: absolute;
  z-index: 2;
  display: block;
  top: var(--inset-top);
  left: var(--inset-left);
  right: calc(var(--inset-right) + 196px);
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--control-size);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: var(--shadow-text);
  pointer-events: none;
}
#viewer.compact .sidebar {
  position: absolute;
  z-index: 6;
  top: auto;
  right: 0;
  bottom: 0;
  left: 0;
  width: auto;
  height: auto;
  max-height: none;
  padding: 0 0 env(safe-area-inset-bottom);
  border-width: var(--border-width) 0 0;
  border-radius: var(--radius-panel) var(--radius-panel) 0 0;
  background: var(--color-surface);
  box-shadow: none;
}
#viewer.compact.sheet-open .sidebar {
  height: var(--sheet-open);
  border-top-color: var(--color-border-strong);
  box-shadow: 0 -16px 60px #0008;
}
#viewer.compact .sidebar-header {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
#viewer.compact .sheet-summary {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: var(--sheet-collapsed);
  padding: 22px var(--space-5) var(--space-4);
  border: 0;
  background: transparent;
  color: var(--color-text);
  text-align: left;
}
.sheet-handle {
  position: absolute;
  top: var(--space-2);
  left: 50%;
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--color-switch-off);
  transform: translateX(-50%);
}
.sheet-summary strong {
  flex: 1;
  font-size: var(--text-base);
}
#sheet-level {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.sheet-summary svg {
  width: var(--icon-size-small);
  height: var(--icon-size-small);
  color: var(--color-text-muted);
  transform: rotate(-90deg);
}
#viewer.compact.sheet-open .sheet-summary {
  min-height: 18px;
  padding: 0;
}
#viewer.compact.sheet-open .sheet-summary > :not(.sheet-handle) {
  display: none;
}
#viewer.compact:not(.sheet-open) .sidebar-body {
  display: none;
}
#viewer.compact #sheet-close {
  display: inline-flex;
  width: 36px;
  height: 36px;
}
#viewer.compact .sidebar-tabbar {
  margin: 0 var(--space-5);
}
#viewer.compact .sidebar-tabs [role=tab] {
  min-height: var(--control-size-compact);
  font-size: var(--text-base);
}
#viewer.compact .filter-field {
  margin: var(--space-3) var(--space-5) var(--space-1h);
}
#viewer.compact .filter-field input {
  min-height: var(--control-size);
  font-size: var(--text-md);
}
#viewer.compact .model-tree {
  padding: 0 var(--space-3) var(--space-3);
}
#viewer.compact .tree-row {
  font-size: .9375rem;
}
#viewer.compact .tree-chevron {
  width: 24px;
  height: 24px;
}
#viewer.compact .tree-actions {
  width: auto;
}
#viewer.compact .tree-actions > :not([data-action=hide]) {
  display: none !important;
}
#viewer.compact .tree-actions [data-action=hide] {
  width: var(--control-size);
  height: var(--control-size);
}
#viewer.compact .tree-actions svg {
  width: var(--icon-size-small);
  height: var(--icon-size-small);
}
#viewer.compact .place-row {
  min-height: var(--control-size);
  font-size: .9375rem;
}
/* Phones: Help and the links move into More (app-tools.css makes the toolbar icon-only), and the
   two scene buttons sit just left of the toolbar, which shows the language code. */
#viewer.compact .help-toggle, #viewer.compact .toolbar-link {
  display: none;
}
#viewer.compact .topbar {
  grid-template-columns: 1fr auto auto;
}
#viewer.compact .compact-only {
  display: flex !important;
}
#viewer.compact .camera-rail {
  top: 50%;
  bottom: auto;
  padding: 0;
  border-radius: var(--radius-control);
  transform: translateY(-50%);
}
#viewer.compact .camera-rail button {
  width: var(--control-size);
  height: var(--control-size);
  border-radius: var(--radius-control);
}
#viewer.compact .navigation-hint, #viewer.compact .fly-button {
  display: none;
}
#viewer.compact .controls {
  bottom: calc(var(--sheet-collapsed) + var(--space-3) + env(safe-area-inset-bottom));
  align-items: center;
  justify-content: stretch;
  gap: var(--space-half);
  padding: var(--space-1);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-dropdown);
  background: var(--color-overlay-soft);
  box-shadow: var(--shadow-dock);
  backdrop-filter: blur(var(--blur-panel));
  pointer-events: auto;
}
#viewer.compact .dock, #viewer.compact .nav-modes {
  position: static;
  gap: var(--space-half);
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}
#viewer.compact .dock {
  flex: 1;
  min-width: 0;
}
#viewer.compact .dock [data-mode] {
  flex: 1;
  flex-direction: column;
  gap: var(--space-half);
  min-width: 0;
  min-height: 52px;
  padding: var(--space-1) var(--space-half);
  font-size: var(--text-2xs);
}
#viewer.compact .dock [data-mode] span {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip-path: none;
}
#viewer.compact .label-long, #viewer.compact .dock [data-mode] .label-long {
  display: none;
}
#viewer.compact .label-short {
  display: inline;
}
#viewer.compact .nav-modes::before {
  content: '';
  align-self: center;
  width: 1px;
  height: 28px;
  margin: 0 var(--space-1);
  background: var(--color-border-strong);
}
#viewer.compact .nav-modes button {
  width: var(--control-size);
  height: 52px;
  border-radius: var(--radius-control);
}
#viewer.compact .inspector {
  right: var(--space-3);
  left: var(--space-3);
  top: calc(var(--inset-top) + var(--control-size) + var(--space-3));
  width: auto;
}
#viewer.compact .notice {
  bottom: calc(var(--sheet-collapsed) + 96px);
}
/* The dock stays above the sheet while walking: the pad and its actions sit above it (62 px dock, 12 px gaps). */
#viewer.compact :is(.move-pad, .touch-walk-actions) {
  bottom: calc(var(--sheet-collapsed) + env(safe-area-inset-bottom) + 86px);
}
@media (pointer: coarse) {
  .field-grid input {
    font-size: var(--text-md);
  }
  .tree-actions {
    width: auto;
  }
  .tree-row:not(:focus-within) .tree-actions > :not([data-action=hide]):not([aria-pressed=true]) {
    display: none;
  }
}
@media (max-height: 500px) {
  .navigation-hint {
    display: none;
  }
  .inspector-details {
    max-height: 30dvh;
  }
}
@media (prefers-reduced-motion: reduce) { *, *::after { transition: none !important; scroll-behavior: auto !important; } }

/* Shown by boot.js only when the viewer cannot start (file:// or a missing configuration). */
.boot-status { max-width: 36rem; margin: 20vh auto 0; padding: 0 16px; color: #fff; font: 15px/1.5 system-ui, sans-serif; }
