:root {
  color-scheme: light;
  font-family: "Segoe UI Variable", "Segoe UI", Inter, Roboto, Arial, sans-serif;
  background: #f3f5f8;
  color: #172033;
  --btn-primary-bg: #334155;
  --btn-primary-border: #475569;
  --btn-primary-hover: #3f5167;
  --btn-primary-active: #2b3849;
  --btn-secondary-bg: #eef1f5;
  --btn-secondary-border: #cbd5e1;
  --btn-secondary-text: #334155;
  --btn-secondary-hover: #e5eaf1;
  --btn-load-bg: #e5ebfa;
  --btn-load-border: #bfcbeb;
  --btn-load-text: #1e3a8a;
  --btn-load-hover: #dae4fb;
  --btn-save-bg: #e7f3ec;
  --btn-save-border: #b7d7c3;
  --btn-save-text: #166534;
  --btn-save-hover: #dceddf;
  --btn-danger-bg: #fdebec;
  --btn-danger-border: #efc6cb;
  --btn-danger-text: #991b1b;
  --btn-danger-hover: #f9dde0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #f3f5f8;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 18px 24px 10px;
}

.title-wrap h1 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: 0;
  font-weight: 700;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-version {
  color: #5a6883;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.app-title-icon {
  display: block;
  width: 45px;
  height: 45px;
  flex: 0 0 auto;
}

.subtitle {
  margin: 4px 0 0;
  color: #5a6883;
  font-size: 0.95rem;
}

.topbar-actions,
.row.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-actions {
  align-items: flex-start;
  justify-content: flex-end;
  min-width: 360px;
  flex: 1;
}

.header-admin-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  border: 1px solid #d8deea;
  border-radius: 10px;
  background: #ffffff;
  padding: 8px 10px;
}

.header-admin-status {
  font-size: 0.78rem;
  color: #405273;
}

.topbar-guide {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 10px;
  border: 1px solid #d8deea;
  border-radius: 10px;
  background: #f7faff;
  padding: 8px 10px;
  width: 100%;
  max-width: 980px;
}

.topbar-guide-col {
  min-width: 0;
}

.topbar-guide-title {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #3d537b;
}

.topbar-guide-text {
  margin: 2px 0 0;
  font-size: 0.82rem;
  line-height: 1.3;
  color: #405273;
}

@media (max-width: 1120px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .topbar-actions {
    min-width: 0;
    justify-content: flex-start;
  }

  .topbar-guide {
    grid-template-columns: 1fr;
  }
}

.stats-bar {
  padding: 0 24px 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.workspace-tabs {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  padding: 0 24px 12px;
  border-bottom: 1px solid #c7d4ee;
}

.workspace-tab {
  border: 1px solid #c7d4ee;
  border-bottom: none;
  background: #edf2fb;
  color: #3a5688;
  border-radius: 10px 10px 0 0;
  padding: 7px 14px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transform: translateY(1px);
}

.workspace-tab.active {
  background: #ffffff;
  color: #1f3256;
  border-color: #c7d4ee;
  border-bottom: 1px solid #ffffff;
}

.workspace-tab:focus-visible {
  outline: 2px solid #5b83d5;
  outline-offset: 1px;
}

.stat-card {
  border: 1px solid #d8deea;
  border-radius: 12px;
  padding: 9px 13px;
  background: #ffffff;
  display: flex;
  flex-direction: row;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 1px 1px rgba(16, 24, 40, 0.04);
}

.stat-card .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.55px;
  color: #6b7891;
  white-space: nowrap;
}

.stat-card strong {
  font-size: 1.02rem;
  font-weight: 700;
  text-align: right;
}

.stat-card.wide {
  grid-column: span 1;
}

.layout {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 0 24px 16px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

body:not(.hosted-catalog-mode) #hosted-catalog-panel {
  display: none;
}

body.hosted-catalog-mode .layout {
  grid-template-columns: 1fr;
  overflow: auto;
}

body.hosted-catalog-mode .layout > :not(#hosted-catalog-panel) {
  display: none;
}
body.hosted-catalog-mode .hosted-catalog-panel {
  min-height: 0;
  max-height: 100%;
}

.catalog-split-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 14px;
  flex: 1;
  min-height: 0;
}

.catalog-models-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  border-right: 1px solid #d8deea;
  padding-right: 14px;
}

.catalog-table-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
}

.viewer-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: hidden;
  padding-right: 2px;
}

.inspector-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.panel {
  border: 1px solid #d8deea;
  border-radius: 12px;
  padding: 14px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.05);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 6px;
  margin-bottom: 8px;
}

.panel.panel-dirty > .panel-head {
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  padding-left: 8px;
  margin-left: -8px;
  border-radius: 2px 0 0 2px;
}

.panel.panel-dirty > .panel-head .panel-title-group h3::after,
.panel.panel-dirty > .panel-head .panel-title-group h2::after {
  content: " ●";
  color: #d97706;
  font-size: 0.55em;
  vertical-align: super;
  font-weight: 400;
}

.panel-head-right {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.panel h2,
.panel h3 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
}

