@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ===== Design tokens ===== */
:root {
    --font-ui: 'Manrope', 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;

    --bg-app: #0e1318;
    --bg-chrome: #141a21;
    --bg-chrome-elevated: #1a222c;
    --bg-panel: #f4f6f8;
    --bg-panel-elevated: #ffffff;
    --bg-canvas: #1c2430;

    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-panel: rgba(15, 23, 32, 0.08);
    --border-strong: rgba(15, 23, 32, 0.14);

    --text-chrome: #e8eef4;
    --text-chrome-muted: #8b9aab;
    --text-panel: #1a2330;
    --text-panel-muted: #5c6b7a;

    --accent: #0f9f8a;
    --accent-hover: #0d8a78;
    --accent-soft: rgba(15, 159, 138, 0.14);
    --accent-strong: rgba(15, 159, 138, 0.28);
    --danger: #e25555;
    --warning: #d97706;
    --info: #3b82f6;

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.18);
    --shadow-float: 0 10px 30px rgba(0, 0, 0, 0.28);

    --menu-height: 32px;
    --left-dock-width: 44px;
    --right-object-list-width: 180px;
    --right-properties-width: 180px;
    --right-collapsed-width: 28px;

    --tool-size: 28px;
    --tool-icon: 14px;
    --transition-fast: 140ms ease;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-ui);
    background: var(--bg-app);
    color: var(--text-panel);
    overflow: hidden;
    height: 100vh;
    direction: ltr;
    text-align: left;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-app);
}

/* Menu Bar Styles */
.menu-bar {
    background: var(--bg-chrome);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 6px;
    display: flex;
    align-items: center;
    height: var(--menu-height);
    box-shadow: none;
    z-index: 2000;
    justify-content: flex-start;
    gap: 2px;
}

.menu-item {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
    flex: none;
}

.menu-label {
    padding: 0 12px;
    height: 100%;
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: var(--text-chrome-muted);
    transition: color var(--transition-fast), background-color var(--transition-fast);
    user-select: none;
}

.menu-label:hover {
    background-color: rgba(255, 255, 255, 0.06);
    color: var(--text-chrome);
}

.menu-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 4px;
    background: var(--bg-panel-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 210px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: all var(--transition-fast);
    z-index: 2001;
    padding: 4px;
    overflow: hidden;
}

.menu-item:hover .menu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.menu-option {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12.5px;
    color: var(--text-panel);
    transition: background-color var(--transition-fast);
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    white-space: nowrap;
    border-radius: var(--radius-sm);
}

.menu-option.disabled {
    opacity: 0.45;
    pointer-events: none;
    cursor: default;
}

.menu-option:hover {
    background-color: var(--accent-soft);
    color: var(--accent-hover);
}

.menu-option:first-child {
    border-radius: var(--radius-sm);
}

.menu-option:last-child {
    border-radius: var(--radius-sm);
}

.menu-option .menu-text {
    flex: 1;
}

.menu-option .shortcut {
    color: var(--text-panel-muted);
    font-size: 11px;
    font-family: var(--font-mono);
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: auto;
}

.menu-separator {
    height: 1px;
    background-color: var(--border-panel);
    margin: 4px 6px;
}

.menu-item-right {
    margin-left: auto;
}

/* Submenu Styles */
.menu-option.has-submenu {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.submenu-arrow {
    font-size: 10px;
    color: #666;
    transition: transform 0.2s ease;
}

.menu-option.has-submenu:hover .submenu-arrow {
    transform: rotate(90deg);
}

.submenu {
    position: absolute;
    left: 100%;
    top: 0;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 140px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px);
    transition: all 0.2s ease;
    z-index: 2002;
}

.menu-option.has-submenu:hover .submenu {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.submenu .menu-option {
    padding: 8px 16px;
    border-radius: 0;
    white-space: nowrap;
}

.submenu .menu-option:first-child {
    border-radius: 4px 4px 0 0;
}

.submenu .menu-option:last-child {
    border-radius: 0 0 4px 4px;
}

/* Preferences Window Styles */
.preferences-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 420px;
    max-height: 80vh;
    background: var(--bg-panel-elevated);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-float);
    border: 1px solid var(--border-strong);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
    overflow: hidden;
    font-family: var(--font-ui);
}

.preferences-window.show {
    opacity: 1;
    visibility: visible;
}

.preferences-header {
    background: var(--bg-chrome);
    border-bottom: 1px solid var(--border-subtle);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preferences-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.close-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.preferences-content {
    padding: 20px;
    max-height: calc(80vh - 80px);
    overflow-y: auto;
}

.preferences-section {
    margin-bottom: 24px;
}

.preferences-section:last-child {
    margin-bottom: 0;
}

.preferences-section h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

.preferences-section .control-group {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.preferences-section .control-group.control-group-vertical {
    flex-direction: column;
    align-items: flex-start;
}

.preferences-section .control-group:last-child {
    margin-bottom: 0;
}

.preferences-section label {
    font-size: 14px;
    color: #555;
    font-weight: 500;
    min-width: 120px;
}

.preferences-section input[type="range"] {
    flex: 1;
    margin: 0 12px;
}

.preferences-section span {
    font-size: 12px;
    color: #666;
    min-width: 30px;
    text-align: right;
}

.preferences-section .btn {
    width: 100%;
    justify-content: center;
}

/* Overlay for preferences window */
.preferences-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.preferences-overlay.show {
    opacity: 1;
    visibility: visible;
}


/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: visible;
    min-height: 0;
}

/* Canvas Container */
.canvas-container {
    flex: 1;
    min-width: 0;
    position: relative;
    background:
        radial-gradient(1200px 600px at 20% 0%, rgba(15, 159, 138, 0.08), transparent 55%),
        radial-gradient(900px 500px at 90% 100%, rgba(59, 130, 246, 0.06), transparent 50%),
        var(--bg-canvas);
    overflow: hidden;
}

.left-dock {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: var(--left-dock-width);
    height: 100%;
    align-self: stretch;
    gap: 4px;
    padding: 6px 4px;
    box-sizing: border-box;
    background: var(--bg-chrome);
    border-right: 1px solid var(--border-subtle);
    overflow: visible;
    z-index: 30;
}

/* Right dock sits beside the canvas and drives viewport width */
.right-dock {
    display: flex;
    flex-shrink: 0;
    height: 100%;
    align-self: stretch;
    z-index: 20;
    overflow: hidden;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.18);
}

