/* Demo Page Styles */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #14b8a6;
    --text: #0f172a;
    --muted: #475569;
    --surface: #ffffff;
    --surface-muted: #f1f5f9;
    --surface-muted-2: #e2e8f0;
    --border: #e2e8f0;
    --success: #16a34a;
    --disabled-bg: #cbd5e1;
    --overlay: rgba(15, 23, 42, 0.55);
    --tutorial-width: 360px;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background: var(--surface-muted);
    color: var(--text);
}

.demo-layout {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: white;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    padding: 16px;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.sidebar-header {
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 2px solid #667eea;
}

.header-top {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.back-btn {
    display: inline-block;
    padding: 8px 16px;
    background: #f8f9fa;
    color: #667eea;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid #e0e0e0;
}

.back-btn:hover {
    background: #667eea;
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.2);
}

.sidebar-header h2 {
    margin: 0;
    color: #333;
    font-size: 20px;
    font-weight: 600;
}

/* File Selection */
.file-selection {
    margin-bottom: 30px;
}

.file-selection h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 18px;
    font-weight: 500;
}

.source-tabs {
    display: flex;
    margin-bottom: 8px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.layer-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #555;
    margin-bottom: 12px;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.legend-dot--a { background: rgb(116, 151, 223); }
.legend-dot--b { background: rgb(38, 166, 154); }

.tab-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: #f8f9fa;
    color: #666;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: #667eea;
    color: white;
}

.tab-btn:hover:not(.active) {
    background: #e9ecef;
}

.source-content {
    display: none;
}

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

.file-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: white;
}

.file-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: default;
    transition: background 0.2s ease;
    display: flex;
    gap: 12px;
    align-items: center;
}
.file-meta {
    flex: 1;
    cursor: pointer;
}

.file-item:hover {
    background: #f8f9fa;
}

.file-item--active {
    background: #f0f3ff;
    border-left: 3px solid #667eea;
    padding-left: 13px;
}

.file-item--active .file-name::after {
    content: ' ★';
    font-size: 11px;
    color: #667eea;
    font-weight: 700;
}

/* Pipeline active-file banner */
.pipeline-active-file {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: #555;
    background: #f0f3ff;
    border: 1px solid #d0d8f8;
    border-radius: 6px;
    padding: 7px 12px;
    margin-bottom: 14px;
}

.pipeline-active-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    flex-shrink: 0;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.pipeline-active-text {
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-all;
}

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

.file-name {
    font-weight: 500;
    color: #333;
    display: block;
    margin-bottom: 4px;
}

.file-toggle {
    display: flex;
    align-items: center;
    user-select: none;
    flex-shrink: 0;
}

.file-toggle input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 36px;
    height: 20px;
    border-radius: 10px;
    background: #ccc;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
    outline: none;
    border: none;
    flex-shrink: 0;
}

.file-toggle input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: white;
    transition: left 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.file-toggle input[type="checkbox"]:checked {
    background: #667eea;
}

.file-toggle input[type="checkbox"]:checked::after {
    left: 19px;
}

.file-size {
    font-size: 12px;
    color: #666;
}

.loading {
    padding: 20px;
    text-align: center;
    color: #666;
}

/* Pipeline Steps */
.pipeline-steps {
    margin-top: 30px;
}

.pipeline-steps h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 18px;
    font-weight: 500;
}

.step {
    display: flex;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    position: relative;
}

/* Step 1: orange when current (Geometric Featurization) */
.step.step-current-orange { border-left-color: rgb(255, 152, 0); }
.step.step-current-orange .step-number { background: rgb(255, 152, 0); }

