:root {
    /* Theme Variables */
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --accent-info: #00aaff; /* Consolidated from marquee and spinner */
    --bg-light: #f8f9fa;
    --panel-bg: rgba(255, 255, 255, 0.98);
    --overlay-bg: rgba(255, 255, 255, 0.85);
    
    /* Grays & Borders */
    --border-color: #ccc;
    --border-light: #eee;   /* Repeated in fieldset, asset-btn, selector */
    --border-subtle: #ddd;  /* Repeated in project-manager h3, material img */
    --bg-hover: #f0f0f0;    /* Repeated in tool-btn, asset-btn, view-item, etc */
    --text-main: #333;
    --text-muted: #666;
    
    /* Unified Spacing & Typography */
    --panel-padding: 8px;
    --group-margin: 8px;
    --input-padding: 4px;
    --radius: 4px;
    --font-size: 13px;
    --font-size-sm: 12px;   /* Unified small text across labels/buttons */
    --screen-offset: 8px;

    /* Shadows */
    --shadow-sm: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.15);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.4);

    /* Revit Wall Bar dynamic bounds */
    --wall-bar-left-space: calc(var(--screen-offset, 8px) + 265px + 12px);
    --wall-bar-right-space: calc(var(--screen-offset, 8px) + 235px + 12px);
}

body.tools-collapsed {
    --wall-bar-left-space: calc(var(--screen-offset, 8px) + 84px + 12px);
}
body.pm-collapsed {
    --wall-bar-right-space: calc(var(--screen-offset, 8px) + 84px + 12px);
}

body { margin: 0; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; touch-action: none; }
canvas { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; }

/* Generic Panel Styling - Unified Base */
#ui-panel, #project-manager {
    position: absolute; 
    top: 54px;
    background: var(--panel-bg); 
    padding: var(--panel-padding);
    border-radius: var(--radius); 
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    z-index: 100;
    user-select: none;
    box-sizing: border-box;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease, visibility 0.28s;
    visibility: visible;
    opacity: 1;
}

#ui-panel {
    left: var(--screen-offset);
    width: 260px; 
    max-height: calc(100vh - 70px); 
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateX(0);
}

#ui-panel.collapsed {
    transform: translateX(calc(-100% - 30px));
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#project-manager {
    right: var(--screen-offset);
    width: 210px;
    max-height: calc(100vh - 70px);
    overflow-y: auto;
    font-family: inherit;
    transform: translateX(0);
}

#project-manager.collapsed {
    transform: translateX(calc(100% + 30px));
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Panel Header & Close Controls */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 6px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
}

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

.panel-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: 0.3px;
}

.panel-close-btn {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: #888;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-close-btn:hover {
    color: var(--danger-color);
    background: rgba(220, 53, 69, 0.1);
}

/* Panel Corner Toggle Buttons */
.panel-toggle-btn {
    position: absolute;
    top: 10px;
    z-index: 150;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #222;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    outline: none;
}

.panel-toggle-btn:hover {
    background: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.panel-toggle-btn.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 3px 12px rgba(0, 123, 255, 0.35);
}

.panel-toggle-btn.active .btn-icon {
    fill: #fff;
}

.panel-toggle-btn .btn-icon {
    width: 15px;
    height: 15px;
    fill: currentColor;
    flex-shrink: 0;
}

.panel-toggle-btn.toggle-left {
    left: 10px;
}

.panel-toggle-btn.toggle-right {
    right: 10px;
}

fieldset { 
    border: 1px solid var(--border-light); 
    border-radius: var(--radius); 
    padding: var(--panel-padding); 
    margin-bottom: var(--group-margin); 
    min-width: 0;
    min-inline-size: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

legend { font-weight: bold; color: var(--text-main); padding: 0 4px; font-size: var(--font-size-sm); text-transform: uppercase; letter-spacing: 0.5px; }

/* Unified Form Controls */
.form-group { 
    margin-top: 6px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    gap: 6px;
    min-width: 0;
    font-size: var(--font-size);
}

.form-group > label {
    white-space: nowrap;
    flex-shrink: 0;
}

.form-group > select {
    max-width: 120px;
    min-width: 0;
    box-sizing: border-box;
}

input[type="number"], select { 
    height: 24px;
    padding: 2px 4px; 
    border: 1px solid var(--border-color); 
    border-radius: var(--radius); 
    background: white;
    font-size: var(--font-size-sm);
}

/* Buttons */
.tool-group { display: flex; gap: 4px; margin-bottom: var(--group-margin); flex-wrap: wrap; }

.tool-group-tools {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: var(--group-margin);
    width: 100%;
}

.tool-group-tools .tool-subrow {
    display: flex;
    gap: 4px;
    width: 100%;
}

@media (min-width: 769px) {
    .tool-group-tools .tool-btn {
        flex: 1 1 0;
        min-width: 0;
        font-size: 11.5px;
    }
}

.tool-btn {
    flex: 1; padding: 6px 4px; font-size: var(--font-size-sm); cursor: pointer;
    background: var(--bg-hover); color: var(--text-main); border: 1px solid var(--border-color); 
    border-radius: var(--radius); font-weight: 500; transition: all 0.15s;
    display: flex; align-items: center; justify-content: center;
}

.tool-btn.active { background: var(--success-color); color: white; border-color: #1e7e34; }
.tool-btn:hover:not(.active) { background: #e2e2e2; }

/* Standard Icon Button */
.icon-btn {
    flex: 1; padding: 4px; background: white; border: 1px solid var(--border-color);
    border-radius: var(--radius); cursor: pointer; transition: all 0.1s;
    display: flex; align-items: center; justify-content: center;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.active { background: #e9ecef; border-color: var(--primary-color); }

/* View Mode Specific Styling */
.view-mode-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-start;
}
.view-mode-group .icon-btn {
    flex: 0 0 auto;
    padding: 3px;
    width: 32px;
    height: 32px;
}
.view-mode-group .icon-btn svg {
    width: 22px;
    height: 22px;
}

.apply-btn {
    width: 100%; padding: 6px; margin-top: 8px;
    background: var(--primary-color); color: white; border: none;
    border-radius: var(--radius); cursor: pointer; font-weight: bold; font-size: var(--font-size-sm);
}
.apply-btn:hover { background: var(--primary-hover); }

/* Geometry Creation Section */
.geom-section-label {
    font-size: 10px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 4px;
}

.geom-param-block {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px dashed #e2e8f0;
}

#panel-geometry input[type="number"] {
    width: 60px;
}

.geom-lathe-editor-wrap {
    margin-top: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    padding: 5px;
}

.geom-lathe-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    font-weight: 700;
    color: #475569;
    margin-bottom: 4px;
}

.geom-mini-link {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    padding: 0 2px;
}

.geom-mini-link:hover {
    text-decoration: underline;
}

.geom-lathe-svg {
    width: 100%;
    height: 105px;
    display: block;
    user-select: none;
    touch-action: none;
}

.geom-extrude-btn {
    background: var(--success-color);
}

.geom-extrude-btn:hover {
    background: #1e7e34;
}

/* Action Bar (Bottom) */
#action-bar {
    position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
    display: none; gap: 12px; z-index: 10; background: var(--panel-bg);
    padding: 8px 16px; border-radius: 25px; box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}
.action-btn {
    width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: transform 0.1s;
}
#btn-accept { background: var(--success-color); }
#btn-cancel { background: var(--danger-color); }
.action-btn svg { width: 20px; height: 20px; fill: white; }

/* Live Creation Dimensions Overlay */
#dim-overlay-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 35;
    display: none;
    overflow: hidden;
}

