/* ============================================================
   SEEKER v2 — Design System
   ============================================================ */

:root {
    /* Palette */
    --bg:          #06080c;
    --bg-subtle:   #0c1017;
    --surface:     rgba(12, 16, 24, 0.85);
    --surface-hover: rgba(20, 26, 38, 0.9);
    --border:      rgba(0, 242, 255, 0.08);
    --border-hover: rgba(0, 242, 255, 0.2);

    /* Text */
    --text-primary:   #e8edf5;
    --text-secondary: #7a8ba8;
    --text-dim:       #3d4a5c;

    /* Accent */
    --cyan:        #00f2ff;
    --cyan-dim:    rgba(0, 242, 255, 0.15);
    --cyan-glow:   rgba(0, 242, 255, 0.4);
    --red:         #ff3e5e;
    --red-dim:     rgba(255, 62, 94, 0.15);
    --gold:        #ffcc00;
    --gold-dim:    rgba(255, 204, 0, 0.15);
    --purple:      #8b5cf6;
    --purple-dim:  rgba(139, 92, 246, 0.15);
    --green:       #22c55e;
    --green-dim:   rgba(34, 197, 94, 0.15);
    --orange:      #f97316;

    /* Category colors */
    --cat-cia:          #00f2ff;
    --cat-parapsychology: #8b5cf6;
    --cat-conspiracy:   #ff3e5e;
    --cat-pop-culture:  #f97316;
    --cat-soviet:       #ef4444;
    --cat-dream:        #6366f1;
    --cat-normalized:   #22c55e;
    --cat-international: #14b8a6;
    --cat-literature:   #a78bfa;
    --cat-uap:          #ff3e5e;
    --cat-phenomena:    #eab308;
    --cat-media-echo:   #f472b6;
    --cat-threat:       #dc2626;
    --cat-key-figures:  #06b6d4;
    --cat-missing:      #ff3e5e;

    /* Typography */
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
    --font-ui:   'Inter', -apple-system, sans-serif;

    /* Sizing */
    --header-h: 56px;
    --sidebar-w: 260px;
    --detail-w:  380px;
    --timeline-h: 48px;
    --radius: 8px;
    --radius-sm: 4px;
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    width: 100%; height: 100%;
    background: var(--bg);
    color: var(--text-primary);
    font-family: var(--font-ui);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* === GRID BACKGROUND === */
#grid-canvas {
    position: fixed;
    inset: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.4;
}

/* === PANELS (shared) === */
.panel {
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* === HEADER === */
#app-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: rgba(6, 8, 12, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-family: var(--font-mono);
    letter-spacing: 2px;
    user-select: none;
}
.logo-num {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--cyan);
    text-shadow: 0 0 12px var(--cyan-glow);
}
.logo-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 3px;
}
.logo-tag {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-dim);
    letter-spacing: 1px;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.header-center {
    flex: 1;
    max-width: 400px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0 12px;
    height: 36px;
    transition: border-color 0.2s;
}
.search-box:focus-within {
    border-color: var(--cyan);
    box-shadow: 0 0 0 2px var(--cyan-dim);
}
.search-icon { color: var(--text-dim); flex-shrink: 0; }
.search-box input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}
.search-box input::placeholder { color: var(--text-dim); }
.search-hint {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 5px;
    flex-shrink: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.stat-pill {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 20px;
    white-space: nowrap;
}
.stat-pill .stat-value {
    color: var(--cyan);
    font-weight: 600;
}
.stat-pill.live {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--red);
    border-color: var(--red-dim);
    font-weight: 600;
    font-size: 0.6rem;
    letter-spacing: 1.5px;
}
.live-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--red);
    box-shadow: 0 0 6px var(--red);
    animation: pulse-dot 1.5s ease-in-out infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* === SIDEBAR === */
#sidebar {
    position: fixed;
    top: calc(var(--header-h) + 12px);
    left: 12px;
    bottom: calc(var(--timeline-h) + 20px);
    width: var(--sidebar-w);
    z-index: 50;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
}
#sidebar.collapsed {
    transform: translateX(calc(-100% - 12px));
    opacity: 0;
    pointer-events: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--border);
}
.sidebar-header h2 {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--cyan);
}

