:root {
  --bg-primary: #0b0f17;
  --bg-surface: #131722;
  --bg-surface-elevated: #1a202c;
  --border-subtle: #242c3d;
  --border-focus: #38bdf8;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #38bdf8;
  --accent-hover: #0284c7;
  --accent-blue: #2563eb;
  --danger: #f43f5e;
  --success: #10b981;
  --warning: #f59e0b;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  --menubar-height: 28px;
  --ribbon-height: 38px;
  --header-total-height: 66px;
  --statusbar-height: 24px;
  --sidebar-width: 280px;
  --props-width: 250px;
}

body.theme-light {
  --bg-primary: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f8fafc;
  --border-subtle: #cbd5e1;
  --border-focus: #0284c7;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --accent-blue: #2563eb;
  scrollbar-color: #cbd5e1 #f1f5f9;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: #2b3547 #0b0f17;
}

/* Ergonomic Modern Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #0b0f17;
}

::-webkit-scrollbar-thumb {
  background: #2b3547;
  border-radius: 4px;
  border: 1px solid #0b0f17;
}

::-webkit-scrollbar-thumb:hover {
  background: #38bdf8;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   DESKTOP APPLICATION HEADER (Menubar + Docked Ribbon)
   ========================================================================== */
.desktop-header {
  height: var(--header-total-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 50;
  flex-shrink: 0;
  user-select: none;
}

/* Top Menubar Row */
.menubar-row {
  height: var(--menubar-height);
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 12px;
  justify-content: space-between;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -0.01em;
  font-size: 12px;
}

.app-logo {
  color: var(--accent);
}

.app-badge {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  letter-spacing: 0.04em;
}

.desktop-menus {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 14px;
}

.menu-item {
  position: relative;
}

.menu-trigger {
  background: transparent;
  border: none;
  color: #cbd5e1;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.menu-trigger:hover,
.menu-item.active .menu-trigger,
.menu-item.open .menu-trigger {
  background: #1e2535;
  color: #fff;
}

/* Desktop Dropdown Menus */
.menu-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  background: #161a25;
  border: 1px solid #283247;
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65);
  padding: 4px;
  min-width: 220px;
  z-index: 1000;
  display: none;
}

.menu-item.open .menu-dropdown,
.menu-dropdown.open {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.dropdown-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 10px;
  background: transparent;
  border: none;
  color: #cbd5e1;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s, color 0.1s;
}

.dropdown-row:hover {
  background: #2563eb;
  color: #fff;
}

.dropdown-row kbd {
  font-size: 10px;
  color: #64748b;
  font-family: monospace;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 5px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.dropdown-row:hover kbd {
  color: #e2e8f0;
  background: rgba(0, 0, 0, 0.4);
}

.dropdown-divider {
  height: 1px;
  background: #242c3d;
  margin: 3px 0;
}

.menubar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
}

.project-pill {
  color: #94a3b8;
  font-family: monospace;
  background: #161a25;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.status-dot-indicator {
  color: #10b981;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Docked Toolstrip Ribbon */
.toolstrip-ribbon {
  height: var(--ribbon-height);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
}

.toolstrip-ribbon::-webkit-scrollbar {
  display: none;
}

.ribbon-group {
  display: flex;
  align-items: center;
  gap: 3px;
}

.ribbon-sep {
  width: 1px;
  height: 18px;
  background: #242c3d;
  margin: 0 4px;
}

.ribbon-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #1c2230;
  border: 1px solid #283247;
  color: #cbd5e1;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.ribbon-btn:hover {
  background: #242c3d;
  border-color: var(--accent);
  color: #fff;
}

.ribbon-btn-primary {
  background: #2563eb;
  border-color: #3b82f6;
  color: #fff;
  font-weight: 600;
}

.ribbon-btn-primary:hover {
  background: #1d4ed8;
}

.ribbon-btn-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1c2230;
  border: 1px solid #283247;
  color: #94a3b8;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s;
}

.ribbon-btn-icon:hover {
  background: #242c3d;
  color: #fff;
  border-color: #38bdf8;
}

.ribbon-tool-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid transparent;
  color: #94a3b8;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.ribbon-tool-btn:hover {
  background: #1c2230;
  color: #fff;
}

.ribbon-tool-btn.active {
  background: rgba(56, 189, 248, 0.12);
  border-color: #38bdf8;
  color: #38bdf8;
  font-weight: 600;
}

.ribbon-btn-action {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #38bdf8;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.ribbon-btn-action:hover {
  background: #38bdf8;
  color: #0b0f17;
}

.cad-segmented-control {
  display: flex;
  background: #0f121a;
  padding: 2px;
  border-radius: 4px;
  border: 1px solid #242c3d;
}

