@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');
:root {
  --bg: #141416; --surface: #1c1c20; --surface-2: #232328; --surface-3: #2c2c32;
  --border: rgba(255,255,255,0.07); --border-h: rgba(255,255,255,0.13);
  --text: #f0ece4; --text-2: #a8a29e; --text-3: #6e6a64;
  --accent: #e8a23a; --accent-h: #f0b254; --accent-glow: rgba(232,162,58,0.15);
  --red: #e85454; --green: #5cc98a; --blue: #5b9cf5;
  --ax-x: #e85454; --ax-y: #5cc98a; --ax-z: #5b9cf5;
  --radius: 8px; --radius-sm: 5px; --radius-lg: 14px;
  --font: 'Plus Jakarta Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --transition: 150ms ease;
  font-family: var(--font); font-size: 13px; color-scheme: dark;
  -webkit-font-smoothing: antialiased;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
::selection { background: var(--accent); color: #000; }
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ── Logo Cube ── */
.logo-cube { width: 32px; height: 32px; position: relative; perspective: 120px; flex-shrink: 0; }
.logo-sm { width: 28px; height: 28px; }
.logo-xs { width: 22px; height: 22px; }
.cube-inner {
  width: 100%; height: 100%; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #d4822a);
  box-shadow: 0 0 18px var(--accent-glow), inset 0 -4px 8px rgba(0,0,0,0.25);
  transform: rotateX(12deg) rotateY(-18deg);
  transition: transform 0.6s ease;
}
.logo-cube:hover .cube-inner { transform: rotateX(20deg) rotateY(25deg); }

/* ── Buttons ── */
button, .btn-ghost, .btn-accent, .tb-btn, .hud-btn, .btn-sm {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text-2); cursor: pointer;
  font-weight: 500; font-size: 0.85rem; transition: all var(--transition);
  min-height: 32px; padding: 5px 12px; white-space: nowrap;
}
button:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-h); }
button:active { transform: scale(0.97); }
button .lucide { width: 14px; height: 14px; stroke-width: 2; }
button.active, button[aria-pressed="true"] {
  background: var(--accent-glow); border-color: var(--accent); color: var(--accent);
}
.btn-accent {
  background: linear-gradient(135deg, var(--accent), #d4822a);
  border-color: transparent; color: #1a1a1a; font-weight: 700;
}
.btn-accent:hover { filter: brightness(1.1); box-shadow: 0 4px 20px var(--accent-glow); color: #1a1a1a; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { min-height: 28px; padding: 3px 10px; font-size: 0.78rem; }
.tb-danger { color: var(--red); }
.tb-danger:hover { background: rgba(232,84,84,0.1); border-color: rgba(232,84,84,0.3); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; min-height: 30px; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: transparent; cursor: pointer; color: var(--text-2); transition: all var(--transition);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .lucide { width: 16px; height: 16px; }

/* ── Section Label ── */
.section-label {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-3); display: flex; align-items: center; gap: 5px; margin: 0;
}
.section-label .lucide { width: 12px; height: 12px; opacity: 0.5; }

/* ═══ AUTH SCREEN ═══ */
.auth-screen {
  display: grid; place-items: center; width: 100vw; height: 100vh;
  background: radial-gradient(ellipse at 30% 20%, rgba(232,162,58,0.08), transparent 50%),
              radial-gradient(ellipse at 70% 80%, rgba(91,156,245,0.05), transparent 50%), var(--bg);
}
.auth-card {
  width: min(400px, 90vw); padding: 36px 32px; border-radius: var(--radius-lg);
  border: 1px solid var(--border); background: var(--surface);
  box-shadow: 0 30px 80px rgba(0,0,0,0.5); display: flex; flex-direction: column; gap: 24px;
}
.auth-logo { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.auth-logo h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; }
.auth-subtitle { color: var(--text-3); font-size: 0.85rem; }
.auth-fields { display: flex; flex-direction: column; gap: 14px; }
.input-group { display: flex; flex-direction: column; gap: 4px; }
.input-group label { font-size: 0.78rem; font-weight: 600; color: var(--text-2); }
.input-wrap {
  display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.input-wrap .lucide { width: 16px; height: 16px; color: var(--text-3); flex-shrink: 0; }
.input-wrap input { flex: 1; border: 0; background: transparent; outline: none; height: 100%; font-size: 0.9rem; }
.auth-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.auth-actions button { min-height: 42px; font-size: 0.9rem; }
.auth-msg { text-align: center; color: var(--text-3); font-size: 0.8rem; min-height: 18px; }

/* ═══ SCENE HUB (Full-page) ═══ */
.hub-page {
  display: flex; flex-direction: column;
  width: 100vw; height: 100vh;
  background: radial-gradient(ellipse at 30% 20%, rgba(232,162,58,0.06), transparent 50%), var(--bg);
}
.hub-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 32px; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.hub-brand { display: flex; align-items: center; gap: 10px; }
.hub-brand h1 { font-size: 1.1rem; font-weight: 800; }
.hub-user { font-size: 0.78rem; color: var(--text-3); }
.hub-body {
  flex: 1; overflow-y: auto; padding: 32px 40px 48px;
  display: flex; flex-direction: column; gap: 24px;
  max-width: 1100px; width: 100%; margin: 0 auto;
}
.hub-welcome h2 { font-size: 1.4rem; font-weight: 800; margin-bottom: 4px; }
.hub-welcome p { color: var(--text-3); font-size: 0.88rem; }
.hub-create-bar { display: flex; gap: 10px; align-items: stretch; }
.hub-name-input {
  flex: 1; height: 44px; padding: 0 14px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: 0.9rem;
  transition: border-color var(--transition);
}
.hub-name-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-glow); }
.hub-create-bar .btn-accent { min-height: 44px; padding: 0 24px; font-size: 0.9rem; white-space: nowrap; }
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.hub-empty { color: var(--text-3); font-size: 0.9rem; padding: 40px 0; text-align: center; grid-column: 1 / -1; }

/* Scene Cards */
.hub-scene-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px; border-radius: var(--radius); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  transition: all var(--transition); position: relative;
}
.hub-scene-card:hover { background: var(--surface-2); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.3); border-color: var(--accent); }
.hub-card-name { font-size: 0.92rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.hub-card-date { color: var(--text-3); font-size: 0.72rem; }
.hub-card-actions {
  display: flex; gap: 6px; margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--border);
}
.hub-card-actions button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 6px 0; border-radius: var(--radius-sm); font-size: 0.72rem; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); border: 1px solid transparent;
  cursor: pointer; transition: all var(--transition);
}
.hub-card-actions button:hover { background: var(--surface-3); border-color: var(--border); }
.hub-card-actions .hub-action-delete { color: var(--danger); }
.hub-card-actions .hub-action-delete:hover { background: rgba(234,88,88,0.12); border-color: var(--danger); }
.hub-card-preview {
  display: block; font-size: 0.72rem; color: var(--accent); text-decoration: none;
  opacity: 0.7; transition: opacity 0.15s;
}
.hub-card-preview:hover { opacity: 1; text-decoration: underline; }