/* Step 2: yellow when current (BKAFI Blocking) */
.step.step-current-yellow { border-left-color: rgb(255, 193, 7); }
.step.step-current-yellow .step-number { background: rgb(255, 193, 7); color: #333; }

/* Any step: green when completed */
.step.step-completed { border-left-color: #28a745; }
.step.step-completed .step-number { background: #28a745; color: white; }

.step-number {
    width: 30px;
    height: 30px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-right: 15px;
    flex-shrink: 0;
}

.step-status {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
}

.step-status.completed {
    color: #28a745;
}

.step-content {
    flex: 1;
}

.step-content h4 {
    margin: 0 0 5px 0;
    color: #333;
    font-size: 14px;
    font-weight: 600;
}

.step-content p {
    margin: 0 0 10px 0;
    color: #666;
    font-size: 12px;
    line-height: 1.4;
}

.step-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.step-btn:hover:not(:disabled) {
    background: #5a6fd8;
}

.step-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.viewer-container {
    flex: 1;
    background: white;
    margin: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: visible;
}

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

.viewer-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.viewer-controls {
    display: none;
}

.control-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s ease;
}

.control-btn:hover {
    background: #5a6fd8;
}


.viewer {
    height: calc(100vh - 120px);
    position: relative;
    background: #f8f9fa;
}

/* Touch-friendly map controls (zoom, rotate, tilt, home) — right side above Cesium toolbar */
.viewer-map-controls {
    position: absolute;
    right: 12px;
    bottom: 50px;
    z-index: 110;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: auto;
}
.viewer-map-control-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    color: rgba(255,255,255,0.95);
    background: rgba(38, 38, 38, 0.88);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}
.viewer-map-control-btn:hover {
    background: rgba(55, 55, 55, 0.95);
    color: #fff;
}
.viewer-map-control-btn:active {
    transform: scale(0.96);
}
.viewer-map-control-btn-home {
    font-size: 18px;
    margin-top: 4px;
}

/* Floating legend — dark Cesium-style panel */
/* ── Layer legend panel column ───────────────────────────────────────────── */

/* The legend is now a fixed-width column between the sidebar and the map,
   not an overlay on top of the Cesium canvas. */
.legend-col {
    width: 260px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.viewer-legend {
    padding: 12px 10px 16px;
    flex: 1;
}

.viewer-legend-title {
    font-size: 10px;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #eee;
}

.viewer-legend-items {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.viewer-legend-group {
    font-size: 10px;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 10px;
    margin-bottom: 2px;
}

.viewer-legend-row {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #444;
    white-space: nowrap;
    overflow: hidden;
}

.viewer-legend-swatch {
    width: 11px;
    height: 11px;
    border-radius: 2px;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.12);
}

/* ── Legend interactive layer controls ───────────────────────────────────── */

.legend-layer-row {
    flex-wrap: nowrap;
    gap: 4px;
    padding: 3px 2px;
    border-radius: 4px;
    transition: background 0.1s;
}
.legend-layer-row:hover { background: #f5f5f5; }

.legend-row-unloaded { opacity: 0.45; }

/* Checkbox */
.legend-layer-cb {
    appearance: none;
    -webkit-appearance: none;
    width: 13px;
    height: 13px;
    border: 1.5px solid #bbb;
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    transition: background 0.15s, border-color 0.15s;
}
.legend-layer-cb:checked {
    background: #7497df;
    border-color: #7497df;
}
.legend-layer-cb:checked::after {
    content: '';
    display: block;
    position: absolute;
    left: 2px; top: 0px;
    width: 5px; height: 8px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}
.legend-layer-cb:hover { border-color: #667eea; }

/* Layer name */
.legend-layer-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    color: #444;
    min-width: 0;
}
.legend-row-active .legend-layer-name { color: #667eea; font-weight: 600; }

/* "active" badge shown next to active Source-A layer */
.legend-active-tag {
    display: inline-block;
    padding: 0 3px;
    font-size: 8px;
    border-radius: 3px;
    background: #667eea;
    color: #fff;
    vertical-align: middle;
    line-height: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    flex-shrink: 0;
}


/* Dim button */
.legend-dim-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    padding: 0 1px;
    line-height: 1;
    flex-shrink: 0;
    color: #bbb;
    transition: color 0.15s;
}
.legend-dim-btn:hover:not(:disabled) { color: #333; }
.legend-dim-btn:disabled { opacity: 0.25; cursor: default; }
.legend-dim-btn.btn-dimmed { color: #ff9800; }

/* Zoom-to-layer button */
.legend-zoom-btn {
    background: none;
    border: none;
    color: #bbb;
    cursor: pointer;
    font-size: 13px;
    padding: 0 1px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s;
}
.legend-zoom-btn:hover:not(:disabled) { color: #333; }
.legend-zoom-btn:disabled { opacity: 0.3; cursor: default; }

/* Zoom-to-layer button in the file list */
.zoom-layer-btn {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 15px;
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s;
}
.zoom-layer-btn:hover:not(:disabled) {
    color: #667eea;
}
.zoom-layer-btn:disabled {
    color: #ddd;
    cursor: default;
}

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

/* Compact summary table */
.summary-section {
    padding: 0;
}
.summary-section--sep {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #e8e8e8;
}
.summary-file-label {
    font-size: 12px;
    font-weight: 600;
    color: #667eea;
    background: #f0f3ff;
    border-left: 3px solid #667eea;
    padding: 5px 10px;
    border-radius: 4px;
    margin-bottom: 8px;
    word-break: break-all;
}
.summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.srow-group td {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #999;
    padding: 8px 0 3px;
}
.srow td {
    padding: 5px 4px;
    border-bottom: 1px solid #f4f4f4;
    vertical-align: middle;
}
.srow:last-child td { border-bottom: none; }
.srow-label {
    color: #444;
    width: 56%;
}
.srow-value {
    font-weight: 700;
    font-size: 15px;
    text-align: right;
    white-space: nowrap;
}
.srow-sub {
    font-size: 11px;
    color: #999;
    text-align: right;
    white-space: nowrap;
    padding-left: 8px;
}

.info-badge {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--muted);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    position: relative;
    padding: 0;
}

.info-badge::after {
    content: attr(data-help);
    position: absolute;
    right: 0;
    top: 28px;
    min-width: 220px;
    max-width: 280px;
    background: #0f172a;
    color: #fff;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.4;
    white-space: normal;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 5;
}

.info-badge:hover::after,
.info-badge.active::after {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
}

.placeholder-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.placeholder p {
    margin: 0;
    font-size: 16px;
}

/* Location Map */
.location-map {
    margin-top: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.location-map h3 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 16px;
    font-weight: 500;
}

#location-map {
    border: 1px solid #e0e0e0;
}

/* Building Properties Window */
.properties-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    max-width: 90vw;
    max-height: 80vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

.properties-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
    border-radius: 12px 12px 0 0;
}

.properties-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.properties-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    max-height: calc(80vh - 200px); /* Ensure scrolling if content exceeds window */
}

.properties-list {
    margin-bottom: 20px;
    /* Remove max-height and overflow - let parent .properties-content handle scrolling */
    padding-right: 5px;
}

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

.properties-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.properties-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.properties-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.property-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

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

.property-key {
    font-weight: 600;
    color: #333;
    font-size: 13px;
    flex: 1;
}

.property-value {
    color: #666;
    font-size: 13px;
    text-align: right;
    flex: 1;
}

.property-separator {
    margin: 15px 0 10px 0;
    padding-top: 15px;
    border-top: 2px solid #e0e0e0;
}

.feature-item {
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 4px;
    margin: 5px 0;
}

.properties-actions {
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
    margin-top: 15px;
}

.action-btn {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.action-btn:hover:not(:disabled) {
    background: #5a6fd8;
}

.action-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

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

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

/* Matches Window */
.matches-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 700px;
    max-width: 95vw;
    max-height: 90vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

.matches-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
    border-radius: 12px 12px 0 0;
}

.matches-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

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

.close-btn:hover {
    background: #e0e0e0;
    color: #000;
}

.matches-content {
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    max-height: calc(90vh - 80px); /* Account for header height */
    box-sizing: border-box;
}

.matches-content > * {
    box-sizing: border-box;
    max-width: 100%;
}

/* Custom scrollbar for matches content */
.matches-content::-webkit-scrollbar {
    width: 8px;
}

.matches-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.matches-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.matches-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.building-info {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #667eea;
}

.building-info h4 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
    display: none; /* Hide building name - only show ID */
}

.building-info p {
    margin: 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.building-props-sources {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #e0e0e0;
}
.building-props-sources .building-sources-label {
    margin: 0 0 4px 0;
    font-size: 12px;
    font-weight: 600;
    color: #555;
}
.building-props-sources .building-sources-list {
    margin: 0;
    font-size: 12px;
    font-weight: normal;
    color: #333;
    word-break: break-all;
    max-height: 3.6em;
    overflow-y: auto;
}

.matches-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.match-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    border-left: 4px solid #667eea;
    transition: all 0.2s ease;
}

.match-item:hover {
    background: #e9ecef;
    transform: translateX(4px);
}

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

.match-source {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.match-confidence {
    background: #28a745;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.match-details {
    font-size: 13px;
    color: #666;
}

.match-details p {
    margin: 4px 0;
}

.match-details strong {
    color: #333;
}

.match-details button {
    margin-top: 10px;
    padding: 8px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s ease;
}

.match-details button:hover {
    background: #5a6fd8;
}

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

.matches-overlay.active {
    display: block;
}

/* BKAFI Comparison Window */
.comparison-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 95vw;
    height: 90vh;
    max-width: 1600px;
    max-height: 900px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Prevent window itself from scrolling */
}

.comparison-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
    border-radius: 12px 12px 0 0;
}