.segmented-btn {
  background: transparent;
  border: none;
  color: #8290a4;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.segmented-btn:hover {
  color: #cbd5e1;
}

.segmented-btn.active {
  background: #22293a;
  color: #38bdf8;
}

.cad-unit-select {
  padding: 3px 6px;
  font-size: 11px;
  background: #1c2230;
  border: 1px solid #283247;
  color: #cbd5e1;
  border-radius: 4px;
  outline: none;
}

/* General Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  transition: all 0.12s ease;
}

.btn:hover {
  background: #2b394d;
  border-color: var(--text-muted);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0f17;
  font-weight: 600;
}

.btn-primary:hover {
  background: #7dd3fc;
  border-color: #7dd3fc;
}

.btn-danger {
  background: rgba(244, 63, 94, 0.12);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

/* ==========================================================================
   WORKSPACE VIEWPORTS & MAIN LAYOUT
   ========================================================================== */
.main-container {
  display: flex;
  flex: 1;
  height: calc(100vh - var(--header-total-height) - var(--statusbar-height));
  overflow: hidden;
  position: relative;
}

.viewport-area {
  flex: 1;
  display: flex;
  position: relative;
  background: var(--bg-primary);
  overflow: hidden;
}

.canvas-wrapper {
  position: relative;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg-surface);
}

.split-half {
  width: 50% !important;
  border-right: 1px solid var(--border-subtle);
}

#canvas-2d {
  display: block;
  width: 100%;
  height: 100%;
}

#container-3d {
  width: 100%;
  height: 100%;
  position: relative;
}

/* ==========================================================================
   SIDEBAR LEFT (Component Library)
   ========================================================================== */
.sidebar-left {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 5;
  transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.2s, opacity 0.2s;
  overflow: hidden;
}

.sidebar-left.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  border: none !important;
  opacity: 0;
  pointer-events: none;
}

.sidebar-header {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.panel-icon-btn {
  width: 20px;
  height: 20px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 3px;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s;
}

.panel-icon-btn:hover {
  background: #242c3d;
  color: #fff;
}

.sidebar-search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.sidebar-search-box .search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.sidebar-search-box .cad-search-input {
  width: 100%;
  padding: 6px 26px 6px 28px;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 11.5px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.sidebar-search-box .cad-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
}

.sidebar-search-box .search-clear-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-search-box .search-clear-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-search-box .search-clear-btn.hidden {
  display: none !important;
}

.sidebar-pack-filter {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 6px;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 2px;
}

.pack-filter-btn {
  flex: 1;
  padding: 3px 6px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.pack-filter-btn:hover {
  color: var(--text-primary);
}

.pack-filter-btn.active {
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
}

body.theme-light .pack-filter-btn.active {
  background: #0284c7;
  color: #ffffff;
}

.grid-card-pack-badge {
  font-size: 8.5px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 1px 4px;
  border-radius: 3px;
  letter-spacing: 0.3px;
}

.grid-card-pack-badge.kenney {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.grid-card-pack-badge.quaternius {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

body.theme-light .grid-card-pack-badge.kenney {
  background: rgba(2, 132, 199, 0.1);
  color: #0284c7;
  border: 1px solid rgba(2, 132, 199, 0.25);
}

body.theme-light .grid-card-pack-badge.quaternius {
  background: rgba(147, 51, 234, 0.1);
  color: #7e22ce;
  border: 1px solid rgba(147, 51, 234, 0.25);
}

.catalog-breadcrumb-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 2px;
}

.catalog-breadcrumb-bar.hidden {
  display: none !important;
}

.catalog-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  flex-shrink: 0;
}

.catalog-back-btn:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.catalog-cat-badge {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.catalog-nav-count {
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(148, 163, 184, 0.12);
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 500;
  flex-shrink: 0;
}

.catalog-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* Category Folders List (Inspiration Table View) */
.category-list-container {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.category-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.category-list-row:hover {
  background: rgba(2, 132, 199, 0.1);
}

.category-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.category-row-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: color 0.12s ease;
}

.category-list-row:hover .category-row-icon {
  color: var(--accent);
}

.category-row-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-row-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.category-row-count {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(148, 163, 184, 0.12);
  padding: 1px 7px;
  border-radius: 10px;
}

.category-row-arrow {
  color: var(--text-muted);
  transition: transform 0.12s ease, color 0.12s ease;
}

.category-list-row:hover .category-row-arrow {
  transform: translateX(2px);
  color: var(--accent);
}

/* 2-Column Catalog Grid (Inspiration Item View) */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 8px;
  width: 100%;
  box-sizing: border-box;
}

.catalog-grid-card {
  background: var(--bg-surface-elevated, #171c28);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: 8px;
  padding: 8px 6px 6px 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  min-height: 126px;
  box-sizing: border-box;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.catalog-grid-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.2);
}

.catalog-grid-card:active {
  transform: scale(0.97);
}

.grid-card-title {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-primary, #e2e8f0);
  line-height: 1.25;
  max-height: 2.5em;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  width: 100%;
  margin-bottom: 2px;
}

.grid-card-thumb-box {
  width: 62px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2px 0;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.grid-card-thumb-canvas {
  width: 60px;
  height: 60px;
  display: block;
}

.grid-card-footer {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--border-subtle);
}

.grid-card-dims {
  font-size: 8.5px;
  font-family: monospace;
  color: var(--text-muted, #94a3b8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  text-align: left;
}

.grid-card-add-btn {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid rgba(2, 132, 199, 0.35);
  background: rgba(2, 132, 199, 0.15);
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
  flex-shrink: 0;
  padding: 0;
}

.grid-card-add-btn:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  transform: scale(1.1);
}

/* Legacy .catalog-card fallback if ever needed */
.catalog-card {
  background: #171c28;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

/* ==========================================================================
   SIDEBAR RIGHT (Properties Inspector)
   ========================================================================== */
.sidebar-right {
  width: var(--props-width);
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 5;
  transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.2s, opacity 0.2s;
  overflow: hidden;
}

.sidebar-right.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  border: none !important;
  opacity: 0;
  pointer-events: none;
}

.props-content {
  padding: 10px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.prop-empty-state {
  color: #64748b;
  font-size: 11.5px;
  text-align: center;
  margin-top: 30px;
  line-height: 1.5;
  padding: 0 10px;
}

.prop-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.prop-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.prop-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.04em;
}

.prop-row {
  display: flex;
  gap: 6px;
}

.input-field {
  width: 100%;
  padding: 5px 8px;
  background: #0c0f17;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: #f1f5f9;
  font-size: 11.5px;
  outline: none;
}

.input-field:focus {
  border-color: var(--accent);
}

.prop-hint-box {
  font-size: 10.5px;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.06);
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.2);
  line-height: 1.35;
}