.panel-title-group {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.panel-chip {
  font-size: 0.75rem;
  border: 1px solid #c7d4ee;
  border-radius: 999px;
  padding: 2px 9px;
  color: #3c567f;
  background: #eef3ff;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Compact "Structure map" trigger shown in the Scene Bundle panel title row. */
.panel-map-btn {
  font-size: 0.72rem;
  padding: 2px 9px;
  line-height: 1.5;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Loaded config name label shown in the panel title row. */
.config-name-label {
  font-size: 0.74rem;
  font-style: italic;
  font-weight: 400;
  color: #3c567f;
  background: #eef3ff;
  border: 1px solid #c7d4ee;
  border-radius: 999px;
  padding: 1px 8px;
  max-width: 22ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Subtitle row below a panel-head showing the currently loaded file/config name. */
.panel-source-label {
  margin: -4px 0 6px;
  font-size: 0.78rem;
  color: #5a7090;
  font-style: italic;
}

.panel-source-label .config-name-label {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  color: #5a7090;
  font-size: 0.78rem;
  max-width: none;
}

.scene-bundle-sync-status.is-synced {
  background: #e8f7ee;
  border-color: #b7dfc6;
  color: #166534;
}

.scene-bundle-sync-status.is-mixed {
  background: #fff4e8;
  border-color: #f5c889;
  color: #9a5b00;
}

/* Node tree: expand/collapse chevron + drag-reparent affordances. */
.tree-node-chevron {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  background: none;
  color: #5a7090;
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
}

.tree-node-chevron:hover {
  color: #1f3256;
}

.tree-node-chevron-spacer {
  visibility: hidden;
  cursor: default;
}

.tree-node.tree-drop-target,
.tree-add-root-bar.tree-drop-target {
  outline: 2px dashed #3b67c7;
  outline-offset: -2px;
  background: #e8f0fd;
}

/* Topbar "Open Scene…" — the Studio's primary entry point to real content. */
.open-scene-btn {
  font-weight: 600;
  white-space: nowrap;
}

.open-scene-card {
  max-width: 560px;
  width: min(560px, calc(100vw - 48px));
}

.open-scene-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.open-scene-section-title {
  margin: 6px 0 2px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5a7090;
}

.open-scene-filter {
  width: 100%;
}

.open-scene-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}

.open-scene-catalog {
  max-height: 300px;
}

.open-scene-entry {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: #f7f9fd;
  border: 1px solid #d8deea;
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
}

.open-scene-entry:hover {
  background: #eef3ff;
  border-color: #c7d4ee;
}

.open-scene-entry.is-loading {
  opacity: 0.6;
  cursor: progress;
}

.open-scene-entry-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.open-scene-entry-meta {
  font-size: 0.72rem;
  color: #5a7090;
  white-space: nowrap;
  flex-shrink: 0;
}

.open-scene-empty {
  margin: 2px 0;
  font-size: 0.8rem;
  color: #5a7090;
  font-style: italic;
}

.doc-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  border: 1px solid #c7d4ee;
  border-radius: 999px;
  background: #eef3ff;
}

.doc-mode-toggle label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: #3c567f;
  font-weight: 600;
}

.doc-mode-toggle input[type="radio"] {
  margin: 0;
}

.hint {
  margin: 0 0 8px;
  color: #61708b;
  font-size: 0.9rem;
}

.code-editor {
  width: 100%;
  flex: 1;
  background: #fbfcff;
  color: #152036;
  border: 1px solid #cfd7e6;
  border-radius: 8px;
  font: 12px/1.5 Consolas, "Courier New", monospace;
  outline: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* .code-editor uses display:flex, which overrides UA [hidden] display:none.
   Enforce hidden state explicitly so JSON/Form mode switches show only one. */
.code-editor[hidden],
.cfg-form-container[hidden] {
  display: none !important;
}

pre {
  width: 100%;
  background: #fbfcff;
  color: #152036;
  border: 1px solid #cfd7e6;
  border-radius: 8px;
  font: 12px/1.5 Consolas, "Courier New", monospace;
  outline: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 12px;
}

.code-editor:focus-within {
  border-color: #7a98cf;
  box-shadow: 0 0 0 3px rgba(87, 133, 255, 0.14);
}

.code-editor>.cm-editor {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100%;
}

.code-editor + .row.actions {
  margin-top: 8px;
}

.cm-editor .cm-scroller {
  font-family: Consolas, "Courier New", monospace;
  overflow: auto;
  height: 100%;
}

.cm-editor.cm-focused {
  outline: none !important;
}

.editor-panel {
  min-height: 0;
  flex: 0 0 auto;
}

.json-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.view-config-panel {
  background: #ffffff;
  padding: 12px;
  flex: 0 0 auto;
}

.view-config-panel .hint {
  margin-bottom: 8px;
  font-size: 0.82rem;
}

.view-config-editor {
  min-height: 220px;
  max-height: 300px;
  flex: 0 0 auto;
}

.config-editor {
  min-height: 180px;
  max-height: 260px;
  flex: 0 0 auto;
}

/* Every config card in the scrolling .json-column sizes to its own content and
   never shrinks. Without this the flex default (0 1 auto) lets the column
   squeeze the card's border box while its fixed-min-height editor keeps its
   size, so the editor and action row render outside the card and cover the
   neighbours below. */
.lighting-config-panel,
.layers-config-panel,
.look-config-panel,
.commentary-config-panel,
.audio-config-panel,
.display-profile-config-panel,
.visibility-state-panel,
.simulation-package-panel {
  flex: 0 0 auto;
}

.editor-panel .code-editor {
  flex: 0 0 auto;
  min-height: 220px;
  max-height: 420px;
}

.json-column .row.actions {
  gap: 6px;
}

.json-column .row.actions button,
.json-column .row.actions .sample-dropdown-wrap > button {
  padding: 4px 8px;
  font-size: 0.78rem;
  line-height: 1.15;
}

.cm-mesh-loaded {
  color: #0f5f3a;
  font-weight: 800;
}

.cm-mesh-missing {
  color: #8b1e2f;
  font-weight: 800;
}

.cm-mesh-indicator {
  margin-left: 8px;
  font-size: 0.68rem;
  vertical-align: baseline;
  border-radius: 999px;
  padding: 1px 7px;
  font-weight: 800;
  letter-spacing: 0.04em;
  border: 1px solid #d4dbea;
  font-family: "Segoe UI Variable", "Segoe UI", Inter, Roboto, Arial, sans-serif;
}

.cm-mesh-indicator.loaded {
  color: #0f5f3a;
  border-color: #a5dec3;
  background: #e9f8f0;
}

.cm-mesh-indicator.missing {
  color: #8b1e2f;
  border-color: #efc2c9;
  background: #fff3f5;
}

.cm-line.cm-mesh-line-loaded {
  background: linear-gradient(to right, rgba(16, 185, 129, 0.12), rgba(16, 185, 129, 0.04));
  border-left: 3px solid #34d399;
  padding-left: 6px;
}

.cm-line.cm-mesh-line-missing {
  background: linear-gradient(to right, rgba(239, 68, 68, 0.14), rgba(239, 68, 68, 0.05));
  border-left: 3px solid #f87171;
  padding-left: 6px;
}

.viewer-panel {
  min-height: 0;
  overflow: auto;
}

.viewer-panel:fullscreen {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  border-radius: 0;
  position: relative;
}

.viewer-panel:fullscreen .viewer-canvas {
  min-height: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  border: none;
  border-radius: 0;
}

.viewer-canvas {
  position: relative;
  flex: 0 0 auto;
  height: auto;
  min-height: 160px;
  max-width: 460px;
  max-height: 360px;
  width: 100%;
  aspect-ratio: 1.6;
  margin: 0 auto;
  border: 1px solid #cfd7e6;
  border-radius: 8px;
  background: #f8faff;
  overflow: hidden;
  transition: border-color 150ms ease, background 150ms ease;
}

.viewer-canvas.fill-mode {
  height: clamp(300px, 52vh, 500px);
  min-height: 300px;
}

.viewer-panel:fullscreen .viewer-canvas {
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
}

.viewer-panel:fullscreen .panel-head,
.viewer-panel:fullscreen .viewer-status-block {
  display: none;
}

.viewer-overlay-toggle {
  display: none;
}

.viewer-panel:fullscreen .viewer-overlay-toggle {
  display: inline-flex;
  position: absolute;
  right: 14px;
  bottom: 92px;
  z-index: 24;
  font-size: 0.72rem;
  padding: 3px 7px;
  border: 1px solid rgba(203, 213, 225, 0.6);
  background: rgba(241, 245, 249, 0.82);
  backdrop-filter: blur(8px);
}

.viewer-panel:fullscreen.overlay-controls-hidden .viewer-overlay-toggle {
  bottom: 14px;
}

.viewer-panel:fullscreen .viewer-actions {
  display: flex;
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 22;
  max-width: calc(100vw - 28px);
  width: calc(100vw - 28px);
  min-width: 0;
  gap: 4px;
  padding: 6px 8px;
  border: 1px solid rgba(203, 213, 225, 0.6);
  border-radius: 12px;
  background: rgba(241, 245, 249, 0.82);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
  overflow-x: auto;
}

.viewer-panel:fullscreen .viewer-actions > button {
  font-size: 0.7rem;
  padding: 3px 6px;
}

.viewer-panel:fullscreen .viewer-actions .viewer-btn-system {
  border-color: #bfcbeb;
  background: #e5ebfa;
  color: #1e3a8a;
}

.viewer-panel:fullscreen .viewer-actions .viewer-btn-mode {
  border-color: #bfcbeb;
  background: #e5ebfa;
  color: #1e3a8a;
}

.viewer-panel:fullscreen .viewer-actions .viewer-btn-preview {
  border-color: #b7d7c3;
  background: #e7f3ec;
  color: #166534;
}

.viewer-panel:fullscreen .viewer-actions .viewer-btn-reset {
  border-color: #efc6cb;
  background: #fdebec;
  color: #991b1b;
}

.viewer-panel:fullscreen .viewer-actions .toggle-view {
  border-color: #bfcbeb;
  background: #e5ebfa;
  color: #1e3a8a;
}

.viewer-panel:fullscreen .viewer-actions .toggle-scene {
  border-color: #cbd5e1;
  background: #eef1f5;
  color: #334155;
}

.viewer-panel:fullscreen .viewer-actions .toggle-material {
  border-color: #b7d7c3;
  background: #e7f3ec;
  color: #166534;
}

.viewer-panel:fullscreen .viewer-actions .toggle-switch {
  font-size: 0.64rem;
  gap: 3px;
  padding: 2px 5px;
}

.viewer-panel:fullscreen .viewer-actions .toggle-switch input[type="checkbox"] {
  width: 11px;
  height: 11px;
}

.viewer-panel:fullscreen.overlay-controls-hidden .viewer-actions {
  display: none;
}

.viewer-framing-guide {
  position: absolute;
  border: 2px dashed rgba(87, 133, 255, 0.75);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.85);
  pointer-events: none;
  z-index: 4;
  display: none;
}

.viewer-canvas.drop-active {
  border-color: #5785ff;
  border-width: 2px;
  background: #f2f6ff;
}

.viewer-canvas canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.viewer-model-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(7, 10, 18, 0.55);
  color: #f8fafc;
  z-index: 6;
  pointer-events: none;
}