.properties-dock {
    width: var(--right-properties-width);
    flex-shrink: 0;
    position: relative;
    height: 100%;
    overflow: hidden;
    transition: width 0.2s ease;
    background: var(--bg-panel);
    border-left: 1px solid var(--border-panel);
}

.object-list-dock {
    width: var(--right-object-list-width);
    flex-shrink: 0;
    position: relative;
    height: 100%;
    overflow: hidden;
    transition: width 0.2s ease;
    background: var(--bg-panel);
    border-left: 1px solid var(--border-panel);
}

/* Sidebar Styles */
.sidebar {
    width: 300px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    padding: 1.5rem;
    overflow-y: auto;
    box-shadow: -2px 0 20px rgba(0, 0, 0, 0.1);
}

.sidebar-section {
    margin-bottom: 2rem;
}

.sidebar-section h3 {
    color: #2c3e50;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #3498db;
}

.control-group {
    margin-bottom: 1rem;
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #555;
    font-weight: 500;
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    background: #3498db;
    color: white;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
}

.btn-primary {
    background: var(--accent);
}

.btn-secondary {
    background: #64748b;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

/* Toggle Button */
.toggle-btn {
    width: 50px;
    height: 30px;
    border: none;
    border-radius: 15px;
    background: #bdc3c7;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-btn.active {
    background: #27ae60;
}

.toggle-btn::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    transition: all 0.3s ease;
    left: 3px;
}

.toggle-btn.active::after {
    left: 23px;
}

/* Statistics Toggle Button */
.btn-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: #f8f9fa;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    min-width: 140px;
}

.btn-toggle:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.btn-toggle.active {
    background-color: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

.btn-toggle .toggle-text {
    margin-left: 8px;
}

.btn-toggle.active .toggle-text::after {
    content: " (ON)";
    font-weight: bold;
}

.btn-toggle:not(.active) .toggle-text::after {
    content: " (OFF)";
    opacity: 0.7;
}

/* Input Styles */
input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

#renderCanvas {
    width: 100%;
    height: 100%;
    display: block;
    outline: none;
    cursor: grab;
    touch-action: none;
    user-select: none;
    pointer-events: auto;
    position: relative;
    z-index: 1;
}

/* Drawing mode cursor - override with !important */
#renderCanvas.drawing-mode {
    cursor: crosshair !important;
}

/* Drawing coordinates tooltip */
.drawing-coordinates-tooltip {
    position: fixed !important;
    pointer-events: none !important;
    background: rgba(0, 0, 0, 0.85) !important;
    color: white !important;
    padding: 6px 10px !important;
    border-radius: 4px !important;
    font-size: 12px !important;
    font-family: monospace !important;
    white-space: nowrap !important;
    z-index: 99999 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
    /* Remove transform - we set position directly via JavaScript */
}

.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

/* Loading Spinner */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: white;
    font-size: 1.1rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Footer */

/* Icon Styles */
.icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        width: 250px;
    }
    
    
}

/* Range Value Display */
.control-group span {
    display: inline-block;
    margin-left: 0.5rem;
    color: #3498db;
    font-weight: 600;
    min-width: 30px;
}

/* Scrollbar Styling */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(52, 152, 219, 0.5);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(52, 152, 219, 0.7);
}

/* Compass Styles */
.compass {
    position: fixed;
    bottom: 20px;
    left: calc(var(--left-dock-width, 48px) + 12px);
    width: 80px;
    height: 80px;
    z-index: 1000;
    pointer-events: none;
}

.compass-inner {
    position: relative;
    width: 100%;
    height: 100%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.compass-needle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 30px;
    background: #ff4444;
    transform-origin: center bottom;
    transform: translate(-50%, -100%) rotate(0deg);
    border-radius: 1px;
    box-shadow: 0 0 5px rgba(255, 68, 68, 0.5);
}

.compass-needle::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -3px;
    width: 8px;
    height: 8px;
    background: #ff4444;
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(255, 68, 68, 0.5);
}

.compass-labels {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.compass-label {
    position: absolute;
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.compass-north {
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
}

.compass-east {
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
}

.compass-south {
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
}

.compass-west {
    left: 5px;
    top: 50%;
    transform: translateY(-50%);
}

/* Drawing Tools Panel Styles — compact icon rail */
.drawing-panel {
    position: relative;
    width: 100%;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    flex-shrink: 0;
}

.panel-header {
    display: none;
}

.panel-header h3 {
    display: none;
}

/* Mobile specific adjustments */
@media (max-width: 768px) {
    :root {
        --left-dock-width: 44px;
        --tool-size: 28px;
        --tool-icon: 14px;
    }
}

@media (max-width: 480px) {
    :root {
        --left-dock-width: 40px;
        --tool-size: 26px;
        --tool-icon: 13px;
    }
}

.drawing-tools {
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: center;
}

.drawing-tools .tool-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--tool-size);
    height: var(--tool-size);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
    flex-shrink: 0;
}