/* ═══ EDITOR LAYOUT ═══ */
.editor {
  display: grid;
  grid-template-rows: 44px minmax(0, 1fr);
  grid-template-columns: 240px minmax(0, 1fr) 270px;
  grid-template-areas: "topbar topbar topbar" "left viewport right";
  width: 100vw; height: 100vh;
}
.topbar { grid-area: topbar; }
.panel-left { grid-area: left; }
.viewport-area { grid-area: viewport; }
.panel-right { grid-area: right; }
.mobile-editor-bar, .drawer-backdrop, .panel-close, .mobile-popup, #mobileMoreBtn, #mobileSaveBtn { display: none; }

/* ── Top Bar ── */
.topbar {
  display: flex; align-items: center; gap: 6px; padding: 0 10px;
  background: var(--surface); border-bottom: 1px solid var(--border); z-index: 5;
}
.topbar-left { display: flex; align-items: center; gap: 8px; margin-right: 8px; }
.topbar-title { font-weight: 700; font-size: 0.88rem; }
.topbar-divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; flex-shrink: 0; }
.topbar-user { font-size: 0.75rem; color: var(--text-3); }
.topbar-tools { display: flex; align-items: center; gap: 4px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.mode-switcher {
  display: flex; gap: 2px; padding: 2px; border-radius: var(--radius);
  background: var(--bg); border: 1px solid var(--border);
}
.mode-switcher .mode-button { border: 0; border-radius: 4px; min-height: 28px; font-size: 0.78rem; background: transparent; }
.mode-switcher .mode-button:hover { background: var(--surface-2); transform: none; }
.mode-switcher .mode-button.active { background: var(--accent-glow); color: var(--accent); box-shadow: none; border: 0; }
.snap-toggle { display: flex; align-items: center; gap: 4px; font-size: 0.78rem; color: var(--text-3); cursor: pointer; padding: 0 6px; }
.snap-toggle input { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; }

/* ── Actions Dropdown ── */
.actions-dropdown { display: inline-flex; }
.actions-popup {
  position: fixed; top: 42px; left: 120px; z-index: 50;
  margin-top: 6px; min-width: 210px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 12px 36px rgba(0,0,0,0.55);
  display: flex; flex-direction: column; gap: 1px;
}
.actions-popup.hidden { display: none; }
.actions-popup-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 5px; border: 0;
  background: transparent; color: var(--text-2); font-size: 0.78rem; font-weight: 500;
  cursor: pointer; transition: all 0.12s; justify-content: flex-start; text-align: left;
}
.actions-popup-item:hover { background: var(--surface-2); color: var(--text); transform: none; }
.actions-popup-item svg { width: 14px; height: 14px; flex-shrink: 0; }
.actions-popup-item kbd {
  margin-left: auto; font-family: var(--mono); font-size: 0.65rem;
  color: var(--text-3); background: var(--bg); padding: 1px 5px;
  border-radius: 3px; border: 1px solid var(--border); line-height: 1.4;
}
.actions-popup-divider { height: 1px; background: var(--border); margin: 3px 6px; }
.actions-popup-sub { padding: 6px 10px 6px; }
.actions-popup-sublabel {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.72rem; font-weight: 600; color: var(--text-3); margin-bottom: 6px;
}
.actions-popup-sublabel svg { width: 14px; height: 14px; }
.actions-popup-subrow { display: flex; gap: 4px; }
.actions-popup-axis {
  flex: 1; padding: 5px 0; border-radius: 4px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text-2); font-size: 0.75rem; font-weight: 700;
  font-family: var(--mono); cursor: pointer; transition: all 0.12s; text-align: center;
}
.actions-popup-axis:hover { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); transform: none; }
#actMirrorX { color: var(--ax-x); }
#actMirrorY { color: var(--ax-y); }
#actMirrorZ { color: var(--ax-z); }
#actMirrorX:hover { border-color: var(--ax-x); background: rgba(232,84,84,0.12); color: var(--ax-x); }
#actMirrorY:hover { border-color: var(--ax-y); background: rgba(92,201,138,0.12); color: var(--ax-y); }
#actMirrorZ:hover { border-color: var(--ax-z); background: rgba(91,156,245,0.12); color: var(--ax-z); }
.act-cam-btn { display: flex; align-items: center; justify-content: center; }
.act-cam-btn svg { width: 14px; height: 14px; }
.act-cam-btn:hover { border-color: var(--accent); background: var(--accent-glow); color: var(--accent); }