/* ==========================================================================
   2D CANVAS OVERLAYS & SCROLLBARS
   ========================================================================== */
.canvas-scrollbar {
  position: absolute;
  background: rgba(13, 16, 23, 0.65);
  backdrop-filter: blur(4px);
  z-index: 5;
  transition: background 0.15s;
  user-select: none;
}

.canvas-scrollbar:hover {
  background: rgba(13, 16, 23, 0.9);
}

.scrollbar-v {
  top: 0;
  right: 0;
  bottom: 10px;
  width: 10px;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
}

.scrollbar-h {
  bottom: 0;
  left: 0;
  right: 10px;
  height: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.scrollbar-thumb {
  position: absolute;
  background: rgba(148, 163, 184, 0.35);
  border-radius: 4px;
  cursor: grab;
  transition: background 0.12s;
}

.scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.7);
}

.scrollbar-thumb:active,
.scrollbar-thumb.dragging {
  cursor: grabbing;
  background: var(--accent);
}

.scrollbar-v .scrollbar-thumb {
  width: 6px;
  left: 2px;
  min-height: 24px;
}

.scrollbar-h .scrollbar-thumb {
  height: 6px;
  top: 2px;
  min-width: 24px;
}

/* Viewport HUD Navigation */
.viewport-hud {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(15, 20, 30, 0.88);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 6px 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  user-select: none;
}

.hud-pan-dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.hud-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.hud-btn {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(28, 36, 50, 0.85);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: bold;
  transition: all 0.12s ease;
}

.hud-btn:hover {
  background: var(--accent);
  color: #0f172a;
  border-color: var(--accent);
}

.hud-btn:active {
  transform: scale(0.95);
}

.hud-btn-fit {
  width: 36px;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.3);
}

.hud-btn-fit:hover {
  background: #38bdf8;
  color: #0f172a;
}

.hud-btn-reset {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
}

.hud-divider {
  width: 100%;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 1px 0;
}

.hud-zoom-controls {
  display: flex;
  align-items: center;
  gap: 3px;
}

.hud-zoom-text {
  font-size: 0.7rem;
  color: var(--text-secondary);
  min-width: 36px;
  text-align: center;
  font-family: monospace;
  font-weight: 600;
}

/* 3D Viewport Controls */
.cam-controls {
  position: absolute;
  top: 10px;
  right: 14px;
  display: flex;
  gap: 6px;
  z-index: 4;
}

.walkthrough-banner {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 20, 30, 0.88);
  backdrop-filter: blur(8px);
  border: 1px solid var(--accent);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.75rem;
  color: #e2e8f0;
  display: flex;
  gap: 12px;
  align-items: center;
  z-index: 4;
}