#dim-overlay-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.dim-line {
    stroke: #0284c7;
    stroke-width: 1.5;
    filter: drop-shadow(0 0 1.5px rgba(255, 255, 255, 0.9));
}

.dim-line-primary {
    stroke: #0056d6;
    stroke-width: 2.2;
}

.dim-ext-line {
    stroke: rgba(2, 132, 199, 0.65);
    stroke-width: 1;
    stroke-dasharray: 4 3;
}

.dim-ref-line {
    stroke: rgba(15, 23, 42, 0.45);
    stroke-width: 1;
    stroke-dasharray: 4 4;
}

.dim-arc {
    stroke: #0284c7;
    stroke-width: 1.5;
    fill: none;
    filter: drop-shadow(0 0 1.5px rgba(255, 255, 255, 0.9));
}

#dim-badges-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
}

.dim-pill {
    position: fixed;
    transform: translate(-50%, -50%);
    pointer-events: auto;
    padding: 3px 8px;
    border-radius: 12px;
    border: 1px solid rgba(2, 132, 199, 0.45);
    background: rgba(255, 255, 255, 0.94);
    color: #0f172a;
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
    cursor: pointer;
    transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
}

.dim-pill:hover:not(.passive) {
    border-color: var(--primary-color);
    transform: translate(-50%, -50%) scale(1.05);
}

.dim-pill.active-prior {
    background: #eff6ff;
    border: 2px solid #0056d6;
    color: #0044b3;
    box-shadow: 0 3px 10px rgba(0, 86, 214, 0.25);
}

.dim-pill.locked {
    background: #ecfdf5;
    border-color: #16a34a;
    color: #15803d;
}

.dim-pill.passive {
    pointer-events: none;
    cursor: default;
}

/* Prior Dimension Numeric Entry Bar */
#dim-input-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 95;
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.14);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16);
    max-width: calc(100vw - 20px);
    flex-wrap: wrap;
    justify-content: center;
}

body.has-action-bar #dim-input-bar {
    bottom: 78px;
}

.dim-fields-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dim-field-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.15s ease;
}

.dim-field-chip.active-prior {
    border-color: #0056d6;
    background: #eff6ff;
    box-shadow: 0 0 0 2px rgba(0, 86, 214, 0.15);
}

.dim-field-chip.locked {
    border-color: #16a34a;
    background: #f0fdf4;
}

.dim-field-chip.readonly {
    background: #f1f5f9;
    border-color: #e2e8f0;
    cursor: default;
}

.dim-field-label {
    font-size: 11px;
    font-weight: 700;
    color: #475569;
    user-select: none;
}

.dim-field-chip.active-prior .dim-field-label {
    color: #0044b3;
}

.dim-field-input-wrap {
    display: flex;
    align-items: center;
    gap: 2px;
}

.dim-field-input {
    width: 58px;
    padding: 2px 5px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    background: #fff;
    color: #0f172a;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    text-align: right;
    outline: none;
}

.dim-field-chip.readonly .dim-field-input {
    border-color: transparent;
    background: transparent;
    color: #334155;
    width: 50px;
}

.dim-field-input:focus {
    border-color: #0056d6;
}

.dim-field-input.dim-invalid {
    border-color: var(--danger-color);
    background: #fef2f2;
    color: #b91c1c;
}

.dim-field-unit {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    user-select: none;
}

.dim-bar-actions {
    display: flex;
    align-items: center;
    gap: 5px;
}

.dim-action-btn {
    padding: 5px 10px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.dim-ok-btn {
    background: var(--success-color);
    color: #fff;
}

.dim-ok-btn:hover {
    background: #1e7e34;
}

.dim-cancel-btn {
    background: #fff;
    border-color: #cbd5e1;
    color: #334155;
}

.dim-cancel-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #b91c1c;
}

/* Canvas Shortcuts Legend (Bottom-Left Corner) */
.canvas-shortcuts {
    position: absolute;
    bottom: 16px;
    left: 16px;
    z-index: 40;
    pointer-events: none;
    user-select: none;
    background: transparent;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.5;
    letter-spacing: 0.3px;
    text-shadow: 
        -1px -1px 0 #000,  
         1px -1px 0 #000,
        -1px  1px 0 #000,
         1px  1px 0 #000,
        -1.5px 0 0 #000,
         1.5px 0 0 #000,
         0 -1.5px 0 #000,
         0  1.5px 0 #000,
         0 2px 4px rgba(0, 0, 0, 0.85);
    -webkit-text-stroke: 0.35px #000;
}

.canvas-shortcuts .shortcut-item {
    margin-bottom: 2px;
    white-space: nowrap;
}

.canvas-shortcuts .shortcut-key {
    font-weight: 800;
    color: #ffffff;
}

.canvas-shortcuts .shortcut-desc {
    font-weight: 700;
    color: #f0f0f0;
}

/* Notifications & Status */
#notification {
    position: absolute; top: var(--screen-offset); left: 50%; transform: translateX(-50%);
    background: var(--danger-color); color: white; padding: 8px 16px; border-radius: var(--radius);
    font-size: var(--font-size); font-weight: bold; display: none; z-index: 2500; align-items: center; gap: 10px;
}
#status-text { color: var(--text-muted); font-size: 11px; margin-top: 6px; text-align: center; font-style: italic; line-height: 1.3; }

/* Asset Browser */
.asset-grid {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 6px; margin-top: 8px; max-height: 220px; overflow-y: auto;
}
.asset-btn {
    background: #fff; border: 1px solid var(--border-light); border-radius: var(--radius); padding: 4px;
    cursor: pointer; display: flex; flex-direction: column; align-items: center;
}
.asset-btn:hover { border-color: var(--primary-color); }
.asset-btn img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 2px; background: var(--bg-hover); }
.asset-btn span { font-size: 10px; margin-top: 4px; color: var(--text-main); }