.icon-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 28px; height: 28px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.icon-btn:hover {
    border-color: var(--cyan);
    color: var(--cyan);
    background: var(--cyan-dim);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.sidebar-content::-webkit-scrollbar { width: 4px; }
.sidebar-content::-webkit-scrollbar-track { background: transparent; }
.sidebar-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-section {
    padding: 8px 12px 12px;
    border-top: 1px solid var(--border);
}
.sidebar-section h3 {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 500;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 4px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}
.filter-item:hover { background: var(--surface-hover); }
.filter-item input[type="checkbox"] { display: none; }

.filter-swatch {
    width: 10px; height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
    transition: box-shadow 0.2s;
}
.filter-item.active .filter-swatch {
    box-shadow: 0 0 6px currentColor;
}
.filter-item.inactive .filter-swatch {
    opacity: 0.3;
}

.filter-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    flex: 1;
}
.filter-item.active .filter-label { color: var(--text-primary); }

.filter-count {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    color: var(--text-dim);
    padding: 1px 5px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.sidebar-footer {
    display: flex;
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
}
.btn-ghost {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-ghost:hover {
    border-color: var(--cyan);
    color: var(--cyan);
    background: var(--cyan-dim);
}

/* === GRAPH CONTAINER === */
#graph-container {
    position: fixed;
    top: var(--header-h);
    left: 0; right: 0;
    bottom: 0;
    z-index: 1;
}

#graph-svg {
    width: 100%;
    height: 100%;
    cursor: grab;
}
#graph-svg:active { cursor: grabbing; }

/* Graph elements */
.node-group { cursor: pointer; }
.node-circle {
    stroke-width: 1.5;
    transition: r 0.2s;
    filter: brightness(1.1);
}
.node-group:hover .node-circle {
    stroke-width: 2.5;
    filter: brightness(1.3);
}
.node-group.dimmed { opacity: 0.2; }
.node-group.highlighted .node-circle {
    stroke-width: 3;
    filter: brightness(1.4) drop-shadow(0 0 6px currentColor);
}
.node-group.search-match .node-circle {
    stroke-width: 3;
    filter: drop-shadow(0 0 8px var(--gold));
}

.node-label {
    font-family: var(--font-mono);
    font-size: 8px;
    fill: var(--text-secondary);
    pointer-events: none;
    user-select: none;
    letter-spacing: 0.5px;
}
.node-group.dimmed .node-label { opacity: 0.3; }
.node-group:hover .node-label,
.node-group.highlighted .node-label {
    fill: var(--text-primary);
    font-weight: 500;
}
.node-label.anchor-label {
    font-size: 10px;
    font-weight: 600;
    fill: var(--text-primary);
    letter-spacing: 1px;
}

/* Photo nodes */
.photo-ring {
    stroke-width: 2;
    fill: var(--bg);
}
.ring-dead {
    stroke: var(--red);
    filter: drop-shadow(0 0 4px rgba(255, 62, 94, 0.5));
}
.ring-missing {
    stroke: var(--orange);
    filter: drop-shadow(0 0 4px rgba(249, 115, 22, 0.5));
    animation: ring-pulse 2s ease-in-out infinite;
}
@keyframes ring-pulse {
    0%, 100% { stroke-opacity: 1; }
    50% { stroke-opacity: 0.5; }
}
.node-photo {
    pointer-events: none;
}

.link-line {
    stroke: rgba(0, 242, 255, 0.12);
    stroke-width: 0.7;
    transition: stroke 0.3s, stroke-width 0.3s;
}
.link-line.dimmed { stroke: rgba(0, 242, 255, 0.03); }
.link-line.highlighted {
    stroke: rgba(0, 242, 255, 0.5);
    stroke-width: 2;
}
.link-line.implicit {
    stroke-dasharray: 4 3;
    stroke: rgba(139, 92, 246, 0.05);
}

/* Zoom controls */
.zoom-controls {
    position: absolute;
    bottom: calc(var(--timeline-h) + 24px);
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 40;
}
.zoom-btn {
    width: 36px; height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    backdrop-filter: blur(8px);
}
.zoom-btn:hover {
    border-color: var(--cyan);
    color: var(--cyan);
    background: rgba(0, 242, 255, 0.05);
}