/* ── Camera Presets ── */
.camera-presets {
  display: flex; gap: 2px; padding: 2px; border-radius: var(--radius);
  background: var(--bg); border: 1px solid var(--border);
}
.cam-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; min-height: 28px; padding: 0;
  border: 0; border-radius: 4px; background: transparent;
  color: var(--text-3); cursor: pointer; transition: all 0.12s;
}
.cam-btn:hover { background: var(--surface-2); color: var(--text); transform: none; }
.cam-btn:active { background: var(--accent-glow); color: var(--accent); }
.cam-btn svg, .cam-btn .lucide { width: 14px; height: 14px; stroke-width: 2; }

/* On wide screens, camera presets are in the topbar — hide them from the Actions popup */
.actions-cam-divider, .actions-cam-section { display: none; }
@media (max-width: 1200px) {
  /* Move camera presets into the Actions popup on smaller screens */
  .camera-presets, .camera-presets + .topbar-divider,
  .topbar-tools > .topbar-divider:has(+ .camera-presets),
  .topbar-tools > .topbar-divider + .camera-presets { display: none; }
  /* Also hide the divider right before camera-presets */
  .camera-presets { display: none !important; }
  .topbar-tools > span.topbar-divider:nth-of-type(2) { display: none; }
  .actions-cam-divider, .actions-cam-section { display: flex; }
  .actions-cam-section { flex-direction: column; }
}