/* Helpers */
.tool-btn.action-svg { min-width: 0; }
.action-svg svg { width: 16px; height: 16px; fill: currentColor; }
#tool-select { flex: 0 0 32px; }
#tool-select svg { width: 14px; height: 14px; }

/* Project Manager Specifics */
#project-manager h3 {
    margin: 0 0 10px 0;
    font-size: 14px;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 5px;
}
.view-category { margin-bottom: 10px; }
.category-title {
    font-weight: 700; font-size: var(--font-size-sm); color: #475569; margin-bottom: 3px;
    display: flex; align-items: center; cursor: pointer; padding: 2px 3px; border-radius: 3px;
}
.category-title:hover { background: var(--bg-hover); }
.category-title::before { content: '▼'; font-size: 8px; margin-right: 5px; color: #64748b; width: 10px; display: inline-block; }
.view-category.collapsed .category-title::before { content: '▶'; }
.view-category.collapsed .view-list,
.view-category.collapsed .pm-add-btn { display: none; }
.view-list { list-style: none; padding: 0 0 0 8px; margin: 0 0 0 5px; border-left: 1px solid #e2e8f0; }
.view-item { padding: 4px 6px 4px 10px; font-size: var(--font-size); cursor: pointer; border-radius: var(--radius); }
.view-item:hover { background: var(--bg-hover); }
.view-item.active { background: var(--primary-color); color: white; }

/* Material Selection Panel */
#material-selector {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 450px; max-width: 90vw; height: 500px; max-height: 80vh;
    background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg);
    z-index: 9999; display: none; flex-direction: column; overflow: hidden;
    border: 1px solid var(--border-color); font-family: inherit;
}

.selector-header {
    padding: 15px 20px; background: var(--bg-light); border-bottom: 1px solid var(--border-light);
    display: flex; justify-content: space-between; align-items: center;
}
.selector-header h4 { margin: 0; color: var(--text-main); font-size: 1.1rem; }
.close-selector { background: none; border: none; font-size: 28px; cursor: pointer; color: #999; transition: color 0.2s; }
.close-selector:hover { color: var(--danger-color); }

.selector-content { padding: 20px; overflow-y: auto; flex-grow: 1; }
.cat-section { margin-bottom: 25px; }
.cat-name {
    font-weight: 600; margin-bottom: 12px; font-size: 14px; color: var(--primary-color);
    text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid #f0f0f0; padding-bottom: 5px;
}

.material-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 15px; }
.material-item {
    cursor: pointer; text-align: center; border: 1px solid var(--border-light); padding: 8px;
    border-radius: 8px; transition: all 0.2s ease; background: #fafafa;
}
.material-item:hover { background: #fff; border-color: var(--primary-color); box-shadow: 0 4px 12px rgba(0,123,255,0.15); transform: translateY(-2px); }
.material-item img { width: 100%; height: 80px; object-fit: cover; border-radius: 6px; margin-bottom: 8px; background: var(--border-subtle); }
.material-item span { font-size: var(--font-size-sm); font-weight: 500; color: #444; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#material-selector-backdrop {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.5); z-index: 9998; display: none;
}

/* Keeping existing styles */
#selection-marquee {
    border: 1px solid var(--accent-info);
    background: rgba(0, 170, 255, 0.2);
    position: fixed;
    pointer-events: none;
    display: none;
    z-index: 10000;
}
.marquee-intersect { border-style: dashed; background: rgba(40, 167, 69, 0.1); border-color: var(--success-color); }

/* New Loading Overlay Styles */
#loading-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--overlay-bg);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 30000;
    font-family: sans-serif;
    color: var(--text-main);
}
.spinner {
    width: 40px; height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--accent-info);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Level Management Styles */
.level-item-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 0;
}
.level-height-input {
    width: 50px; font-size: 11px; padding: 2px; margin-left: 5px;
    border: 1px solid var(--border-color); border-radius: 3px;
}
#btn-add-level, .pm-add-btn {
    width: 100%; margin-top: 6px; cursor: pointer;
    background: var(--bg-hover); border: 1px dashed #aaa;
    border-radius: var(--radius); padding: 3px; font-weight: bold; color: var(--text-muted);
}
#btn-add-level:hover, .pm-add-btn:hover { background: #e8e8e8; }

.section-item-container {
    display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 1px 0;
}
.section-dir-badge {
    font-size: 9px; font-weight: 700; color: #64748b; text-transform: uppercase;
    padding: 1px 4px; border-radius: 3px; background: rgba(100,116,139,0.12); flex-shrink: 0;
}
.view-item.active .section-dir-badge {
    color: #fff; background: rgba(255,255,255,0.22);
}
.section-delete-btn {
    background: none; border: none; color: #94a3b8; cursor: pointer; font-size: 13px; line-height: 1; padding: 0 2px;
}
.section-delete-btn:hover { color: var(--danger-color); }
.view-item.active .section-delete-btn { color: rgba(255,255,255,0.85); }

#level-dialog-backdrop, #section-dialog-backdrop {
    position: fixed; top:0; left:0; width: 100%; height:100%;
    background: rgba(0,0,0,0.3); display: none; z-index: 40000;
}
#level-dialog, #section-dialog {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: white; padding: 20px; border-radius: 8px; box-shadow: var(--shadow-md);
    z-index: 40001; display: none; font-family: sans-serif; width: 250px;
}
#level-dialog h4, #section-dialog h4 { margin-top: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 15px; }
/* STANDALONE TOP BAR (Removed as excessive) */
.standalone-top-bar {
    display: none !important;
}

.standalone-back-btn {
    display: none !important;
}

/* Canvas Center Project Name Pill */
#canvas-project-name {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 90;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: min(320px, calc(100vw - 360px));
    padding: 5px 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.14);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    color: #1e293b;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.2px;
    cursor: pointer;
    transition: all 0.18s ease;
    pointer-events: auto;
}

body.is-embed #canvas-project-name {
    top: 10px;
}

#project-name-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#canvas-project-name:hover {
    background: #fff;
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.18);
}

/* Save As & Open Project Dialogs */
.project-dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 40000;
    display: none;
}

.project-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 340px;
    max-width: calc(100vw - 24px);
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
    border: 1px solid var(--border-color);
    z-index: 40001;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: inherit;
}

.project-dialog.project-dialog-wide {
    width: 440px;
}

.project-dialog-header {
    padding: 12px 16px;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.project-dialog-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
}

.project-dialog-header .close-selector {
    font-size: 22px;
    line-height: 1;
    padding: 0 4px;
}

.project-dialog-body {
    padding: 16px;
}

.project-dialog-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 6px;
}

.project-dialog-input {
    width: 100%;
    height: auto;
    min-height: 36px;
    line-height: 1.35;
    box-sizing: border-box;
    padding: 7px 10px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    outline: none;
    color: var(--text-main);
    background: #fff;
}