/* === DETAIL PANEL === */
.detail-panel {
    position: fixed;
    top: calc(var(--header-h) + 12px);
    right: 12px;
    bottom: calc(var(--timeline-h) + 20px);
    width: var(--detail-w);
    z-index: 50;
    overflow-y: auto;
    transform: translateX(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.detail-panel::-webkit-scrollbar { width: 4px; }
.detail-panel::-webkit-scrollbar-track { background: transparent; }
.detail-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.detail-panel.hidden {
    transform: translateX(calc(100% + 24px));
    opacity: 0;
    pointer-events: none;
}

.detail-close {
    position: sticky;
    top: 0;
    float: right;
    width: 32px; height: 32px;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 2;
    margin: 12px 12px 0 0;
    transition: all 0.2s;
}
.detail-close:hover {
    border-color: var(--red);
    color: var(--red);
    background: var(--red-dim);
}

#detail-content {
    padding: 16px;
}

.detail-header {
    margin-bottom: 16px;
}
.detail-cat {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    letter-spacing: 2px;
    margin-bottom: 6px;
    opacity: 0.8;
}
.detail-name {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.3;
}
.detail-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.badge {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 3px;
    font-weight: 500;
}
.badge-substantiated { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34, 197, 94, 0.2); }
.badge-partial { background: var(--gold-dim); color: var(--gold); border: 1px solid rgba(255, 204, 0, 0.2); }
.badge-mythologized { background: var(--purple-dim); color: var(--purple); border: 1px solid rgba(139, 92, 246, 0.2); }
.badge-unsubstantiated { background: var(--red-dim); color: var(--red); border: 1px solid rgba(255, 62, 94, 0.2); }
.badge-type {
    background: var(--cyan-dim);
    color: var(--cyan);
    border: 1px solid rgba(0, 242, 255, 0.15);
}
.badge-rigor {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.detail-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.detail-section-title {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    margin-bottom: 8px;
}
.detail-desc {
    font-size: 0.82rem;
    line-height: 1.7;
    color: var(--text-secondary);
}
.detail-desc a {
    color: var(--cyan);
    text-decoration: none;
    border-bottom: 1px solid var(--cyan-dim);
}
.detail-desc a:hover { border-color: var(--cyan); }

.detail-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 0.75rem;
}
.detail-meta-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-dim);
    letter-spacing: 0.5px;
}
.detail-meta-value {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-primary);
}

.detail-connections {
    list-style: none;
}
.detail-conn-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
}
.detail-conn-item:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}
.detail-conn-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.detail-lifecycle {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
}
.lifecycle-step {
    font-family: var(--font-mono);
    font-size: 0.5rem;
    letter-spacing: 0.5px;
    padding: 3px 6px;
    border-radius: 2px;
    background: var(--cyan-dim);
    color: var(--cyan);
    border: 1px solid rgba(0, 242, 255, 0.1);
}
.lifecycle-step:last-child {
    background: var(--red-dim);
    color: var(--red);
    border-color: rgba(255, 62, 94, 0.1);
}

.detail-significance {
    font-size: 0.78rem;
    line-height: 1.6;
    color: var(--text-secondary);
    font-style: italic;
    padding: 10px;
    border-left: 2px solid var(--cyan-dim);
    background: rgba(0, 242, 255, 0.02);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* === TIMELINE === */
#timeline-bar {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: min(600px, calc(100% - 40px));
    height: var(--timeline-h);
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
}

.timeline-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-dim);
    letter-spacing: 1px;
    flex-shrink: 0;
}
.timeline-value {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--cyan);
    font-weight: 600;
    flex-shrink: 0;
    min-width: 36px;
    text-align: center;
}

#timeline-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
#timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--cyan);
    border: 2px solid var(--bg);
    box-shadow: 0 0 8px var(--cyan-glow);
    cursor: pointer;
    transition: transform 0.15s;
}
#timeline-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
#timeline-slider::-moz-range-thumb {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--cyan);
    border: 2px solid var(--bg);
    box-shadow: 0 0 8px var(--cyan-glow);
    cursor: pointer;
}

