:root {
    --bg-dark: #0d1117;
    --bg-panel: rgba(22, 27, 34, 0.94);
    --bg-hover: rgba(56, 139, 253, 0.15);
    --border-color: rgba(240, 246, 252, 0.12);
    --text-main: #f0f6fc;
    --text-muted: #8b949e;
    --accent-blue: #388bfd;
    --accent-gold: #f59e0b;
    --accent-green: #2ea043;
    --accent-red: #f85149;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
}

/* App Header */
#header {
    height: 52px;
    flex-shrink: 0;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
    backdrop-filter: blur(12px);
    white-space: nowrap;
    gap: 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 15px;
    color: var(--accent-blue);
    flex-shrink: 0;
}

.brand svg {
    width: 22px;
    height: 22px;
    fill: var(--accent-blue);
}

.header-center {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    max-width: 680px;
    margin: 0 12px;
    position: relative;
    min-width: 0;
}

.model-select-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

select.app-select {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    outline: none;
    cursor: pointer;
    max-width: 170px;
}

select.app-select:hover {
    border-color: var(--accent-blue);
}

/* Search Box */
.search-container {
    flex: 1;
    position: relative;
    min-width: 180px;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0 8px;
    transition: all 0.2s;
}

.search-input-wrapper:focus-within {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(56, 139, 253, 0.25);
    background: rgba(255, 255, 255, 0.1);
}

.search-icon {
    font-size: 13px;
    color: var(--text-muted);
    margin-right: 6px;
}

#search-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    padding: 6px 0;
    font-size: 12px;
}

#search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #1c2128;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-height: 340px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 2000;
}
    z-index: 2000;
}

.search-result-item {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.search-result-item:hover, .search-result-item.active {
    background: var(--bg-hover);
}

.search-result-item .item-title {
    font-weight: 600;
    color: var(--text-main);
}

.search-result-item .item-sub {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Header Tools */
.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-blue);
}

.btn-primary {
    background: #238636;
    border-color: #2ea043;
    color: #fff;
    font-weight: 600;
}

.btn-primary:hover {
    background: #2ea043;
}

/* Main Layout */
#main-container {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* Left Sidebar */
#sidebar {
    width: 330px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 500;
    backdrop-filter: blur(12px);
}

.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
}

.tab-btn {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
    background: rgba(56, 139, 253, 0.05);
}

.tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: none;
}

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

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.section-actions {
    display: flex;
    gap: 8px;
}

.link-btn {
    color: var(--accent-blue);
    background: none;
    border: none;
    font-size: 11px;
    cursor: pointer;
}

.link-btn:hover {
    text-decoration: underline;
}

/* Floor & Category Switch Items */
.filter-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 6px;
    margin-bottom: 4px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.filter-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.filter-item.active {
    border-color: rgba(56, 139, 253, 0.3);
}

.filter-label-group {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.filter-checkbox {
    cursor: pointer;
    accent-color: var(--accent-blue);
    width: 16px;
    height: 16px;
}

.badge {
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
}

.badge-count {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-muted);
}

.badge-elev {
    background: rgba(56, 139, 253, 0.2);
    color: #58a6ff;
    font-family: var(--font-mono);
}

/* 3D Canvas Area */
#viewport-container {
    flex: 1;
    position: relative;
    background: radial-gradient(circle at center, #151b26 0%, #0d1117 100%);
}

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

/* Floating View Toolbar */
#view-toolbar {
    position: absolute;
    top: 16px;
    left: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-panel);
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    z-index: 100;
}

.tool-btn {
    padding: 6px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-main);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.tool-btn:hover, .tool-btn.active {
    background: var(--accent-blue);
    color: #fff;
}

/* Progress Overlay */
#progress-box {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(13, 17, 23, 0.94);
    border: 1px solid var(--accent-blue);
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    display: none;
    z-index: 1200;
    min-width: 380px;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
}

#progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-blue);
    transition: width 0.2s;
}