select.project-dialog-input,
#units-length-select,
#wp-select-named {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    display: block !important;
    width: 100% !important;
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    line-height: normal !important;
    padding: 0 36px 0 12px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    font-family: inherit !important;
    color: #1e293b !important;
    background-color: #ffffff !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23334155' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: calc(100% - 12px) center !important;
    background-size: 14px 14px !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 6px !important;
    box-sizing: border-box !important;
    outline: none !important;
    cursor: pointer !important;
    vertical-align: middle !important;
}

select.project-dialog-input:focus,
#units-length-select:focus,
#wp-select-named:focus {
    border-color: #007bff !important;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.18) !important;
}

select.project-dialog-input option,
#units-length-select option,
#wp-select-named option {
    font-size: 14px !important;
    color: #1e293b !important;
    background-color: #ffffff !important;
    padding: 8px 12px;
}

/* Custom UI Select Dropdown for Project Units */
.units-custom-select-wrap {
    position: relative;
    width: 100%;
}

.units-custom-select-wrap.has-custom-ui #units-length-select {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    border: none;
}

.units-custom-select-trigger {
    display: none;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 40px;
    padding: 0 14px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    color: #0f172a;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 6px;
    box-sizing: border-box;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
}

.units-custom-select-wrap.has-custom-ui .units-custom-select-trigger {
    display: flex;
}

.units-custom-select-trigger:hover {
    border-color: #94a3b8;
}

.units-custom-select-trigger:focus,
.units-custom-select-trigger.active {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.18);
}

.units-custom-select-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: normal;
    text-align: left;
}

.units-custom-select-arrow {
    display: inline-flex;
    align-items: center;
    color: #475569;
    transition: transform 0.18s ease;
    flex-shrink: 0;
    margin-left: 8px;
}

.units-custom-select-trigger.active .units-custom-select-arrow {
    transform: rotate(180deg);
}

.units-custom-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
    z-index: 1050;
    overflow: hidden;
    padding: 4px;
}

.units-custom-opt {
    padding: 9px 12px;
    font-size: 13.5px;
    font-weight: 500;
    color: #1e293b;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.12s ease, color 0.12s ease;
    user-select: none;
}

.units-custom-opt:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.units-custom-opt.selected {
    background: #eff6ff;
    color: #007bff;
    font-weight: 600;
}

.units-custom-opt-check {
    display: inline-flex;
    align-items: center;
    color: #007bff;
    font-weight: 700;
    font-size: 14px;
}

.project-dialog-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.16);
}

.project-dialog-error {
    margin-top: 6px;
    font-size: 12px;
    color: var(--danger-color);
    min-height: 16px;
}

.project-dialog-actions {
    padding: 10px 16px 14px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid #f1f5f9;
    background: #fafafa;
}

.project-btn {
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.project-btn-secondary {
    background: #fff;
    border-color: var(--border-color);
    color: var(--text-main);
}

.project-btn-secondary:hover {
    background: #f1f5f9;
}

.project-btn-primary {
    background: var(--primary-color);
    color: #fff;
}

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

.open-project-list {
    max-height: min(340px, 55vh);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.project-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.15s ease;
}

.project-list-item:hover {
    background: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.12);
}

.project-list-item.active {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.project-item-info {
    flex: 1;
    min-width: 0;
}

.project-item-name {
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-item-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 700;
    border-radius: 10px;
    background: var(--primary-color);
    color: #fff;
    vertical-align: middle;
}

.project-item-meta {
    margin-top: 3px;
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-item-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.project-open-btn {
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid var(--primary-color);
    background: var(--primary-color);
    color: #fff;
    cursor: pointer;
}

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

.project-delete-btn {
    padding: 5px 8px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    border-radius: 6px;
    border: 1px solid #fecaca;
    background: #fff;
    color: var(--danger-color);
    cursor: pointer;
}

.project-delete-btn:hover {
    background: var(--danger-color);
    border-color: var(--danger-color);
    color: #fff;
}

.project-list-empty,
.project-list-loading {
    padding: 24px 12px;
    text-align: center;
    font-size: 13px;
    color: #64748b;
}

/* RESPONSIVE & MOBILE RULES */
@media (max-width: 768px) {
    :root {
        --screen-offset: 8px;
    }

    .panel-toggle-btn {
        top: 8px;
        height: 34px;
        padding: 0 10px;
        font-size: 12px;
    }

    .panel-toggle-btn.toggle-left {
        left: 8px;
    }

    .panel-toggle-btn.toggle-right {
        right: 8px;
    }

    #ui-panel {
        top: 48px;
        left: 8px;
        width: min(210px, calc(100vw - 16px));
        max-height: calc(100vh - 60px);
        padding: 6px;
    }

    #project-manager {
        top: 48px;
        right: 8px;
        width: min(190px, calc(100vw - 16px));
        max-height: calc(100vh - 60px);
        padding: 6px;
    }

    /* Divide 3rd tool group into two rows for mobile */
    .tool-group-tools {
        flex-direction: column;
        gap: 4px;
    }

    .tool-group-tools .tool-subrow {
        display: flex;
        width: 100%;
        gap: 4px;
    }

    .tool-group-tools .tool-subrow .tool-btn {
        flex: 1;
        min-width: 0;
        padding: 6px 2px;
        font-size: 11px;
    }

    #tool-select {
        flex: 0 0 28px;
        padding: 6px 2px;
    }

    /* Form controls compactness on mobile */
    .form-group {
        font-size: 12px;
        gap: 6px;
    }

    .form-group select {
        max-width: 105px;
        font-size: 11px;
        height: 22px;
        padding: 1px 3px;
    }

    .form-group input[type="number"] {
        max-width: 55px;
        font-size: 11px;
        height: 22px;
        padding: 1px 3px;
    }

    .comp-param-ctrl input[type="number"] {
        width: 48px;
        max-width: 48px;
    }

    fieldset {
        padding: 6px;
        margin-bottom: 6px;
    }

    legend {
        font-size: 11px;
    }

    .view-mode-group .icon-btn {
        width: 28px;
        height: 28px;
        padding: 2px;
    }

    .view-mode-group .icon-btn svg {
        width: 14px;
        height: 14px;
    }

    #status-text {
        font-size: 10px;
        margin-top: 4px;
    }

    .standalone-top-bar {
        top: 8px;
        gap: 6px;
    }

    #canvas-project-name,
    body.is-embed #canvas-project-name {
        top: 8px;
        max-width: min(230px, calc(100vw - 220px));
        padding: 4px 11px;
        font-size: 11.5px;
    }

    .canvas-shortcuts {
        display: none;
    }

    #dim-input-bar {
        padding: 5px 8px;
        gap: 6px;
        bottom: 14px;
    }

    body.has-action-bar #dim-input-bar {
        bottom: 72px;
    }

    .dim-field-input {
        width: 48px;
        font-size: 11px;
    }

    .dim-action-btn {
        padding: 4px 8px;
        font-size: 11px;
    }
}