/* === TOOLTIP === */
.tooltip {
    position: fixed;
    pointer-events: none;
    z-index: 200;
    background: rgba(6, 8, 12, 0.95);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius);
    padding: 10px 14px;
    max-width: 280px;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.tooltip.hidden { display: none; }
.tooltip-name {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.tooltip-cat {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    letter-spacing: 1px;
    margin-bottom: 6px;
}
.tooltip-desc {
    font-size: 0.72rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* === LEGEND === */
.legend {
    position: fixed;
    bottom: calc(var(--timeline-h) + 20px);
    left: 12px;
    z-index: 40;
    min-width: 160px;
}
.legend-toggle {
    width: 100%;
    padding: 8px 14px;
    background: none;
    border: none;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 2px;
    color: var(--text-dim);
    cursor: pointer;
    text-align: left;
    transition: color 0.2s;
}
.legend-toggle:hover { color: var(--cyan); }

.legend-content {
    padding: 6px 14px 12px;
    max-height: 300px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.legend-content.hidden { display: none; }

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
}
.legend-dot {
    width: 8px; height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}
.legend-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

/* === SIDEBAR OPEN TOGGLE (when collapsed) === */
#sidebar-open {
    position: fixed;
    top: calc(var(--header-h) + 12px);
    left: 12px;
    z-index: 50;
    width: 36px; height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    backdrop-filter: blur(8px);
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
#sidebar-open:hover {
    border-color: var(--cyan);
    color: var(--cyan);
}
#sidebar-open.visible { display: flex; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    :root {
        --sidebar-w: 240px;
        --detail-w: 320px;
    }
    .header-center { display: none; }
    .stat-pill:not(.live) { display: none; }
    .legend { display: none; }
}

/* === VIGNETTE === */
#graph-container::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 60%, rgba(6, 8, 12, 0.35) 100%);
    pointer-events: none;
    z-index: 2;
}

/* === ENTRANCE ANIMATION === */
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
#app-header    { animation: fadeSlideIn 0.5s ease-out; }
/* 'backwards', not 'both': a forwards-filling animation keeps holding opacity/transform
   after it ends and overrides #sidebar.collapsed, so the sidebar could never slide away. */
#sidebar       { animation: fadeSlideIn 0.6s ease-out 0.1s backwards; }
#sidebar.collapsed { animation: none; }
#timeline-bar  { animation: fadeSlideIn 0.5s ease-out 0.2s both; }
.zoom-controls { animation: fadeSlideIn 0.4s ease-out 0.3s both; }

@keyframes graphFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
#graph-svg { animation: graphFadeIn 1s ease-out 0.3s both; }

/* === UTILITY === */
.hidden { display: none !important; }

/* === SELECTION STYLES === */
::selection {
    background: var(--cyan-dim);
    color: var(--cyan);
}

/* === SCROLLBAR (global) === */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* === DOCUMENTED / UNVERIFIED badges (lowercase variants) === */
.badge-documented { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34, 197, 94, 0.2); }
.badge-unverified_claims { background: var(--red-dim); color: var(--red); border: 1px solid rgba(255, 62, 94, 0.2); }

/* === VIEW SWITCHER === */
.view-switcher { padding-top: 12px !important; }
.view-tabs {
    display: flex;
    gap: 2px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 2px;
    border: 1px solid var(--border);
}
.view-tab {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.55rem;
    letter-spacing: 1px;
    padding: 6px 4px;
    border: none;
    border-radius: 3px;
    background: none;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.2s;
}
.view-tab:hover { color: var(--text-secondary); }
.view-tab.active {
    background: var(--cyan-dim);
    color: var(--cyan);
    font-weight: 600;
}
.view-options {
    margin-top: 8px;
}
.layout-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}
.layout-btn {
    font-family: var(--font-mono);
    font-size: 0.5rem;
    letter-spacing: 0.5px;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: none;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.2s;
}
.layout-btn:hover { color: var(--text-secondary); border-color: var(--text-dim); }
.layout-btn.active {
    background: var(--cyan-dim);
    color: var(--cyan);
    border-color: rgba(0, 242, 255, 0.3);
    font-weight: 600;
}
.toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-secondary);
    cursor: pointer;
}
.toggle-row input[type="checkbox"] {
    accent-color: var(--cyan);
}

