:root {
  --bg: #f0f2f8;
  --card: #fff;
  --panel: #fff;
  --text: #1a1d2e;
  --muted: #8b90a8;
  --light: #b5b9cc;
  --accent: #7c6ef7;
  --accent-soft: #ede9fe;
  --border: #e8eaf2;
  --viewport: #e8eaf2;
  --shadow: 0 4px 20px rgba(0,0,0,.08);
  --radius: 16px;
  --transition: .18s cubic-bezier(.4,0,.2,1);
}

:root.theme-dark {
  --bg: #11131a;
  --card: #1a1d27;
  --panel: #171a23;
  --text: #f4f6fb;
  --muted: #a9afc1;
  --light: #737b90;
  --accent: #a79cff;
  --accent-soft: rgba(124,110,247,.18);
  --border: #2b3040;
  --viewport: #10121a;
  --shadow: 0 6px 24px rgba(0,0,0,.34);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  font-size: 13px;
}
button, input, select { font: inherit; }
button { color: inherit; }
button, select, input[type="range"], input[type="color"] { cursor: pointer; }
svg:not(.logo-svg) { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.topbar {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  position: relative;
  z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand { color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 16px; }
.brand .logo-svg {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}
.logo-svg-animated {
  overflow: visible;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.logo-svg-animated:hover,
.brand:hover .logo-svg-animated {
  transform: scale(1.20) rotate(9deg);
}
@keyframes logo-palette-breathe {
  0%,100% { transform: rotate(-1.5deg) scale(1); }
  50% { transform: rotate(1.8deg) scale(1.025); }
}
.logo-palette-group {
  transform-box: fill-box;
  transform-origin: center;
  animation: logo-palette-breathe 5.5s ease-in-out infinite;
}
@keyframes logo-float-1 {
  0%,100% { transform: translate(0px, 0px); }
  25% { transform: translate(0.7px,-1.3px); }
  50% { transform: translate(-0.5px, 0.7px); }
  75% { transform: translate(0.9px, -0.5px); }
}
@keyframes logo-float-2 {
  0%,100% { transform: translate(0px, 0px); }
  30% { transform: translate(-1.1px, 0.6px); }
  60% { transform: translate(0.7px, 1.2px); }
  80% { transform: translate(-0.5px,-0.7px); }
}
@keyframes logo-float-3 {
  0%,100% { transform: translate(0px, 0px); }
  20% { transform: translate(0.9px, 0.6px); }
  55% { transform: translate(-0.7px,-1.3px); }
  75% { transform: translate(0.3px, 0.8px); }
}
@keyframes logo-float-4 {
  0%,100% { transform: translate(0px, 0px); }
  35% { transform: translate(-0.8px, 1.1px); }
  65% { transform: translate(1.1px, -0.7px); }
  90% { transform: translate(0.4px, 0.5px); }
}
@keyframes logo-dot-pulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.28); }
}
@keyframes logo-shim-pulse {
  0%,55%,100% { opacity: 0; }
  28% { opacity: 0.8; }
}
.logo-float { transform-box: fill-box; transform-origin: center; }
.logo-float-1 { animation: logo-float-1 4.1s ease-in-out infinite; }
.logo-float-2 { animation: logo-float-2 5.2s ease-in-out infinite 0.9s; }
.logo-float-3 { animation: logo-float-3 3.8s ease-in-out infinite 1.6s; }
.logo-float-4 { animation: logo-float-4 4.7s ease-in-out infinite 2.3s; }
.logo-pulse { transform-box: fill-box; transform-origin: center; }
.logo-pulse-1 { animation: logo-dot-pulse 3.5s ease-in-out infinite 0.3s; }
.logo-pulse-2 { animation: logo-dot-pulse 4.8s ease-in-out infinite 1.4s; }
.logo-pulse-3 { animation: logo-dot-pulse 5.3s ease-in-out infinite 0.7s; }
.logo-pulse-4 { animation: logo-dot-pulse 4.1s ease-in-out infinite 2.1s; }
.logo-shim {
  animation: logo-shim-pulse 11s ease-in-out infinite 5s;
  pointer-events: none;
}
.brand:hover .logo-float-1 { animation-duration: 1.0s; }
.brand:hover .logo-float-2 { animation-duration: 1.3s; }
.brand:hover .logo-float-3 { animation-duration: 0.9s; }
.brand:hover .logo-float-4 { animation-duration: 1.2s; }
.brand:hover .logo-pulse-1 { animation-duration: 0.7s; }
.brand:hover .logo-pulse-2 { animation-duration: 0.9s; }
.brand:hover .logo-pulse-3 { animation-duration: 0.8s; }
.brand:hover .logo-pulse-4 { animation-duration: 0.75s; }
.product-name {
  color: var(--text);
  font-weight: 800;
  letter-spacing: -.5px;
  padding-right: 10px;
  border-right: 1px solid var(--border);
  background: linear-gradient(135deg, var(--text) 30%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.beta-pill { font-size: 9px; letter-spacing: .09em; color: var(--accent); background: var(--accent-soft); padding: 4px 7px; border-radius: 99px; }
.btn-back-link {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px;
  border-radius: 99px; border: 1.5px solid var(--border); background: var(--card);
  color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,.06); text-decoration: none;
  transition: border-color var(--transition), color var(--transition), transform var(--transition);
}
.btn-back-link:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.btn-back-link svg { width: 14px; height: 14px; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.save-state { font-size: 11px; color: var(--muted); margin-right: 4px; }
.icon-btn, .tool-btn {
  display: grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--border); border-radius: 9px; background: var(--card);
}
.primary-btn, .secondary-btn, .remix-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; border-radius: 9px; padding: 0 14px; font-weight: 700; border: 1px solid transparent;
}
.primary-btn svg,
.secondary-btn svg {
  width: 15px;
  height: 15px;
}
.primary-btn { color: #fff; background: var(--accent); }
.secondary-btn { background: var(--card); border-color: var(--border); }
.utility-menu { position: relative; }
.utility-menu-btn {
  width: 36px; height: 36px; display: grid; place-items: center; padding: 0;
  border: 1px solid var(--border); border-radius: 9px; background: var(--card); color: var(--text);
}
.utility-menu-btn svg { width: 18px; }
.utility-menu-popover {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 40;
  width: 220px; padding: 8px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--card); box-shadow: var(--shadow);
}
.utility-menu-popover.hidden { display: none; }
.utility-menu-popover a,
.utility-menu-popover button {
  width: 100%; min-height: 34px; display: flex; align-items: center; justify-content: flex-start;
  padding: 8px 10px; border: 0; border-radius: 8px; background: transparent;
  color: var(--text); text-decoration: none; text-align: left; font-weight: 600; font-size: 12px;
}
.utility-menu-popover a:hover,
.utility-menu-popover button:hover { background: var(--bg); transform: none; border-color: transparent; }
.utility-menu-warning {
  margin: 7px 8px 5px;
  color: #b91c1c;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.35;
}
.utility-menu-popover button.utility-menu-danger { color: #b91c1c; font-weight: 800; }
.utility-menu-popover button.utility-menu-danger:hover { background: #fee2e2; color: #991b1b; }
.utility-menu-popover hr { margin: 6px 0; border: 0; border-top: 1px solid var(--border); }
.utility-menu-toggle { justify-content: space-between !important; }
.utility-menu-toggle::after {
  content: ""; width: 28px; height: 16px; border-radius: 99px; margin-left: auto;
  background: var(--border); box-shadow: inset 0 0 0 1px rgba(0,0,0,.04);
}
.utility-menu-toggle[aria-pressed="true"]::after { background: var(--accent); }
button { transition: transform var(--transition), border-color var(--transition), background var(--transition), color var(--transition), opacity var(--transition); }
button:not(.disabled):hover { transform: translateY(-1px); border-color: var(--accent); }
button:active { transform: translateY(0); }

.loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  z-index: 99999;
  background: linear-gradient(90deg, #FF6B6B, #7C6EF7, #4ECDC4, #FFE66D, #FF6B6B);
  background-size: 200% 100%;
  animation: loadingGlow 1.2s linear infinite;
  transition: opacity 0.4s ease, transform 0.4s ease;
  transform-origin: left;
}
.loading-bar.hidden {
  opacity: 0;
  transform: scaleX(0);
  pointer-events: none;
}
@keyframes loadingGlow {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

.lab-creator-showcase {
  height: 88px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px; padding: 10px 14px 8px;
}
.lab-creator-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  min-width: 0; padding: 9px 16px; color: #fff; text-decoration: none; border-radius: 12px;
  box-shadow: 0 8px 22px rgba(42,35,88,.16); overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.lab-creator-card:hover { color: #fff; transform: translateY(-2px); box-shadow: 0 11px 25px rgba(42,35,88,.23); }
.lab-creator-card-skdsam { background: linear-gradient(135deg, #6658e8, #8f6df4); }
.lab-creator-card-mrsteve { background: linear-gradient(135deg, #176b87, #22a699); }
.lab-creator-mark {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.22);
  font-size: 14px; font-weight: 900;
}
.lab-creator-copy { display: flex; flex-direction: column; min-width: 0; }
.lab-creator-copy small {
  color: rgba(255,255,255,.72); font-size: 9px; font-weight: 800;
  letter-spacing: .07em; text-transform: uppercase;
}
.lab-creator-copy strong { font-size: 15px; line-height: 1.3; }
.lab-creator-cta { color: rgba(255,255,255,.9); font-size: 11px; font-weight: 700; white-space: nowrap; }

.lab-shell {
  height: calc(100vh - 150px);
  display: grid;
  grid-template-columns: 260px minmax(420px, 1fr) 280px;
  gap: 14px;
  padding: 14px;
}
.panel, .viewport-card {
  min-height: 0; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel); box-shadow: 0 1px 2px rgba(0,0,0,.02); overflow: hidden;
}
.panel { overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.panel-heading, .inspector-head { padding: 18px 18px 15px; display: flex; align-items: center; justify-content: space-between; }
.eyebrow { display: block; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .14em; margin-bottom: 5px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 18px; letter-spacing: -.03em; }
h2 { font-size: 13px; }
h3 { font-size: 12px; }
.status-dot { display: flex; align-items: center; gap: 6px; color: #38a169; font-size: 10px; font-weight: 700; }
.status-dot i { width: 7px; height: 7px; border-radius: 50%; background: #48bb78; box-shadow: 0 0 0 4px rgba(72,187,120,.12); }
.control-section { padding: 16px 18px; border-top: 1px solid var(--border); }
.control-section.compact { padding-bottom: 18px; }
.section-title-row { display: flex; justify-content: space-between; align-items: center; }
.text-btn { color: var(--accent); background: none; border: 0; padding: 2px; font-size: 10px; font-weight: 700; }
.section-copy { margin-top: 6px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.palette-strip { display: grid; grid-template-columns: repeat(var(--palette-count, 5), minmax(0, 1fr)); gap: 7px; margin-top: 12px; }
.swatch {
  position: relative; height: 55px; border: 3px solid transparent; border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
  cursor: grab;
}
.swatch:active { cursor: grabbing; }
.swatch.dragging { opacity: .45; transform: scale(.94); }
.swatch.active { border-color: var(--card); outline: 2px solid var(--accent); transform: translateY(-2px); }
.swatch span { position: absolute; bottom: -17px; left: 50%; transform: translateX(-50%); color: var(--muted); font-size: 8px; font-family: monospace; }
.palette-strip { margin-bottom: 17px; }
.palette-strip.compact { gap: 4px; }
.palette-strip.compact .swatch span { display: none; }
.palette-inputs { display: grid; gap: 6px; margin: 8px 0 0; }
.apply-colour-btn {
  width: 100%; min-height: 38px; display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 10px; padding: 8px 10px; border: 1px solid var(--accent); border-radius: 9px;
  color: var(--accent); background: var(--accent-soft); font-size: 10px; font-weight: 800;
}
.apply-colour-btn:hover { color: #fff; background: var(--accent); }
.apply-colour-dot { width: 12px; height: 12px; flex: 0 0 auto; border-radius: 4px; background: var(--accent); border: 1px solid rgba(0,0,0,.12); }
.apply-colour-btn:hover .apply-colour-dot { border-color: rgba(255,255,255,.55); }
.palette-input-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 28px; gap: 7px; }
.palette-input-row input[type="color"] { width: 28px; height: 28px; padding: 0; border: 0; background: none; }
.palette-drag-chip {
  width: 28px; height: 28px; display: block; border-radius: 3px; cursor: grab;
  border: 1px solid rgba(0,0,0,.12); box-shadow: inset 0 0 0 1px rgba(255,255,255,.15);
}
.palette-drag-chip:active { cursor: grabbing; }
.palette-input-row input[type="text"], .text-input {
  width: 100%; border: 1px solid var(--border); border-radius: 8px; color: var(--text); background: var(--card); padding: 7px 9px;
}
.palette-remove-btn {
  width: 28px; height: 28px; border: 1px solid var(--border); background: var(--card);
  color: var(--muted); border-radius: 7px; font-size: 18px; line-height: 1;
}
.palette-remove-btn:hover:not(:disabled) { color: #e85d75; border-color: #e85d75; }
.palette-remove-btn:disabled { opacity: .35; cursor: not-allowed; }
.palette-manage { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; color: var(--muted); font-size: 9px; }
.palette-add-btn { border: 1px solid var(--border); background: var(--card); color: var(--accent); border-radius: 7px; padding: 6px 8px; font-size: 9px; font-weight: 700; }
.palette-add-btn:disabled { opacity: .4; cursor: not-allowed; }
.send-palette-btn {
  width: 100%; min-height: 34px; margin-top: 7px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); border-radius: 9px; font-size: 10px; font-weight: 700;
}
.send-palette-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.hidden { display: none !important; }
.field-label { display: block; color: var(--muted); font-size: 9px; font-weight: 700; margin: 12px 0 6px; text-transform: uppercase; letter-spacing: .05em; }
select {
  width: 100%; height: 34px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--text); padding: 0 9px; outline: none;
}
select:focus, input:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.remix-btn { width: 100%; height: 38px; margin-top: 9px; color: #fff; background: linear-gradient(135deg, #7c6ef7, #9f70f4); box-shadow: 0 7px 18px rgba(124,110,247,.2); }
.hint { text-align: center; color: var(--muted); margin-top: 10px; font-size: 9px; }
kbd { border: 1px solid var(--border); background: var(--bg); padding: 1px 4px; border-radius: 4px; font-size: 8px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--bg); border-radius: 8px; padding: 3px; margin-top: 10px; }
#lighting-mode { grid-template-columns: repeat(2, 1fr); }
.segmented button { border: 0; border-radius: 6px; background: transparent; padding: 7px 4px; color: var(--muted); font-size: 10px; font-weight: 600; }
.segmented button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.lighting-note { margin-top: 8px; color: var(--muted); font-size: 8px; line-height: 1.45; }
.range-row input:disabled { cursor: not-allowed; opacity: .42; }
.range-row { margin-top: 14px; }
.range-row label { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; }
.range-row output { color: var(--text); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; height: 3px; margin-top: 9px; accent-color: var(--accent); }
.view-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 10px; }
.view-option { padding: 7px 3px; background: var(--card); border: 1px solid var(--border); border-radius: 7px; color: var(--muted); font-size: 9px; }
.view-option.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.viewport-card { display: grid; grid-template-rows: 48px minmax(0, 1fr) 54px; background: var(--card); }
.viewport-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 0 12px; border-bottom: 1px solid var(--border); }
.scene-tabs, .viewport-actions { display: flex; gap: 5px; }
.scene-tabs button { border: 0; background: none; padding: 7px 9px; color: var(--muted); font-size: 10px; border-radius: 7px; }
.scene-tabs button.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.scene-tabs button:not(.active):hover { background: var(--bg); color: var(--text); }
.scene-tabs button span { font-size: 7px; text-transform: uppercase; margin-left: 4px; }
.disabled { opacity: .45; cursor: not-allowed; }
.tool-btn { width: 30px; height: 30px; }
.tool-btn.active { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.tool-btn svg { width: 15px; }
.viewport { position: relative; min-height: 0; overflow: hidden; background: var(--viewport); }
.viewport::after {
  content: "Drop colour onto an object";
  position: absolute; inset: 9px; z-index: 4; display: grid; place-items: center;
  border: 2px dashed rgba(255,255,255,.8); border-radius: 12px;
  color: white; background: rgba(65,52,145,.18); backdrop-filter: blur(1px);
  font-size: 11px; font-weight: 700; letter-spacing: .01em;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.viewport.colour-drag-active::after { opacity: 1; }
.viewport.colour-drag-over::after { background: rgba(124,110,247,.3); border-color: white; }
#scene-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.loading-screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--viewport); z-index: 5; transition: opacity .35s;
}
.loading-screen.loaded { opacity: 0; pointer-events: none; }
.loading-screen strong { font-size: 13px; margin-top: 12px; }
.loading-screen span { color: var(--muted); font-size: 10px; margin-top: 5px; }
.loading-mark { width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.viewport-badge { position: absolute; top: 12px; left: 12px; color: rgba(255,255,255,.85); background: rgba(13,16,25,.46); backdrop-filter: blur(8px); padding: 5px 7px; border-radius: 6px; font-size: 8px; font-weight: 700; letter-spacing: .08em; pointer-events: none; }
.selection-toast {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(13,16,25,.72); color: white; border: 1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(10px); padding: 7px 12px; border-radius: 99px; font-size: 9px; pointer-events: none; opacity: .9;
}
.camera-help { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; gap: 12px; color: rgba(255,255,255,.78); background: rgba(13,16,25,.45); padding: 6px 10px; border-radius: 7px; font-size: 8px; pointer-events: none; white-space: nowrap; }
.camera-help b { color: white; }
.scene-summary { display: flex; justify-content: space-between; align-items: center; padding: 0 14px; border-top: 1px solid var(--border); }
.summary-copy { display: flex; align-items: center; gap: 10px; }
.summary-copy .summary-icon { display: grid; place-items: center; width: 30px; height: 30px; flex: 0 0 30px; background: var(--accent-soft); color: var(--accent); border-radius: 8px; }
.summary-icon svg { display: block; width: 15px; }
.summary-copy strong, .summary-copy span { display: block; }
.summary-copy strong { font-size: 11px; }
.summary-copy div span { color: var(--muted); font-size: 8px; margin-top: 3px; }
.legend { display: flex; gap: 10px; color: var(--muted); font-size: 8px; }
.legend span { display: flex; gap: 4px; align-items: center; }
.legend-dot { width: 6px; height: 6px; border-radius: 50%; background: #49b87a; }
.legend-dot.locked { background: #f2ae49; }

.inspector-head { padding-bottom: 10px; }
.inspector-head h2 { font-size: 16px; letter-spacing: -.02em; }
.lock-btn { border: 1px solid var(--border); background: var(--card); border-radius: 8px; height: 30px; padding: 0 8px; display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 9px; }
.lock-btn[aria-pressed="true"] { color: #ca7d16; border-color: #f0c77f; background: #fff8e8; }
:root.theme-dark .lock-btn[aria-pressed="true"] { background: rgba(202,125,22,.12); }
.lock-btn svg { width: 13px; }
.object-chip { margin: 0 18px 12px; display: flex; gap: 6px; }
.object-chip span { background: var(--bg); color: var(--muted); border-radius: 5px; padding: 4px 6px; font-size: 8px; font-weight: 700; }
.inspector-section { padding-top: 14px; padding-bottom: 14px; }
.inspector-section h3 { margin-bottom: 10px; }
.assigned-colour { display: flex; align-items: center; gap: 10px; }
.assigned-colour input { width: 42px; height: 42px; border: 0; padding: 0; background: transparent; }
.assigned-colour strong, .assigned-colour span { display: block; }
.assigned-colour strong { font-family: monospace; font-size: 12px; }
.assigned-colour span { color: var(--muted); font-size: 9px; margin-top: 4px; }
.scene-tree { display: grid; gap: 4px; }
.tree-group { display: grid; gap: 4px; }
.tree-group + .tree-group { margin-top: 11px; padding-top: 11px; border-top: 1px solid var(--border); }
.tree-group-heading {
  display: flex; align-items: center; justify-content: space-between; padding: 0 7px 4px;
  color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
.tree-group-heading b {
  min-width: 18px; padding: 2px 5px; border-radius: 99px; text-align: center;
  color: var(--accent); background: var(--accent-soft); font-size: 8px;
}
.tree-item { display: flex; align-items: center; justify-content: space-between; border: 1px solid transparent; background: transparent; border-radius: 7px; padding: 6px 7px; text-align: left; width: 100%; }
.tree-item:hover, .tree-item.active { background: var(--accent-soft); border-color: transparent !important; transform: none !important; }
.tree-item.colour-drop-target { outline: 2px solid var(--accent); background: var(--accent-soft); }
.tree-name { display: flex; align-items: center; gap: 7px; min-width: 0; }
.tree-name i { width: 9px; height: 9px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); flex: 0 0 auto; }
.tree-name span { font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-meta { display: flex; gap: 5px; color: var(--light); font-size: 8px; }
.tree-lock { color: #d28b29; }
.beta-note { margin: 12px 18px 18px; padding: 11px; border-radius: 9px; background: var(--accent-soft); }
.beta-note strong, .beta-note span { display: block; }
.beta-note strong { color: var(--accent); font-size: 9px; }
.beta-note span { margin-top: 4px; color: var(--muted); font-size: 8px; line-height: 1.45; }
.toast { position: fixed; left: 50%; bottom: 22px; z-index: 50; transform: translate(-50%, 15px); opacity: 0; pointer-events: none; color: white; background: #202331; padding: 9px 13px; border-radius: 8px; box-shadow: var(--shadow); transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

dialog { width: min(430px, calc(100vw - 28px)); border: 1px solid var(--border); border-radius: 16px; background: var(--card); color: var(--text); padding: 0; box-shadow: 0 28px 80px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(9,11,17,.52); backdrop-filter: blur(3px); }
dialog form { padding: 20px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; }
.dialog-head h2 { font-size: 18px; }
.dialog-close { border: 0; background: none; font-size: 24px; color: var(--muted); }
dialog p { margin: 13px 0; color: var(--muted); line-height: 1.55; font-size: 11px; }
.export-preview { margin: 14px 0; border: 1px solid var(--border); border-radius: 10px; padding: 13px; background: var(--bg); }
.export-preview span, .export-preview strong, .export-preview small { display: block; }
.export-preview span { color: var(--accent); font-size: 8px; font-weight: 800; letter-spacing: .12em; }
.export-preview strong { font-size: 11px; margin-top: 6px; }
.export-preview small { color: var(--muted); margin-top: 4px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 1050px) {
  .lab-shell { grid-template-columns: 225px minmax(390px, 1fr) 240px; gap: 9px; padding: 9px; }
  .camera-help { display: none; }
}
@media (max-width: 820px) {
  body { overflow: auto; }
  .topbar { position: sticky; top: 0; }
  .save-state { display: none; }
  .topbar-left { gap: 8px; }
  .lab-creator-showcase { height: 72px; gap: 8px; padding: 8px; }
  .lab-creator-card { gap: 8px; padding: 8px 10px; }
  .lab-creator-mark { width: 34px; height: 34px; border-radius: 10px; }
  .lab-creator-cta { display: none; }
  .lab-creator-copy small { display: none; }
  .lab-creator-copy strong { font-size: 12px; }
  .lab-shell { height: auto; grid-template-columns: 1fr; }
  .viewport-card { order: -1; height: 65vh; min-height: 470px; }
  .panel { overflow: visible; }
  .right-panel { margin-bottom: 16px; }
  .topbar-actions .btn-label { display: none; }
  .primary-btn,
  .secondary-btn {
    width: 36px;
    padding: 0;
  }
}
@media (max-width: 500px) {
  .btn-back-link { width: 34px; padding: 0; justify-content: center; }
  .btn-back-link span { display: none; }
  .primary-btn { padding: 0 10px; }
  .primary-btn svg { width: 15px; }
  .utility-menu-popover { width: min(220px, calc(100vw - 24px)); }
  .lab-shell { padding: 7px; }
  .scene-tabs .disabled { display: none; }
  .legend { display: none; }
}