/* Object Inspector Material Rows & Wall Layers */
.obj-mat-section {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid #eceff3;
}

.obj-mat-row {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 5px;
    margin-top: 4px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 11px;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.obj-mat-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

.obj-mat-label {
    flex: 1 1 0%;
    width: 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #1e293b;
    font-weight: 500;
}

.obj-mat-sub {
    display: block;
    font-size: 9.5px;
    color: #64748b;
    font-weight: 400;
}

.obj-mat-btn {
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 600;
    background: #fff;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
}

.obj-mat-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #eff6ff;
}

/* Component Type vs Instance Parameter Controls */
.comp-param-ctrl {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.comp-param-ctrl input[type="number"],
.comp-param-ctrl input[type="text"] {
    width: 56px;
    height: 22px;
    font-size: 11px;
    padding: 1px 4px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    box-sizing: border-box;
}

.comp-param-scope-btn {
    width: 20px;
    height: 20px;
    padding: 0;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.12s ease;
    border: 1px solid #93c5fd;
    background: #eff6ff;
    color: #1d4ed8;
}

.comp-param-scope-btn:hover {
    filter: brightness(0.95);
    transform: translateY(-0.5px);
}

.comp-param-scope-btn[data-scope="instance"] {
    border-color: #fcd34d;
    background: #fffbeb;
    color: #b45309;
}

.comp-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-top: 5px;
    font-size: 11.5px;
}

.comp-meta-label {
    color: #475569;
    font-weight: 500;
}

.comp-meta-value {
    color: #0f172a;
    font-weight: 600;
    font-size: 11px;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
}

.wall-layers-mat-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
}

/* Revit-Style Material Browser & Editor Dialog */
#material-editor-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 41000;
    display: none;
}

#material-editor-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(760px, calc(100vw - 32px));
    height: min(600px, calc(100vh - 40px));
    background: #fff;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.35);
    z-index: 41001;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: inherit;
    user-select: none;
}

.mat-editor-header {
    padding: 11px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mat-editor-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}

.mat-editor-subtitle {
    font-size: 11px;
    color: #64748b;
    margin-top: 2px;
}

.mat-editor-body {
    flex: 1;
    min-height: 0;
    display: flex;
}

.mat-editor-left {
    width: 245px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e2e8f0;
    background: #fafafa;
}

.mat-browser-filters {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    border-bottom: 1px solid #e2e8f0;
}

.mat-browser-filters input,
.mat-browser-filters select {
    width: 100%;
    box-sizing: border-box;
    padding: 5px 8px;
    font-size: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #fff;
    height: auto;
}

.mat-browser-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mat-browser-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 5px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}

.mat-browser-item:hover {
    background: #eef2ff;
}

.mat-browser-item.active {
    background: #e0f2fe;
    border-color: #3b82f6;
}

.mat-item-swatch {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

.mat-item-info {
    flex: 1;
    min-width: 0;
}

.mat-item-name {
    font-size: 12px;
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mat-item-meta {
    font-size: 10px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mat-empty-msg {
    padding: 16px;
    text-align: center;
    font-size: 12px;
    color: #94a3b8;
}

.mat-browser-actions {
    padding: 8px;
    display: flex;
    gap: 4px;
    border-top: 1px solid #e2e8f0;
    background: #f1f5f9;
}

.mat-mini-btn {
    flex: 1;
    padding: 4px 6px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #fff;
    color: #1e293b;
    cursor: pointer;
}

.mat-mini-btn:hover:not(:disabled) {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.mat-mini-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.mat-mini-danger:hover:not(:disabled) {
    border-color: var(--danger-color);
    color: var(--danger-color);
}

.mat-editor-right {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.mat-preview-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid #e2e8f0;
    background: #fcfcfd;
}

.mat-preview-swatches {
    display: flex;
    gap: 8px;
}

.mat-swatch-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.mat-swatch-card canvas {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
}

.mat-swatch-card span {
    font-size: 9px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
}

.mat-preview-meta {
    flex: 1;
    min-width: 0;
}

.mat-preview-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mat-preview-summary {
    font-size: 11px;
    color: #475569;
    margin-top: 3px;
}

.mat-tabs-bar {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    padding: 0 10px;
    gap: 2px;
    overflow-x: auto;
}

.mat-tab-btn {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
}

.mat-tab-btn:hover {
    color: #0f172a;
}

.mat-tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: #fff;
}

.mat-tab-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 16px;
}

.mat-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #475569;
    margin: 12px 0 6px;
    padding-bottom: 3px;
    border-bottom: 1px solid #eef2f7;
}

.mat-section-title:first-child {
    margin-top: 0;
}

.mat-field-row {
    display: grid;
    grid-template-columns: 165px 1fr;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
}

.mat-field-row label {
    color: #334155;
    font-weight: 500;
}

.mat-field-row input[type="text"],
.mat-field-row input[type="number"],
.mat-field-row select,
.mat-field-row textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 4px 7px;
    font-size: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #fff;
    color: #0f172a;
    height: auto;
    font-family: inherit;
}

.mat-field-row input[type="color"] {
    width: 44px;
    height: 24px;
    padding: 1px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
}

.mat-check-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mat-color-pair,
.mat-inline-calc {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mat-color-pair span {
    font-family: monospace;
    font-size: 11px;
    color: #475569;
}

.mat-preset-strip {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    padding: 6px 8px;
    background: #f1f5f9;
    border-radius: 5px;
}

.mat-preset-strip select {
    flex: 1;
    padding: 4px 6px;
    font-size: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
}

.mat-preset-strip .mat-mini-btn {
    flex: 0 0 auto;
    padding: 4px 10px;
}

.mat-therm-derived {
    margin-top: 10px;
    padding: 8px 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: 11px;
    color: #334155;
    font-weight: 500;
}

.mat-editor-footer {
    padding: 10px 16px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

@media (max-width: 768px) {
    #material-editor-dialog {
        width: calc(100vw - 14px);
        height: calc(100vh - 20px);
    }

    .mat-editor-body {
        flex-direction: column;
    }

    .mat-editor-left {
        width: 100%;
        max-height: 170px;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }

    .mat-field-row {
        grid-template-columns: 125px 1fr;
        font-size: 11px;
    }
}

@media (max-width: 440px) {
    #canvas-project-name,
    body.is-embed #canvas-project-name {
        top: 8px;
        max-width: min(180px, calc(100vw - 180px));
    }
}