/* === TOUR BUTTONS === */
.tour-buttons {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.tour-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: none;
    color: var(--tour-color, var(--text-secondary));
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}
.tour-btn:hover {
    background: rgba(0, 242, 255, 0.03);
    border-color: var(--tour-color, var(--cyan));
}
.tour-icon {
    font-size: 0.5rem;
    opacity: 0.6;
}

/* === VIEW MODE TABS === */
.view-mode-tabs {
    display: flex;
    gap: 2px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 2px;
    border: 1px solid var(--border);
}
.mode-tab {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.55rem;
    letter-spacing: 0.5px;
    padding: 5px 4px;
    border: none;
    border-radius: 3px;
    background: none;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.2s;
}
.mode-tab.active {
    background: var(--cyan-dim);
    color: var(--cyan);
}

/* === NARRATIVE OVERLAY === */
.narrative-overlay {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 12px 20px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, rgba(0,0,0,0.2) 70%, transparent 100%);
    animation: fadeIn 0.3s ease-out;
}
.narrative-overlay.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.narrative-panel {
    background: rgba(6, 8, 12, 0.92);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius);
    padding: 16px 20px;
    max-width: 720px;
    width: 100%;
    backdrop-filter: blur(16px);
    box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.5);
    margin-bottom: calc(var(--timeline-h) + 12px);
    pointer-events: all;
}
.narrative-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.narrative-step-counter {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 2px;
    color: var(--cyan);
}
.narrative-close {
    width: 28px; height: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-dim);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}
.narrative-close:hover { border-color: var(--red); color: var(--red); }

.narrative-title {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.narrative-text {
    font-size: 0.75rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 10px;
    max-height: 100px;
    overflow-y: auto;
}
.narrative-citation {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--cyan);
    text-decoration: none;
    border: 1px solid var(--cyan-dim);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    margin-bottom: 16px;
    transition: all 0.2s;
}
.narrative-citation:hover {
    background: var(--cyan-dim);
    border-color: var(--cyan);
}
.narrative-citation.hidden { display: none; }

.narrative-controls {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.narrative-next {
    background: var(--cyan-dim) !important;
    border-color: rgba(0, 242, 255, 0.2) !important;
    color: var(--cyan) !important;
}

/* === PHOTO GALLERY (in detail panel) === */
.photo-gallery {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.photo-cell {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: border-color 0.2s;
}
.photo-cell:hover { border-color: var(--cyan); }
.photo-cell img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    display: block;
}
.photo-stamp {
    position: absolute;
    top: 4px;
    left: 4px;
    font-family: var(--font-mono);
    font-size: 0.45rem;
    letter-spacing: 1px;
    color: var(--red);
    background: rgba(0, 0, 0, 0.7);
    padding: 2px 5px;
    border-radius: 2px;
}
.photo-caption {
    font-size: 0.6rem;
    color: var(--text-dim);
    padding: 4px 6px;
    line-height: 1.4;
}

/* === DOSSIER (military-style) === */
.dossier-block {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 8px;
}
.dossier-classification {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 1px;
    color: var(--gold);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.ce-badge {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 3px;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 8px;
}
.ce1 { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34, 197, 94, 0.2); }
.ce2 { background: var(--gold-dim); color: var(--gold); border: 1px solid rgba(255, 204, 0, 0.2); }
.ce3 { background: rgba(249, 115, 22, 0.15); color: var(--orange); border: 1px solid rgba(249, 115, 22, 0.2); }
.ce4 { background: var(--red-dim); color: var(--red); border: 1px solid rgba(255, 62, 94, 0.2); }
.ce5 { background: var(--purple-dim); color: var(--purple); border: 1px solid rgba(139, 92, 246, 0.2); }

.personnel-item {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}
.personnel-item:last-child { border-bottom: none; }
.personnel-name {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--cyan);
    font-weight: 500;
}
.personnel-role {
    font-size: 0.6rem;
    color: var(--text-dim);
    margin-top: 2px;
}
.personnel-action {
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.timeline-item {
    display: flex;
    gap: 10px;
    padding: 5px 0;
    font-size: 0.65rem;
}
.timeline-date {
    font-family: var(--font-mono);
    color: var(--cyan);
    flex-shrink: 0;
    min-width: 70px;
    font-size: 0.6rem;
}
.timeline-event {
    color: var(--text-secondary);
    line-height: 1.5;
}

/* === SCIENTIST DOSSIER (in detail panel) === */
.scientist-status {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    display: inline-block;
    margin-bottom: 12px;
}
.status-dead {
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid rgba(255, 62, 94, 0.3);
}
.status-missing {
    background: rgba(249, 115, 22, 0.15);
    color: var(--orange);
    border: 1px solid rgba(249, 115, 22, 0.3);
    animation: ring-pulse 2s ease-in-out infinite;
}

/* Dossier portrait in detail panel */
.dossier-portrait {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}
.dossier-portrait-frame {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    overflow: hidden;
    border: 2.5px solid;
    box-shadow: 0 0 12px rgba(255, 62, 94, 0.3);
}
.dossier-portrait-frame.portrait-dead {
    border-color: var(--red);
}
.dossier-portrait-frame.portrait-missing {
    border-color: var(--orange);
    animation: ring-pulse 2s ease-in-out infinite;
    box-shadow: 0 0 12px rgba(249, 115, 22, 0.3);
}
.dossier-portrait-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(30%) contrast(1.1);
}
.dossier-portrait-frame:hover img {
    filter: grayscale(0%) contrast(1.0);
}