/* ==========================================================================
   DESKTOP STATUS BAR
   ========================================================================== */
.app-statusbar {
  height: var(--statusbar-height);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: monospace;
  user-select: none;
  z-index: 10;
  flex-shrink: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.app-statusbar.hidden {
  display: none !important;
}

.status-cell {
  padding: 0 8px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.status-cell-main {
  flex: 1;
  color: #cbd5e1;
  font-family: var(--font-family);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  width: 650px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.data-table th, .data-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table th {
  background: #0b0f17;
  color: var(--text-secondary);
}

.hidden {
  display: none !important;
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-item {
  background: #0b0f17;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.12s ease;
}

.project-item:hover {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.03);
}

.project-info h4 {
  font-size: 0.9rem;
  margin-bottom: 3px;
}

.project-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
}

.project-actions {
  display: flex;
  gap: 6px;
}

/* ==========================================================================
   ARCHITECTURAL ROOM CREATION WIZARD MODAL
   ========================================================================== */
.modal-card-wizard {
  width: 720px;
  max-width: 94vw;
  max-height: 88vh;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(56, 189, 248, 0.2);
}

.modal-header-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-subtitle {
  font-size: 11px;
  color: #8290a4;
  margin-top: 2px;
}

.wizard-body {
  padding: 12px 18px;
  gap: 11px;
  overflow-y: auto;
}

.wizard-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wizard-section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.04em;
}

.wizard-hint {
  font-size: 10px;
  font-weight: 400;
  color: #94a3b8;
  text-transform: none;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.preset-chip {
  background: #0c0f17;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  cursor: pointer;
  text-align: left;
  transition: all 0.12s ease;
  user-select: none;
}

.preset-chip:hover {
  background: rgba(56, 189, 248, 0.05);
  border-color: rgba(56, 189, 248, 0.4);
}

.preset-chip.active {
  background: rgba(56, 189, 248, 0.12);
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px #38bdf8;
}

.chip-title {
  font-size: 11px;
  font-weight: 600;
  color: #f1f5f9;
  line-height: 1.2;
}

.chip-dims {
  font-size: 10px;
  color: #94a3b8;
  font-family: monospace;
}

.chip-badge {
  font-size: 9.5px;
  font-weight: 600;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  padding: 1px 5px;
  border-radius: 3px;
  margin-top: 2px;
}

.wizard-row-split {
  display: flex;
  gap: 12px;
}

@media (max-width: 600px) {
  .wizard-row-split {
    flex-direction: column;
  }
}

.wizard-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wizard-dim-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wizard-dim-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dim-label {
  font-size: 10px;
  font-weight: 600;
  color: #8290a4;
  text-transform: uppercase;
}

.dim-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.dim-input-wrap .input-field {
  padding-right: 28px;
}

.dim-unit {
  position: absolute;
  right: 10px;
  font-size: 11px;
  color: #64748b;
  font-family: monospace;
  pointer-events: none;
}

.dim-times {
  font-size: 18px;
  color: #64748b;
  font-weight: bold;
  margin-top: 16px;
  user-select: none;
}

.wizard-area-hud {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 6px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

.area-hud-primary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 13px;
  color: #38bdf8;
}

.area-hud-metric {
  font-size: 11.5px;
  color: #94a3b8;
  font-weight: 500;
}

.area-hud-secondary {
  font-size: 11px;
  color: #cbd5e1;
  font-family: monospace;
  background: rgba(255, 255, 255, 0.04);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.wizard-walls-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wizard-walls-header {
  display: flex;
  align-items: center;
}

.cad-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.cad-checkbox-label input[type="checkbox"] {
  accent-color: #38bdf8;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.cad-checkbox-text {
  font-size: 11.5px;
  font-weight: 600;
  color: #f1f5f9;
}

.wizard-walls-options {
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.wizard-inline-tip {
  font-size: 10.5px;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  padding: 6px 10px;
  line-height: 1.35;
  width: 100%;
}

.floor-swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 6px;
}

.swatch-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #0c0f17;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s ease;
  user-select: none;
}

.swatch-btn:hover {
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.04);
}

.swatch-btn.active {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  box-shadow: 0 0 0 1px #38bdf8;
}

.swatch-color {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.swatch-label {
  font-size: 11px;
  color: #e2e8f0;
  font-weight: 500;
  white-space: nowrap;
}

.wizard-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  background: #0c0f17;
}

/* ==========================================================================
   ENCLOSED ROOM AUTO-DETECTION BANNER
   ========================================================================== */
.room-detect-banner {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 30px;
  padding: 6px 14px 6px 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(56, 189, 248, 0.2);
  user-select: none;
  animation: slideDownFade 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDownFade {
  from {
    opacity: 0;
    transform: translate(-50%, -12px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.detect-badge-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  animation: pulseGlow 2s infinite ease-in-out;
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.4);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(56, 189, 248, 0);
  }
}

.detect-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.detect-title {
  font-size: 11px;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: 0.02em;
}

.detect-desc {
  font-size: 10.5px;
  color: #94a3b8;
  font-family: monospace;
}

.detect-desc strong {
  color: #38bdf8;
}

.detect-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
}

.btn-sm {
  padding: 4px 10px !important;
  font-size: 11px !important;
  height: 26px !important;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ==========================================================================
   COLLAPSIBLE WORKSPACE PANELS & FLOATING DOCK TABS
   ========================================================================== */
.panel-collapse-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: all 0.15s ease;
  line-height: 1;
}

.panel-collapse-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

body.theme-light .panel-collapse-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.dock-tab {
  position: absolute;
  top: 70px;
  z-index: 25;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: all 0.15s ease;
  user-select: none;
}

.dock-tab:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

.dock-tab.dock-left {
  left: 0;
  border-left: none;
  border-radius: 0 6px 6px 0;
}

.dock-tab.dock-right {
  right: 0;
  border-right: none;
  border-radius: 6px 0 0 6px;
}

/* Viewport Navigation HUD minimize toggle */
.hud-mini-btn {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 17px;
  height: 17px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  border-radius: 50%;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  z-index: 2;
  transition: all 0.15s ease;
}

.hud-mini-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: scale(1.1);
}