.viewer-model-loading-overlay[hidden] {
  display: none !important;
}

.viewer-model-loading-spinner {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.28);
  border-top-color: #e2e8f0;
  animation: viewerModelLoadingSpin 900ms linear infinite;
}

.viewer-model-loading-text {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

@keyframes viewerModelLoadingSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.viewer-tooltip {
  position: absolute;
  z-index: 10;
  pointer-events: none;
  max-width: 260px;
  padding: 7px 9px;
  border: 1px solid #cad5ea;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.96);
  color: #1f2c46;
  box-shadow: 0 6px 16px rgba(15, 26, 47, 0.18);
  font: 12px/1.4 "Segoe UI", Arial, sans-serif;
  white-space: pre-line;
}

.viewer-tooltip[hidden] {
  display: none;
}

.row.actions.viewer-actions {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  align-items: stretch;
  gap: 6px;
  width: 100%;
}

.viewer-actions > button,
.viewer-actions > .toggle-switch {
  width: 100%;
  justify-content: center;
}

.viewer-actions > .toggle-switch {
  text-align: center;
}

.viewer-actions > .control-wide {
  grid-column: 1 / -1;
}

.viewer-control-stack {
  display: grid;
  gap: 6px;
}

.viewer-control-row {
  display: grid;
  gap: 6px;
  width: 100%;
}

.viewer-view-row {
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
}

.viewer-animation-row {
  grid-template-columns: max-content max-content;
  justify-content: start;
  align-items: center;
}

.viewer-control-row > button,
.viewer-control-row > .toggle-switch,
.viewer-control-row > .viewer-radio-group {
  width: auto;
}

.viewer-view-row > #viewer-fullscreen {
  min-width: 210px;
}

.viewer-radio-group {
  margin: 0;
  border: 1px solid #c7d4ee;
  background: #eef3ff;
  color: #3c567f;
  border-radius: 10px;
  padding: 4px 8px 6px;
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: 4px 8px;
  min-width: 0;
  width: auto;
  justify-content: start;
}

.viewer-radio-group legend {
  padding: 0 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #3c567f;
}

.viewer-radio-option {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  font-size: 0.76rem;
  line-height: 1.1;
  white-space: nowrap;
}

.viewer-radio-option input[type="radio"] {
  margin: 0;
}

.viewer-status-block {
  margin-top: 6px;
  padding: 0 2px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.viewer-status-line {
  margin: 0;
  font-size: 0.62rem;
  line-height: 1.35;
  color: #53627e;
}

.viewer-summary {
  margin: 0;
  flex: 1 1 100%;
  font-size: 0.82rem;
}

.command-panel {
  min-height: 0;
}

.panel.collapsed {
  flex: 0 0 auto;
  min-height: auto;
}

.panel.collapsed > *:not(.panel-head) {
  display: none;
}

/* Keep the loaded-file subtitle row visible even when the panel is collapsed. */
.panel.collapsed > .panel-source-label {
  display: block;
}

.panel.collapsed .doc-mode-toggle {
  display: none;
}

.panel.collapsed > .collapse-load-row {
  display: flex;
  margin-top: 4px;
}

.panel.collapsed > .collapse-load-row > * {
  display: none;
}

.panel.collapsed > .collapse-load-row > :first-child,
.panel.collapsed > .collapse-load-row > .collapse-primary {
  display: inline-flex;
}

.panel.collapsed > .collapse-load-row > .collapse-primary.sample-dropdown-wrap {
  display: inline-flex;
}

.panel.collapsed > .collapse-load-row > button:not(.collapse-primary):not(:first-child) {
  display: none;
}

.panel-collapse-btn,
.panel-collapse-btn.secondary {
  border-color: #c7d4ee;
  background: #ffffff;
  color: #334b76;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.1;
}

.panel-collapse-btn:hover,
.panel-collapse-btn.secondary:hover {
  background: #f2f6ff;
  box-shadow: none;
  transform: none;
}

.config-placeholder {
  margin: 0;
  min-height: 120px;
  max-height: 220px;
  overflow: auto;
  white-space: pre;
}

.model-cache-meta {
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: #445577;
}

.model-cache-meta-under-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 6px;
}

.model-panel-top {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: start;
  width: 100%;
  min-width: 0;
}