.comparison-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.comparison-content {
    flex: 1;
    padding: 15px; /* Reduced padding to save space */
    overflow-y: auto; /* Enable scrolling for entire comparison window */
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Allow flex children to shrink */
    /* Ensure scrollbar is always visible when content overflows */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on mobile */
}

/* Style scrollbar for comparison content */
.comparison-content::-webkit-scrollbar {
    width: 8px;
}

.comparison-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.comparison-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.comparison-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Style scrollbar for classifier results */
#classifier-results::-webkit-scrollbar {
    width: 6px;
}

#classifier-results::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#classifier-results::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

#classifier-results::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* When tutorial panel is open, keep comparison window clear of the 400px right panel */
body.tutorial-open .comparison-window {
    left: 0;
    right: 400px;
    transform: translateY(-50%);
    width: auto;
    max-width: none;
}

/* Responsive design for mobile/phone */
@media (max-width: 768px) {
    .comparison-window {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        top: 0;
        left: 0;
        transform: none;
    }
    
    .comparison-layout {
        flex-direction: column; /* Stack vertically on mobile */
        gap: 10px;
    }
    
    .comparison-viewer-container,
    .comparison-pairs-container {
        flex: 0 0 auto; /* Don't flex on mobile, use natural height */
    }
    
    .comparison-viewer {
        height: 180px;
        min-height: 180px;
        max-height: 180px;
    }
    
    .comparison-pair-viewer {
        height: 160px;
        min-height: 160px;
        max-height: 160px;
        flex: 0 0 auto;
    }
    
    .comparison-pairs-viewers {
        overflow-y: auto; /* Allow scrolling on mobile */
    }
    
    .comparison-content {
        overflow-y: auto; /* Allow scrolling on mobile */
        padding: 8px;
    }
    
    #classifier-results {
        max-height: 300px; /* Limit height on mobile */
    }

    .comparison-header {
        position: sticky;
        top: 0;
        z-index: 2;
    }

    .comparison-content {
        padding-bottom: 20px;
    }
}