.viewport-hud.minimized .hud-pan-dpad,
.viewport-hud.minimized .hud-divider {
  display: none !important;
}

.viewport-hud.minimized {
  padding: 4px 6px;
}

/* ==========================================================================
   ARCHITECTURAL STUDIO LIGHT THEME
   ========================================================================== */
body.theme-light .app-brand {
  color: #0f172a;
}

body.theme-light .menu-trigger {
  color: #334155;
}

body.theme-light .menu-trigger:hover,
body.theme-light .menu-item.open .menu-trigger {
  background: #e2e8f0;
  color: #0f172a;
}

body.theme-light .menu-dropdown {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
}

body.theme-light .dropdown-row {
  color: #334155;
}

body.theme-light .dropdown-row:hover {
  background: #0284c7;
  color: #ffffff;
}

body.theme-light .dropdown-row:hover kbd {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.4);
}

body.theme-light .dropdown-row kbd {
  background: #e2e8f0;
  color: #475569;
  border-color: #cbd5e1;
}

body.theme-light .dropdown-divider {
  background: #e2e8f0;
}

body.theme-light .project-pill {
  background: #e2e8f0;
  color: #334155;
  border-color: #cbd5e1;
}

body.theme-light .ribbon-btn {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #334155;
}

body.theme-light .ribbon-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #94a3b8;
}

body.theme-light .ribbon-btn.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
  font-weight: 600;
}

body.theme-light .ribbon-btn-icon {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #475569;
}

body.theme-light .ribbon-btn-icon:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #94a3b8;
}

body.theme-light .ribbon-sep {
  background: #cbd5e1;
}

body.theme-light .cad-unit-select,
body.theme-light .cad-search-input,
body.theme-light .select-filter,
body.theme-light .input-field {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}

body.theme-light .cad-search-input:focus,
body.theme-light .select-filter:focus,
body.theme-light .input-field:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

/* Left Sidebar Catalog & Cards */
body.theme-light .catalog-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

body.theme-light .catalog-card:hover {
  background: #f8fafc;
  border-color: #0284c7;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.08);
}

body.theme-light .card-title {
  color: #0f172a;
}

body.theme-light .card-dims {
  color: #64748b;
}

body.theme-light .card-thumb-box {
  background: #f8fafc;
  border-color: #cbd5e1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

body.theme-light .card-badge {
  background: #f1f5f9;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  font-weight: 600;
}

body.theme-light .btn-add-item {
  background: #0284c7;
  border: 1px solid #0284c7;
  color: #ffffff;
  font-weight: 600;
}

body.theme-light .btn-add-item:hover {
  background: #0369a1;
  border-color: #0369a1;
  color: #ffffff;
}

/* Sidebars & Header Bars */
body.theme-light .sidebar-left,
body.theme-light .sidebar-right {
  background: #ffffff;
  border-color: #cbd5e1;
}

body.theme-light .sidebar-header {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
}

body.theme-light .sidebar-title {
  color: #0f172a;
}

body.theme-light .panel-icon-btn,
body.theme-light .panel-collapse-btn {
  color: #64748b;
}

body.theme-light .panel-icon-btn:hover,
body.theme-light .panel-collapse-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}

body.theme-light .prop-empty-state {
  color: #475569;
}

body.theme-light .prop-label {
  color: #334155;
}