.model-preview-settings {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.model-panel-info .hint {
  margin-bottom: 6px;
}

.model-preview-card {
  border: 1px solid #d5deec;
  border-radius: 10px;
  padding: 7px;
  background: #f7faff;
  min-width: 0;
  overflow: hidden;
}

.model-preview-card:fullscreen {
  width: 100vw;
  height: 100vh;
  margin: 0;
  border-radius: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
}

.model-preview-card:fullscreen .model-preview-canvas {
  flex: 1;
  min-height: 0;
  height: auto;
  aspect-ratio: auto;
}

.model-preview-card:fullscreen .model-preview-status {
  white-space: normal;
  overflow: visible;
  text-overflow: initial;
}

.model-preview-canvas {
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid #cfd7e6;
  border-radius: 8px;
  background: #f8faff;
  overflow: hidden;
  position: relative;
}

.model-preview-canvas canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.model-preview-status {
  margin: 6px 2px 0;
  font-size: 0.74rem;
  color: #4a5f86;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-preview-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  background: linear-gradient(180deg, rgba(244, 248, 255, 0.96), rgba(231, 239, 252, 0.96));
}

/* display:flex above overrides the UA stylesheet [hidden]=display:none, so enforce it explicitly */
.model-preview-overlay[hidden] {
  display: none;
}

.model-preview-overlay.transparent {
  background: transparent;
}

.model-preview-overlay-message {
  margin: 0;
  text-align: center;
  font-size: 0.74rem;
  line-height: 1.35;
  color: #2d446f;
}

.model-preview-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid #cfd7e6;
  background: #ffffff;
}

.inline-assets-list {
  flex: 1;
  min-height: 160px;
  max-height: none;
}

.inline-assets-list[hidden] {
  display: none !important;
}

/* ── Catalog source files panel ─────────────────────────── */

.catalog-source-files {
  margin: 5px 0 0;
  border: 1px solid #d5deec;
  border-radius: 8px;
  background: #f7faff;
  padding: 6px 8px 5px;
}

.catalog-source-files-heading {
  font-size: 0.68rem;
  font-weight: 700;
  color: #3d5278;
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.catalog-source-files-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.catalog-source-file-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 5px;
  border-radius: 5px;
  font-size: 0.73rem;
  font-family: "Segoe UI Variable", "Segoe UI", Inter, Roboto, Arial, sans-serif;
  color: #2a3d60;
  cursor: default;
}

.catalog-source-file-item.previewable {
  cursor: pointer;
}

.catalog-source-file-item.previewable:hover {
  background: #e4edfb;
}

.catalog-source-file-item.active {
  background: #d9e8fb;
  font-weight: 600;
}

.catalog-source-file-type {
  font-size: 0.63rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid #cdd7ee;
  background: #eef3ff;
  color: #4a65a0;
  flex-shrink: 0;
  font-family: "Segoe UI Variable", "Segoe UI", Inter, Roboto, Arial, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.catalog-source-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.catalog-source-file-status {
  flex-shrink: 0;
  font-size: 0.67rem;
}

.catalog-source-file-status.cached {
  color: #0f7a4c;
}

.catalog-source-file-status.not-cached {
  color: #9aabcc;
}

/* ── Models column upload panel (admin only) ────────────── */

.catalog-models-upload-panel {
  margin: 5px 0 0;
  border: 1px solid #d5deec;
  border-radius: 8px;
  background: #f7faff;
  padding: 6px 8px 8px;
}

.catalog-models-upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 10px;
  border: 2px dashed #b8caef;
  border-radius: 6px;
  background: #f0f5ff;
  text-align: center;
  cursor: default;
  transition: border-color 0.15s, background 0.15s;
}

.catalog-models-upload-zone.drag-over {
  border-color: #3b67c7;
  background: #e8f0fd;
}

.catalog-models-upload-icon {
  font-size: 1.3rem;
  color: #7a96c4;
  line-height: 1;
}

.catalog-models-upload-label {
  margin: 0;
  font-size: 0.73rem;
  font-weight: 600;
  color: #1f3256;
}

.catalog-models-upload-browse-btn {
  display: inline-block;
  margin-top: 2px;
  padding: 4px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid #3b67c7;
  border-radius: 6px;
  background: #eef3ff;
  color: #1f3256;
  cursor: pointer;
}

.catalog-models-upload-browse-btn:hover {
  background: #dbe5f7;
}

.catalog-models-upload-progress {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.catalog-models-upload-status {
  margin: 4px 0 0;
  font-size: 0.68rem;
  color: #5a7099;
  min-height: 1em;
  word-break: break-word;
}

.catalog-models-upload-channel-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.7rem;
  color: #5a7099;
}

.catalog-models-upload-channel-row select {
  font-size: 0.7rem;
  padding: 2px 4px;
}

.command-test-compat {
  display: none;
}

.command-panel .code-editor {
  flex: 1;
  min-height: 0;
}

.command-reference {
  margin-top: 10px;
  border: 1px solid #d8deea;
  border-radius: 8px;
  padding: 10px;
  background: #fafcff;
}

.command-reference-head {
  font-size: 0.82rem;
  font-weight: 700;
  color: #3a4f76;
  margin-bottom: 8px;
}

.command-template-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.command-template {
  border: 1px solid #cad6ed;
  background: #f2f6ff;
  color: #304a77;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.2;
}

.command-template:hover {
  background: #e8efff;
  box-shadow: none;
  transform: none;
}

.command-template-hint {
  margin: 8px 0 0;
  font-size: 0.78rem;
}

/* Topbar diagnostics badge — replaces the always-visible Diagnostics panel.
   Click opens the diagnostics modal. */
.diagnostics-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid #d8deea;
  border-radius: 999px;
  padding: 4px 8px;
  cursor: pointer;
  color: inherit;
}

.diagnostics-badge:hover {
  background: #eef3ff;
}

.diagnostics-badge.is-clean .diag-badge.error,
.diagnostics-badge.is-clean .diag-badge.warn {
  color: #166534;
  border-color: #b7dfc6;
  background: #e8f7ee;
}

.diagnostics-badge.has-errors {
  border-color: #efc2c9;
  background: #fff3f5;
}

.diagnostics-badge.has-warnings {
  border-color: #f1d8b0;
  background: #fff8ee;
}

.diagnostics-card {
  max-width: 720px;
  width: min(720px, calc(100vw - 48px));
}

.diagnostics-card pre {
  margin: 0;
  max-height: 60vh;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 0.8rem;
}

.diag-inline {
  display: flex;
  gap: 8px;
}

/* "More ▾" action menu — a native <details> holding a panel's secondary
   load/save actions so the primary row stays short. Button ids inside are
   unchanged; all existing wiring keeps working. */
.action-menu {
  position: relative;
  display: inline-block;
}

.action-menu > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--btn-secondary-border, #c4cede);
  background: var(--btn-secondary-bg, #f3f6fc);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.85rem;
  user-select: none;
}

.action-menu > summary::-webkit-details-marker {
  display: none;
}