/* Manage Section (Materials & Project Units) */
.manage-btn-row {
    display: flex;
    gap: 6px;
}

.manage-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-weight: 600;
    font-size: 11.5px;
}

.manage-btn-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.units-status-badge {
    margin-top: 6px;
    padding: 3px 6px;
    font-size: 10.5px;
    font-weight: 600;
    color: #334155;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    text-align: center;
}

/* Project Units Modal */
.units-system-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.units-sys-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 9px 11px;
    border-radius: 7px;
    border: 1.5px solid #cbd5e1;
    background: #f8fafc;
    color: #0f172a;
    cursor: pointer;
    text-align: left;
    transition: all 0.14s ease;
}

.units-sys-btn strong {
    font-size: 13px;
}

.units-sys-btn span {
    font-size: 11px;
    color: #64748b;
}

.units-sys-btn:hover {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.units-sys-btn.active {
    border-color: var(--primary-color);
    background: #dbeafe;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.15);
}

.units-preview-note {
    margin-top: 10px;
    padding: 8px 10px;
    font-size: 11px;
    line-height: 1.4;
    color: #475569;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}

/* Wall Type Assembly Layers Editor */
.wall-new-type-btn {
    padding: 3px 7px;
    font-size: 10.5px;
    font-weight: 600;
    background: #f1f5f9;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.wall-new-type-btn:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

.wall-type-structure-section {
    margin-top: 4px;
    margin-bottom: 8px;
    padding: 6px 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}

.wall-structure-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    padding: 2px 0;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    color: inherit;
}

.wall-structure-toggle:hover .geom-section-label {
    color: #0284c7;
}

.wall-structure-toggle-left {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
}

.wall-structure-chevron {
    display: inline-block;
    font-size: 11px;
    line-height: 1;
    color: #64748b;
    transition: transform 0.15s ease;
}

.wall-structure-toggle[aria-expanded="true"] .wall-structure-chevron {
    transform: rotate(90deg);
}

.wall-type-badge {
    display: inline-block;
    padding: 1px 4px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #0369a1;
    background: #e0f2fe;
    border: 1px solid #bae6fd;
    border-radius: 3px;
}

.wall-structure-body {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #e2e8f0;
}

.wall-type-scope-hint {
    font-size: 10px;
    line-height: 1.35;
    color: #64748b;
    margin-bottom: 4px;
}

.wall-layers-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.wall-type-total-thick {
    font-size: 10.5px;
    font-weight: 700;
    color: #0369a1;
}

.wall-layer-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 5px 6px;
    margin-top: 4px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
}

.wall-layer-top {
    display: flex;
    align-items: center;
    gap: 5px;
}

.wall-layer-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-size: 10.5px;
    color: #475569;
}

.wall-layer-thick-wrap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.wall-layer-thick-input {
    width: 56px !important;
    height: 20px !important;
    padding: 1px 4px !important;
    font-size: 11px !important;
}

.wall-layer-del-btn {
    padding: 1px 5px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    background: transparent;
    color: #dc2626;
    border: 1px solid transparent;
    border-radius: 3px;
    cursor: pointer;
}

.wall-layer-del-btn:hover:not(:disabled) {
    background: #fee2e2;
    border-color: #fca5a5;
}

.wall-layer-del-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.wall-add-layer-btn {
    width: 100%;
    margin-top: 6px;
    padding: 4px 6px;
    font-size: 11px;
    font-weight: 600;
    background: #f1f5f9;
    color: #0f172a;
    border: 1px dashed #94a3b8;
    border-radius: 4px;
    cursor: pointer;
}

.wall-add-layer-btn:hover {
    background: #e0f2fe;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Compact Top Select + Choose Work Plane Bar */
.tool-top-strip {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-bottom: 4px;
}

.tool-select-compact {
    flex: 0 0 auto;
    padding: 5px 8px;
    gap: 4px;
    font-size: 11px;
}

.tool-select-compact svg {
    width: 13px;
    height: 13px;
    fill: currentColor;
}

.tool-choose-wp-btn {
    flex: 1 1 0;
    min-width: 0;
    gap: 4px;
    padding: 5px 6px;
    font-size: 11px;
    white-space: nowrap;
}

.wp-quick-pick-btn {
    flex: 0 0 auto;
    min-width: 48px;
    gap: 3px;
    padding: 5px 6px;
    font-size: 11px;
    font-weight: 600;
    background: #ffffff;
    color: #0284c7;
    border: 1px solid #7dd3fc;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
}

.wp-quick-pick-btn:hover {
    background: #f0f9ff;
    border-color: #0284c7;
}

.tool-choose-wp-btn.active-picking,
.wp-quick-pick-btn.active-picking {
    background: #0284c7 !important;
    color: #ffffff !important;
    border-color: #0369a1 !important;
    animation: wp-pulse 1.6s ease-in-out infinite;
}

.wp-active-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    margin-bottom: 6px;
    padding: 2px 4px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 4px;
    font-size: 10.5px;
    color: #0369a1;
}

.wp-active-badge {
    flex: 1;
    min-width: 0;
    background: none;
    border: none;
    padding: 2px 4px;
    text-align: left;
    font-size: 10.5px;
    font-weight: 600;
    color: #0369a1;
    cursor: pointer;
    border-radius: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.wp-active-badge:hover {
    background: #e0f2fe;
    color: #0284c7;
}

.wp-grid-toggle {
    flex: 0 0 auto;
    padding: 1px 5px;
    font-size: 10px;
    font-weight: 600;
    background: #ffffff;
    color: #0369a1;
    border: 1px solid #7dd3fc;
    border-radius: 3px;
    cursor: pointer;
}

.wp-grid-toggle.active {
    background: #0284c7;
    color: #ffffff;
    border-color: #0369a1;
}

.wp-orient-toggle {
    flex: 0 0 auto;
    padding: 1px 5px;
    font-size: 10px;
    font-weight: 600;
    background: #ffffff;
    color: #0369a1;
    border: 1px solid #7dd3fc;
    border-radius: 3px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.wp-orient-toggle:hover {
    background: #e0f2fe;
}

.wp-orient-toggle.active {
    background: #0284c7;
    color: #ffffff;
    border-color: #0369a1;
}

/* Revit-Style Work Plane Dialog */
.wp-modal-dialog {
    max-width: 380px;
    width: 90vw;
}

.wp-dialog-body {
    padding: 12px 16px;
}

.wp-dialog-status-card {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 12px;
}

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

.wp-status-label {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #0284c7;
}

.wp-reset-btn {
    background: none;
    border: none;
    padding: 0;
    font-size: 10.5px;
    font-weight: 600;
    color: #0369a1;
    text-decoration: underline;
    cursor: pointer;
}

.wp-reset-btn:hover {
    color: #0c4a6e;
}

.wp-status-val {
    margin-top: 2px;
    font-size: 12.5px;
    font-weight: 700;
    color: #0f172a;
    word-break: break-word;
}

.wp-specify-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 0;
    border-top: 1px solid #e2e8f0;
}

.wp-specify-title {
    font-size: 11px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 4px;
}

.wp-radio-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    cursor: pointer;
    user-select: none;
}