/* Unsaved changes dot on Save button */
.btn-dirty { position: relative; }
.btn-dirty::after {
  content: ""; position: absolute; top: 4px; right: 4px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--danger);
  animation: pulse-dot 1.5s ease-in-out infinite;
}
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ── Panels ── */
.panel {
  display: flex; flex-direction: column; gap: 8px; padding: 10px;
  overflow-y: auto; background: var(--surface); min-width: 0;
}
.panel-left { border-right: 1px solid var(--border); }
.panel-right { border-left: 1px solid var(--border); }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 4px 2px; }
.panel-header-actions { display: flex; gap: 2px; }
.scene-name-row { padding-bottom: 4px; border-bottom: 1px solid var(--border); margin-bottom: 2px; }
.scene-name-input {
  width: 100%; height: 30px; padding: 0 8px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font-size: 0.82rem;
  transition: border-color var(--transition);
}
.scene-name-input:focus { border-color: var(--accent); outline: none; }

.add-object-popup {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 20;
  display: flex; flex-direction: column; gap: 2px; padding: 4px;
  margin-top: 4px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.add-object-popup.hidden { display: none; }
.add-obj-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 4px; border: 0;
  background: transparent; color: var(--text-2); font-size: 0.78rem; font-weight: 500;
  cursor: pointer; transition: all 0.12s; justify-content: flex-start;
}
.add-obj-item:hover { background: var(--surface-2); color: var(--text); }
.add-obj-item svg { width: 14px; height: 14px; }
.obj-count {
  font-size: 0.7rem; font-weight: 600; color: var(--text-3);
  background: var(--surface-2); padding: 1px 6px; border-radius: 8px;
}

/* ── Hierarchy List ── */
.hierarchy-list { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 60px; }
.hierarchy-list p { color: var(--text-3); font-size: 0.8rem; padding: 12px 0; text-align: center; }
.object-row {
  display: flex; align-items: center; gap: 6px; min-height: 30px; padding: 2px 8px;
  border-radius: var(--radius-sm); font-size: 0.82rem; text-align: left;
  justify-content: flex-start; transition: all var(--transition);
}
.object-row:hover { background: var(--surface-2); transform: none; box-shadow: none; }
.object-row.active { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }
.object-color { width: 10px; height: 10px; border-radius: 3px; border: 1px solid rgba(255,255,255,0.15); flex-shrink: 0; }
.object-kind { margin-left: auto; font-size: 0.68rem; color: var(--text-3); font-family: var(--mono); }

/* ── Scene List ── */
.scene-actions-row { display: flex; gap: 4px; padding-bottom: 4px; }
.scene-list { display: flex; flex-direction: column; gap: 2px; }
.saved-scene-row {
  display: grid; grid-template-columns: 1fr auto; align-items: center;
  min-height: 28px; padding: 2px 8px; border-radius: var(--radius-sm);
  font-size: 0.8rem; text-align: left; transition: all var(--transition);
}
.saved-scene-row:hover { background: var(--surface-2); transform: none; box-shadow: none; }
.saved-scene-row.active { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }
.saved-scene-row small { color: var(--text-3); font-size: 0.68rem; font-family: var(--mono); }