body.theme-light .prop-hint-box {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-left: 3px solid #0284c7;
  color: #0f172a;
}

/* Segmented View Mode Controls (2D / Split / 3D) */
body.theme-light .cad-segmented-control {
  background: #e2e8f0;
  border-color: #cbd5e1;
}

body.theme-light .segmented-btn {
  color: #334155;
}

body.theme-light .segmented-btn:hover {
  color: #0f172a;
}

body.theme-light .segmented-btn.active {
  background: #ffffff;
  color: #0284c7;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Ribbon Tool & Action Buttons */
body.theme-light .ribbon-tool-btn {
  color: #334155;
}

body.theme-light .ribbon-tool-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}

body.theme-light .ribbon-tool-btn.active {
  background: #0284c7;
  border-color: #0284c7;
  color: #ffffff;
  font-weight: 600;
}

body.theme-light .ribbon-btn-action {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  font-weight: 600;
}

body.theme-light .ribbon-btn-action:hover {
  background: #0284c7;
  border-color: #0284c7;
  color: #ffffff;
}

body.theme-light .ribbon-btn-primary {
  background: #0284c7;
  border-color: #0284c7;
  color: #ffffff;
}

body.theme-light .ribbon-btn-primary:hover {
  background: #0369a1;
  border-color: #0369a1;
}

/* Canvas Scrollbars & Native Webkit Scrollbars */
body.theme-light::-webkit-scrollbar,
body.theme-light *::-webkit-scrollbar {
  background: #f1f5f9;
  width: 8px;
  height: 8px;
}

body.theme-light::-webkit-scrollbar-thumb,
body.theme-light *::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
  border: 1px solid #f1f5f9;
}

body.theme-light::-webkit-scrollbar-thumb:hover,
body.theme-light *::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

body.theme-light .canvas-scrollbar {
  background: rgba(241, 245, 249, 0.8);
  border-color: #cbd5e1;
}

body.theme-light .canvas-scrollbar:hover {
  background: rgba(241, 245, 249, 0.96);
}

body.theme-light .scrollbar-thumb {
  background: rgba(148, 163, 184, 0.45);
}

body.theme-light .scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.7);
}

body.theme-light .scrollbar-thumb:active,
body.theme-light .scrollbar-thumb.dragging {
  background: #0284c7;
}

/* Modals, Tables & Projects */
body.theme-light .modal-overlay {
  background: rgba(15, 23, 42, 0.5);
}

body.theme-light .data-table th {
  background: #f8fafc;
  color: #475569;
  border-bottom: 1px solid #cbd5e1;
}

body.theme-light .data-table td {
  color: #0f172a;
  border-bottom: 1px solid #e2e8f0;
}

body.theme-light .project-item {
  background: #f8fafc;
  border-color: #e2e8f0;
}

body.theme-light .project-item:hover {
  background: #f0f9ff;
  border-color: #0284c7;
}

body.theme-light .project-info h4 {
  color: #0f172a;
}

body.theme-light .project-meta {
  color: #64748b;
}

body.theme-light .modal-subtitle {
  color: #64748b;
}

body.theme-light .chip-dims {
  color: #64748b;
}

body.theme-light .chip-badge {
  background: #e0f2fe;
  color: #0284c7;
}

body.theme-light .dim-label {
  color: #64748b;
}

body.theme-light .dim-times,
body.theme-light .dim-unit {
  color: #64748b;
}

body.theme-light .area-hud-metric {
  color: #475569;
}

body.theme-light .area-hud-secondary {
  color: #334155;
}

body.theme-light .cam-controls .btn {
  background: rgba(255, 255, 255, 0.9);
  color: #334155;
  border-color: #cbd5e1;
}

body.theme-light .cam-controls .btn:hover {
  background: #ffffff;
  color: #0284c7;
  border-color: #0284c7;
}

body.theme-light .viewport-hud {
  background: rgba(255, 255, 255, 0.94);
  border-color: #cbd5e1;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

body.theme-light .hud-btn {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #334155;
}

body.theme-light .hud-btn:hover {
  background: #f1f5f9;
  color: #0284c7;
  border-color: #0284c7;
}

body.theme-light .hud-zoom-text {
  color: #0f172a;
}

body.theme-light .hud-divider {
  background: #e2e8f0;
}

body.theme-light .modal-card {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.18);
  color: #0f172a;
}

body.theme-light .modal-header {
  border-bottom-color: #e2e8f0;
}

body.theme-light .modal-footer,
body.theme-light .wizard-footer {
  border-top-color: #e2e8f0;
  background: #f8fafc;
}

body.theme-light .btn {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #334155;
}

body.theme-light .btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

body.theme-light .status-cell-main {
  color: #334155;
}