.wp-radio-row input[type="radio"] {
    margin: 0;
    cursor: pointer;
    accent-color: #0284c7;
}

.wp-radio-subfield {
    margin-left: 22px;
    margin-top: 2px;
    margin-bottom: 6px;
}

.wp-radio-subdesc {
    margin-left: 22px;
    font-size: 11px;
    color: #64748b;
    line-height: 1.35;
}

.wp-dialog-options-row {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e2e8f0;
}

.wp-chk-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11.5px;
    color: #334155;
    cursor: pointer;
    user-select: none;
}

.wp-chk-label input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    accent-color: #0284c7;
}

/* Floating Work Plane Viewer Banner */
.wp-viewer-banner {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 950;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 14px;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(56, 189, 248, 0.4);
    border-radius: 20px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.28);
    color: #ffffff;
    font-size: 11.5px;
    pointer-events: auto;
}

.wp-viewer-info {
    display: flex;
    align-items: center;
    gap: 6px;
}

.wp-viewer-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #38bdf8;
    box-shadow: 0 0 8px #38bdf8;
    animation: wp-dot-pulse 1.4s infinite;
}

.wp-viewer-label {
    color: #94a3b8;
    font-weight: 500;
}

.wp-viewer-plane-name {
    color: #7dd3fc;
    font-weight: 600;
}

.wp-viewer-return-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #0284c7;
    color: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.wp-viewer-return-btn:hover {
    background: #0369a1;
}

.wp-viewer-return-btn:active {
    transform: scale(0.97);
}

/* 3D Pick a Plane Cursor Tooltip */
.wp-pick-tooltip {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 11px;
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid #38bdf8;
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    color: #ffffff;
    font-size: 11px;
    white-space: nowrap;
    transform: translate(14px, 14px);
    transition: transform 0.04s ease-out;
}

.wp-pick-crosshair-icon {
    stroke: #38bdf8;
    flex-shrink: 0;
}

.wp-pick-tooltip-body {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.wp-pick-title {
    font-weight: 600;
    color: #bae6fd;
    font-size: 11px;
}

.wp-pick-sub {
    font-size: 9.5px;
    color: #94a3b8;
}

@keyframes wp-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(2, 132, 199, 0.45);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(2, 132, 199, 0);
    }
}

@keyframes wp-dot-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.35;
        transform: scale(0.85);
    }
}

/* United Create Section (Ultra-Compact Label + 3x3 Tool Grid) */
.create-fieldset {
    padding: 3px 6px 6px;
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
    background: #fcfcfd;
}

.create-fieldset > legend {
    font-size: 9px;
    line-height: 1;
    padding: 0 3px;
    margin: 0;
    letter-spacing: 0.35px;
    color: #475569;
}

.create-tools-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    margin-top: 3px;
}

.create-tools-grid .tool-btn {
    padding: 4px 2px;
    font-size: 10.5px;
    line-height: 1.15;
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: normal;
    word-break: normal;
}

/* Door Controls */
.door-flip-row {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}

.door-flip-row .tool-btn {
    padding: 5px 4px;
    font-size: 11px;
}

/* Roof Settings & Boundary Edges */
.roof-pitch-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 0 4px;
    font-size: 10px;
    font-weight: 700;
    color: #0369a1;
    background: #e0f2fe;
    border-radius: 3px;
}

.roof-edges-list {
    max-height: 150px;
    overflow-y: auto;
    margin-top: 4px;
}

.roof-edge-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    padding: 3px 5px;
    margin-top: 3px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 10.5px;
}

.roof-edge-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
}

.roof-edge-slope-wrap {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    color: #475569;
}

.roof-edge-slope-input {
    width: 44px !important;
    height: 19px !important;
    padding: 1px 3px !important;
    font-size: 10.5px !important;
}

/* Work Plane Panel Inputs */
.wp-name-input {
    width: 120px;
    height: 24px;
    padding: 2px 6px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: var(--font-size-sm);
    box-sizing: border-box;
}

/* Column Type Segmented Selector */
.col-type-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    width: 100%;
}

.col-type-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 4px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #ffffff;
    color: #334155;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.col-type-btn svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

.col-type-btn:hover {
    background: #f1f5f9;
}

.col-type-btn.active {
    background: #007bff;
    border-color: #0069d9;
    color: #ffffff;
}

/* Family Dropdown + Compact Load Trigger inside 260px Sidebar */
.comp-fam-ctrl {
    flex: 1;
    min-width: 0;
    max-width: 148px;
}

.comp-fam-ctrl select {
    flex: 1;
    min-width: 0;
    width: 0;
    max-width: 100%;
    height: 24px;
    font-size: 11px;
    padding: 1px 4px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text-main);
    text-overflow: ellipsis;
    box-sizing: border-box;
}

.comp-load-fam-btn {
    flex-shrink: 0;
    padding: 3px 6px;
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.2;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #f8fafc;
    color: #1e293b;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}

.comp-load-fam-btn:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

.manage-full-btn {
    width: 100%;
    margin-top: 6px;
    box-sizing: border-box;
}

/* Revit-Style Family Library Browser Dialog */
.famlib-dialog {
    width: 680px;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 36px);
}

.famlib-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 14px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
}

.famlib-cat-tabs {
    display: inline-flex;
    gap: 4px;
}

.famlib-cat-tab {
    padding: 4px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    background: #ffffff;
    color: #334155;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
}

.famlib-cat-tab.active {
    background: #007bff;
    border-color: #0069d9;
    color: #ffffff;
}

.famlib-search-input {
    flex: 1;
    min-width: 170px;
    padding: 5px 9px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    font-size: 12px;
    color: var(--text-main);
    background: #ffffff;
    box-sizing: border-box;
}

.famlib-body {
    display: grid;
    grid-template-columns: 205px 1fr;
    min-height: 330px;
    max-height: 58vh;
    overflow: hidden;
}

.famlib-folders-pane {
    border-right: 1px solid var(--border-light);
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.famlib-pane-title {
    padding: 8px 10px 6px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0;
}

.famlib-folders-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.famlib-folder-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    padding: 5px 8px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: #334155;
    font-size: 11.5px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}

.famlib-folder-btn:hover {
    background: #e2e8f0;
}

.famlib-folder-btn.active {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1d4ed8;
    font-weight: 700;
}