.source-link {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--cyan);
    text-decoration: none;
    padding: 4px 0;
    border-bottom: 1px dashed var(--border);
}
.source-link:hover { color: var(--text-primary); }

/* === PHOTO LIGHTBOX === */
.photo-lightbox {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.9);
    cursor: pointer;
    padding: 40px;
}
.photo-lightbox.hidden { display: none !important; }
.photo-lightbox img {
    max-width: 90%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.lightbox-caption {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 12px;
    text-align: center;
    max-width: 600px;
}

/* === MAP STYLES === */
.map-ocean {
    fill: #060b14;
}
.map-land {
    fill: #0d1520;
    stroke: #1a2a3a;
    stroke-width: 0.5;
}
.map-graticule {
    fill: none;
    stroke: rgba(0, 242, 255, 0.04);
    stroke-width: 0.3;
}
.map-sphere {
    fill: #060b14;
    stroke: #1e3048;
    stroke-width: 1;
}

/* === SANKEY === */
#sankey-container {
    position: absolute;
    inset: 0;
    top: 0;
}
#sankey-container svg {
    width: 100%;
    height: 100%;
}
.sankey-link {
    fill: none;
    stroke-opacity: 0.3;
}
.sankey-link:hover {
    stroke-opacity: 0.6;
}
.sankey-node rect {
    cursor: pointer;
    transition: stroke 0.2s;
}
.sankey-node rect:hover {
    stroke: #fff !important;
    stroke-width: 2;
}
.sankey-label {
    font-family: var(--font-mono);
    font-size: 9px;
    fill: var(--text-secondary);
    pointer-events: none;
}
.sankey-header {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 2px;
    fill: var(--text-dim);
}
.sankey-back {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
}

/* === SKY SCANNER (modal injected by scanner.js) === */
.scanner-modal {
    position: fixed;
    inset: 0;
    z-index: 250;
}
.scanner-modal.hidden { display: none !important; }

/* === PARITY WITH SEEKER v1 (Sept 2026) === */
/* Label declutter: at 300+ nodes only anchors are labelled until you zoom in, hover or select */
.node-label:not(.anchor-label) { opacity: 0; transition: opacity 0.2s; }
.zoomed-in .node-label,
.node-group:hover .node-label,
.node-group.highlighted .node-label,
.node-group.neighbor .node-label,
.node-group.search-match .node-label { opacity: 1; }
.zoomed-in .node-group.dimmed .node-label { opacity: 0.25; }