body.theme-light .status-cell {
  border-right-color: #cbd5e1;
}

body.theme-light .preset-chip {
  background: #f8fafc;
  border-color: #e2e8f0;
}

body.theme-light .preset-chip:hover {
  border-color: #0284c7;
}

body.theme-light .preset-chip.active {
  background: #f0f9ff;
  border: 2px solid #0284c7;
}

body.theme-light .preset-chip .chip-title {
  color: #0f172a;
  font-weight: 600;
}

body.theme-light .preset-chip.active .chip-title {
  color: #0369a1;
  font-weight: 700;
}

body.theme-light .wizard-area-hud {
  background: #f8fafc;
  border-color: #e2e8f0;
}

body.theme-light .area-hud-primary {
  color: #0284c7;
}

body.theme-light .wizard-walls-box {
  background: #f8fafc;
  border-color: #e2e8f0;
}

body.theme-light .swatch-btn {
  background: #f8fafc;
  border-color: #cbd5e1;
}

body.theme-light .swatch-btn:hover {
  background: #f1f5f9;
  border-color: #0284c7;
}

body.theme-light .swatch-btn.active {
  background: #f0f9ff;
  border: 2px solid #0284c7;
  box-shadow: 0 0 0 1px #0284c7;
}

body.theme-light .swatch-label {
  color: #0f172a;
}

body.theme-light .room-detect-banner {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(2, 132, 199, 0.45);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(2, 132, 199, 0.2);
}

body.theme-light .detect-title {
  color: #0f172a;
}

body.theme-light .detect-desc {
  color: #475569;
}

body.theme-light .detect-desc strong {
  color: #0284c7;
}

/* ==========================================================================
   HIERARCHICAL CATALOG NAVIGATION & FOLDER CARDS
   ========================================================================== */
.catalog-breadcrumb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  margin-top: 2px;
}

.catalog-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s;
}

.catalog-back-btn:hover {
  background: var(--accent);
  color: #0b0f17;
}

body.theme-light .catalog-back-btn {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

body.theme-light .catalog-back-btn:hover {
  background: #0369a1;
  border-color: #0369a1;
  color: #ffffff;
}

.catalog-cat-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(56, 189, 248, 0.1);
  padding: 2px 7px;
  border-radius: 4px;
}

body.theme-light .catalog-cat-badge {
  color: #0f172a;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
}

.catalog-folder-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: #171c28;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.catalog-folder-card:hover {
  background: #202738;
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.12);
  transform: translateX(2px);
}

body.theme-light .catalog-folder-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
}

body.theme-light .catalog-folder-card:hover {
  background: #f8fafc;
  border-color: #0284c7;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.08);
}

.catalog-folder-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.folder-thumb-box {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 4px;
  overflow: hidden;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

body.theme-light .folder-thumb-box {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.folder-thumb-canvas {
  width: 36px;
  height: 36px;
  display: block;
}

.folder-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.folder-title {
  font-weight: 600;
  font-size: 11.5px;
  color: #e2e8f0;
}

body.theme-light .folder-title {
  color: #0f172a;
}

.folder-desc {
  font-size: 9.5px;
  color: #64748b;
  font-family: monospace;
}

body.theme-light .folder-desc {
  color: #64748b;
}

.catalog-folder-count {
  font-size: 10.5px;
  font-family: monospace;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 7px;
  border-radius: 8px;
}

body.theme-light .catalog-folder-count {
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  font-weight: 600;
}

/* ==========================================================================
   STORY LEVELS TAB BAR (MULTI-LEVEL DRAFTING)
   ========================================================================== */
.level-tabs-bar {
  position: absolute;
  top: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(12px);
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid rgba(51, 65, 85, 0.7);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  max-width: calc(100% - 140px);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  transition: all 0.2s ease;
}

.level-tabs-bar::-webkit-scrollbar {
  display: none;
}

.level-indicator-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.level-tabs-list {
  display: flex;
  align-items: center;
  gap: 4px;
}

.level-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: rgba(30, 41, 59, 0.6);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.level-tab:hover {
  background: rgba(51, 65, 85, 0.8);
  color: var(--text-primary);
}

.level-tab.active {
  background: var(--accent);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

.level-tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}

.level-tab-elev {
  font-size: 0.7rem;
  opacity: 0.8;
  padding: 1px 4px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
  font-family: monospace;
}

.level-tabs-divider {
  width: 1px;
  height: 18px;
  background: var(--border-subtle);
  margin: 0 4px;
}

.level-tab-action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: rgba(30, 41, 59, 0.6);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.level-tab-action-btn:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--accent);
}

.level-tab-action-btn.active {
  background: rgba(2, 132, 199, 0.15);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

/* 3D Camera Controls Divider */
.cam-controls-divider {
  width: 1px;
  height: 18px;
  background: var(--border-subtle);
  margin: 0 4px;
}

/* Story Levels Manager Modal Dynamic Rows */
.level-manager-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}