.action-menu[open] > summary {
  background: #e8f0fd;
}

.action-menu-items {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-width: 200px;
  padding: 8px;
  background: #ffffff;
  border: 1px solid #d8deea;
  border-radius: 10px;
  box-shadow: 0 8px 22px rgba(16, 24, 40, 0.14);
}

.action-menu-items > button,
.action-menu-items .sample-dropdown-wrap > button {
  width: 100%;
  text-align: left;
}

.diag-badge {
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 3px 8px;
  border: 1px solid #d4dbea;
}

.diag-badge.error {
  color: #8b1e2f;
  border-color: #efc2c9;
  background: #fff3f5;
}

.diag-badge.warn {
  color: #7e4a00;
  border-color: #f1d8b0;
  background: #fff8ee;
}

button {
  border: 1px solid var(--btn-primary-border);
  background: var(--btn-primary-bg);
  color: #ffffff;
  border-radius: 7px;
  padding: 5px 9px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

button.secondary {
  border-color: var(--btn-secondary-border);
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
}

button.secondary:hover {
  background: var(--btn-secondary-hover);
}

button.load-action {
  border-color: var(--btn-load-border);
  background: var(--btn-load-bg);
  color: var(--btn-load-text);
}

button.load-action:hover {
  background: var(--btn-load-hover);
}

button.save-action {
  border-color: var(--btn-save-border);
  background: var(--btn-save-bg);
  color: var(--btn-save-text);
}

button.save-action:hover {
  background: var(--btn-save-hover);
}

button.danger-action {
  border-color: var(--btn-danger-border);
  background: var(--btn-danger-bg);
  color: var(--btn-danger-text);
}

button.danger-action:hover {
  background: var(--btn-danger-hover);
}

.info-icon {
  width: 22px;
  height: 22px;
  min-width: 22px;
  border-radius: 999px;
  border: 1px solid #c6d2e8;
  background: #f5f8ff;
  color: #35507f;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
}

.info-icon:hover {
  background: #e9f0ff;
  box-shadow: none;
  transform: none;
}

.info-icon:active {
  transform: none;
}

.modal-shell {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-shell.open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 40, 0.42);
}

.modal-card {
  position: relative;
  width: min(680px, calc(100vw - 40px));
  max-height: calc(100vh - 60px);
  overflow: auto;
  border: 1px solid #d6deec;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 18px 50px rgba(17, 29, 53, 0.22);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e2e8f4;
  padding: 14px 16px;
}

.modal-head h3 {
  margin: 0;
  font-size: 1.02rem;
}

.modal-close {
  min-width: 28px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid #d0d9ea;
  background: #f8faff;
  color: #3c4e6d;
  font-size: 16px;
  padding: 0;
}

.modal-close:hover {
  background: #eef3ff;
  transform: none;
  box-shadow: none;
}

.modal-body {
  padding: 14px 16px 16px;
  color: #2f3f5f;
  line-height: 1.6;
}

.modal-body p {
  margin: 0 0 10px;
}

.modal-body ul {
  margin: 0;
  padding-left: 20px;
}

.modal-select {
  width: 100%;
  border: 1px solid #c7d4ee;
  border-radius: 8px;
  padding: 8px 10px;
  background: #ffffff;
  color: #1e2f4d;
  font-size: 0.9rem;
}

/* Cloud save modal: prefix + editable file name inline row */
.cloud-save-form-label {
  display: block;
  font-size: 0.84rem;
  color: #33486b;
  margin-bottom: 4px;
}

.cloud-save-key-row {
  display: flex;
  align-items: stretch;
  border: 1px solid #c7d4ee;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.cloud-save-prefix {
  padding: 8px 10px;
  background: #f0f4fb;
  color: #4a6080;
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  border-right: 1px solid #c7d4ee;
  display: flex;
  align-items: center;
}

.cloud-save-sep {
  padding: 0 4px;
  color: #9baec8;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
}

.cloud-save-key-row input {
  flex: 1;
  border: none;
  padding: 8px 10px;
  background: transparent;
  color: #1e2f4d;
  font-size: 0.9rem;
  min-width: 0;
}

.cloud-save-key-row input:focus {
  outline: none;
}

.cloud-save-key-preview {
  margin-top: 5px !important;
  color: #6b7d9c;
  font-size: 0.8rem;
}

button:hover {
  background: var(--btn-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(45, 58, 73, 0.22);
}

button:active {
  transform: translateY(0);
}

.save-scene-btn,
.save-scene-btn.secondary {
  border-color: var(--btn-save-border);
  background: var(--btn-save-bg);
  color: var(--btn-save-text);
}

.save-scene-btn:hover,
.save-scene-btn.secondary:hover {
  background: var(--btn-save-hover);
}

.save-scene-btn:active,
.save-scene-btn.secondary:active {
  background: #d2e4d7;
}

.save-view-btn,
.save-view-btn.secondary {
  border-color: var(--btn-save-border);
  background: var(--btn-save-bg);
  color: var(--btn-save-text);
}

.save-view-btn:hover,
.save-view-btn.secondary:hover {
  background: var(--btn-save-hover);
}

.save-view-btn:active,
.save-view-btn.secondary:active {
  background: #d2e4d7;
}

#status {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #223252;
}

.scene-preflight-details {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 4px;
}

.scene-preflight-details li {
  margin: 0;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.8rem;
  border: 1px solid #d6deec;
  color: #324b74;
  background: #f7fafd;
}

.scene-preflight-details li.pass {
  border-color: #c6e8cf;
  background: #edf9f1;
  color: #1f5f39;
}

.scene-preflight-details li.fail {
  border-color: #f3c5cc;
  background: #fff1f4;
  color: #9a2533;
}

#scene-config-preflight-status.pass {
  color: #1f5f39;
}

#scene-config-preflight-status.fail {
  color: #9a2533;
}

.assets-list {
  list-style: none;
  padding: 0;
  margin: 10px 0;
  border: 1px solid #d6deec;
  border-radius: 8px;
  max-height: 250px;
  overflow-y: auto;
}

.assets-list.inline-assets-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  height: 100%;
}

.assets-list li {
  padding: 8px 12px;
  border-bottom: 1px solid #e2e8f4;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.assets-list li:last-child {
  border-bottom: none;
}

.assets-list li.asset-row {
  align-items: flex-start;
}

.assets-list li.asset-row.used {
  background: #f2fbf6;
}

.assets-list li.asset-row.unused {
  background: #fff3f5;
}

.assets-list li.asset-row.selected {
  outline: 2px solid #4e7bd4;
  outline-offset: -2px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.75);
}

.asset-row-text {
  min-width: 0;
  flex: 1;
}

.asset-top-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

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

.catalog-env-thumb {
  display: inline-block;
  width: 48px;
  height: 24px;
  margin-right: 6px;
  object-fit: cover;
  vertical-align: middle;
  border-radius: 3px;
  border: 1px solid #cdd7ee;
  background: #10131a;
}

