[data-theme="dark"] {
    /* Bitcoin Data Labs "Obsidian Data" Theme Variables */
    --bg-primary: #05070A;
    --bg-secondary: #0D0F14;
    --surface: #0D0F14;
    --card-bg: #080A0F;

    --text-primary: #FDF6E3;
    --text-secondary: #94A3B8;

    --primary: #E8916B;
    /* Brand Terracotta */
    --accent: var(--primary);

    --border: rgba(253, 246, 227, 0.08);
    --border-subtle: rgba(253, 246, 227, 0.05);

    --primary-bg-hover: rgba(232, 145, 107, 0.08);
    --primary-bg-active: rgba(232, 145, 107, 0.12);
    --primary-border: rgba(232, 145, 107, 0.3);

    --card-shadow: 0 10px 50px rgba(0, 0, 0, 0.6);

    /* Warm Data Palette - 5 Core Roles */
    --legend-creator: #FFB000;
    --legend-architect: #E8916B;
    --legend-engineer: #D4A298;
    --legend-researcher: #8293AB;
    --legend-participant: #2D3748;

    /* Theme Colors for Network Categories - Refined for Obsidian */
    --color-consensus: #ef4444;
    --color-script: #f59e0b;
    --color-l2: #10b981;
    --color-privacy: #8b5cf6;
    --color-wallet: #3b82f6;
    --color-mempool: #ec4899;
    --color-network: #06b6d4;
    --color-mining: #71717a;
    --color-other: #444;

    /* Header & Navigation Sync - Using 'Classy' Terracotta for selections */
    --bdl-header-bg: rgba(5, 7, 10, 0.9);
    --bdl-header-bg-compressed: rgba(5, 7, 10, 0.98);
    --bdl-subnav-bg: #05070A;
    --bdl-nav-active-bg: rgba(247, 147, 26, 0.12);
    --bdl-nav-active-text: #f7931a;
}

/* App name text beside logo */
#currentAppName,
#header .app-name,
#header [id*="appName"],
#header .app-logo a {
    color: var(--primary) !important;
    font-weight: 700 !important;
    letter-spacing: 0.02em;
}

/* Global Reset & Base */
html,
body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    color-scheme: dark;
    overflow-x: hidden;
    min-height: 100vh;
    scroll-behavior: smooth;
    /* Ensure scrollIntoView accounts for fixed headers */
    scroll-padding-top: calc(var(--header-height, 90px) + var(--subnav-height, 50px) + 20px);
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    box-sizing: border-box;
}

/* Global Overrides for Bitcoin Data Labs Layout */
body.has-sub-nav.has-fixed-header {
    /* Remove the default 20px gap for a sleek flush app look */
    padding-top: calc(var(--header-height, 90px) + var(--subnav-height, 50px)) !important;
}

/* App Layout */
#main-container {
    display: flex;
    flex-direction: column;
    /* Exactly fill the remaining viewport, preventing body scroll so the network sidebar works perfectly */
    height: calc(100vh - var(--header-height, 90px) - var(--subnav-height, 50px)) !important;
}

#header,
#footer {
    flex-shrink: 0;
}

#app-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}



#graph-container {
    flex: 1;
    position: relative;
    background-color: var(--bg-primary);
}

#sidebar {
    width: 360px;
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 10;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

#sidebar::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

/* Header & Sidebar Typography */
.sidebar-header h1 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: 0.02em;
}

.sidebar-header h1 i {
    font-size: 14px;
    opacity: 0.8;
}

.sidebar-header p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 8px 0 0 0;
    line-height: 1.5;
}

/* Components: Filter Groups & Buttons */
.filter-group {
    background: var(--card-bg);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
}

.legend-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 10px 0 0 0;
    color: var(--text-secondary);
    font-size: 11px;
}

