*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 13px;
  background: #1a1a1a;
  color: #d4d4d4;
}

/* ── App shell ──────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ── Left panel ─────────────────────────────────────────────────────────────── */
#left-panel {
  display: flex;
  flex-direction: column;
  width: 264px;
  min-width: 200px;
  flex-shrink: 0;
  background: #252526;
  border-right: 1px solid #3c3c3c;
  overflow: hidden;
}

/* ── Archive section ────────────────────────────────────────────────────────── */
#archive-section {
  display: flex;
  flex-direction: column;
  max-height: 44%;
  flex-shrink: 0;
  border-bottom: 1px solid #3c3c3c;
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  background: #2d2d2d;
  border-bottom: 1px solid #3c3c3c;
  flex-shrink: 0;
}

.section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #9d9d9d;
}

.icon-btn {
  background: none;
  border: none;
  color: #9d9d9d;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 13px;
  line-height: 1;
}
.icon-btn:hover { background: #3c3c3c; color: #d4d4d4; }

#archive-list {
  overflow-y: auto;
  flex: 1;
  padding: 3px 0;
}

.model-group { user-select: none; }

.group-header {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  cursor: pointer;
  color: #9d9d9d;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.group-header:hover { background: #2d2d2d; }

.group-arrow {
  display: inline-block;
  font-size: 9px;
  width: 10px;
  text-align: center;
  transition: transform .15s;
  flex-shrink: 0;
}
.group-header.open .group-arrow { transform: rotate(90deg); }

.group-files { display: none; }
.group-header.open + .group-files { display: block; }

/* Nested sub-group header (e.g. discipline inside Xeokit BIM examples) */
.group-header-sub {
  padding-left: 22px;
  font-size: 9px;
}

/* Indented model items inside nested sub-groups */
.model-item-sub {
  padding-left: 34px;
}

.model-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 22px;
  cursor: pointer;
  border-left: 2px solid transparent;
}
.model-item:hover { background: #2d2d2d; }
.model-item.active { background: #094771; border-left-color: #007acc; color: #fff; }

.model-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.fmt-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 2px;
  letter-spacing: .04em;
  flex-shrink: 0;
  opacity: .8;
}
.fmt-xkt  { background: #1e7340; color: #fff; }
.fmt-ifc  { background: #1565a8; color: #fff; }
.fmt-glb,
.fmt-gltf { background: #6b4fa8; color: #fff; }
.fmt-rvt     { background: #5a3a1a; color: #ccc; }
.fmt-project { background: #7a4a00; color: #ffd; }

.archive-empty {
  padding: 16px 12px;
  color: #666;
  font-size: 12px;
  text-align: center;
}

/* ── Explorer section ───────────────────────────────────────────────────────── */
#explorer-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#explorer-tabs {
  display: flex;
  border-bottom: 1px solid #3c3c3c;
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #9d9d9d;
  cursor: pointer;
  font-size: 11px;
  padding: 7px 2px;
  text-align: center;
  transition: color .1s, border-color .1s;
}
.tab-btn:hover { color: #d4d4d4; background: #2a2a2a; }
.tab-btn.active { color: #fff; border-bottom-color: #007acc; }

#explorer-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.tab-panel {
  display: none;
  flex-direction: column;
  height: 100%;
}
.tab-panel.active { display: flex; }

/* Tree toolbar (Show All / Hide All) */
.tree-toolbar {
  display: flex;
  gap: 4px;
  padding: 5px 8px;
  border-bottom: 1px solid #333;
  flex-shrink: 0;
}

.tree-tool-btn {
  flex: 1;
  background: #2d2d2d;
  border: 1px solid #444;
  border-radius: 3px;
  color: #aaa;
  cursor: pointer;
  font-size: 11px;
  padding: 3px 6px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.tree-tool-btn:hover { background: #3c3c3c; color: #fff; }
.tree-tool-btn.active { background: #1a73e8; border-color: #1a73e8; color: #fff; }
.tree-tool-btn.active:hover { background: #1c7cff; }

.tree-host {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  min-height: 0;
}

/* ── xeokit TreeViewPlugin styles ───────────────────────────────────────────── */
.tree-host ul {
  list-style: none;
  padding-left: 16px;
}
.tree-host ul:first-child { padding-left: 6px; }

/* Tree nodes — the plugin emits plain <li> elements */
.tree-host li {
  display: block;
  padding: 3px 6px;
  border-radius: 2px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  color: #d4d4d4;
  line-height: 22px;
}
.tree-host li:hover { background: #2d2d2d; }
.tree-host li.xrayed-node { opacity: 0.4; }

/* Expand / collapse toggle — <a class="plus"> / <a class="minus"> */
.tree-host a.plus,
.tree-host a.minus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  width: 16px;
  height: 16px;
  border: 1px solid #555;
  border-radius: 2px;
  background: #2a2a2a;
  color: #bbb;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background .1s, border-color .1s, color .1s;
}
.tree-host a.plus:hover,
.tree-host a.minus:hover {
  background: #3c3c3c;
  border-color: #888;
  color: #fff;
}
.tree-host a.plus:focus-visible,
.tree-host a.minus:focus-visible {
  outline: 2px solid #007acc;
  outline-offset: 1px;
}

/* Checkbox */
.tree-host input[type="checkbox"] {
  cursor: pointer;
  accent-color: #007acc;
  vertical-align: middle;
  width: 13px;
  height: 13px;
  margin: 0 0 0 6px;
}

/* Label text */
.tree-host li > span {
  vertical-align: middle;
  margin-left: 6px;
}

/* Properties tab */
.props-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 10px;
  color: #555;
  text-align: center;
  line-height: 1.6;
  font-size: 12px;
  padding: 20px;
}

.prop-group-title {
  padding: 5px 10px 3px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #777;
  border-bottom: 1px solid #333;
  margin-top: 2px;
}

.prop-row {
  display: flex;
  padding: 3px 10px;
  font-size: 12px;
  border-bottom: 1px solid #2a2a2a;
}
.prop-key {
  color: #9d9d9d;
  width: 42%;
  flex-shrink: 0;
  padding-right: 6px;
  word-break: break-word;
}
.prop-val { flex: 1; word-break: break-word; }

/* ── Canvas area ────────────────────────────────────────────────────────────── */
#canvas-area {
  flex: 1;
  position: relative;
  background: #000;
  overflow: hidden;
}

#viewer-canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

#navcube-canvas {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 200px;
  height: 200px;
  pointer-events: none;
}

/* ── Camera pivot marker (shown by xeokit during orbit) ─────────────────────── */
#camera-pivot-marker {
  display: none;
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 80, 80, 0.8);
  background: rgba(255, 80, 80, 0.15);
  box-shadow: 0 0 8px 2px rgba(0,0,0,0.6);
  pointer-events: none;
  z-index: 10000;
  transform: translate(-50%, -50%);
}

/* ── Canvas cursor per tool ──────────────────────────────────────────────────── */
#canvas-area.cursor-crosshair #viewer-canvas { cursor: crosshair; }
#canvas-area.cursor-cell       #viewer-canvas { cursor: cell; }
#canvas-area.cursor-none-drop  #viewer-canvas { cursor: no-drop; }

/* ── Toolbar ────────────────────────────────────────────────────────────────── */
#toolbar {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  z-index: 10;
  background: rgba(28,28,28,.92);
  border: 1px solid #444;
  border-radius: 7px;
  padding: 6px;
  backdrop-filter: blur(6px);
}

.tb-btn {
  position: relative;
  width: 32px;
  height: 32px;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #bbb;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .1s, border-color .1s, color .1s;
  flex-shrink: 0;
}
.tb-btn:hover { background: #3c3c3c; border-color: #555; color: #fff; }
.tb-btn.active { background: #007acc; border-color: #007acc; color: #fff; }
.tb-btn.active:hover { background: #006ab8; }

.tb-sep { height: 1px; background: #3c3c3c; margin: 2px 0; }

.tb-group { display: flex; gap: 1px; align-items: center; }

.tb-dd-arrow {
  width: 16px !important;
  min-width: 0 !important;
  padding: 0;
  font-size: 9px;
  border-radius: 3px;
}

/* ── Split dropdown button — icon on top, left-caret strip at bottom ─────── */
.tb-split {
  display: flex;
  flex-direction: column;
  width: 32px;
  border: 1px solid transparent;
  border-radius: 4px;
  transition: border-color .1s;
}
.tb-split:hover { border-color: #555; }

.tb-split-main {
  position: relative;           /* anchor for .section-badge */
  width: 32px;
  height: 26px;
  background: none;
  border: none;
  border-radius: 4px 4px 0 0;
  color: #bbb;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .1s, color .1s;
  flex-shrink: 0;
}
.tb-split-main:hover { background: #3c3c3c; color: #fff; }
.tb-split-main.active { background: #007acc; color: #fff; }
.tb-split-main.active:hover { background: #006ab8; }

.tb-split-arr {
  width: 32px;
  height: 10px;
  background: rgba(255,255,255,0.03);
  border: none;
  border-top: 1px solid #2c2c2c;
  border-radius: 0 0 4px 4px;
  color: #555;
  cursor: pointer;
  font-size: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .1s, color .1s;
  flex-shrink: 0;
}
.tb-split-arr:hover { background: #363636; color: #bbb; }

/* ── Marquee mode panel ──────────────────────────────────────────────────────── */
.marquee-mode-panel {
  position: fixed;
  z-index: 50000;
  background: rgba(28,28,28,.97);
  border: 1px solid #444;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,.6);
  font-size: 12px;
  user-select: none;
  backdrop-filter: blur(6px);
  min-width: 170px;
}
.mm-title {
  padding: 7px 12px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #666;
  border-bottom: 1px solid #333;
}
.mm-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  cursor: pointer;
  color: #ccc;
  transition: background .1s, color .1s;
}
.mm-row:last-child { border-radius: 0 0 6px 6px; }
.mm-row:hover { background: #3a3a3a; color: #fff; }
.mm-row.active { color: #4af; }
.mm-row .mm-icon { width: 14px; text-align: center; flex-shrink: 0; font-size: 11px; }
.mm-row .mm-label { font-weight: 500; }
.mm-row .mm-sub { font-size: 10px; color: #666; margin-left: auto; padding-left: 8px; }
.mm-row.active .mm-sub { color: #39f; }

/* ── Section dropdown panel ──────────────────────────────────────────────────── */
.sec-dropdown {
  position: fixed;
  z-index: 50000;
  background: rgba(28,28,28,.97);
  border: 1px solid #444;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,.6);
  width: 236px;
  font-size: 12px;
  user-select: none;
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}

.sec-dd-title {
  padding: 7px 12px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #666;
  border-bottom: 1px solid #333;
  flex-shrink: 0;
}

.sec-dd-subtitle {
  padding: 6px 12px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #555;
  flex-shrink: 0;
}

/* 2×2 global action grid */
.sec-dd-globals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid #333;
  flex-shrink: 0;
}

.sec-dd-glob-btn {
  background: #2d2d2d;
  border: 1px solid #444;
  border-radius: 3px;
  color: #bbb;
  cursor: pointer;
  font-size: 11px;
  padding: 5px 4px;
  text-align: center;
  transition: background .1s, color .1s;
}
.sec-dd-glob-btn:hover { background: #3c3c3c; color: #fff; }
.sec-dd-glob-btn.sec-dd-danger { color: #e06c75; }
.sec-dd-glob-btn.sec-dd-danger:hover { background: #6b1a22; color: #ff8080; }

/* Per-plane list */
.sec-dd-plane-list {
  overflow-y: auto;
  flex-shrink: 1;
  min-height: 0;
  max-height: 220px;
}

.sec-dd-empty {
  padding: 12px;
  color: #555;
  text-align: center;
  font-size: 11px;
  font-style: italic;
}

.sec-plane-row {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 4px 6px;
  border-bottom: 1px solid #252525;
  transition: background .1s;
}
.sec-plane-row:hover { background: #252525; }
.sec-plane-inactive { opacity: .4; }

.sec-plane-name {
  flex: 1;
  font-size: 11px;
  color: #ccc;
  padding: 0 4px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sec-plane-btn {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  padding: 4px 5px;
  border-radius: 3px;
  font-size: 11px;
  line-height: 1;
  flex-shrink: 0;
  transition: background .1s, color .1s;
}
.sec-plane-btn:hover { background: #3c3c3c; color: #ccc; }
.sec-plane-btn-active { background: #094771 !important; color: #4db8ff !important; }
.sec-plane-btn-danger:hover { background: #6b1a22 !important; color: #e05252 !important; }

.sec-dd-sep { height: 1px; background: #333; flex-shrink: 0; }

/* Add-slice mode buttons */
.sec-dd-modes {
  display: flex;
  gap: 4px;
  padding: 8px;
  flex-shrink: 0;
}

.sec-dd-mode {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 4px;
  background: #2d2d2d;
  border: 1px solid #444;
  border-radius: 3px;
  cursor: pointer;
  color: #bbb;
  font-size: 11px;
  transition: background .1s, border-color .1s, color .1s;
}
.sec-dd-mode:hover { background: #3c3c3c; color: #fff; }
.sec-dd-mode.sec-dd-active { border-color: #007acc; background: #094771; color: #4db8ff; }

.sec-axis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}
.sec-axis-x { background: #8b1a1a; color: #ff8080; }
.sec-axis-y { background: #1a6b1a; color: #80ff80; }
.sec-axis-z { background: #1a1a8b; color: #8080ff; }

/* Small overlay icon (clear-meas / clear-section) */
.tb-sub-icon {
  position: absolute;
  right: 4px;
  bottom: 4px;
  font-size: 7px;
  line-height: 1;
}

/* Section badge counter */
.section-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e74c3c;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  padding: 0 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.section-badge.hidden { display: none; }

/* Active tool label */
#tool-label {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.7);
  color: #ccc;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 12px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
}
#tool-label.hidden { display: none; }

/* Suppress xeokit's built-in spinner — we use #loading-overlay instead */
.sk-fading-circle { display: none !important; }

/* ── Overlays ────────────────────────────────────────────────────────────────── */
#loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 20;
  color: #ccc;
  font-size: 13px;
}
#loading-overlay.hidden { display: none; }

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #444;
  border-top-color: #007acc;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#loading-bar-track {
  width: 200px;
  height: 4px;
  background: rgba(255,255,255,.15);
  border-radius: 2px;
  overflow: hidden;
}
#loading-bar-track.hidden { display: none; }
#loading-bar {
  height: 100%;
  width: 0%;
  background: #007acc;
  border-radius: 2px;
  transition: width .25s ease;
}
#loading-bar-track.indeterminate #loading-bar {
  width: 35%;
  animation: bar-slide 1.3s ease-in-out infinite;
}
@keyframes bar-slide {
  0%   { transform: translateX(-200%); }
  100% { transform: translateX(450%); }
}

#cancel-load-btn {
  margin-top: 14px;
  padding: 6px 20px;
  background: transparent;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 4px;
  color: rgba(255,255,255,.8);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
#cancel-load-btn:hover {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.6);
}

#hint-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 5;
}
#hint-overlay.hidden { display: none; }

.hint-box {
  text-align: center;
  color: #444;
  font-size: 14px;
  line-height: 2.2;
}

/* ── Context menu ───────────────────────────────────────────────────────────── */
.bv-ctx-menu {
  position: fixed;
  z-index: 50000;
  background: #1e1e1e;
  border: 1px solid #444;
  border-radius: 5px;
  box-shadow: 0 4px 20px rgba(0,0,0,.6);
  padding: 4px 0;
  min-width: 170px;
  font-size: 12px;
  user-select: none;
}

.ctx-item {
  padding: 6px 16px;
  cursor: pointer;
  color: #d4d4d4;
  white-space: nowrap;
}
.ctx-item:hover { background: #094771; color: #fff; }
.ctx-item.ctx-disabled { color: #555; cursor: default; }
.ctx-item.ctx-disabled:hover { background: none; }

.ctx-sep {
  height: 1px;
  background: #3c3c3c;
  margin: 3px 0;
}

/* ── Background picker ───────────────────────────────────────────────────────── */
.bg-menu {
  position: fixed;
  background: rgba(28,28,28,.97);
  border: 1px solid #444;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,.6);
  padding: 10px;
  z-index: 50000;
  backdrop-filter: blur(6px);
  white-space: nowrap;
}
.bg-menu-label {
  font-size: 10px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
  text-align: center;
}
.bg-swatches {
  display: flex;
  gap: 6px;
}
.bg-swatch {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
  flex-shrink: 0;
}
.bg-swatch:hover  { border-color: #aaa; transform: scale(1.1); }
.bg-swatch.active { border-color: #007acc; }

/* ── Scrollbars ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ── Mobile / responsive ────────────────────────────────────────────────────── */

/* Hamburger toggle — hidden on desktop */
#menu-toggle {
  display: none;
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 20;
  width: 44px;
  height: 44px;
  background: rgba(28,28,28,.92);
  border: 1px solid #444;
  border-radius: 7px;
  color: #bbb;
  cursor: pointer;
  font-size: 16px;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  flex-shrink: 0;
}
#menu-toggle:hover { background: #3c3c3c; color: #fff; }

/* Panel backdrop overlay */
#panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
  touch-action: none;
}
#panel-overlay.visible { display: block; }

@media (max-width: 768px) {
  /* Show hamburger */
  #menu-toggle { display: flex; }

  /* Left panel: off-canvas drawer */
  #left-panel {
    position: fixed;
    top: 0;
    left: -280px;
    height: 100%;
    width: 280px;
    z-index: 100;
    transition: left .25s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,.6);
  }
  #left-panel.panel-open { left: 0; }

  /* Canvas fills full viewport */
  #canvas-area { flex: 1; }

  /* Toolbar: scrollable, stays right side */
  #toolbar {
    max-height: calc(100vh - 30px);
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* Touch-friendly toolbar buttons */
  .tb-btn { width: 44px; height: 44px; font-size: 15px; }
  .tb-dd-arrow { width: 22px !important; height: 44px; }
  .tb-split { width: 44px; }
  .tb-split-main { width: 44px; height: 36px; font-size: 15px; }
  .tb-split-arr { width: 44px; height: 13px; font-size: 8px; }

  /* Hide navcube (200×200 is too large for mobile) */
  #navcube-canvas { display: none; }

  /* Larger touch targets */
  .model-item { padding: 8px 10px 8px 22px; min-height: 36px; }
  .tab-btn { padding: 10px 2px; font-size: 12px; }
  .tree-host li { font-size: 13px; line-height: 28px; }
  .tree-host a.plus,
  .tree-host a.minus { width: 20px; height: 20px; font-size: 14px; }
  .tree-tool-btn { padding: 8px 6px; font-size: 12px; }
  .icon-btn { padding: 6px 10px; font-size: 15px; }
  .ctx-item { padding: 10px 16px; }

  /* Section dropdown: respect viewport width */
  .sec-dropdown { width: min(236px, calc(100vw - 80px)); }
}

@media (max-width: 480px) {
  #left-panel { width: min(280px, 90vw); left: -90vw; }
  #left-panel.panel-open { left: 0; }
  .tb-btn { width: 40px; height: 40px; }
  #toolbar { gap: 2px; padding: 4px; }
}

/* ── Branding footer ─────────────────────────────────────────────────────────── */
#branding-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-top: 1px solid #3c3c3c;
  background: #1e1e1e;
  flex-shrink: 0;
  gap: 6px;
}

.brand-logo {
  flex: 1;
  min-width: 0;
  max-height: 32px;
  width: auto;
  object-fit: contain;
  object-position: left center;
  opacity: 0.65;
  filter: invert(1);
  transition: opacity .15s;
}
#branding-footer:hover .brand-logo { opacity: 0.9; }

#about-btn {
  flex-shrink: 0;
  font-size: 15px;
  color: #666;
  padding: 3px 5px;
}
#about-btn:hover { color: #007acc; background: #2a2a2a; }

/* ── About modal ─────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200000;
  backdrop-filter: blur(3px);
}
.modal-backdrop.hidden { display: none; }

.modal-box {
  background: #252526;
  border: 1px solid #3c3c3c;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,.7);
  width: min(400px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #3c3c3c;
  flex-shrink: 0;
}

.modal-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #9d9d9d;
}

.modal-body {
  padding: 24px 24px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.about-logo-wrap {
  background: #f2f2f2;
  border-radius: 8px;
  padding: 16px 20px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.about-logo {
  max-height: 52px;
  width: 100%;
  max-width: 320px;
  object-fit: contain;
}

.about-app-name {
  font-size: 17px;
  font-weight: 700;
  color: #e8e8e8;
  text-align: center;
  margin: 0;
}

.about-desc {
  font-size: 12px;
  color: #888;
  text-align: center;
  line-height: 1.7;
  max-width: 320px;
}

.about-credits {
  width: 100%;
  border: 1px solid #3c3c3c;
  border-radius: 6px;
  overflow: hidden;
}

.about-credit-row {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 9px 14px;
  border-bottom: 1px solid #333;
  font-size: 12px;
}
.about-credit-row:last-child { border-bottom: none; }

.about-credit-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #666;
  flex-shrink: 0;
  width: 70px;
}

.about-credit-row a {
  color: #4ea8d8;
  text-decoration: none;
  line-height: 1.4;
}
.about-credit-row a:hover { color: #7dc7f0; text-decoration: underline; }