/* Tooltip on Hover */
#hover-tooltip {
    position: absolute;
    pointer-events: none;
    background: rgba(13, 17, 23, 0.95);
    border: 1px solid var(--accent-blue);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    display: none;
    z-index: 1500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Loading Overlay */
#loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    transition: opacity 0.3s;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 14px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loading-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
}

/* Right Floating BIM Property Inspector Drawer */
#property-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    bottom: 12px;
    width: 400px;
    max-width: calc(100vw - 24px);
    background: rgba(18, 23, 31, 0.96);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    z-index: 800;
    backdrop-filter: blur(20px);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
    overflow: hidden;
}

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

.panel-header {
    height: 48px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
    flex-shrink: 0;
    gap: 8px;
}

.panel-title {
    font-size: 13px;
    font-weight: 600;
    color: #f0f6fc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.panel-action-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 4px 8px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
    user-select: none;
}

.panel-action-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
    color: #58a6ff;
}

.panel-action-btn.active {
    background: rgba(245, 158, 11, 0.25);
    border-color: var(--accent-gold);
    color: #fbbf24;
}

.panel-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    margin-top: 50px;
    font-size: 13px;
    line-height: 1.6;
}

.prop-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
}

.prop-card-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.prop-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 12px;
}

.prop-table tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.prop-table tr:last-child {
    border-bottom: none;
}

.prop-table td {
    padding: 5px 0;
}

.prop-table td.prop-key {
    color: var(--text-muted);
    width: 38%;
    word-break: break-word;
    font-size: 11px;
    vertical-align: top;
}

.prop-table td.prop-val {
    color: var(--text-main);
    font-family: var(--font-mono);
    width: 62%;
    word-break: break-all;
    font-size: 11px;
    user-select: text;
    padding-left: 4px;
}

/* Floating Isolate Banner */
#isolate-banner {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(245, 158, 11, 0.95);
    color: #0f141c;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    z-index: 600;
    backdrop-filter: blur(8px);
    white-space: nowrap;
}

#isolate-banner button {
    background: #0f141c;
    color: #fff;
    border: none;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.15s;
}

#isolate-banner button:hover {
    background: #24292f;
}

/* Accordion for Psets */
.pset-accordion {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 8px;
    overflow: hidden;
}

.pset-header {
    background: rgba(255, 255, 255, 0.04);
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    transition: background 0.2s;
}

.pset-header:hover {
    background: rgba(255, 255, 255, 0.08);
}

.pset-header .arrow {
    transition: transform 0.2s;
    font-size: 10px;
}

.pset-accordion.open .pset-header .arrow {
    transform: rotate(90deg);
}

.pset-content {
    display: none;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.15);
}

.pset-accordion.open .pset-content {
    display: block;
}

/* Bottom Status Bar */
#statusbar {
    height: 30px;
    background: #090d13;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    z-index: 1000;
}

.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* ==========================================================================
   4-Layer Element Tree (Building -> Storey -> Element Type -> Element)
   ========================================================================== */
.tree-controls-bar {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tree-search-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-canvas);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 8px;
    gap: 6px;
}

.tree-search-icon {
    font-size: 12px;
    opacity: 0.6;
}

#tree-search-input {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 12px;
    width: 100%;
    outline: none;
}

.icon-btn-clear {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    padding: 2px 4px;
}
.icon-btn-clear:hover {
    color: var(--text-main);
}

.tree-actions-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
}

.badge-mini {
    font-size: 10px;
    padding: 2px 6px;
    background: rgba(88, 166, 255, 0.12);
    color: #58a6ff;
    border-radius: 10px;
    border: 1px solid rgba(88, 166, 255, 0.25);
    font-family: var(--font-mono);
}

.tree-btn-group {
    display: flex;
    gap: 8px;
}

.tree-view-container {
    padding: 6px 4px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    font-size: 12px;
}

/* Tree Nodes */
.tree-node-row {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 6px;
    border-radius: 5px;
    cursor: pointer;
    user-select: none;
    transition: background 0.12s, color 0.12s;
    min-height: 26px;
}