.famlib-folder-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.famlib-folder-count {
    font-size: 10px;
    font-weight: 700;
    color: #64748b;
    background: rgba(148, 163, 184, 0.2);
    border-radius: 999px;
    padding: 1px 6px;
    flex-shrink: 0;
}

.famlib-items-pane {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #ffffff;
}

.famlib-breadcrumb {
    padding: 7px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #475569;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.famlib-items-list {
    flex: 1;
    min-height: 120px;
    overflow-y: auto;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    border-bottom: 1px solid #e2e8f0;
}

.famlib-item-btn {
    width: 100%;
    text-align: left;
    padding: 7px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #ffffff;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s;
}

.famlib-item-btn:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.famlib-item-btn.active {
    background: #eff6ff;
    border-color: #2563eb;
}

.famlib-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.famlib-item-title {
    font-size: 12.5px;
    font-weight: 700;
    color: #0f172a;
}

.famlib-loaded-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
}

.famlib-loaded-badge.is-loaded {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.famlib-loaded-badge.is-unloaded {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.famlib-item-sub {
    margin-top: 2px;
    font-size: 10.5px;
    color: #64748b;
}

.famlib-details-box {
    padding: 10px 12px;
    background: #f8fafc;
    overflow-y: auto;
    max-height: 175px;
}

.famlib-detail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.famlib-detail-head h5 {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
}

.famlib-cat-pill {
    font-size: 9.5px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: #e2e8f0;
    color: #334155;
}

.famlib-detail-path {
    margin-top: 3px;
    font-size: 10.5px;
    color: #475569;
    font-family: monospace;
}

.famlib-detail-desc {
    margin: 5px 0 7px;
    font-size: 11px;
    line-height: 1.4;
    color: #334155;
}

.famlib-detail-label {
    margin-top: 6px;
    margin-bottom: 3px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #64748b;
}

.famlib-chip-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.famlib-chip {
    font-size: 10.5px;
    padding: 2px 6px;
    border-radius: 4px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #1e293b;
}

.famlib-param-chip {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
}

.famlib-footer {
    justify-content: space-between;
    align-items: center;
}

.famlib-status-text {
    font-size: 11px;
    color: #475569;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.famlib-footer-btns {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.famlib-empty {
    padding: 18px 10px;
    text-align: center;
    font-size: 11.5px;
    color: #64748b;
}

@media (max-width: 640px) {
    .famlib-body {
        grid-template-columns: 1fr;
        max-height: 62vh;
    }
    .famlib-folders-pane {
        border-right: none;
        border-bottom: 1px solid var(--border-light);
        max-height: 130px;
    }
}

/* ==========================================================================
   Revit-Style Contextual Wall Options Bar
   ========================================================================== */
.revit-wall-bar {
    position: fixed;
    top: 46px;
    left: var(--wall-bar-left-space);
    right: var(--wall-bar-right-space);
    width: fit-content;
    max-width: calc(100vw - var(--wall-bar-left-space) - var(--wall-bar-right-space));
    margin-left: auto;
    margin-right: auto;
    z-index: 92;
    display: none;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
    font-family: inherit;
    font-size: 12px;
    color: #1e293b;
    pointer-events: auto;
    overflow-x: auto;
    scrollbar-width: thin;
    white-space: nowrap;
}

body.is-embed .revit-wall-bar {
    top: 46px;
}

.revit-bar-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.revit-bar-label {
    font-size: 11.5px;
    font-weight: 600;
    color: #475569;
}

.revit-bar-divider {
    width: 1px;
    height: 22px;
    background: #cbd5e1;
    margin: 0 2px;
    flex-shrink: 0;
}

.revit-draw-gallery {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #f1f5f9;
    padding: 2px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.revit-draw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 26px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: #475569;
    padding: 0;
    transition: all 0.15s ease;
}

.revit-draw-btn svg {
    width: 16px;
    height: 16px;
}

.revit-draw-btn:hover {
    background: #ffffff;
    color: #007bff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.revit-draw-btn.active {
    background: #007bff;
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 123, 255, 0.35);
}

.revit-select {
    height: 28px;
    line-height: normal;
    padding: 0 8px;
    font-size: 12px;
    font-family: inherit;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    color: #1e293b;
    outline: none;
    cursor: pointer;
    box-sizing: border-box;
}

.revit-select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.18);
}

.revit-num-input {
    height: 28px;
    padding: 0 6px;
    font-size: 12px;
    font-family: inherit;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    color: #1e293b;
    outline: none;
    box-sizing: border-box;
    text-align: right;
}

.revit-num-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.18);
}

.revit-unit-suffix {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
}

.revit-check-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 500;
    color: #334155;
    cursor: pointer;
    user-select: none;
}

.revit-check-label input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    accent-color: #007bff;
}

.revit-btn-flip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 28px;
    padding: 0 10px;
    font-size: 11.5px;
    font-weight: 600;
    font-family: inherit;
    color: #007bff;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.revit-btn-flip:hover {
    background: #007bff;
    color: #ffffff;
    border-color: #007bff;
}

.revit-bar-prompt {
    margin-left: 8px;
    padding: 3px 8px;
    background: #f1f5f9;
    border-radius: 6px;
    font-size: 11px;
    color: #64748b;
    font-style: italic;
    border: 1px dashed #cbd5e1;
    white-space: nowrap;
}

@media (max-width: 900px) {
    .revit-wall-bar {
        max-width: calc(100vw - 20px);
        top: auto;
        bottom: 74px;
    }
}

/* ==========================================================================
   Revit-Style Context Model In-Place Bar & Finish/Cancel Controls
   ========================================================================== */
.cm-finish-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: #16a34a;
    color: #ffffff;
    border: 1px solid #15803d;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.cm-finish-btn:hover {
    background: #15803d;
}

.cm-finish-btn:active {
    transform: scale(0.97);
}

.cm-cancel-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: #ef4444;
    color: #ffffff;
    border: 1px solid #dc2626;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.cm-cancel-btn:hover {
    background: #dc2626;
}

.cm-cancel-btn:active {
    transform: scale(0.97);
}

.cm-wp-chip,
.cm-mat-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    color: #1e293b;
    cursor: pointer;
    height: 26px;
    font-size: 11px;
    transition: background 0.15s, border-color 0.15s;
}

.cm-wp-chip:hover,
.cm-mat-chip:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

/* Panel Collision Prevention:
   When any top options bar is visible (Wall Bar or Context Model Bar),
   dynamically push the Work Plane Viewer Banner below it so they never collide! */
body.has-top-options-bar .wp-viewer-banner {
    top: 110px !important;
}

body.is-embed.has-top-options-bar .wp-viewer-banner {
    top: 110px !important;
}

/* Hide center project name pill when perpendicular viewer mode is active to prevent overlap */
body.wp-viewer-active #canvas-project-name {
    display: none !important;
}