.drawing-tools .tool-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
    transform: none;
}

.drawing-tools .tool-item .tool-icon {
    width: var(--tool-icon);
    height: var(--tool-icon);
    filter: brightness(0) saturate(100%) invert(92%);
    opacity: 0.9;
}

/* Measurement Tools Panel Styles */
.measurement-panel {
    position: relative;
    width: 100%;
    background: transparent;
    border: none;
    border-top: 1px solid var(--border-subtle);
    border-radius: 0;
    padding: 4px 0 0;
    margin-top: 2px;
    box-shadow: none;
    flex-shrink: 0;
}

.measurement-tools {
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: center;
}

.measurement-tools .tool-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--tool-size);
    height: var(--tool-size);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
    flex-shrink: 0;
}

.measurement-tools .tool-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
    transform: none;
}

.measurement-tools .tool-item .tool-icon {
    width: var(--tool-icon);
    height: var(--tool-icon);
    filter: brightness(0) saturate(100%) invert(92%);
    opacity: 0.9;
}

.measurement-tools .tool-item.active {
    background: var(--accent-soft);
    border-color: rgba(15, 159, 138, 0.45);
    box-shadow: none;
}

.measurement-tools .tool-item.active .tool-icon {
    filter: brightness(0) saturate(100%) invert(64%) sepia(42%) saturate(700%) hue-rotate(118deg) brightness(95%) contrast(95%);
    opacity: 1;
}

/* Tree Tool Submenu Indicator */
.drawing-tools .tool-item[data-tool="tree"] {
    position: relative;
}

.drawing-tools .tool-item[data-object-type].active {
    background: var(--accent-soft);
    border-color: rgba(15, 159, 138, 0.45);
    box-shadow: none;
}

.drawing-tools .tool-item[data-object-type="building"].active {
    background: rgba(226, 232, 240, 0.12);
    border-color: rgba(226, 232, 240, 0.35);
}

.drawing-tools .tool-item[data-object-type="ground"].active {
    background: rgba(180, 130, 70, 0.22);
    border-color: rgba(180, 130, 70, 0.45);
}

.drawing-tools .tool-item[data-object-type="grass"].active {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.4);
}

.drawing-tools .tool-item[data-object-type="highway"].active {
    background: rgba(148, 163, 184, 0.18);
    border-color: rgba(148, 163, 184, 0.4);
}

.drawing-tools .tool-item[data-object-type="waterway"].active {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.45);
}

/* Shape submenu (geometry tools for selected object type) — horizontal */
.shape-submenu {
    position: absolute;
    left: 100%;
    top: 0;
    margin-left: 6px;
    display: none;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    background: var(--bg-chrome-elevated);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 5px 6px;
    z-index: 1001;
    white-space: nowrap;
    box-shadow: var(--shadow-float);
}

.shape-submenu-label {
    color: var(--text-chrome-muted);
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: center;
    margin-right: 2px;
    flex-shrink: 0;
}

.shape-tools {
    display: flex;
    flex-direction: row;
    gap: 3px;
    align-items: center;
}

.shape-tools .tool-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--tool-size);
    height: var(--tool-size);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.shape-tools .tool-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
}

.shape-tools .tool-item .tool-icon {
    width: var(--tool-icon);
    height: var(--tool-icon);
    filter: brightness(0) saturate(100%) invert(92%);
}

.shape-tools .tool-item[data-tool="rectangle"].active {
    background: rgba(52, 152, 219, 0.45) !important;
    border-color: rgba(52, 152, 219, 0.9) !important;
    box-shadow: 0 0 10px rgba(52, 152, 219, 0.45) !important;
}

.shape-tools .tool-item[data-tool="rectangle"].active .tool-icon {
    filter: brightness(0) saturate(100%) invert(50%) sepia(100%) saturate(2000%) hue-rotate(200deg) brightness(100%) contrast(100%) !important;
}

.shape-tools .tool-item[data-tool="circle"].active {
    background: rgba(155, 89, 182, 0.45) !important;
    border-color: rgba(155, 89, 182, 0.9) !important;
    box-shadow: 0 0 10px rgba(155, 89, 182, 0.45) !important;
}

.shape-tools .tool-item[data-tool="circle"].active .tool-icon {
    filter: brightness(0) saturate(100%) invert(50%) sepia(100%) saturate(2000%) hue-rotate(280deg) brightness(100%) contrast(100%) !important;
}

.shape-tools .tool-item[data-tool="polygon"].active {
    background: rgba(230, 126, 34, 0.45) !important;
    border-color: rgba(230, 126, 34, 0.9) !important;
    box-shadow: 0 0 10px rgba(230, 126, 34, 0.45) !important;
}

.shape-tools .tool-item[data-tool="polygon"].active .tool-icon {
    filter: brightness(0) saturate(100%) invert(50%) sepia(100%) saturate(2000%) hue-rotate(30deg) brightness(100%) contrast(100%) !important;
}

.tree-submenu-indicator {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 5px solid rgba(255, 255, 255, 0.7);
    pointer-events: none;
    user-select: none;
}

/* Tree Tool Styles - removed tool-label styles since tree button doesn't have text */

/* Tree Submenu Styles */
.tree-submenu {
    position: absolute;
    left: 100%;
    top: 0;
    margin-left: 6px;
    background: var(--bg-chrome-elevated);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 5px;
    min-width: 48px;
    z-index: 1001;
    box-shadow: var(--shadow-float);
}