.tree-node-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.tree-node-row.selected {
    background: rgba(88, 166, 255, 0.2) !important;
    border: 1px solid rgba(88, 166, 255, 0.4);
    color: #58a6ff;
    font-weight: 500;
}

.tree-node-row.active-type {
    background: rgba(255, 255, 255, 0.03);
}

.tree-expander {
    width: 14px;
    height: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: var(--text-muted);
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.tree-expander.expanded {
    transform: rotate(90deg);
    color: var(--text-main);
}

.tree-expander.leaf {
    visibility: hidden;
}

.tree-icon {
    font-size: 13px;
    flex-shrink: 0;
}

.tree-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
}

.tree-count-badge {
    font-size: 10px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.06);
    padding: 1px 5px;
    border-radius: 8px;
    margin-left: 4px;
    flex-shrink: 0;
    font-family: var(--font-mono);
}

.tree-node-children {
    display: none;
    margin-left: 12px;
    padding-left: 4px;
    border-left: 1px dashed rgba(255, 255, 255, 0.1);
}

.tree-node-children.open {
    display: block;
}

/* Quick Action Buttons on hover */
.tree-node-actions {
    display: none;
    gap: 3px;
    margin-left: 4px;
    flex-shrink: 0;
}

.tree-node-row:hover .tree-node-actions {
    display: flex;
}

.tree-mini-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 3px;
    padding: 1px 4px;
    font-size: 10px;
    cursor: pointer;
    line-height: 1.2;
}

.tree-mini-btn:hover {
    background: var(--accent-blue);
    color: #fff;
}

/* Layer Specific Highlighting */
.tree-layer-1 > .tree-node-row {
    font-weight: 600;
    color: #f0f6fc;
    background: rgba(255, 255, 255, 0.03);
    margin-bottom: 2px;
}

.tree-layer-2 > .tree-node-row {
    font-weight: 500;
    color: #d1d7e0;
}

.tree-layer-3 > .tree-node-row {
    color: #adbac7;
}

.tree-layer-4 > .tree-node-row {
    color: var(--text-secondary);
    font-size: 11.5px;
}

/* ==========================================================================
   IFC Relationships & Geometry Chaser Modal Window
   ========================================================================== */
.relations-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2500;
    padding: 20px;
}

.relations-window {
    background: #121820;
    border: 1px solid rgba(88, 166, 255, 0.3);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    width: 1080px;
    max-width: 95vw;
    height: 84vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalPopIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.relations-window.maximized {
    width: 99vw !important;
    max-width: 99vw !important;
    height: 98vh !important;
    border-radius: 4px;
}

@keyframes modalPopIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.relations-header {
    background: #161f2c;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    cursor: default;
    user-select: none;
}

.relations-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
    color: #f0f6fc;
}

.relations-header-right {
    display: flex;
    gap: 6px;
}

.window-control-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: 5px;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 12px;
}

.window-control-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-main);
}

#btn-rel-close:hover {
    background: #da3633;
    color: #fff;
    border-color: #da3633;
}

/* Target Element Bar */
.relations-target-bar {
    padding: 9px 16px;
    background: rgba(0, 0, 0, 0.25);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.target-badge-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-type {
    background: rgba(88, 166, 255, 0.15);
    border: 1px solid rgba(88, 166, 255, 0.35);
    color: #58a6ff;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-mono);
}

.badge-step {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #fbbf24;
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-mono);
}

.target-name {
    font-size: 13px;
    color: #f0f6fc;
    font-weight: 500;
    max-width: 500px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.target-guid-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.target-guid-wrapper code {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    color: #8b949e;
    font-family: var(--font-mono);
}

.btn-copy-small {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 12px;
    opacity: 0.7;
}
.btn-copy-small:hover {
    opacity: 1;
}

/* Modal Tabs */
.relations-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
    padding: 0 16px;
}

