/* ===== Zorin Dark Theme (default) ===== */
:root {
    --bg: #05070D;
    --panel: #0E1624;
    --secondary-panel: #111C2E;
    --border: #243044;
    --blue: #2F80ED;
    --cyan: #00D1FF;
    --green: #22C55E;
    --amber: #F59E0B;
    --red: #EF4444;
    --text: #F5F7FA;
    --muted: #9AA4B2;
  }
  
  /* Light theme overrides */
  body.light {
    --bg: #F8FAFC;
    --panel: #FFFFFF;
    --secondary-panel: #F1F5F9;
    --border: #CBD5E1;
    --text: #0F172A;
    --muted: #475569;
    --blue: #2563EB;
    --cyan: #0891B2;
  }
  
  * { margin:0; padding:0; box-sizing:border-box; }
  body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', 'Space Grotesk', system-ui, sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background 0.3s, color 0.3s;
  }
  
  #app {
    display: flex;
    flex-direction: column;
    height: 100vh;
  }
  
  /* Toolbar */
  .toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 1rem;
    flex-shrink: 0;
  }
  .toolbar-left { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
  .logo { font-weight: bold; color: var(--cyan); font-size: 1.2rem; margin-right: 1rem; }
  
  /* Dropdown menus */
  .dropdown {
    position: relative;
    display: inline-block;
  }
  .dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    z-index: 100;
    min-width: 180px;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  }
  .dropdown-content button {
    display: block;
    width: 100%;
    background: none;
    border: none;
    color: var(--text);
    padding: 0.5rem 1rem;
    text-align: left;
    font-size: 0.85rem;
    cursor: pointer;
  }
  .dropdown-content button:hover {
    background: var(--secondary-panel);
  }
  .dropdown:hover .dropdown-content { display: block; }
  
  .icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 1rem;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
  }
  .icon-btn:hover { background: var(--secondary-panel); }
  .back-link { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
  
  /* Main layout grid */
  .main-container {
    display: grid;
    grid-template-columns: 220px 1fr 260px;
    flex: 1;
    min-height: 0;
  }
  
  /* Sidebar */
  .sidebar {
    background: var(--panel);
    border-right: 1px solid var(--border);
    padding: 1rem;
    overflow-y: auto;
  }
  .left-sidebar { border-right: 1px solid var(--border); }
  .right-sidebar { border-left: 1px solid var(--border); border-right: none; }
  
  .tabs {
    display: flex;
    gap: 0.2rem;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
  }
  .tab {
    background: var(--secondary-panel);
    border: none;
    color: var(--muted);
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    flex: 1 0 auto;
  }
  .tab.active { background: var(--blue); color: #fff; }
  
  .object-list, .template-list, .zone-list, .utility-list, .parts-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
  }
  .object-item, .template-item, .zone-item, .utility-item, .part-item {
    background: var(--secondary-panel);
    border: 1px solid var(--border);
    padding: 0.5rem;
    border-radius: 4px;
    cursor: grab;
    font-size: 0.85rem;
  }
  .object-item:hover, .part-item:hover { border-color: var(--cyan); }
  
  /* Canvas */
  .canvas-wrapper {
    position: relative;
    overflow: hidden;
    background: var(--bg);
  }
  .canvas-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    display: flex;
    gap: 0.4rem;
    background: var(--panel);
    padding: 0.3rem;
    border-radius: 6px;
    border: 1px solid var(--border);
  }
  .canvas-controls button, .view-btn {
    background: var(--secondary-panel);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
  }
  .view-btn.active { background: var(--blue); }
  #zoomRange { width: 80px; }
  
  .floor-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
  }
  .floor {
    position: absolute;
    width: 5000px;   /* 5000 mm = 5000 * SCALE px? No, CSS pixels based on SCALE=2, so 5000mm * 2 = 10000px */
    height: 5000px;
    background-color: var(--bg);
    background-image:
      linear-gradient(var(--border) 1px, transparent 1px),
      linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 100px 100px; /* 50 mm grid at SCALE=2 */
    transform-origin: 0 0;
    transition: transform 0.3s ease;
  }
  
  /* Layout objects */
  .layout-object {
    position: absolute;
    background: var(--blue);
    border: 1px solid var(--cyan);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.7rem;
    cursor: move;
    user-select: none;
    overflow: hidden;
    transform-origin: center;
  }
  .layout-object.selected {
    border-color: var(--amber);
    box-shadow: 0 0 0 2px var(--amber);
  }
  .resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--amber);
    border: 1px solid #000;
  }
  .resize-handle.nw { top: -5px; left: -5px; cursor: nw-resize; }
  .resize-handle.ne { top: -5px; right: -5px; cursor: ne-resize; }
  .resize-handle.sw { bottom: -5px; left: -5px; cursor: sw-resize; }
  .resize-handle.se { bottom: -5px; right: -5px; cursor: se-resize; }
  
  /* Properties panel */
  #propForm { display: flex; flex-direction: column; gap: 0.5rem; }
  #propForm label { font-size: 0.8rem; display: flex; flex-direction: column; gap: 0.2rem; }
  #propForm input, #propForm textarea {
    background: var(--secondary-panel);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.3rem;
    border-radius: 4px;
  }
  .prop-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
  .prop-actions button {
    background: var(--red);
    border: none;
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
  }
  .prop-actions button:last-child { background: var(--blue); }
  
  /* Bottom Panel */
  .bottom-panel {
    background: var(--panel);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    height: 200px;
    display: flex;
    flex-direction: column;
  }
  .bottom-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
  }
  .bottom-tab {
    background: transparent;
    border: none;
    color: var(--muted);
    padding: 0.5rem 1rem;
    cursor: pointer;
  }
  .bottom-tab.active { background: var(--secondary-panel); color: var(--cyan); }
  .bottom-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    font-size: 0.85rem;
    color: var(--text);
  }
  
  /* Status bar */
  .status-bar {
    background: var(--secondary-panel);
    border-top: 1px solid var(--border);
    padding: 0.3rem 1rem;
    display: flex;
    gap: 1.5rem;
    font-size: 0.75rem;
    color: var(--muted);
    flex-wrap: wrap;
  }
  
  .hidden { display: none !important; }
  
  /* Light theme adjustments for canvas */
  body.light .floor {
    background-color: #F8FAFC;
    background-image:
      linear-gradient(#CBD5E1 1px, transparent 1px),
      linear-gradient(90deg, #CBD5E1 1px, transparent 1px);
  }
  body.light .layout-object {
    color: #0F172A;
    font-weight: 600;
  }