/* ── Viewport ── */
.viewport-area { position: relative; background: #0d0d10; min-width: 0; min-height: 0; }
#renderCanvas { display: block; width: 100%; height: 100%; outline: none; touch-action: none; }
.viewport-hud {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px; padding: 4px 6px;
  min-height: 36px; width: min(480px, calc(100% - 20px));
  background: rgba(20,20,22,0.75); backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid var(--border); border-radius: var(--radius); z-index: 1;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.hud-btn { min-height: 28px; padding: 3px 10px; font-size: 0.78rem; background: transparent; border-color: transparent; }
.hud-btn:hover { background: var(--surface-2); border-color: var(--border); }
.hud-btn[aria-pressed="true"] { color: var(--accent); background: var(--accent-glow); }
.hud-spacer { flex: 1; }
.hud-status { font-size: 0.75rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 4px; }
.hud-mobile-actions { display: none; gap: 2px; }

/* ── Inspector ── */
.inspector-identity { padding: 6px 4px 10px; border-bottom: 1px solid var(--border); margin-bottom: 2px; }
.inspector-title-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.inspector-name { font-size: 1rem; font-weight: 700; color: var(--text); text-transform: none; letter-spacing: normal; flex: 1; min-width: 0; }
.inspector-focus-btn { flex-shrink: 0; opacity: 0.6; transition: opacity 0.15s; }
.inspector-focus-btn:hover { opacity: 1; }
.inspector-meta { font-size: 0.78rem; color: var(--text-3); margin-top: 2px; }
.inspector-empty { padding: 32px 12px; text-align: center; color: var(--text-3); font-size: 0.82rem; line-height: 1.6; }
.inspector-section { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.inspector-section:last-child { border-bottom: 0; }

/* Transform */
.transform-block { display: flex; flex-direction: column; gap: 4px; }
.prop-row { display: grid; grid-template-columns: 28px 1fr 1fr 1fr; gap: 3px; align-items: center; }
.prop-label { font-size: 0.75rem; font-weight: 600; color: var(--text-3); font-family: var(--mono); }
.axis-input {
  display: flex; align-items: center; gap: 2px; height: 26px; padding: 0 4px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg);
  font-size: 0.72rem; color: var(--text-3); transition: border-color var(--transition);
  overflow: hidden;
}
.axis-input:focus-within { border-color: var(--accent); }
.ax-x { border-left: 2px solid var(--ax-x); }
.ax-y { border-left: 2px solid var(--ax-y); }
.ax-z { border-left: 2px solid var(--ax-z); }
.axis-input input { flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; outline: none; color: var(--text); font-family: var(--mono); font-size: 0.72rem; font-variant-numeric: tabular-nums; }

/* Material */
.material-grid { display: flex; flex-direction: column; gap: 8px; }
.mat-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.82rem; color: var(--text-2); }
input[type="color"] { width: 40px; height: 24px; padding: 1px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); cursor: pointer; }
input[type="color"]:hover { border-color: var(--accent); }
input[type="range"] { width: 55%; accent-color: var(--accent); cursor: pointer; }

/* Data */
.data-actions { display: flex; gap: 4px; }
textarea {
  width: 100%; min-height: 100px; resize: vertical; padding: 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text); font-family: var(--mono); font-size: 0.78rem; line-height: 1.5;
}
textarea:focus { border-color: var(--accent); outline: none; }

/* Background */
.bg-controls { display: flex; flex-direction: column; gap: 8px; }
.bg-image-row { display: flex; gap: 4px; }
.bg-image-label { font-size: 0.72rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Preview Modes */
.preview-mode-controls { display: flex; flex-direction: column; gap: 6px; }
.preview-mode-toggle {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--border);
  cursor: pointer; transition: border-color 0.15s;
}
.preview-mode-toggle:hover { border-color: var(--accent); }
.preview-mode-toggle input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.preview-mode-toggle span { font-size: 0.82rem; font-weight: 600; }
.preview-mode-toggle small { font-size: 0.7rem; color: var(--text-3); margin-left: auto; }

/* Actions Inspector */
.actions-summary { display: flex; align-items: center; gap: 8px; }
.actions-count { font-size: 0.78rem; color: var(--text-3); flex: 1; }