.rel-tab-btn {
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.rel-tab-btn:hover {
    color: var(--text-main);
}

.rel-tab-btn.active {
    color: #58a6ff;
    border-bottom-color: #58a6ff;
    font-weight: 600;
}

/* Relations Body */
.relations-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.rel-tab-content {
    display: none;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.rel-tab-content.active {
    display: flex;
    flex-direction: column;
}

/* Geometry Chaser Tab Layout */
.geom-chaser-layout {
    display: flex;
    flex: 1;
    min-height: 0;
}

.geom-chaser-tree-col {
    width: 48%;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: rgba(0, 0, 0, 0.15);
}

.geom-chaser-detail-col {
    width: 52%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #0d121a;
}

.column-title {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.badge-tag {
    font-size: 10px;
    padding: 1px 5px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    color: var(--text-secondary);
    font-weight: normal;
}

.chaser-tree-view {
    flex: 1;
    overflow-y: auto;
    padding: 10px 8px;
    font-size: 12px;
}

.chaser-detail-view {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
}

/* Chaser Node Styles */
.chaser-node-card {
    border-left: 2px solid #30363d;
    margin-left: 10px;
    padding-left: 10px;
    margin-bottom: 6px;
}

.chaser-node-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.12s;
}

.chaser-node-header:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(88, 166, 255, 0.3);
}

.chaser-node-header.active {
    background: rgba(88, 166, 255, 0.18);
    border-color: #58a6ff;
    color: #58a6ff;
}

.chaser-step-id {
    font-size: 10px;
    font-family: var(--font-mono);
    color: #e3b341;
    background: rgba(245, 158, 11, 0.1);
    padding: 1px 4px;
    border-radius: 3px;
}

.chaser-type-title {
    font-weight: 600;
    font-size: 12px;
}

.chaser-attr-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: auto;
}

/* Network Layout */
.network-layout {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.network-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 14px;
}

.network-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 14px;
    transition: border-color 0.15s;
}

.network-card:hover {
    border-color: rgba(88, 166, 255, 0.3);
}

.network-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 8px;
    margin-bottom: 10px;
}

.network-card-title {
    font-size: 12px;
    font-weight: 600;
    color: #58a6ff;
    display: flex;
    align-items: center;
    gap: 6px;
}

.network-item-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 4px 0;
    font-size: 12px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.04);
}

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

.network-key {
    color: var(--text-muted);
    font-size: 11.5px;
    width: 40%;
}

.network-val {
    color: var(--text-main);
    font-size: 12px;
    width: 60%;
    text-align: right;
    word-break: break-word;
}

/* STEP Inspector Tab */
.step-inspector-layout {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 14px 16px;
    gap: 12px;
    overflow-y: auto;
}

.step-nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
}

.step-history-nav {
    display: flex;
    gap: 8px;
}

.nav-history-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}
.nav-history-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.step-direct-jump {
    display: flex;
    align-items: center;
    gap: 8px;
}

#step-jump-input {
    background: var(--bg-canvas);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-main);
    padding: 4px 8px;
    font-size: 12px;
    width: 90px;
    font-family: var(--font-mono);
}

.btn-jump {
    background: var(--accent-blue);
    border: none;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.raw-step-banner {
    background: #090d13;
    border: 1px solid rgba(88, 166, 255, 0.25);
    border-radius: 6px;
    padding: 10px 14px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: #e6edf3;
    word-break: break-all;
    line-height: 1.5;
}

.step-ref-link {
    color: #58a6ff;
    cursor: pointer;
    text-decoration: underline;
    font-family: var(--font-mono);
    font-weight: 500;
}
.step-ref-link:hover {
    color: #79c0ff;
}

.attr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-top: 8px;
}

.attr-table th {
    background: rgba(255, 255, 255, 0.04);
    text-align: left;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 11px;
}

.attr-table td {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 11.5px;
    vertical-align: top;
}

/* ==========================================================================
   Ruler Measurement & Corner Point Locator Styles
   ========================================================================== */

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

/* 3D Label Overlay Container */
#viewport-overlay-labels {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 90;
}