.comparison-layout {
    display: flex;
    gap: 15px;
    flex: 0 0 auto; /* Don't grow — let classifier section sit naturally below */
    align-items: stretch; /* Both columns same height */
}

.comparison-viewer-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    align-items: center; /* Center horizontally within the container */
    min-height: 0; /* Allow container to shrink */
    /* Use flex to distribute space: candidate gets fixed height, results get remaining space */
}

.comparison-pairs-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.viewer-label {
    font-weight: 600;
    color: #667eea;
    margin-bottom: 8px; /* Reduced margin to save space */
    font-size: 13px; /* Slightly smaller font */
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.comparison-viewer {
    width: 100%;
    height: 240px;
    min-height: 240px;
    max-height: 240px;
    flex-shrink: 0;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    position: relative;
}

.comparison-pairs-viewers {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    overflow: hidden;
}

/* Carousel card fills the right column */
#carousel-pair-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

#comparison-classifier-section {
    width: 100%;
    border-top: 2px solid #e0e0e0;
    padding-top: 12px;
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#classifier-results {
    flex: 1; /* Take all available space in the section */
    overflow-y: auto; /* Only scroll if content exceeds available space */
    min-height: 0;
}

.comparison-pair-viewer {
    width: 100%;
    height: 180px; /* Same size as candidate viewer */
    min-height: 180px;
    max-height: 180px;
    flex-shrink: 0; /* Prevent flexbox from shrinking */
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    position: relative;
}

.viewer-building-id {
    margin-top: 5px; /* Reduced margin to save space */
    margin-bottom: 5px;
    font-size: 11px; /* Slightly smaller font */
    color: #666;
    text-align: center;
    font-weight: 500;
}

.comparison-pair-item {
    display: flex;
    flex-direction: column;
    border: 3px solid transparent;
    border-radius: 8px;
    padding: 4px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
    position: relative;
}
.comparison-pair-item:hover:not(.pair-revealed) {
    border-color: #667eea55;
    box-shadow: 0 0 0 2px #667eea33;
}
.comparison-pair-item.pair-selected {
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px #f59e0b44;
    transform: scale(1.01);
}
.comparison-pair-item.pair-result-true {
    border-color: #22c55e;
    box-shadow: 0 0 0 3px #22c55e44;
}
.comparison-pair-item.pair-result-false-positive {
    border-color: #f97316;
    box-shadow: 0 0 0 3px #f9731644;
}
.comparison-pair-item.pair-result-no-match {
    border-color: #94a3b8;
}