.tree-option {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
}

.tree-option:last-child {
    margin-bottom: 0;
}

.tree-option:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
}

.tree-option.active {
    background: rgba(155, 89, 182, 0.3);
    border-color: rgba(155, 89, 182, 0.6);
    box-shadow: 0 0 10px rgba(155, 89, 182, 0.3);
}

.tree-option .tree-icon {
    width: 16px;
    height: 16px;
    filter: brightness(0) saturate(100%) invert(100%);
}

.tree-option.active .tree-icon {
    filter: brightness(0) saturate(100%) invert(50%) sepia(100%) saturate(2000%) hue-rotate(280deg) brightness(100%) contrast(100%);
}

/* Tree Height Controls */
.tree-height-controls {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.height-control-group {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    gap: 6px;
}

.height-control-group:last-child {
    margin-bottom: 0;
}

.height-control-group label {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.8);
    min-width: 25px;
    text-align: left;
}

.height-control-group input[type="number"] {
    flex: 1;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    outline: none;
    color: rgba(255, 255, 255, 0.9);
    font-size: 10px;
    padding: 0 4px;
    text-align: center;
}

.height-control-group input[type="number"]:focus {
    border-color: #3498db;
    background: rgba(255, 255, 255, 0.15);
}

.height-control-group input[type="number"]::-webkit-outer-spin-button,
.height-control-group input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.height-control-group input[type="number"] {
    -moz-appearance: textfield;
}

/* Transform Tools Panel Styles */
.transform-panel {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 26, 34, 0.92);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    padding: 4px 8px;
    z-index: 10;
    box-shadow: var(--shadow-float);
}

.transform-tools {
    display: flex;
    gap: 2px;
    align-items: center;
    justify-content: center;
}

.transform-panel .tool-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-radius: 999px;
    min-width: 32px;
    min-height: 32px;
    position: relative;
    border: 1px solid transparent;
}

.transform-panel .tool-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.transform-panel .tool-item.active {
    background: var(--accent-soft);
    border: 1px solid rgba(15, 159, 138, 0.4);
}

.transform-panel .tool-item.active::after {
    content: '';
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
}

.transform-panel .tool-icon {
    width: 16px;
    height: 16px;
    filter: brightness(0) saturate(100%) invert(78%);
    transition: filter var(--transition-fast);
}

.transform-panel .tool-item.active .tool-icon {
    filter: brightness(0) saturate(100%) invert(64%) sepia(42%) saturate(700%) hue-rotate(118deg) brightness(95%) contrast(95%);
}

/* Coordinate Toggle Button Styles */
#coordinateToggle {
    border-left: 1px solid var(--border-subtle);
    margin-left: 6px;
    padding-left: 8px;
    position: relative;
}

#coordinateToggle::before {
    display: none;
}

#coordinateToggle.global-mode {
    background: rgba(231, 76, 60, 0.3);
    border: 1px solid rgba(231, 76, 60, 0.6);
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.3);
}

#coordinateToggle.global-mode .tool-icon {
    filter: brightness(0) saturate(100%) invert(30%) sepia(100%) saturate(2000%) hue-rotate(0deg) brightness(100%) contrast(100%);
}

#coordinateToggle.local-mode {
    background: rgba(46, 204, 113, 0.3);
    border: 1px solid rgba(46, 204, 113, 0.6);
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.3);
}

#coordinateToggle.local-mode .tool-icon {
    filter: brightness(0) saturate(100%) invert(50%) sepia(100%) saturate(2000%) hue-rotate(100deg) brightness(100%) contrast(100%);
}

#coordinateToggle:hover {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

/* Right dock panel widths (object list + properties) */
body.object-list-collapsed {
    --right-object-list-width: var(--right-collapsed-width);
}

body.properties-collapsed {
    --right-properties-width: var(--right-collapsed-width);
}

/* Properties panels fill the properties dock slot */
.properties-popup {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-panel);
    z-index: 1;
    display: none;
    overflow: hidden;
    font-family: var(--font-ui);
}

.properties-popup.show {
    display: flex;
    flex-direction: column;
}

.properties-popup .properties-content {
    flex: 1;
    overflow-y: auto;
}

.properties-empty-content {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #666;
    min-height: 160px;
    padding: 24px;
}

.properties-empty-content p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

/* Circle, Polygon, Tree, and STL Properties Popup - fill properties dock */
#circlePropertiesPopup,
#polygonPropertiesPopup,
#treePropertiesPopup,
#stlPropertiesPopup,
#propertiesEmptyPanel {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-panel);
    z-index: 1;
    display: none;
    overflow: hidden;
    font-family: var(--font-ui);
}

#circlePropertiesPopup.show,
#polygonPropertiesPopup.show,
#treePropertiesPopup.show,
#stlPropertiesPopup.show,
#propertiesEmptyPanel.show {
    display: flex;
    flex-direction: column;
}

/* Collapsed properties: keep a strip, hide form content */
body.properties-collapsed .properties-popup.show .properties-content {
    display: none;
}

body.properties-collapsed .properties-popup.show .properties-header {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    height: 100%;
    padding: 12px 4px;
}

body.properties-collapsed .properties-popup.show .properties-header h3 {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    font-size: 12px;
    letter-spacing: 0.5px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.properties-collapsed .properties-popup.show {
    cursor: pointer;
}

.properties-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: var(--bg-chrome);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-chrome);
    flex-shrink: 0;
}

.properties-header h3 {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text-chrome);
}