.catalog-file-summary {
  display: inline-block;
  margin-left: 5px;
  font-size: 0.69rem;
  color: #5a6e99;
  background: #eef3ff;
  border: 1px solid #cdd7ee;
  border-radius: 4px;
  padding: 1px 5px;
  vertical-align: middle;
  font-family: "Segoe UI Variable", "Segoe UI", Inter, Roboto, Arial, sans-serif;
  white-space: nowrap;
}

.asset-side-badge {
  font-size: 0.7rem;
  border-radius: 999px;
  padding: 2px 7px;
  border: 1px solid #d7deec;
  color: #3f577e;
  background: #eef3ff;
  font-family: "Segoe UI Variable", "Segoe UI", Inter, Roboto, Arial, sans-serif;
  font-weight: 600;
  flex: 0 0 auto;
}

.model-usage-badge {
  font-size: 0.72rem;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid #d4dbea;
  font-family: "Segoe UI Variable", "Segoe UI", Inter, Roboto, Arial, sans-serif;
  font-weight: 700;
  letter-spacing: 0.01em;
  flex: 0 0 auto;
}

.model-usage-badge.used {
  color: #0f5f3a;
  border-color: #a5dec3;
  background: #e9f8f0;
}

.model-usage-badge.unused {
  color: #8b1e2f;
  border-color: #efc2c9;
  background: #fff3f5;
}

.asset-mapping-line {
  font-size: 0.75rem;
  color: #445577;
  font-family: "Segoe UI Variable", "Segoe UI", Inter, Roboto, Arial, sans-serif;
}

.asset-material-maps {
  font-size: 0.73rem;
  color: #3f577e;
  font-family: "Segoe UI Variable", "Segoe UI", Inter, Roboto, Arial, sans-serif;
}

.assets-list li button {
  padding: 4px 8px;
  font-size: 0.75rem;
  background: #fff0f0;
  color: #c92a2a;
  border-color: #ffc9c9;
}

.assets-list li button:hover {
  background: #ffe3e3;
}

.asset-registry-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.asset-admin-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid #d6deec;
  border-radius: 10px;
  padding: 10px;
  background: #f8fbff;
}

.asset-admin-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.asset-admin-status {
  margin: 0;
  font-size: 0.84rem;
  color: #223252;
}

.asset-admin-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.asset-admin-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.84rem;
  color: #33486b;
}

.asset-admin-form input {
  width: 100%;
  border: 1px solid #c7d4ee;
  border-radius: 8px;
  padding: 8px 10px;
  background: #ffffff;
  color: #1e2f4d;
}

.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrapper input {
  padding-right: 36px;
}

.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: #5a6a8a;
  font-size: 0.95rem;
  padding: 0;
}

.password-toggle:hover {
  background: #eef2fb;
  color: #1e2f4d;
}

.password-toggle:focus-visible {
  outline: 2px solid #6584c1;
  outline-offset: 1px;
}

.password-toggle[aria-pressed="true"] .password-toggle-icon {
  opacity: 0.55;
}

.asset-admin-forgot-row {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
}

.link-button {
  background: none;
  border: none;
  padding: 2px 4px;
  color: #3b5fa2;
  font-size: 0.83rem;
  cursor: pointer;
  text-decoration: underline;
}

.link-button:hover {
  color: #1e3a78;
}

.link-button:disabled {
  color: #8a99b6;
  cursor: not-allowed;
  text-decoration: none;
}

.asset-recover-status {
  margin-top: 8px;
  font-size: 0.84rem;
  color: #33486b;
  min-height: 1.2em;
}

.asset-recover-status.is-error {
  color: #b1203a;
}

.asset-recover-status.is-success {
  color: #1f6f3a;
}

.asset-registry-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.toolbar-row-break {
  flex-basis: 100%;
  height: 0;
  margin: 0;
}

.asset-registry-toolbar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.asset-registry-toolbar-group[hidden] {
  display: none;
}

.mode-toggle-btn {
  border: none;
  border-radius: 0;
  background: #f3f7ff;
  color: #33486b;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 6px 18px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex: 0 0 auto;
}

.mode-toggle-btn:not(:last-child) {
  border-right: 1px solid #c7d4ee;
}

.mode-toggle-btn.active {
  background: #2563eb;
  color: #ffffff;
}

.mode-toggle-btn:not(.active):hover {
  background: #e5edff;
}

.asset-registry-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.84rem;
  color: #33486b;
}

.asset-registry-toolbar input,
.asset-registry-toolbar select {
  width: 100%;
  border: 1px solid #c7d4ee;
  border-radius: 8px;
  padding: 8px 10px;
  background: #f8fbff;
  color: #1e2f4d;
}

.hosted-catalog-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.hosted-catalog-toolbar label {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.hosted-catalog-toolbar select {
  width: auto;
  min-width: 170px;
}

.hosted-catalog-toolbar #hosted-catalog-refresh {
  margin-left: auto;
}

.asset-registry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.84rem;
  color: #3f577e;
}

.asset-registry-status {
  margin: 0;
  border: 1px solid #d6deec;
  border-radius: 8px;
  padding: 8px 10px;
  background: #f8fbff;
  color: #223252;
  font-size: 0.84rem;
}

.asset-action-list {
  margin: 0;
  padding-left: 18px;
  color: #33486b;
  font-size: 0.84rem;
  line-height: 1.45;
}

.registry-row {
  align-items: flex-start;
}

.registry-row-text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.registry-meta-line {
  font-size: 0.75rem;
  color: #445577;
  font-family: "Segoe UI Variable", "Segoe UI", Inter, Roboto, Arial, sans-serif;
}

.registry-badge {
  font-size: 0.72rem;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid #d4dbea;
  font-family: "Segoe UI Variable", "Segoe UI", Inter, Roboto, Arial, sans-serif;
  font-weight: 700;
  letter-spacing: 0.01em;
  flex: 0 0 auto;
}

.registry-badge.ok {
  color: #0f5f3a;
  border-color: #a5dec3;
  background: #e9f8f0;
}

.registry-badge.missing {
  color: #8b1e2f;
  border-color: #efc2c9;
  background: #fff3f5;
}

.registry-badge.config {
  color: #284d8f;
  border-color: #b8caef;
  background: #eef3ff;
}

.registry-badge.public {
  color: #6b4d11;
  border-color: #ead29a;
  background: #fff7dd;
}

.registry-badge.admin {
  color: #113d72;
  border-color: #a9c7f1;
  background: #eaf3ff;
}

.registry-badge.local,
.registry-badge.local-only {
  color: #3b5a2c;
  border-color: #9ecb85;
  background: #eef7e8;
}

.registry-badge.registry-local {
  color: #14532d;
  border-color: #86efac;
  background: #dcfce7;
}

.registry-badge.registry-only {
  color: #713f12;
  border-color: #fde68a;
  background: #fefce8;
}