/* Thematic links: shared field / geography only — no documentary connection */
.link-line.thematic { stroke: rgba(179, 136, 255, 0.28); stroke-dasharray: 5 4; }
.link-line.thematic.highlighted { stroke: rgba(179, 136, 255, 0.85); stroke-dasharray: 5 4; }
.link-line.thematic.dimmed { stroke: rgba(179, 136, 255, 0.05); }
.legend-line { display: inline-block; width: 16px; border-top: 2px solid rgba(0, 242, 255, 0.6); margin-right: 2px; }
.legend-line.thematic { border-top: 2px dashed #b388ff; }
.conn-thematic { margin-left: 6px; font-family: var(--font-mono); font-size: 0.5rem; letter-spacing: 1px; color: #b388ff; border: 1px solid rgba(179, 136, 255, 0.4); border-radius: 3px; padding: 1px 4px; }

.detail-warning { margin: 10px 0; padding: 8px 10px; border-left: 2px solid var(--gold); background: var(--gold-dim); font-size: 0.68rem; line-height: 1.5; color: var(--text-primary); }
.detail-warning-label { display: block; font-family: var(--font-mono); font-size: 0.55rem; letter-spacing: 2px; color: var(--gold); margin-bottom: 3px; }

.drone-attribution { font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 1px; color: #c0ff3e; }
.drone-attribution.attr-ATTRIBUTED { color: var(--red); }
.drone-attribution.attr-SUSPECTED { color: var(--orange); }
.drone-attribution.attr-PROSAIC { color: var(--text-secondary); }
.lifecycle-step.drone-tag { border-color: rgba(192, 255, 62, 0.4); color: #c0ff3e; }
.drone-bar { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 0.58rem; margin: 2px 0; color: var(--text-secondary); }
.drone-bar-label { flex: 0 0 112px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drone-bar-track { flex: 1; height: 5px; background: rgba(255, 255, 255, 0.06); border-radius: 3px; }
.drone-bar-fill { display: block; height: 100%; background: #c0ff3e; border-radius: 3px; }
.drone-bar-n { flex: 0 0 18px; text-align: right; }

.narrative-text { max-height: 170px; }
.narrative-text strong { color: var(--text-primary); }
.narrative-handoff.hidden { display: none; }

/* === SIDEBAR: scrolling body + per-node checkboxes === */
/* The category list used flex:1 inside a fixed-height column and was squeezed
   to nothing once the other sections grew; the whole body now scrolls. */
.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border-hover) transparent; }
.sidebar-scroll::-webkit-scrollbar { width: 5px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
.sidebar-scroll > .sidebar-section:first-child { border-top: none; }

.cat-expand { background: none; border: none; color: var(--text-dim); font-size: 0.7rem; width: 20px; height: 20px; cursor: pointer; border-radius: var(--radius-sm); transition: transform 0.15s, color 0.15s; }
.cat-expand:hover { color: var(--cyan); background: var(--cyan-dim); }
.cat-expand.open { transform: rotate(90deg); color: var(--cyan); }

.node-list { margin: 2px 0 6px 9px; padding-left: 9px; border-left: 1px solid var(--border-hover); max-height: 240px; overflow-y: auto; scrollbar-width: thin; }
.node-item { display: flex; align-items: center; gap: 6px; padding: 2px 2px; font-family: var(--font-mono); font-size: 0.58rem; color: var(--text-secondary); cursor: pointer; border-radius: 3px; }
.node-item:hover { background: var(--surface-hover); color: var(--text-primary); }
.node-item input { accent-color: var(--cyan); width: 11px; height: 11px; flex-shrink: 0; cursor: pointer; }
.node-item-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-focus { background: none; border: none; color: var(--text-dim); font-size: 0.7rem; cursor: pointer; opacity: 0; padding: 0 3px; }
.node-item:hover .node-focus { opacity: 1; }
.node-focus:hover { color: var(--cyan); }

/* Layouts that don't use links (radial, treemap) */
.links-layer.layout-nolinks { display: none; }
/* In structural layouts labels would collide at the fitted zoom; they follow the normal zoom rule */


/* === ACCESSIBILITY: MOTION =============================================== */
/* Respect the operating-system setting. Decorative pulses and breathing
   effects are suppressed entirely; anything that must still move is reduced
   to a single, near-instant step. WCAG 2.2.2 / 2.3.3. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .ring-missing,
    .live-dot,
    .node-group circle,
    .node-group path {
        animation: none !important;
    }
}


/* --- DENSE-GRAPH GUARD ---------------------------------------------------
   Matches the v1 build. Above the threshold, decorative node animation stops;
   static styling that carries meaning is untouched. Set by applyDensityGuard()
   in app.js. */
body.dense-graph .node-group circle,
body.dense-graph .node-group path,
body.dense-graph .photo-ring {
    animation: none !important;
}

/* Keep the panels off a repainting backdrop. */
#detail-panel,
.narrative-panel,
#sidebar {
    will-change: transform;
}

/* Witness glyphs share the amber of the WITNESS category. */
.node-group.WITNESS .node-circle {
    stroke-width: 1.5;
}

/* === HELIX === */
#helix-container {
    position: absolute;
    inset: 0;
    overflow: auto;
    padding: 20px 24px calc(var(--timeline-h) + 48px) calc(var(--sidebar-w) + 24px);
    box-sizing: border-box;
}
#sidebar.collapsed ~ #graph-container #helix-container { padding-left: 56px; }
.helix-svg { display: block; }
.helix-strand { fill: none; stroke-linecap: round; }
.helix-strand.back { stroke-width: 2.5; opacity: 0.28; }
.helix-strand.front { stroke-width: 4; }
.helix-rung line { stroke-width: 3; }
.helix-rung line.helix-bond { stroke: #e8edf5; stroke-width: 1; opacity: 0.8; }
.helix-rung line.helix-hit { stroke: transparent; stroke-width: 14; cursor: pointer; }
.helix-node { stroke: var(--bg); stroke-width: 1.5; cursor: pointer; }
.helix-node:hover, .helix-node:focus { r: 7; outline: none; stroke: var(--text-primary); }
.helix-base { font-family: var(--font-mono); font-size: 9px; font-weight: 700; pointer-events: none; }
.helix-title { font-family: var(--font-mono); font-size: 13px; font-weight: 700; letter-spacing: 1px; white-space: pre; }
.helix-strand-name { cursor: pointer; }
.helix-strand-name:hover, .helix-strand-name:focus { text-decoration: underline; outline: none; }
.helix-title-sep { fill: var(--text-secondary); }
.helix-meta { font-family: var(--font-mono); font-size: 10px; fill: var(--text-secondary); }
.helix-label { font-family: var(--font-mono); font-size: 10px; fill: var(--text-secondary); }
.helix-end { font-family: var(--font-mono); font-size: 10px; font-weight: 700; }
.helix-empty { padding: 40px; color: var(--text-secondary); font-family: var(--font-mono); text-align: center; }
.helix-tip {
    position: fixed; z-index: 200; max-width: 320px; pointer-events: none;
    background: var(--surface); border: 1px solid var(--border-hover); border-radius: var(--radius-sm);
    padding: 8px 10px; font-family: var(--font-mono); font-size: 0.65rem; line-height: 1.5; color: var(--text-primary);
}
.helix-tip[hidden] { display: none; }
.helix-tip span { color: var(--text-secondary); }
.helix-tip-pair { font-weight: 700; margin-bottom: 4px; }
.helix-tip-sub { color: var(--text-secondary); }
.helix-pick { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; font-family: var(--font-mono); font-size: 0.55rem; letter-spacing: 1px; }
.helix-pick select {
    background: var(--bg); color: var(--text-primary); border: 1px solid var(--border-hover);
    border-radius: var(--radius-sm); padding: 5px 6px; font-family: var(--font-mono); font-size: 0.62rem; max-width: 100%;
}
.helix-key { display: flex; flex-direction: column; gap: 5px; margin: 6px 0 8px; font-family: var(--font-mono); font-size: 0.55rem; color: var(--text-secondary); }
.helix-key b { color: var(--text-primary); margin-right: 4px; }
.hx-pair { display: inline-flex; flex-direction: column; width: 3px; height: 14px; margin-right: 8px; vertical-align: middle; }
.hx-pair i { flex: 1; display: block; }
.hx-pair.dashed i { opacity: 0.7; }
.helix-note { font-family: var(--font-mono); font-size: 0.55rem; line-height: 1.5; color: var(--text-secondary); margin: 0; }
@media (max-width: 768px) {
    #helix-container { padding-left: 16px; padding-right: 16px; }
}