.close-btn,
.collapse-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 14px;
    cursor: pointer;
    color: var(--text-chrome);
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.close-btn:hover,
.collapse-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.collapse-btn {
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
}

.properties-content {
    padding: 8px 10px 12px;
}

/* Stacked field layout: label above control */
.properties-popup .property-group,
#propertiesEmptyPanel .property-group,
#circlePropertiesPopup .property-group,
#polygonPropertiesPopup .property-group,
#treePropertiesPopup .property-group,
#stlPropertiesPopup .property-group {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 2px;
    margin-bottom: 7px;
}

.properties-popup .property-group[style*="display: none"],
.properties-popup .property-group[style*="display:none"],
#circlePropertiesPopup .property-group[style*="display: none"],
#circlePropertiesPopup .property-group[style*="display:none"],
#polygonPropertiesPopup .property-group[style*="display: none"],
#polygonPropertiesPopup .property-group[style*="display:none"],
#treePropertiesPopup .property-group[style*="display: none"],
#treePropertiesPopup .property-group[style*="display:none"],
#stlPropertiesPopup .property-group[style*="display: none"],
#stlPropertiesPopup .property-group[style*="display:none"] {
    display: none !important;
}

.property-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 7px;
    gap: 2px;
}

.property-group label {
    min-width: 0;
    width: 100%;
    font-weight: 600;
    color: var(--text-panel-muted);
    font-size: 10px;
    line-height: 1.15;
    letter-spacing: 0.01em;
    text-transform: none;
    flex-shrink: 0;
}

.property-group input,
.property-group select {
    width: 100%;
    flex: none;
    padding: 5px 8px;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    font-size: 12px;
    font-family: var(--font-ui);
    background: var(--bg-panel-elevated);
    color: var(--text-panel);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    min-height: 28px;
    height: 28px;
}

.property-group input:focus,
.property-group select:focus {
    outline: none;
    border-color: rgba(15, 159, 138, 0.55);
    box-shadow: 0 0 0 2px rgba(15, 159, 138, 0.16);
}

.property-group input[type="color"] {
    width: 50px;
    height: 40px;
    padding: 4px;
    cursor: pointer;
}

.property-group input[type="number"] {
    -webkit-appearance: textfield;
    -moz-appearance: textfield;
    appearance: textfield;
}

.property-group input[type="number"]::-webkit-outer-spin-button,
.property-group input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: inner-spin-button;
    opacity: 1;
    height: 20px;
    width: 20px;
    cursor: pointer;
}

/* Remove spinner arrows for readonly number inputs */
.property-group input[type="number"][readonly] {
    -webkit-appearance: textfield;
    -moz-appearance: textfield;
    appearance: textfield;
}

.property-group input[type="number"][readonly]::-webkit-outer-spin-button,
.property-group input[type="number"][readonly]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

.property-group input[readonly] {
    background-color: #f8f9fa;
    color: #666;
    cursor: default;
    padding-right: 12px; /* Ensure consistent padding without spinner */
}

.property-group .error-message {
    display: block;
    color: #dc3545;
    font-size: 12px;
    margin-top: 4px;
    padding: 4px 8px;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
}

.properties-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--accent);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
}

.btn-secondary {
    background-color: #64748b;
    color: white;
}

.btn-secondary:hover {
    background-color: #475569;
}

/* Popup Overlay */
.properties-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2999;
    display: none;
}

.properties-overlay.show {
    display: block;
}

/* Object List Panel Styles */
.object-list-panel {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-panel);
    z-index: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--font-ui);
}

.object-list-panel.collapsed .object-list-container {
    display: none;
}

.object-list-panel.collapsed {
    cursor: pointer;
}

.object-list-panel.collapsed .object-list-header {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    height: 100%;
    padding: 12px 4px;
}

.object-list-panel.collapsed .object-list-header h3 {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    font-size: 12px;
    letter-spacing: 0.5px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.object-list-header {
    background: var(--bg-chrome);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-chrome);
    padding: 8px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.object-list-header h3 {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text-chrome);
}

.refresh-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-chrome);
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.refresh-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.object-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px 12px;
}

.object-list-container::-webkit-scrollbar {
    width: 6px;
}

.object-list-container::-webkit-scrollbar-track {
    background: rgba(15, 23, 32, 0.06);
    border-radius: 3px;
}

.object-list-container::-webkit-scrollbar-thumb {
    background: rgba(15, 159, 138, 0.35);
    border-radius: 3px;
}

.object-list-container::-webkit-scrollbar-thumb:hover {
    background: rgba(15, 159, 138, 0.55);
}

/* Category Styles */
.object-category {
    margin-bottom: 7px;
    border: 1px solid var(--border-panel);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-panel-elevated);
}

.category-header {
    background: rgba(15, 23, 32, 0.04);
    padding: 6px 8px;
    cursor: default;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-panel);
    transition: background-color var(--transition-fast);
}

.category-header:hover {
    background: rgba(15, 23, 32, 0.07);
}