/* ── Publish-scene form ────────────────────────────────── */
.publish-scene-details { margin-top: 8px; border: 1px solid #d6deec; border-radius: 8px; background: #f8fbff; }
.publish-scene-details summary { padding: 8px 12px; font-size: 0.84rem; font-weight: 600; color: #33486b; cursor: pointer; list-style: none; user-select: none; }
.publish-scene-details summary::before { content: "▸ "; color: #7a96c4; font-size: 0.7rem; }
.publish-scene-details[open] summary::before { content: "▾ "; }
.publish-scene-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; padding: 8px 12px 12px; }
.publish-scene-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; color: #33486b; flex: 1 1 160px; }
.publish-scene-form input, .publish-scene-form select { border: 1px solid #c7d4ee; border-radius: 6px; padding: 6px 8px; font-size: 0.84rem; background: #ffffff; color: #1e2f4d; }
.upload-browse-btn { margin-top: 4px; display: inline-block; padding: 6px 16px; border: 1px solid #3b67c7; border-radius: 8px; background: #eef3ff; color: #1f3256; font-size: 0.84rem; font-weight: 600; cursor: pointer; }
.upload-browse-btn:hover { background: #dbe5f7; }
.upload-browse-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.upload-progress-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid #d6deec; }
.upload-progress-list:empty { display: none; }
.upload-progress-item { display: flex; align-items: center; gap: 8px; padding: 7px 14px; font-size: 0.82rem; border-bottom: 1px solid #edf2fb; }
.upload-progress-item:last-child { border-bottom: none; }
.upload-progress-item .up-name { flex: 1; color: #1f3256; font-family: monospace; font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-status.pending { color: #6b7fa8; } .up-status.uploading { color: #284d8f; } .up-status.ok { color: #0f5f3a; } .up-status.error { color: #8b1e2f; }

/* ── Filter tabs + browser toolbar ─────────────────────── */
.asset-browser-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; justify-content: space-between; }
.asset-filter-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.asset-filter-tab { padding: 5px 12px; border: 1px solid #c7d4ee; border-radius: 999px; background: #f0f4fc; color: #33486b; font-size: 0.78rem; font-weight: 500; cursor: pointer; }
.asset-filter-tab:hover { background: #dbe5f7; }
.asset-filter-tab.active, .asset-filter-tab[aria-selected="true"] { background: #1f3256; border-color: #1f3256; color: #ffffff; }
.asset-browser-actions { display: flex; align-items: flex-end; gap: 8px; }
.asset-browser-actions label { display: flex; flex-direction: column; gap: 3px; font-size: 0.78rem; color: #33486b; }
.asset-browser-actions select { border: 1px solid #c7d4ee; border-radius: 8px; padding: 6px 8px; font-size: 0.84rem; background: #f8fbff; color: #1e2f4d; }

/* ── Copy URL button ─────────────────────────────────────── */
.copy-url-btn { padding: 2px 8px; border: 1px solid #c7d4ee; border-radius: 6px; background: #f0f4fc; color: #33486b; font-size: 0.72rem; cursor: pointer; white-space: nowrap; }
.copy-url-btn:hover { background: #dbe5f7; }
.copy-url-btn.copied { background: #e9f8f0; color: #0f5f3a; border-color: #a5dec3; }
/* ── Sortable registry table ────────────────────────────── */

.asset-registry-table-wrap {
  overflow-x: auto;
  border: 1px solid #d6deec;
  border-radius: 10px;
  background: #ffffff;
}

/* Hosted catalog keeps table headers pinned while rows scroll. */
#hosted-catalog-panel .asset-registry-table-wrap {
  overflow: auto;
  max-height: 56vh;
}

#hosted-catalog-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #edf2fb;
}

.asset-registry-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  color: #1f3256;
  table-layout: auto;
}

.asset-registry-table thead tr {
  background: #edf2fb;
  border-bottom: 1px solid #c7d4ee;
}

.asset-registry-table th {
  padding: 7px 10px;
  text-align: left;
  font-size: 0.73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #4a6289;
  white-space: nowrap;
  user-select: none;
}

.asset-registry-table th.sortable {
  cursor: pointer;
}

.asset-registry-table th.sortable:hover {
  background: #dbe5f7;
  color: #1f3256;
}

.asset-registry-table th.active-sort {
  color: #1f3256;
  background: #dce6fa;
}

.sort-icon {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.45;
  font-style: normal;
  font-size: 0.8em;
  vertical-align: middle;
}

.sort-icon.asc,
.sort-icon.desc {
  opacity: 1;
  color: #3b67c7;
}

.asset-registry-table tbody tr {
  border-bottom: 1px solid #edf2fb;
  transition: background 0.1s;
}

.asset-registry-table tbody tr:last-child {
  border-bottom: none;
}

.asset-registry-table tbody tr:hover {
  background: #f5f8ff;
}

.asset-registry-table tbody tr.catalog-row-selected {
  background: #e9f2ff;
  outline: 2px solid #4e7bd4;
  outline-offset: -2px;
}

.asset-registry-table td {
  padding: 7px 10px;
  vertical-align: top;
  line-height: 1.35;
}

.asset-registry-table .col-path {
  min-width: 220px;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.75rem;
  word-break: break-all;
}

.asset-registry-table .col-url {
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.72rem;
  color: #33486b;
  word-break: break-all;
  max-width: 300px;
}

.asset-registry-table .col-version,
.asset-registry-table .col-channel,
.asset-registry-table .col-status,
.asset-registry-table .col-type {
  white-space: nowrap;
}

.hosted-cache-action-col {
  white-space: nowrap;
}

.hosted-cache-btn {
  padding: 3px 8px;
  font-size: 0.74rem;
}

.hosted-download-action-col {
  white-space: nowrap;
}

.hosted-download-btn {
  padding: 3px 8px;
  font-size: 0.74rem;
}

.registry-table-empty td {
  text-align: center;
  color: #6b7fa8;
  padding: 18px;
}

/* ── Sample dropdown ───────────────────────────────────── */
.sample-dropdown-wrap {
  position: relative;
  display: inline-flex;
}

.sample-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 200;
  min-width: 200px;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: #ffffff;
  border: 1px solid #c7d4ee;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(17, 29, 53, 0.15);
}

.sample-dropdown-menu li {
  padding: 0;
  border: none;
}

.sample-dropdown-menu [role="menuitem"] {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 0;
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 500;
  color: #1f3256;
  box-shadow: none;
  transform: none;
}

.sample-dropdown-menu [role="menuitem"]:hover {
  background: #eef3ff;
  color: #2f4f89;
  transform: none;
  box-shadow: none;
}

/* ── Breakpoint: 1200px (existing) ─────────────────────── */
@media (max-width: 1200px) {
  .stats-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .editor-panel textarea,
  .command-panel textarea {
    min-height: 240px;
  }

  .view-config-editor {
    min-height: 180px;
    max-height: 220px;
  }

  .model-panel-top {
    grid-template-columns: 1fr;
  }
}

/* ── Mobile breakpoint: 768px ──────────────────────────── */
@media (max-width: 768px) {
  body {
    overflow: auto;
    max-height: none;
    height: auto;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 16px 10px;
    gap: 10px;
  }

  .topbar-actions {
    flex-wrap: wrap;
    width: 100%;
  }

  .topbar-actions button,
  .topbar-actions .sample-dropdown-wrap {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }

  .topbar-actions button {
    text-align: center;
  }

  .stats-bar {
    padding: 0 16px 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout {
    padding: 0 16px 16px;
    grid-template-columns: 1fr;
    overflow: visible;
    flex: none;
  }

  .hosted-catalog-toolbar #hosted-catalog-refresh {
    margin-left: 0;
  }

  .viewer-canvas {
    width: 100%;
  }

  .viewer-canvas.fill-mode {
    min-height: 220px;
  }

  .viewer-view-row,
  .viewer-animation-row {
    grid-template-columns: 1fr;
  }

  .viewer-control-stack {
    gap: 5px;
  }

  .sample-dropdown-menu {
    left: 0;
    right: auto;
    min-width: 180px;
  }
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #405273;
  cursor: pointer;
  user-select: none;
  background: rgba(255, 255, 255, 0.4);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(203, 213, 225, 0.5);
  transition: all 0.2s;
}

.toggle-pill,
.viewer-actions .toggle-switch {
  border: 1px solid #c7d4ee;
  background: #eef3ff;
  color: #3c567f;
  font-size: 10px;
  gap: 5px;
  padding: 2px 6px;
  border-radius: 999px;
  line-height: 1.1;
}

.toggle-pill:hover,
.viewer-actions .toggle-switch:hover {
  background: #e1e9fc;
  border-color: #a3badf;
}

.viewer-actions>button {
  padding: 4px 8px;
}

.toggle-switch:hover {
  background: #ffffff;
  border-color: #cbd5e1;
}

.toggle-switch input[type="checkbox"] {
  width: 11px;
  height: 11px;
  accent-color: #3b82f6;
  cursor: pointer;
}

.model-toggle {
  margin: 4px 0;
}
/* ------------------------------------------------------------------ */
/* R-UI-2 / R-UI-4 / R-UI-6: Node Tree Inspector & Properties Panels  */
/* ------------------------------------------------------------------ */

.node-tree-panel,
.node-properties-panel {
  flex: 1;
  min-height: 0;
}

.node-tree-search-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

#node-tree-search {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid var(--btn-secondary-border, #cbd5e1);
  border-radius: 4px;
  background: #ffffff;
  color: #172033;
  font-size: 0.85rem;
}

#node-tree-search:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 1px;
}

.node-tree-container {
  flex: 1;
  min-height: 40px;
  overflow-y: auto;
}

.tree-empty-hint {
  color: #64748b;
  font-size: 0.8rem;
  margin: 4px 0;
}

.tree-node {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
}

.tree-node:hover {
  background: rgba(59, 130, 246, 0.06);
}

.tree-node.selected {
  background: rgba(59, 130, 246, 0.12);
  outline: 1px solid rgba(59, 130, 246, 0.3);
}

.tree-node:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 1px;
}

.tree-node-indent {
  display: inline-block;
  flex-shrink: 0;
}

.tree-node-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  color: #64748b;
  width: 16px;
}

.tree-node-icon svg {
  display: block;
}

.tree-node-type {
  font-size: 0.7rem;
  padding: 1px 5px;
  border-radius: 3px;
  background: #e2e8f0;
  color: #475569;
  flex-shrink: 0;
}

.tree-node-id {
  font-size: 0.85rem;
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Node Properties Panel */
.node-properties-container {
  padding: 4px 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.node-prop-empty {
  color: #64748b;
  font-size: 0.8rem;
  margin: 4px 0;
}

.node-prop-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 0.85rem;
  margin: 0;
}

.node-prop-label {
  color: #64748b;
  font-size: 0.8rem;
  white-space: nowrap;
}

.node-prop-value {
  font-family: monospace;
  word-break: break-all;
  margin: 0;
}

/* ------------------------------------------------------------------ */
/* Admin-mode node property form                                        */
/* ------------------------------------------------------------------ */
.node-prop-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
}
.node-prop-form-section {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #e2e8f0;
}
.node-prop-form-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.node-prop-field {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 4px;
  align-items: center;
}
.node-prop-field label {
  color: #64748b;
  font-size: 0.78rem;
  white-space: nowrap;
}
.node-prop-field input,
.node-prop-field select {
  width: 100%;
  padding: 3px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 0.82rem;
  background: #ffffff;
  color: #172033;
}
.node-prop-field input[readonly] {
  background: #f1f5f9;
  color: #64748b;
}
.node-prop-apply-btn {
  margin-top: 8px;
  padding: 5px 14px;
  background: #3b82f6;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.node-prop-apply-btn:hover {
  background: #2563eb;
}
.node-prop-apply-feedback {
  font-size: 0.78rem;
  color: #16a34a;
  margin-top: 4px;
}
/* Tree move buttons (admin mode) */
.tree-node-actions {
  margin-left: auto;
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.tree-move-btn {
  background: none;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 0.7rem;
  cursor: pointer;
  color: #64748b;
  line-height: 1;
}
.tree-move-btn:hover {
  background: #e2e8f0;
}
.tree-add-btn:hover {
  color: #16a34a;
  border-color: #16a34a;
}
.tree-del-btn:hover {
  color: #dc2626;
  border-color: #dc2626;
}
.tree-add-root-bar {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #e2e8f0;
}
.tree-add-root-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px dashed #cbd5e1;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.75rem;
  color: #64748b;
  cursor: pointer;
  width: 100%;
  justify-content: center;
}
.tree-add-root-btn:hover {
  border-color: #3b82f6;
  color: #3b82f6;
}

/* ------------------------------------------------------------------ */
/* Config Form View (replaces generic tree inspector)                   */
/* ------------------------------------------------------------------ */

/* Scrollable container shared by all config form panels. */
.cfg-form-container {
  overflow-y: auto;
  max-height: 360px;
  border: 1px solid #cfd7e6;
  border-radius: 6px;
  padding: 8px 10px;
  background: #f8faff;
  margin-bottom: 6px;
}

/* The form inside the container reuses node-prop-form styles.
   Override label column width to be a bit narrower in these compact panels. */
.cfg-form-container .node-prop-field {
  grid-template-columns: 120px 1fr;
}

/* Field note — the coupling a label cannot carry (e.g. that ambientIntensity
   only applies when every light is disabled). Spans both grid columns. */
.cfg-field-hint {
  display: block;
  grid-column: 1 / -1;
  margin: -2px 0 4px;
  color: #64748b;
  font-size: 0.7rem;
  line-height: 1.35;
}

/* View toggle button in panel head */
.cfg-view-toggle {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