.legend-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.filter-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 12px;
    display: block;
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.theme-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.filter-btn {
    background: transparent;
    border: 1px solid transparent;
    padding: 8px 16px;
    color: var(--text-secondary);
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    flex: 1;
    min-width: 80px;
    font-weight: 500;
    position: relative;
}

.filter-btn:hover {
    background: rgba(253, 246, 227, 0.03);
    color: var(--text-primary);
}

.filter-btn.active {
    background: rgba(232, 145, 107, 0.06);
    color: var(--text-primary);
    font-weight: 700;
}

.filter-btn.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    height: 60%;
    width: 2px;
    background: var(--primary);
    border-radius: 0 2px 2px 0;
}

/* Keep primary CTA as a subtle ghost block for surgical UX */
#view-directory-btn,
.btn-primary {
    background: transparent;
    color: var(--primary);
    border: 1px solid rgba(232, 145, 107, 0.3);
    transition: all 0.3s ease;
    border-radius: 8px;
}

#view-directory-btn:hover,
.btn-primary:hover {
    background: var(--primary-bg-hover);
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(232, 145, 107, 0.1);
}

#view-directory-btn.active,
.btn-primary.active {
    background: var(--primary-bg-active);
    border-color: var(--primary);
    color: var(--primary);
}

/* Reusable Social/External Link Action */
.link-action {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.link-action:hover {
    background: var(--primary-bg-hover);
    border-color: var(--primary-border);
    color: var(--text-primary);
}

.link-action:active {
    background: var(--primary-bg-active);
    font-weight: 700;
}

.link-action:focus,
.link-action:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Premium Surgical Tooltips */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    width: 220px;
    padding: 12px 14px;
    background: rgba(13, 15, 20, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(232, 145, 107, 0.2);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 11px;
    line-height: 1.5;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    opacity: 0;
    transform: translateY(5px);
    transition: all 0.2s ease;
    z-index: 100;
}

[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* HUD & Overlays */
.hud {
    position: absolute;
    top: 24px;
    left: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 5;
}

.search-container {
    position: relative;
}

#unified-search {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
    background: rgba(8, 10, 15, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

#unified-search:focus {
    border-color: var(--primary);
    background: rgba(8, 10, 15, 0.9);
    box-shadow: 0 15px 40px rgba(232, 145, 107, 0.1);
}

.search-meta {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
    padding: 0 4px;
    min-height: 20px;
}

.stats-hud {
    background: rgba(8, 10, 15, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 18px;
    color: var(--text-secondary);
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: var(--card-shadow);
    min-width: 200px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}



.stat-val {
    font-weight: 700;
    color: var(--text-primary);
}

.stat-val.highlight {
    color: var(--primary);
}

/* Map Controls */
.controls {
    position: absolute;
    top: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 5;
}

.control-btn {
    background: rgba(8, 10, 15, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    padding: 10px;
    color: var(--text-primary);
    border-radius: 10px;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.control-btn:hover {
    background: rgba(232, 145, 107, 0.1);
    border-color: var(--primary);
    color: var(--primary);
    transform: scale(1.05);
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(26, 18, 8, 0.98);
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: 12px;
    font-size: 12px;
    pointer-events: none;
    z-index: 100;
    color: var(--text-primary);
    display: none;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    min-width: 200px;
}

/* D3 Graph Styles */
svg#viz {
    width: 100%;
    height: 100%;
}

line.link {
    stroke-opacity: 0.15;
    transition: stroke-opacity 0.2s, stroke-width 0.2s;
}

circle.node {
    transition: r 0.3s, fill 0.3s, stroke 0.2s;
    stroke-width: 0.5px;
    cursor: pointer;
}

text.label {
    fill: var(--text-primary);
    font-size: 9px;
    font-weight: 500;
    pointer-events: none;
    opacity: 0.6;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* Selection Panel / Profile */
.info-panel {
    background: var(--card-bg);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.info-title {
    font-size: 15px;
    font-weight: 800;
    margin-bottom: 20px;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.expertise-meter {
    display: flex;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    background: var(--card-bg);
    margin: 8px 0 16px 0;
}

.expertise-segment {
    height: 100%;
}

.bip-chip {
    display: inline-block;
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    margin-right: 6px;
    margin-bottom: 6px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.bip-chip:hover {
    background: rgba(232, 145, 107, 0.08);
    color: var(--text-primary);
}

.info-item {
    font-size: 13px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
}

.info-label {
    color: var(--text-secondary);
}

.info-val {
    color: var(--text-primary);
    font-weight: 600;
}

.expertise-label {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 16px;
    margin-bottom: 4px;
    display: block;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.tag {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tag-new {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.tag-rising {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.tag-steady {
    background: rgba(59, 130, 246, 0.08);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.14);
}

.tag-fading {
    background: rgba(244, 63, 94, 0.08);
    color: #f43f5e;
    border: 1px solid rgba(244, 63, 94, 0.14);
}

.tag-retired {
    background: rgba(148, 163, 184, 0.08);
    color: #94A3B8;
    border: 1px solid rgba(148, 163, 184, 0.14);
}

.tag-active {
    background: rgba(253, 246, 227, 0.04);
    color: #cbd5e1;
    border: 1px solid rgba(253, 246, 227, 0.1);
}

.tag-mixed {
    background: rgba(253, 246, 227, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}

/* 📱 Responsive Engineering 📱 */
@media screen and (max-width: 1024px) {
    #main-container {
        height: auto !important;
        min-height: 100vh;
    }
    
    #app-content {
        flex-direction: column;
        overflow: visible;
        flex: none;
    }

    #sidebar {
        width: 100%;
        height: auto;
        border-left: none;
        border-top: 1px solid var(--border-subtle);
        overflow: visible;
    }

    #graph-container {
        height: 60vh;
        flex: none;
    }
}

@media screen and (max-width: 768px) {
    .hide-on-mobile {
        display: none !important;
    }

    /* Fix mobile menu overlay covering the header */
    body.has-nav .nav-links-wrapper {
        z-index: 9999 !important;
        justify-content: flex-start !important;
        padding-top: calc(var(--header-height, 90px) + 2rem) !important;
    }

    /* Brand the suite menu section with Terracotta */
    .mobile-suite-content > div > div:first-child {
        color: var(--primary) !important;
        font-weight: 700 !important;
        text-transform: uppercase;
        letter-spacing: 1px !important;
    }

    .mobile-suite-content .suite-link-mobile:hover {
        color: var(--primary) !important;
        background-color: rgba(232, 145, 107, 0.1) !important;
    }

    .hud {
        top: 10px;
        left: 10px;
        right: 10px;
        flex-direction: column;
        gap: 10px;
        background: rgba(13, 15, 20, 0.9);
        padding: 12px;
        border-radius: 12px;
    }

    .search-container {
        width: 100%;
    }

    #unified-search {
        width: 100% !important;
    }

    .stats-hud {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stats-hud .stat-row:last-child {
        grid-column: span 2;
        border-top: 1px solid var(--border-subtle);
    }
}

@media screen and (max-width: 480px) {
    .controls {
        bottom: 20px;
        right: 20px;
    }

    #view-directory-btn {
        font-size: 12px;
        padding: 10px;
    }
}

/* Scrollbar Styles */
#sidebar::-webkit-scrollbar,
.search-dropdown::-webkit-scrollbar {
    width: 6px;
}

#sidebar::-webkit-scrollbar-track,
.search-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

#sidebar::-webkit-scrollbar-thumb,
.search-dropdown::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

#sidebar::-webkit-scrollbar-thumb:hover,
.search-dropdown::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Shared Header Overrides */
#header .app-header {
    border-bottom: 1px solid var(--border) !important;
}

#header .nav-link.active {
    color: var(--primary) !important;
}

#header .top-container,
#header .nav-container {
    max-width: 1100px !important;
    padding: 0 24px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    box-sizing: border-box !important;
}