.category-info {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.category-actions {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}

.category-visibility,
.category-select,
.object-visibility {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    background: var(--accent);
    color: white;
    border-radius: var(--radius-sm);
    line-height: 1;
    transition: background-color var(--transition-fast);
    user-select: none;
    flex-shrink: 0;
}

.category-visibility:hover,
.category-select:hover,
.object-visibility:hover {
    background: var(--accent-hover);
}

.category-visibility.hidden,
.object-visibility.hidden {
    background: var(--danger);
}

.category-visibility.hidden:hover,
.object-visibility.hidden:hover {
    background: #c94444;
}

.category-select {
    background: var(--info);
}

.category-select:hover {
    background: #2563eb;
}

.category-action-icon {
    width: 11px;
    height: 11px;
    display: block;
    filter: brightness(0) invert(1);
    pointer-events: none;
}

.category-name {
    font-weight: 600;
    color: var(--text-panel);
    font-size: 10px;
    line-height: 1.15;
    letter-spacing: 0.01em;
}

.category-count {
    color: var(--text-panel-muted);
    font-size: 10px;
    margin-left: 4px;
}

.category-toggle {
    color: var(--text-panel-muted);
    font-size: 10px;
    transition: transform var(--transition-fast);
}

.category-content {
    max-height: 300px;
    overflow-y: auto;
}

/* Object Item Styles */
.object-item {
    display: flex;
    align-items: center;
    padding: 5px 8px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-panel);
    transition: background-color var(--transition-fast);
    background: var(--bg-panel-elevated);
    gap: 6px;
}

.object-item:last-child {
    border-bottom: none;
}

.object-item:hover {
    background: rgba(15, 159, 138, 0.06);
}

.object-item.selected {
    background: var(--accent-soft);
    border-left: 2px solid var(--accent);
}

.object-icon {
    font-size: 12px;
    margin-right: 0;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
    color: var(--text-panel-muted);
}

.object-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.object-name {
    font-weight: 500;
    color: var(--text-panel);
    font-size: 11px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.object-type {
    font-size: 9px;
    color: var(--text-panel-muted);
    text-transform: none;
    letter-spacing: 0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.object-visibility {
    margin-left: auto;
}

.object-visibility:hover {
    background: var(--accent-hover);
}

.object-visibility.hidden {
    background: var(--danger);
}

.object-visibility.hidden:hover {
    background: #c94444;
}

/* Empty State */
.object-list-empty {
    text-align: center;
    padding: 24px 10px;
    color: var(--text-panel-muted);
}

.object-list-empty .empty-icon {
    font-size: 28px;
    margin-bottom: 10px;
    opacity: 0.5;
}

.object-list-empty h4 {
    margin: 0 0 6px 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-panel);
}

.object-list-empty p {
    margin: 0;
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-panel-muted);
}

/* Responsive Design */
@media (max-width: 768px) {
    :root {
        --right-object-list-width: 170px;
        --right-properties-width: 170px;
    }
    
    .property-group label {
        min-width: 0;
        font-size: 11px;
    }
    
    .object-list-header {
        padding: 8px 10px;
    }
    
    .object-list-header h3 {
        font-size: 12px;
    }
    
    .object-item {
        padding: 5px 8px;
    }
    
    .object-name {
        font-size: 11px;
    }
    
    .object-type {
        font-size: 9px;
    }
}

@media (max-width: 480px) {
    :root {
        --right-object-list-width: 150px;
        --right-properties-width: 150px;
    }
    
    .property-group label {
        min-width: 0;
        font-size: 10px;
    }
    
    .property-group input,
    .property-group select {
        font-size: 12px;
        padding: 6px 8px;
    }
    
    .object-list-header {
        padding: 8px 10px;
    }
    
    .object-list-header h3 {
        font-size: 12px;
    }
    
    .object-item {
        padding: 4px 6px;
    }
    
    .object-icon {
        font-size: 14px;
        margin-right: 8px;
    }
}

/* Properties Panel Styles */
.properties-panel {
    position: fixed;
    top: calc(28px + 66.67vh + 10px); /* Below object list panel */
    right: 0;
    width: 300px;
    height: calc(100vh - 28px - 66.67vh - 20px); /* Remaining height */
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: -2px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 1500;
    display: none;
    overflow-y: auto;
}

.properties-panel.show {
    display: block;
}

.properties-header {
    background: var(--bg-chrome);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-chrome);
    padding: 8px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1;
    flex-shrink: 0;
}

.properties-header h3 {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text-chrome);
}

.close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.properties-content {
    padding: 16px;
}

.properties-empty {
    text-align: center;
    color: #666;
    padding: 40px 20px;
}

.properties-empty p {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 500;
}

.properties-empty small {
    font-size: 14px;
    color: #999;
}

.property-section {
    margin-bottom: 20px;
}

.property-section h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #eee;
    padding-bottom: 6px;
}

.property-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 7px;
    gap: 2px;
}

.property-group label {
    display: block;
    margin-bottom: 0;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-panel-muted);
    text-transform: none;
    letter-spacing: 0.01em;
    min-width: 0;
    width: 100%;
}

.property-group input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    font-size: 12px;
    background: var(--bg-panel-elevated);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    min-height: 28px;
    height: 28px;
}

.property-group input:focus {
    outline: none;
    border-color: rgba(15, 159, 138, 0.55);
    box-shadow: 0 0 0 2px rgba(15, 159, 138, 0.16);
}

.property-group input[readonly] {
    background-color: #eef1f4;
    color: #666;
    cursor: not-allowed;
}

.property-group select {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    font-size: 12px;
    background: var(--bg-panel-elevated);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    min-height: 28px;
    height: 28px;
}

.property-group select:focus {
    outline: none;
    border-color: rgba(15, 159, 138, 0.55);
    box-shadow: 0 0 0 2px rgba(15, 159, 138, 0.16);
}