/* Modal Overlay */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(6px);
}
.modal-card {
  width: min(520px, 92vw); max-height: 80vh; overflow-y: auto;
  padding: 24px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-header h2 { font-size: 1rem; font-weight: 700; }

/* Action Editor */
.action-loop-toggle {
  display: flex; align-items: center; gap: 8px; padding: 6px 0 12px;
  font-size: 0.82rem; cursor: pointer;
}
.action-loop-toggle input { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }

.action-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.action-row {
  display: flex; align-items: center; gap: 6px; padding: 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.action-row select {
  width: 80px; padding: 4px 6px; border-radius: 4px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  font-size: 0.78rem; font-family: var(--font); cursor: pointer;
}
.action-row select:focus { border-color: var(--accent); outline: none; }
.action-row .action-fields { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.action-row .action-field {
  display: flex; align-items: center; gap: 2px; font-size: 0.72rem; color: var(--text-2);
}
.action-row .action-field input {
  width: 52px; padding: 3px 5px; border-radius: 4px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  font-size: 0.78rem; font-family: var(--mono); text-align: center;
}
.action-row .action-field input:focus { border-color: var(--accent); outline: none; }
.action-row .action-delete {
  width: 24px; height: 24px; border-radius: 4px; border: none;
  background: transparent; color: var(--text-3); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; line-height: 1;
}
.action-row .action-delete:hover { color: var(--danger); background: rgba(234,88,88,0.1); }
.action-row .action-num { font-size: 0.68rem; color: var(--text-3); min-width: 16px; text-align: center; }
.action-add-btn { width: 100%; }

/* ── Utility ── */
.hidden { display: none !important; }
.is-disabled { opacity: 0.4; pointer-events: none; }
.lucide { width: 14px; height: 14px; stroke-width: 2; }

/* ── Responsive ── */
@media (max-width: 980px) {
  .editor { display: block; position: relative; height: 100dvh; overflow: hidden;
    grid-template-rows: unset; grid-template-columns: unset; grid-template-areas: unset; }
  .topbar { display: none; }
  .mobile-editor-bar {
    position: fixed; top: 8px; left: 8px; right: 8px; z-index: 8;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    min-height: 48px; padding: 4px 8px;
    background: rgba(20,20,22,0.85); backdrop-filter: blur(16px);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  }
  #mobileMoreBtn, #mobileSaveBtn { display: inline-flex; }
  .mobile-title { flex: 1; text-align: center; min-width: 0; }
  .mobile-title strong { font-size: 0.85rem; }
  .mobile-title span { display: block; font-size: 0.72rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .viewport-area { width: 100vw; height: 100dvh; }
  .viewport-hud { position: fixed; top: auto; bottom: 10px; left: 50%; z-index: 301; }
  .viewport-hud .hud-status { display: none; }
  .hud-mobile-actions { display: flex; }
  .actions-popup {
    position: fixed; top: 108px; left: 8px; right: 8px; z-index: 50;
    margin-top: 0; min-width: unset; max-height: 70vh; overflow-y: auto;
  }
  .panel {
    position: fixed; top: 0; bottom: 0; z-index: 12;
    width: min(85vw, 320px); transition: transform 200ms ease;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6); border: 0;
  }
  .panel-left { left: 0; transform: translateX(-104%); }
  .panel-right { right: 0; transform: translateX(104%); }
  .panel-left.drawer-open, .panel-right.drawer-open { transform: translateX(0); }
  .panel-close { display: inline-flex; position: sticky; top: 0; align-self: flex-end; z-index: 2; margin-bottom: -4px; }
  .drawer-backdrop { position: fixed; inset: 0; z-index: 11; display: block; background: rgba(0,0,0,0.5); backdrop-filter: blur(2px); }
  .drawer-backdrop.hidden { display: none; }

  /* Mobile popup menu */
  .mobile-popup {
    position: fixed; top: 58px; left: 8px; z-index: 10;
    display: flex; gap: 4px; padding: 6px;
    background: rgba(20,20,22,0.85); backdrop-filter: blur(16px);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  }
  .mobile-popup.hidden { display: none; }
  .mobile-popup-btn {
    display: flex; align-items: center; gap: 5px;
    padding: 8px 12px; border-radius: 6px;
    font-size: 0.75rem; font-weight: 600; white-space: nowrap;
    background: transparent; color: var(--text-2); border: 1px solid var(--border);
    cursor: pointer; transition: all 0.15s;
  }
  .mobile-popup-btn:hover, .mobile-popup-btn:active {
    background: var(--surface); color: var(--text); border-color: var(--accent);
  }
  .mobile-popup-btn svg { width: 14px; height: 14px; }
  .mobile-icon-btn { padding: 6px 10px; min-width: 0; }
}

/* ── Toast Notifications ── */
.toast-container {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 300;
  display: flex; flex-direction: column-reverse; align-items: center; gap: 6px;
  pointer-events: none;
}
.toast {
  padding: 8px 20px; border-radius: 999px; font-size: 0.8rem; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4); white-space: nowrap;
  opacity: 0; transform: translateY(12px) scale(0.95);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: auto;
}
.toast.toast-visible { opacity: 1; transform: translateY(0) scale(1); }
.toast-accent { border-color: var(--accent); color: var(--accent); }
.toast-error { border-color: #ea5858; color: #ea5858; }
@media (max-width: 980px) {
  .toast-container { bottom: 70px; }
}

/* ── Inspector Rename ── */
.inspector-rename {
  font-size: 1rem; font-weight: 700; color: var(--text); width: 100%;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 2px 6px; transition: border-color 0.15s, background 0.15s; outline: none;
}
.inspector-rename:hover { border-color: var(--border); background: var(--bg); }
.inspector-rename:focus { border-color: var(--accent); background: var(--bg); box-shadow: 0 0 0 3px var(--accent-glow); }

/* ── Texture Slots ── */
.texture-slot {
  display: flex; align-items: center; gap: 6px; padding: 5px 0;
  border-bottom: 1px solid var(--border); min-height: 36px;
}
.texture-slot:last-child { border-bottom: none; }
.texture-slot-label { font-size: 0.75rem; color: var(--text-2); min-width: 56px; flex-shrink: 0; }
.texture-thumb {
  width: 28px; height: 28px; border-radius: 4px; border: 1px solid var(--border);
  background-size: cover; background-position: center; flex-shrink: 0;
  background-color: var(--bg);
}
.texture-name {
  font-size: 0.72rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; flex: 1; min-width: 0;
}
.texture-slot-actions { display: flex; gap: 3px; flex-shrink: 0; }
.tex-btn {
  padding: 3px 8px; font-size: 0.68rem; font-weight: 600; border-radius: 4px;
  border: 1px solid var(--border); background: transparent; color: var(--text-3);
  cursor: pointer; transition: all 0.12s; min-height: 24px;
}
.tex-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-h); transform: none; }
.tex-btn-clear { color: #ea5858; border-color: rgba(232,88,88,0.2); }
.tex-btn-clear:hover { background: rgba(232,88,88,0.1); color: #ea5858; }

/* ── Texture Library Popup ── */
.texture-library-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(3px);
}
.texture-library-popup {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px; width: 380px; max-width: 90vw; max-height: 80vh; overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
.texture-library-popup h3 { margin: 0 0 12px; font-size: 0.9rem; color: var(--text); }
.texture-library-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.tex-lib-item {
  aspect-ratio: 1; border-radius: 6px; border: 2px solid var(--border);
  background-size: cover; background-position: center; cursor: pointer;
  transition: border-color 0.15s, transform 0.1s; position: relative; overflow: hidden;
}
.tex-lib-item:hover { border-color: var(--accent); transform: scale(1.05); }
.tex-lib-item span {
  position: absolute; bottom: 0; left: 0; right: 0;
  font-size: 0.6rem; font-weight: 600; color: var(--text); text-align: center;
  padding: 2px; background: rgba(0,0,0,0.65);
}

/* ── Wireframe Toggle ── */
.wireframe-row {
  display: flex; align-items: center; gap: 8px; padding: 4px 0;
}
.wireframe-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 0.8rem; color: var(--text-2); }
.wireframe-row input[type="checkbox"] { accent-color: var(--accent); }

/* ── Object Grouping ── */
.object-row.is-group { background: var(--surface-2); font-weight: 600; }
.object-row.is-group .object-kind { color: var(--accent); }
.group-toggle {
  width: 14px; text-align: center; font-size: 0.7rem; color: var(--text-3);
  cursor: pointer; flex-shrink: 0; user-select: none; transition: transform 0.15s;
}
.group-toggle.collapsed { transform: rotate(-90deg); }
.object-row.is-child { padding-left: 28px; font-size: 0.78rem; opacity: 0.85; }
.object-row.multi-selected { outline: 1px solid var(--accent); outline-offset: -1px; }
.group-actions-bar {
  display: flex; gap: 4px; padding: 4px 8px; background: var(--surface-2);
  border-radius: var(--radius-sm); margin-bottom: 4px;
}
.group-actions-bar .tex-btn { font-size: 0.7rem; }
.object-row.is-hidden { opacity: 0.35; }
.object-row.is-hidden span:nth-child(2) { text-decoration: line-through; }
.object-row.is-locked { border-left: 2px solid var(--text-3); }