.level-row-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  transition: all 0.15s ease;
}

.level-row-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.level-row-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

.level-row-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.level-row-badge-active {
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--accent);
  color: #ffffff;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.level-row-metrics {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.level-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Light Theme Overrides - High WCAG Contrast */
body.theme-light .level-tabs-bar {
  background: rgba(255, 255, 255, 0.96);
  border-color: #cbd5e1;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

body.theme-light .level-tab {
  background: #f1f5f9;
  color: #1e293b;
  border-color: #cbd5e1;
}

body.theme-light .level-tab:hover {
  background: #e2e8f0;
  color: #0f172a;
}

body.theme-light .level-tab.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

body.theme-light .level-tab.active .level-tab-elev {
  background: rgba(0, 0, 0, 0.25);
  color: #ffffff;
}

body.theme-light .level-tab-action-btn {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #1e293b;
}

body.theme-light .level-tab-action-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #0284c7;
}

body.theme-light .level-tab-action-btn.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

body.theme-light .level-row-card {
  background: #ffffff;
  border-color: #cbd5e1;
}

body.theme-light .level-row-card.active {
  border-color: #0284c7;
  box-shadow: 0 0 0 1px #0284c7;
}

body.theme-light .level-row-title {
  color: #0f172a;
}

body.theme-light .level-row-metrics {
  color: #475569;
}

/* Ribbon Toolbar Toggle Hidden */
.toolstrip-ribbon.hidden,
#main-ribbon-toolbar.hidden {
  display: none !important;
}

/* Structural Alignment Advisor HUD */
.structural-advisor-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 6px 0 10px 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: all 0.2s ease;
}

.struct-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.struct-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.struct-badge.struct-ok {
  background: rgba(16, 185, 129, 0.16);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.struct-badge.struct-info {
  background: rgba(2, 132, 199, 0.16);
  color: #38bdf8;
  border: 1px solid rgba(2, 132, 199, 0.35);
}

.struct-badge.struct-warn {
  background: rgba(245, 158, 11, 0.16);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.struct-type-tag {
  font-size: 10px;
  font-family: monospace;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.2);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border-subtle);
}

.struct-card-body {
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-secondary);
}

/* Light Theme Overrides for Structural Advisor (WCAG High Contrast) */
body.theme-light .structural-advisor-card {
  background: #f8fafc;
  border-color: #cbd5e1;
}

body.theme-light .struct-badge.struct-ok {
  background: rgba(16, 185, 129, 0.14);
  color: #047857;
  border-color: #10b981;
}

body.theme-light .struct-badge.struct-info {
  background: rgba(2, 132, 199, 0.12);
  color: #0284c7;
  border-color: #0284c7;
}

body.theme-light .struct-badge.struct-warn {
  background: #fffbeb;
  color: #b45309;
  border-color: #f59e0b;
}

body.theme-light .struct-type-tag {
  color: #334155;
  background: #e2e8f0;
  border-color: #cbd5e1;
}

body.theme-light .struct-card-body {
  color: #1e293b;
}

/* Light Theme Overrides for Components Sidebar */
body.theme-light .sidebar-search-box .cad-search-input {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}

body.theme-light .sidebar-search-box .cad-search-input:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

body.theme-light .sidebar-search-box .search-clear-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

body.theme-light .catalog-back-btn {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #1e293b;
}

body.theme-light .catalog-back-btn:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

body.theme-light .category-list-row {
  border-bottom: 1px solid #e2e8f0;
}

body.theme-light .category-list-row:hover {
  background: #f1f5f9;
}

body.theme-light .category-row-name {
  color: #0f172a;
}

body.theme-light .category-row-count {
  background: #e2e8f0;
  color: #475569;
}

body.theme-light .category-row-icon {
  color: #475569;
}

body.theme-light .category-list-row:hover .category-row-icon,
body.theme-light .category-list-row:hover .category-row-arrow {
  color: #0284c7;
}

body.theme-light .catalog-grid-card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

body.theme-light .catalog-grid-card:hover {
  border-color: #0284c7;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.15);
}

body.theme-light .grid-card-title {
  color: #0f172a;
}

body.theme-light .grid-card-thumb-box {
  background: #f8fafc;
  border-color: #e2e8f0;
}

body.theme-light .grid-card-dims {
  color: #475569;
}

body.theme-light .grid-card-footer {
  border-top: 1px solid #e2e8f0;
}

body.theme-light .grid-card-add-btn {
  background: #e0f2fe;
  border-color: #38bdf8;
  color: #0284c7;
}

body.theme-light .grid-card-add-btn:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}