.property-group input[type="color"] {
    width: 100%;
    height: 40px;
    padding: 4px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.property-group input[type="color"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.property-actions {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
}

.btn-primary, .btn-secondary {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 159, 138, 0.28);
}

.btn-secondary {
    background: #f8f9fa;
    color: #666;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background: #e9ecef;
    border-color: #ccc;
}

/* Responsive Design for Properties Panel */
@media (max-width: 768px) {
    .properties-panel {
        width: 200px;
        height: calc(100vh - 28px - 60vh - 20px);
    }
    
    .properties-header {
        padding: 10px 12px;
    }
    
    .properties-header h3 {
        font-size: 14px;
    }
    
    .properties-content {
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .properties-panel {
        width: 200px;
        height: calc(100vh - 28px - 50vh - 20px);
    }
    
    .properties-header {
        padding: 8px 10px;
    }
    
    .properties-header h3 {
        font-size: 12px;
    }
    
    .properties-content {
        padding: 10px;
    }
}


/* Responsive Design */
@media (max-width: 768px) {
    .left-dock {
        padding: 8px 4px;
        gap: 8px;
    }

    .drawing-panel,
    .measurement-panel {
        padding: 4px;
    }
    
    .drawing-tools .tool-item,
    .measurement-tools .tool-item {
        width: 28px;
        height: 28px;
    }
    
    .drawing-tools .tool-item .tool-icon,
    .measurement-tools .tool-item .tool-icon {
        width: 14px;
        height: 14px;
    }
    
    .panel-header h3 {
        font-size: 9px;
    }
}

/* ===== MODAL DIALOG STYLES ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal-dialog {
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    min-width: 400px;
    max-width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.modal-close:hover {
    background-color: #f0f0f0;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

/* ===== DRAWING TOOLS ACTIVE STATES - FINAL OVERRIDE ===== */
/* Rectangle tool active state - Blue */
#drawingPanel .drawing-tools .tool-item[data-tool="rectangle"].active {
    background: rgba(52, 152, 219, 0.3) !important;
    border-color: rgba(52, 152, 219, 0.6) !important;
    box-shadow: 0 0 10px rgba(52, 152, 219, 0.3) !important;
}

/* Circle tool active state - Purple */
#drawingPanel .drawing-tools .tool-item[data-tool="circle"].active {
    background: rgba(155, 89, 182, 0.3) !important;
    border-color: rgba(155, 89, 182, 0.6) !important;
    box-shadow: 0 0 10px rgba(155, 89, 182, 0.3) !important;
}

/* Polygon tool active state - Orange */
#drawingPanel .drawing-tools .tool-item[data-tool="polygon"].active {
    background: rgba(230, 126, 34, 0.3) !important;
    border-color: rgba(230, 126, 34, 0.6) !important;
    box-shadow: 0 0 10px rgba(230, 126, 34, 0.3) !important;
}

/* Tree tool active state - Green */
#drawingPanel .drawing-tools .tool-item[data-tool="tree"].active {
    background: rgba(46, 204, 113, 0.3) !important;
    border-color: rgba(46, 204, 113, 0.6) !important;
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.3) !important;
}

/* Rectangle tool icon active state - Blue */
#drawingPanel .drawing-tools .tool-item[data-tool="rectangle"].active .tool-icon {
    filter: brightness(0) saturate(100%) invert(50%) sepia(100%) saturate(2000%) hue-rotate(200deg) brightness(100%) contrast(100%) !important;
}

/* Circle tool icon active state - Purple */
#drawingPanel .drawing-tools .tool-item[data-tool="circle"].active .tool-icon {
    filter: brightness(0) saturate(100%) invert(50%) sepia(100%) saturate(2000%) hue-rotate(280deg) brightness(100%) contrast(100%) !important;
}

/* Polygon tool icon active state - Orange */
#drawingPanel .drawing-tools .tool-item[data-tool="polygon"].active .tool-icon {
    filter: brightness(0) saturate(100%) invert(50%) sepia(100%) saturate(2000%) hue-rotate(30deg) brightness(100%) contrast(100%) !important;
}

/* Tree tool icon active state - Green */
#drawingPanel .drawing-tools .tool-item[data-tool="tree"].active .tool-icon {
    filter: brightness(0) saturate(100%) invert(50%) sepia(100%) saturate(2000%) hue-rotate(100deg) brightness(100%) contrast(100%) !important;
}

/* Transform Input Panel (Bottom of Screen) */
.transform-input-panel {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 26, 34, 0.94);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border-subtle);
    border-bottom: none;
    box-shadow: var(--shadow-float);
    padding: 8px 14px;
    z-index: 1400;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 280px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.transform-input-container {
    display: flex;
    gap: 14px;
    align-items: center;
}

.transform-input-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.transform-input-group label {
    font-weight: 600;
    font-size: 12px;
    color: var(--text-chrome-muted);
    min-width: 16px;
}

.transform-input {
    width: 88px;
    padding: 5px 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: var(--font-mono);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-chrome);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.transform-input:focus {
    outline: none;
    border-color: rgba(15, 159, 138, 0.55);
    box-shadow: 0 0 0 2px rgba(15, 159, 138, 0.18);
}

.transform-input:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

/* Surface Types Manager Styles */
.surface-types-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 400px;
}

.surface-types-tabs {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.tab-button {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    transition: all 0.2s;
    position: relative;
}

.tab-button:hover {
    background: rgba(102, 126, 234, 0.1);
    color: var(--accent);
}

.tab-button.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: white;
}

.surface-types-content {
    flex: 1;
    overflow: hidden;
    padding: 20px;
}

.tab-content {
    display: none;
    height: 100%;
    overflow-y: auto;
}

.tab-content.active {
    display: block;
}

.surface-types-table-container {
    width: 100%;
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.surface-types-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.surface-types-table thead {
    background: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
}

.surface-types-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #e0e0e0;
    white-space: nowrap;
}