/* Pick button on each pair card */
.pair-pick-btn {
    display: block;
    width: 100%;
    margin-top: 5px;
    padding: 6px 0;
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    letter-spacing: 0.02em;
}
.pair-pick-btn:hover { background: #5a6fd6; }
.pair-pick-btn.selected {
    background: #f59e0b;
    color: #fff;
}
.pair-pick-btn:disabled { background: #94a3b8; cursor: default; }

/* Your-pick badge on top of viewer */
.pair-your-pick-badge {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: #f59e0b;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 12px;
    z-index: 20;
    white-space: nowrap;
    pointer-events: none;
}

/* Result badge (after reveal) */
.pair-result-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    margin-top: 4px;
}
.pair-result-badge.true-match  { background: #22c55e; color: #fff; }
.pair-result-badge.false-pos   { background: #f97316; color: #fff; }
.pair-result-badge.no-match    { background: #94a3b8; color: #fff; }

/* ── Pair carousel ──────────────────────────────────────────────────────────── */
.carousel-nav-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border: none;
    border-radius: 50%;
    background: rgba(102, 126, 234, 0.82);
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
    line-height: 1;
    padding: 0;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.carousel-nav-btn:hover  { background: rgba(90, 111, 214, 0.95); }
.carousel-nav-btn:active { transform: translateY(-50%) scale(0.93); }
.carousel-nav-btn:disabled { background: rgba(203,213,225,0.7); color: #94a3b8; cursor: default; }

.carousel-nav-prev { left: 8px; }
.carousel-nav-next { right: 8px; }

/* Counter pill — floating at top-center of viewer */
.carousel-counter-overlay {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 30, 50, 0.6);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 14px;
    border-radius: 20px;
    z-index: 20;
    white-space: nowrap;
    pointer-events: none;
    letter-spacing: 0.02em;
}
.carousel-dot-row {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 4px;
}
.carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e1;
    transition: background 0.2s, transform 0.2s;
}
.carousel-dot.active {
    background: #667eea;
    transform: scale(1.2);
}
.carousel-dot.picked  { background: #f59e0b; }
.carousel-dot.result-true { background: #22c55e; }
.carousel-dot.result-fp   { background: #f97316; }
.carousel-dot.result-none { background: #94a3b8; }

/* Single pair card (carousel) — border goes on the viewer box itself via .comparison-viewer */
.carousel-pair-card {
    display: flex;
    flex-direction: column;
}
/* After reveal, result border is applied to the viewer box inside the card */
.carousel-pair-card.pair-selected      > .comparison-viewer { border-color: #f59e0b; box-shadow: 0 0 0 3px #f59e0b33; }
.carousel-pair-card.pair-result-true   > .comparison-viewer { border-color: #22c55e; box-shadow: 0 0 0 3px #22c55e33; }
.carousel-pair-card.pair-result-false-positive > .comparison-viewer { border-color: #f97316; box-shadow: 0 0 0 3px #f9731633; }
.carousel-pair-card.pair-result-no-match > .comparison-viewer { border-color: #94a3b8; }

/* "Your Pick" ribbon inside carousel */
.carousel-your-pick {
    display: none;
    position: absolute;
    top: 8px; left: 50%;
    transform: translateX(-50%);
    background: #f59e0b;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 12px;
    border-radius: 12px;
    z-index: 20;
    white-space: nowrap;
    pointer-events: none;
}
.carousel-your-pick.visible { display: block; }

/* Carousel result badge */
.carousel-result-badge {
    display: none;
    text-align: center;
    padding: 4px 0 6px;
    font-size: 12px;
    font-weight: 700;
}
.carousel-result-badge.visible { display: block; }
.carousel-result-badge.true-match  { color: #16a34a; }
.carousel-result-badge.false-pos   { color: #ea580c; }
.carousel-result-badge.no-match    { color: #64748b; }

/* ────────────────────────────────────────────────────────────────────────────── */

/* Game intro bar */
.game-intro-bar {
    background: linear-gradient(90deg, #667eea11, #764ba211);
    border: 1px solid #667eea33;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    color: #444;
    margin-bottom: 12px;
    text-align: center;
}
.game-intro-bar strong { color: #667eea; }

/* Guess bar under candidate */
.game-guess-bar {
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    font-size: 13px;
    text-align: center;
    color: #555;
    width: 100%;
}
.game-guess-bar .guess-text { font-weight: 600; color: #f59e0b; }

/* Reveal button */
.reveal-answer-btn {
    display: inline-block;
    width: auto;
    padding: 9px 24px;
    background: #22c55e;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    letter-spacing: 0.03em;
}
.reveal-answer-btn:hover { background: #16a34a; }
.reveal-answer-btn:disabled { opacity: 0.45; cursor: default; }

/* Back to Map button */
.back-to-map-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    align-self: center;
    margin-top: 4px;
}
.back-to-map-btn:hover  { background: #5a6fd6; }
.back-to-map-btn:active { transform: scale(0.97); }

/* Score banner (after reveal) */
.game-score-banner {
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    width: 100%;
    animation: fadeInScale 0.3s ease;
}
.game-score-banner.correct   { background: #dcfce7; color: #16a34a; border: 1.5px solid #22c55e; }
.game-score-banner.incorrect { background: #ffedd5; color: #c2410c; border: 1.5px solid #f97316; }
.game-score-banner.no-pick   { background: #f1f5f9; color: #475569; border: 1.5px solid #94a3b8; }

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

.comparison-pair-label {
    font-size: 12px;
    color: #667eea;
    font-weight: 600;
    margin-bottom: 5px;
}

.comparison-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    display: none;
}

.comparison-overlay.active {
    display: block;
}

/* Mobile action bar and panel */
.mobile-actions {
    display: none;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.mobile-action-btn {
    flex: 1 1 30%;
    min-width: 120px;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.mobile-panel-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    z-index: 10002;
}

.mobile-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.25);
    z-index: 10003;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mobile-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-muted);
}

.mobile-panel-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--text);
}

.mobile-panel-body {
    padding: 16px;
    overflow-y: auto;
}

body.mobile-panel-open {
    overflow: hidden;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .demo-layout,
    .sidebar,
    .main-content,
    .viewer-container,
    .viewer {
        max-width: 100%;
        overflow-x: hidden;
    }

    .demo-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
    }

    .sidebar-header h2 {
        font-size: 20px;
    }

    .header-top {
        flex-direction: column;
        align-items: stretch;
    }

    .back-btn,
    .tutorial-toggle-btn {
        display: block;
        width: 100%;
        text-align: center;
    }

    .header-top {
        text-align: center;
    }

    .tutorial-toggle-btn {
        margin-left: 0;
    }

    .mobile-actions {
        display: flex;
        flex-wrap: wrap;
        overflow-x: visible;
        padding-bottom: 6px;
        gap: 10px;
    }

    .sidebar .file-selection,
    .sidebar .location-map,
    .sidebar .pipeline-steps,
    .sidebar .repository-link {
        display: none;
    }

    .mobile-action-btn {
        flex: 1 1 calc(50% - 10px);
        min-width: 140px;
        font-size: 13px;
    }

    .mobile-panel .file-list {
        max-height: none;
    }

    .mobile-panel #location-map {
        height: 260px;
    }
    
    .main-content {
        display: none;
    }

    .properties-overlay {
        z-index: 10004;
    }

    .properties-window {
        z-index: 10005;
    }

    .viewer {
        height: 400px;
    }
    
    .matches-window {
        width: 95vw;
        max-height: 90vh;
    }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.loading-content {
    background: white;
    padding: 30px 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    min-width: 250px;
}

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.loading-message {
    font-size: 16px;
    color: #333;
    font-weight: 500;
}

/* Welcome Guide Modal */
.welcome-guide-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.welcome-guide-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
    position: relative;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.welcome-guide-header {
    padding: 25px 30px;
    border-bottom: 2px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 16px 16px 0 0;
}

.welcome-guide-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

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

.welcome-guide-header .close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.welcome-guide-body {
    padding: 30px;
}

.welcome-intro {
    font-size: 16px;
    color: #555;
    line-height: 1.6;
    margin-bottom: 30px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.guide-steps {
    margin-bottom: 30px;
}

.guide-step {
    display: flex;
    margin-bottom: 25px;
    align-items: flex-start;
}

.guide-step-number {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
    margin-right: 20px;
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}

.guide-step-content {
    flex: 1;
}

.guide-step-content h4 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: #333;
    font-weight: 600;
}

.guide-step-content p {
    margin: 0;
    color: #666;
    line-height: 1.6;
    font-size: 15px;
}

.guide-sublist {
    margin: 10px 0 0 0;
    padding-left: 20px;
    color: #666;
}

.guide-sublist li {
    margin-bottom: 8px;
    line-height: 1.5;
    font-size: 14px;
}

.guide-tips {
    background: #fff9e6;
    border: 1px solid #ffd700;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.guide-tips h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: #333;
}

.guide-tips ul {
    margin: 0;
    padding-left: 20px;
    color: #666;
}

.guide-tips li {
    margin-bottom: 8px;
    line-height: 1.5;
    font-size: 14px;
}

.welcome-guide-footer {
    padding: 20px 30px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    border-radius: 0 0 16px 16px;
}

.dont-show-again {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    user-select: none;
}

.dont-show-again input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.welcome-guide-footer .action-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}

.welcome-guide-footer .action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(102, 126, 234, 0.4);
}

.welcome-guide-footer .action-btn.primary:active {
    transform: translateY(0);
}

/* Tutorial Toggle Button */
.tutorial-toggle-btn {
    display: inline-block;
    padding: 8px 16px;
    background: #f8f9fa;
    color: #667eea;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    margin-left: 10px;
}

.tutorial-toggle-btn:hover {
    background: #667eea;
    color: white;
    text-decoration: none;
}

.header-top {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Interactive Tutorial Guide - Side Panel Style */
.tutorial-guide-overlay {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100%;
    background: transparent;
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    z-index: 10001;
    pointer-events: none;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.tutorial-guide-content {
    background: white;
    border-radius: 16px 0 0 16px;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.2);
    width: 100%;
    height: 100%;
    max-height: 100vh;
    overflow-y: auto;
    animation: slideInRight 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    border-left: 3px solid #667eea;
}

.tutorial-guide-header {
    padding: 20px 25px;
    border-bottom: 2px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 16px 0 0 0;
    flex-shrink: 0;
}

.tutorial-guide-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

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

.tutorial-guide-header .close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.tutorial-guide-body {
    padding: 20px 25px;
    flex: 1;
    overflow-y: auto;
}

.tutorial-step-content {
    min-height: 200px;
}

.tutorial-intro {
    font-size: 16px;
    color: #555;
    line-height: 1.6;
    margin-bottom: 15px;
}

.tutorial-step-content h4 {
    margin: 0 0 12px 0;
    font-size: 18px;
    color: #333;
    font-weight: 600;
}

.tutorial-step-content p {
    margin: 0 0 12px 0;
    color: #666;
    line-height: 1.6;
    font-size: 15px;
}

.tutorial-hint {
    background: #fff9e6;
    border-left: 4px solid #ffd700;
    padding: 12px 15px;
    margin: 15px 0;
    border-radius: 4px;
    font-style: italic;
    color: #666;
}

/* Example building cards used in the tutorial */
.tutorial-example-buildings {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 14px 0;
}

.tutorial-building-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid;
    font-size: 14px;
    line-height: 1.5;
}

.tutorial-building-card code {
    font-size: 12px;
    background: rgba(0,0,0,0.06);
    padding: 1px 4px;
    border-radius: 3px;
}

.tutorial-building-card small {
    color: #777;
    display: block;
    margin-top: 2px;
}

.tutorial-building-true {
    background: #f0fff4;
    border-color: #a8d5b5;
}

.tutorial-building-false {
    background: #fff5f5;
    border-color: #f5b8b8;
}

.tutorial-building-icon {
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Tag labels replacing emojis in tutorial building cards */
.tutorial-tag {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    flex-shrink: 0;
    margin-top: 2px;
    align-self: flex-start;
}

.tutorial-tag-match {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.tutorial-tag-fp {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffcc80;
}

/* Color swatch row for pipeline stage explanations */
.tutorial-color-legend {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 9px 12px;
    margin: 12px 0;
    font-size: 13px;
    color: #555;
    flex-wrap: wrap;
}

.tutorial-swatch {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.15);
    vertical-align: middle;
    flex-shrink: 0;
}

.tutorial-sublist {
    margin: 15px 0 0 0;
    padding-left: 20px;
    color: #666;
}

.tutorial-sublist li {
    margin-bottom: 10px;
    line-height: 1.6;
    font-size: 14px;
}

.tutorial-tips {
    background: #f0f7ff;
    border: 1px solid #667eea;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.tutorial-tips h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: #333;
}

.tutorial-tips ul {
    margin: 0;
    padding-left: 20px;
    color: #666;
}

.tutorial-tips li {
    margin-bottom: 8px;
    line-height: 1.5;
    font-size: 14px;
}

.tutorial-progress {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.tutorial-progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.tutorial-progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.tutorial-progress-text {
    font-size: 14px;
    color: #666;
    text-align: center;
    display: block;
}

.tutorial-guide-footer {
    padding: 15px 25px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    border-radius: 0 0 0 16px;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 10px;
}

.tutorial-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.tutorial-guide-footer .action-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    white-space: nowrap;
}

.tutorial-guide-footer .action-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}

.tutorial-guide-footer .action-btn.primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(102, 126, 234, 0.4);
}

.tutorial-guide-footer .action-btn.primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.tutorial-guide-footer .action-btn.secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.tutorial-guide-footer .action-btn.secondary:hover {
    background: #f0f7ff;
}

/* Tutorial Highlight Overlay — spotlight backdrop */
.tutorial-highlight {
    position: fixed;
    border: 3px solid #667eea;
    border-radius: 8px;
    pointer-events: none;
    z-index: 10000;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45), 0 0 20px rgba(102, 126, 234, 0.6);
    animation: tutHighlightPulse 2s ease-in-out infinite;
}


@keyframes tutHighlightPulse {
    0%, 100% { box-shadow: 0 0 0 9999px rgba(0,0,0,0.45), 0 0 20px rgba(102,126,234,0.6); }
    50%       { box-shadow: 0 0 0 9999px rgba(0,0,0,0.45), 0 0 32px rgba(102,126,234,0.9); }
}

/* ── Tutorial Beacon — pulsing ring on the target button ─────────────────── */
#tutorial-beacon {
    position: fixed;
    pointer-events: none;
    z-index: 10003;
    border-radius: 8px;
}

.tutorial-beacon-multi {
    position: fixed;
    pointer-events: none;
    z-index: 10003;
    border-radius: 8px;
}

.tutorial-beacon-ring {
    position: absolute;
    inset: 0;
    border: 3px solid #667eea;
    border-radius: 8px;
    animation: beaconRing 1.4s ease-in-out infinite;
}

.tutorial-beacon-ring::before {
    content: '';
    position: absolute;
    inset: -6px;
    border: 2px solid rgba(102, 126, 234, 0.45);
    border-radius: 11px;
    animation: beaconRing 1.4s ease-in-out infinite 0.35s;
}

@keyframes beaconRing {
    0%   { opacity: 1;   transform: scale(1);    }
    60%  { opacity: 0.3; transform: scale(1.06); }
    100% { opacity: 1;   transform: scale(1);    }
}

.tutorial-beacon-label {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: #667eea;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
    letter-spacing: 0.03em;
    box-shadow: 0 2px 8px rgba(102,126,234,0.45);
}

.tutorial-beacon-label::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #667eea;
}

/* ── Demo button (▶ Run for me) ──────────────────────────────────────────── */
.tutorial-demo-btn {
    background: linear-gradient(135deg, #43a047 0%, #2e7d32 100%) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 3px 10px rgba(67,160,71,0.35) !important;
}

.tutorial-demo-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 14px rgba(67,160,71,0.5) !important;
}

/* ── tutorial-action-row — left-pointing arrow hint inside step content ──── */
.tutorial-action-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #f0f4ff;
    border: 1px solid #c5cff5;
    border-radius: 8px;
    padding: 10px 14px;
    margin: 12px 0;
    font-size: 14px;
    color: #444;
    line-height: 1.5;
}

.tutorial-action-arrow {
    font-size: 22px;
    font-weight: 700;
    color: #667eea;
    flex-shrink: 0;
    line-height: 1.2;
    animation: arrowBounce 1.2s ease-in-out infinite;
}

@keyframes arrowBounce {
    0%, 100% { transform: translateX(0); }
    50%       { transform: translateX(-5px); }
}

/* Responsive for tutorial guide */
@media (max-width: 768px) {
    .tutorial-guide-overlay {
        width: 100%;
        justify-content: center;
    }
    
    .tutorial-guide-content {
        width: 95%;
        max-height: 90vh;
        border-radius: 16px;
        border-left: none;
        border-top: 3px solid #667eea;
    }
    
    .tutorial-guide-header {
        padding: 20px;
        border-radius: 16px 16px 0 0;
    }
    
    .tutorial-guide-header h2 {
        font-size: 18px;
    }
    
    .tutorial-guide-body {
        padding: 20px;
    }
    
    .tutorial-guide-footer {
        flex-direction: column;
        gap: 10px;
        padding: 15px 20px;
        border-radius: 0 0 16px 16px;
    }
    
    .tutorial-buttons {
        width: 100%;
        display: flex;
        gap: 10px;
    }
    
    .tutorial-guide-footer .action-btn {
        flex: 1;
    }
}

/* Repository Link */
.repository-link {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.repository-link h3 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 16px;
    font-weight: 500;
}

.repository-link p {
    margin: 0 0 10px 0;
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

.repository-link a {
    display: block;
    padding: 9px 16px;
    background: #667eea;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    transition: all 0.2s ease;
}

.repository-link a + a {
    margin-top: 8px;
}

.repository-link a:hover {
    background: #5568d3;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
    text-decoration: none;
}

/* Palette and layout overrides (cool professional palette) */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.sidebar-header {
    border-bottom: 2px solid var(--primary);
}

.sidebar-header h2,
.file-selection h3,
.pipeline-steps h3,
.viewer-header h3,
.location-map h3,
.properties-header h3,
.matches-header h3,
.comparison-header h3,
.repository-link h3 {
    color: var(--text);
}

.back-btn,
.tutorial-toggle-btn {
    flex: 1;
    text-align: center;
    background: var(--surface-muted);
    color: var(--primary);
    border: 1px solid var(--border);
}

.back-btn:hover,
.tutorial-toggle-btn:hover {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.tab-btn {
    background: var(--surface-muted);
    color: var(--muted);
}

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

.tab-btn:hover:not(.active) {
    background: var(--surface-muted-2);
}

.file-list,
.viewer-container,
.loading-content,
.welcome-guide-content,
.tutorial-guide-content {
    background: var(--surface);
}

.file-list,
.location-map,
.viewer-header,
.properties-header,
.matches-header,
.comparison-header,
.tutorial-guide-footer,
.tutorial-progress,
.welcome-guide-footer {
    border-color: var(--border);
}

.file-name,
.step-content h4,
.property-key,
.match-source,
.match-details strong {
    color: var(--text);
}

.file-size,
.loading,
.step-content p,
.property-value,
.match-details,
.viewer-building-id,
.tutorial-step-content p,
.tutorial-sublist,
.tutorial-progress-text,
.repository-link p {
    color: var(--muted);
}

.step,
.feature-item,
.match-item,
.location-map,
.viewer-header,
.tutorial-guide-footer,
.welcome-guide-footer {
    background: var(--surface-muted);
}

.step,
.match-item,
.building-info {
    border-left-color: var(--primary);
}

.step-number,
.step-btn,
.control-btn,
.action-btn,
.repository-link a,
.match-details button {
    background: var(--primary);
}

.step-btn:hover:not(:disabled),
.control-btn:hover,
.action-btn:hover:not(:disabled),
.repository-link a:hover,
.match-details button:hover {
    background: var(--primary-dark);
}

.step-btn:disabled,
.action-btn:disabled {
    background: var(--disabled-bg);
}

.step-status.completed,
.match-confidence {
    color: #fff;
    background: var(--success);
}

.viewer,
.placeholder {
    background: var(--surface-muted);
}

.tutorial-guide-overlay {
    width: var(--tutorial-width);
}

.tutorial-guide-header,
.welcome-guide-header,
.tutorial-progress-fill,
.welcome-guide-footer .action-btn.primary,
.tutorial-guide-footer .action-btn.primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
}

.tutorial-guide-content {
    border-left: 3px solid var(--primary);
}

.tutorial-guide-footer .action-btn.secondary {
    color: var(--primary);
    border-color: var(--primary);
}

.tutorial-guide-footer .action-btn.secondary:hover {
    background: #e0f2fe;
}

.tutorial-highlight {
    border-color: var(--primary);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4), 0 0 20px rgba(37, 99, 235, 0.6);
}

.comparison-overlay,
.loading-overlay,
.welcome-guide-overlay {
    background: var(--overlay);
}

.tutorial-open .main-content {
    margin-right: var(--tutorial-width);
}

@media (max-width: 768px) {
    .viewer {
        height: min(60vh, 520px);
    }

    .tutorial-open .main-content {
        margin-right: 0;
    }

    .tutorial-guide-overlay {
        width: 100%;
    }

    .tutorial-guide-content {
        border-left: none;
        border-top: 3px solid var(--primary);
    }
}