/* Measurement Dimension Badge */
.dim-badge {
    position: absolute;
    background: rgba(13, 17, 23, 0.94);
    border: 1px solid #00f0ff;
    border-radius: 6px;
    padding: 5px 9px;
    color: #f0f6fc;
    font-family: var(--font-mono);
    font-size: 11px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6), 0 0 10px rgba(0, 240, 255, 0.2);
    pointer-events: auto;
    cursor: default;
    user-select: none;
    white-space: nowrap;
    z-index: 95;
    transition: all 0.2s;
}

.dim-badge:hover {
    border-color: #58a6ff;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.8), 0 0 14px rgba(0, 240, 255, 0.4);
    z-index: 98;
}

.dim-badge-main {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dim-icon {
    font-size: 12px;
}

.dim-length {
    color: #00f0ff;
    font-weight: 700;
    font-size: 12px;
}

.dim-m {
    color: #8b949e;
    font-size: 10.5px;
}

.dim-btn-del {
    background: none;
    border: none;
    color: #8b949e;
    cursor: pointer;
    font-size: 11px;
    padding: 0 3px;
    margin-left: 2px;
    border-radius: 3px;
    line-height: 1;
}

.dim-btn-del:hover {
    color: #f85149;
    background: rgba(248, 81, 73, 0.15);
}

.dim-badge-deltas {
    font-size: 9.5px;
    color: #8b949e;
    margin-top: 3px;
    padding-top: 2px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    gap: 6px;
}

/* Corner Pin Badge */
.corner-pin-badge {
    position: absolute;
    background: rgba(13, 17, 23, 0.94);
    border: 1px solid #ffeb3b;
    border-radius: 6px;
    padding: 5px 9px;
    color: #f0f6fc;
    font-family: var(--font-mono);
    font-size: 10.5px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6), 0 0 10px rgba(255, 235, 59, 0.25);
    pointer-events: auto;
    user-select: none;
    white-space: nowrap;
    z-index: 95;
    transition: all 0.2s;
}

.corner-pin-badge:hover {
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.8), 0 0 14px rgba(255, 235, 59, 0.5);
    z-index: 98;
}

.pin-badge-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-weight: 600;
    color: #ffeb3b;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 2px;
    margin-bottom: 3px;
}

.pin-btn-del {
    background: none;
    border: none;
    color: #8b949e;
    cursor: pointer;
    font-size: 11px;
    padding: 0 3px;
    line-height: 1;
}

.pin-btn-del:hover {
    color: #f85149;
    background: rgba(248, 81, 73, 0.15);
}

.pin-badge-coords {
    font-size: 10px;
    color: #c9d1d9;
    line-height: 1.35;
}

.pin-badge-coords b {
    color: #58a6ff;
}

.pin-badge-meta {
    font-size: 9px;
    color: #8b949e;
    margin-top: 3px;
}

/* Floating Tool HUDs (Ruler & Corner Locator) */
.floating-hud {
    position: absolute;
    top: 68px;
    left: 16px;
    background: rgba(13, 17, 23, 0.94);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px;
    width: 300px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    z-index: 100;
}

.hud-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.hud-title-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 12px;
    color: #f0f6fc;
}

.hud-instruction {
    font-size: 11px;
    color: #8b949e;
    line-height: 1.4;
    margin-bottom: 8px;
}

.hud-readout {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 8px;
    font-family: var(--font-mono);
}

.readout-primary {
    font-size: 13px;
    font-weight: 700;
    color: #00f0ff;
}

.readout-sub {
    font-size: 11px;
    color: #8b949e;
    font-weight: 400;
    margin-left: 4px;
}

.readout-deltas {
    font-size: 10px;
    color: #8b949e;
    margin-top: 4px;
}

.hud-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Corner Points Table in Properties Panel */
.corners-table-wrapper {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow-y: auto;
    max-height: 180px;
}

.corner-row {
    transition: background 0.15s;
}

.corner-row:hover {
    background: rgba(56, 139, 253, 0.12);
}

.btn-locate-corner {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: #58a6ff;
    padding: 2px 6px;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-locate-corner:hover {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
}