.surface-types-table td {
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
    color: #555;
}

.surface-types-table tbody tr:hover {
    background: #f8f9fa;
}

.surface-types-table tbody tr:last-child td {
    border-bottom: none;
}

.surface-type-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.surface-type-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.surface-type-input:hover {
    border-color: #bbb;
}

.add-row-btn {
    width: auto;
    margin-top: 10px;
    padding: 6px 12px;
    font-size: 13px;
}

.delete-row-btn {
    padding: 4px 8px;
    font-size: 12px;
    min-width: 60px;
}

.delete-row-btn:hover {
    background: #dc3545;
    color: white;
}

/* Smaller buttons for Surface Types Manager dialog */
#surfaceTypesManagerDialog .modal-footer {
    justify-content: flex-start !important;
}

#surfaceTypesManagerDialog .modal-footer .btn {
    padding: 8px 20px !important;
    font-size: 13px !important;
    width: auto !important;
    min-width: 70px !important;
    max-width: 100px !important;
    margin: 0 5px;
}

#surfaceTypesManagerDialog .modal-footer .btn:disabled,
#surfaceTypesManagerDialog .modal-footer .btn.btn-disabled {
    background: #ccc !important;
    color: #666 !important;
    cursor: not-allowed !important;
    opacity: 0.5 !important;
}
/* Account chip + Profile window */
.menu-spacer {
    flex: 1 1 auto;
}

.account-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 28px;
    margin-right: 8px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.08);
    color: #e8f0ec;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.account-chip:hover {
    background: rgba(255, 255, 255, 0.14);
}

.account-chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3dd68c;
    box-shadow: 0 0 0 3px rgba(61, 214, 140, 0.2);
}

.profile-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(760px, calc(100vw - 32px));
    max-height: 86vh;
    background: var(--bg-panel-elevated);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-float);
    border: 1px solid var(--border-strong);
    z-index: 2100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
    overflow: hidden;
    font-family: var(--font-ui);
    display: flex;
    flex-direction: column;
}

.profile-window.show {
    opacity: 1;
    visibility: visible;
}

#profileOverlay.show {
    opacity: 1;
    visibility: visible;
}

.profile-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.profile-header-btn {
    background: transparent;
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
}

.profile-header-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.profile-status {
    min-height: 0;
    padding: 0 20px;
    font-size: 13px;
    color: var(--text-secondary, #556);
}

.profile-status.error {
    color: #9b2c2c;
    padding-top: 10px;
}

.profile-tabs {
    display: flex;
    gap: 4px;
    padding: 12px 16px 0;
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
}

.profile-tab {
    border: none;
    background: transparent;
    color: var(--text-secondary, #667);
    padding: 10px 12px;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
}

.profile-tab.active {
    color: var(--text-primary, #1a2e28);
    background: rgba(31, 122, 92, 0.1);
    box-shadow: inset 0 -2px 0 #1f7a5c;
}

.profile-content {
    padding: 16px 20px 20px;
    overflow-y: auto;
    max-height: calc(86vh - 140px);
}

.profile-tab-panel {
    display: none;
}

.profile-tab-panel.active {
    display: block;
}

.profile-field {
    flex-direction: column;
    align-items: stretch !important;
    gap: 6px;
}

.profile-field .form-control,
.profile-field input,
.profile-field select {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-strong, #ccd);
    background: #fff;
    font: inherit;
}

.profile-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.profile-muted {
    color: var(--text-secondary, #6b7c75);
    font-size: 12px;
}

.profile-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 650;
    background: #eef2f0;
    color: #334;
}

.profile-badge.ok {
    background: #e5f7ee;
    color: #146c43;
}

.profile-badge.warn {
    background: #fff4e5;
    color: #9a6700;
}

.profile-badge.danger {
    background: #fde8e8;
    color: #9b2c2c;
}

.profile-row-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border-subtle, #dde5e1);
    border-radius: 10px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.55);
}

.profile-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

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

.profile-summary-line {
    margin-bottom: 10px;
    font-size: 13px;
}

.profile-btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.profile-signed-out,
.profile-signed-in {
    padding-bottom: 8px;
}

.profile-signed-out {
    padding: 24px 20px;
}

.hidden {
    display: none !important;
}

.account-bar {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: 8px;
}

.account-signout-btn {
    height: 28px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(180, 60, 60, 0.25);
    color: #ffd7d7;
    font: inherit;
    font-size: 12px;
    font-weight: 650;
    cursor: pointer;
}

.account-signout-btn:hover {
    background: rgba(180, 60, 60, 0.4);
}

.profile-header-logout {
    height: 28px;
    padding: 0 12px;
    margin-right: 4px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font: inherit;
    font-size: 12px;
    font-weight: 650;
    cursor: pointer;
}

.profile-header-logout:hover {
    background: rgba(255, 255, 255, 0.22);
}

.auth-boot-screen {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: grid;
    place-items: center;
    background:
        radial-gradient(ellipse 70% 50% at 20% 20%, rgba(200, 230, 192, 0.25), transparent 55%),
        linear-gradient(155deg, #0f2a24, #1a4a3c 50%, #245a4a);
    color: #e8f5e4;
    font-family: var(--font-ui, 'Segoe UI', sans-serif);
}

.auth-boot-card {
    text-align: center;
    padding: 1.5rem 2rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.auth-boot-card strong {
    font-size: 1.6rem;
    letter-spacing: -0.02em;
}

.auth-boot-card p {
    margin: 0.5rem 0 0;
    opacity: 0.85;
}
