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

.nav-link, .mobile-nav-link {
    text-decoration: none;
}

:root {
    --color-bg: #F7F8FA;
    --color-surface: #FFFFFF;
    --color-border: #E4E7EC;
    --color-border-light: #F0F2F5;
    --color-text-primary: #111827;
    --color-text-secondary: #4B5563;
    --color-text-tertiary: #9CA3AF;
    --radius-sm: 6px;
    --transition-fast: 150ms ease;
    --graph-bg: #f0f1f5;
    --controls-bg: rgba(255, 255, 255, 0.92);
    --controls-border: rgba(180, 190, 210, 0.4);
    --controls-text: #111827;
    --controls-label: #6b7280;
    --controls-accent: #4f5fff;
    --controls-accent-light: #a0b0ff;
    --controls-input-bg: rgba(240, 242, 245, 0.8);
    --controls-input-border: rgba(180, 190, 210, 0.4);
    --stats-text: #6b7280;
    --stats-accent: #4f5fff;
    --tooltip-bg: rgba(255, 255, 255, 0.95);
    --tooltip-border: rgba(180, 190, 210, 0.5);
    --tooltip-title: #4f5fff;
    --tooltip-label: #6b7280;
    --tooltip-val: #111827;
    --slider-track: rgba(200, 205, 220, 0.6);
    --slider-thumb: #4f5fff;
    --slider-thumb-border: #a0b0ff;
    --threshold-color: #4f5fff;
    --search-placeholder: #9ca3af;
    --legend-text: #6b7280;
    --community-hover-bg: rgba(200, 205, 220, 0.3);
    --community-active-bg: rgba(79, 95, 255, 0.12);
    --community-active-border: rgba(79, 95, 255, 0.3);
    --sim-btn-bg: rgba(240, 242, 245, 0.8);
    --sim-btn-color: #4f5fff;
    --sim-btn-hover-bg: rgba(220, 225, 235, 0.6);
    --sim-btn-active-bg: rgba(79, 95, 255, 0.15);
    --alpha-bar-bg: rgba(220, 225, 235, 0.6);
    --scrollbar-thumb: rgba(79, 95, 255, 0.3);
}

[data-theme="dark"] {
    --color-bg: #111318;
    --color-surface: #1A1D24;
    --color-border: #2A2D35;
    --color-border-light: #22252D;
    --color-text-primary: #F0F1F3;
    --color-text-secondary: #A0A4AD;
    --color-text-tertiary: #6B7280;
    --graph-bg: #0a0a1a;
    --controls-bg: rgba(20, 20, 40, 0.92);
    --controls-border: rgba(100, 120, 255, 0.25);
    --controls-text: #e0e0e0;
    --controls-label: #8090b0;
    --controls-accent: #a0b0ff;
    --controls-accent-light: #a0b0ff;
    --controls-input-bg: rgba(30, 30, 60, 0.8);
    --controls-input-border: rgba(100, 120, 255, 0.3);
    --stats-text: #8090b0;
    --stats-accent: #a0b0ff;
    --tooltip-bg: rgba(20, 20, 40, 0.95);
    --tooltip-border: rgba(100, 120, 255, 0.4);
    --tooltip-title: #a0b0ff;
    --tooltip-label: #8090b0;
    --tooltip-val: #e0e0e0;
    --slider-track: rgba(60, 60, 120, 0.6);
    --slider-thumb: #6080ff;
    --slider-thumb-border: #a0b0ff;
    --threshold-color: #6080ff;
    --search-placeholder: #506080;
    --legend-text: #8090b0;
    --community-hover-bg: rgba(60, 60, 120, 0.4);
    --community-active-bg: rgba(80, 100, 255, 0.2);
    --community-active-border: rgba(100,120,255,0.4);
    --sim-btn-bg: rgba(30, 30, 60, 0.8);
    --sim-btn-color: #a0b0ff;
    --sim-btn-hover-bg: rgba(60, 60, 120, 0.6);
    --sim-btn-active-bg: rgba(80, 100, 255, 0.3);
    --alpha-bar-bg: rgba(40,40,80,0.6);
    --scrollbar-thumb: rgba(100,120,255,0.3);
}

body { font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--color-bg); color: var(--color-text-primary); overflow: hidden; height: 100vh; -webkit-font-smoothing: antialiased; }

/* ─── Header ─── */
.header {
    background: var(--color-surface);
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
    position: relative;
    z-index: 50;
}

.header-brand {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.header h1 {
    font-family: 'Urbanist', sans-serif;
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--color-text-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.header-subtitle {
    font-size: 0.75rem;
    color: var(--color-text-tertiary);
    font-weight: 400;
    line-height: 1.35;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ─── Nav Links (desktop) ─── */
.header-nav {
    display: flex;
    align-items: center;
    gap: 0.125rem;
}

.nav-link {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color var(--transition-fast), background var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    background: none;
    border: none;
    font-family: inherit;
}

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

/* ─── Theme Toggle ─── */
.theme-toggle {
    width: 32px;
    height: 32px;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-tertiary);
    transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
    outline: none;
}

.theme-toggle:hover {
    color: var(--color-text-secondary);
    border-color: var(--color-text-tertiary);
    background: var(--color-bg);
}

.theme-toggle:focus-visible {
    box-shadow: 0 0 0 2px rgba(90, 69, 255, 0.3);
}

.theme-toggle svg {
    width: 16px;
    height: 16px;
}

.theme-toggle .icon-moon {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: block;
}

/* ─── Hamburger (mobile) ─── */
.hamburger {
    display: none;
    width: 32px;
    height: 32px;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0;
    flex-shrink: 0;
    transition: background var(--transition-fast);
}

.hamburger:hover { background: var(--color-bg); }

.hamburger-line {
    width: 14px;
    height: 1.5px;
    background: var(--color-text-secondary);
    border-radius: 2px;
    transition: transform 200ms ease, opacity 200ms ease;
    display: block;
}

/* ─── Mobile Menu ─── */
.mobile-menu {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    z-index: 200;
    flex-direction: column;
    padding: 0;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.mobile-menu.open { display: flex; }

.mobile-nav-link {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    padding: 0.875rem 1.5rem;
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
    text-align: left;
    width: 100%;
    transition: background var(--transition-fast), color var(--transition-fast);
    border-bottom: 1px solid var(--color-border-light);
}

.mobile-nav-link:last-child { border-bottom: none; }
.mobile-nav-link:hover { background: var(--color-bg); color: var(--color-text-primary); }

/* ─── Graph Container ─── */
#sigma-container { position: relative; width: 100%; height: calc(100vh - 60px - 46px); background: var(--graph-bg); }
#edge-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }

/* ─── Controls ─── */
#controls-wrapper {
  position: absolute; top: 20px; left: 20px; z-index: 100;
}
#controls-toggle {
  width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--controls-border);
  background: var(--controls-bg); backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s ease;
}
#controls-toggle:hover { border-color: var(--slider-thumb); background: var(--controls-bg); }
#controls-toggle svg { width: 22px; height: 22px; fill: none; stroke: var(--controls-accent); stroke-width: 2; stroke-linecap: round; }
#controls {
  background: var(--controls-bg); border: 1px solid var(--controls-border);
  border-radius: 12px; padding: 20px; min-width: 280px; margin-top: 8px;
  backdrop-filter: blur(12px); box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  display: none;
}
#controls-wrapper.open #controls { display: block; }
#controls-wrapper.open #controls-toggle { border-color: var(--slider-thumb); }
#controls h2 { font-size: 16px; font-weight: 600; margin-bottom: 16px; color: var(--controls-accent); letter-spacing: 0.5px; }
.control-group { margin-bottom: 14px; }
.control-group label { display: block; font-size: 11px; font-weight: 500; color: var(--controls-label); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.8px; }
select, input[type=range] { width: 100%; }
select {
  background: var(--controls-input-bg); border: 1px solid var(--controls-input-border);
  color: var(--controls-text); padding: 8px 10px; border-radius: 6px; font-size: 14px;
  cursor: pointer; outline: none;
}
select:hover { border-color: var(--slider-thumb); }
input[type=range] {
  -webkit-appearance: none; appearance: none; height: 6px;
  background: var(--slider-track); border-radius: 3px; outline: none; margin-top: 4px;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px;
  background: var(--slider-thumb); border-radius: 50%; cursor: pointer; border: 2px solid var(--slider-thumb-border);
}

/* ─── Stats ─── */
#stats {
  position: absolute; bottom: 20px; left: 20px; z-index: 100;
  background: var(--controls-bg); border: 1px solid var(--controls-border);
  border-radius: 10px; padding: 14px 18px; backdrop-filter: blur(12px);
  font-size: 13px; color: var(--stats-text);
}
#stats span { color: var(--stats-accent); font-weight: 600; }

/* ─── Tooltip ─── */
#tooltip {
  position: absolute; z-index: 200; display: none;
  background: var(--tooltip-bg); border: 1px solid var(--tooltip-border);
  border-radius: 8px; padding: 12px 16px; pointer-events: none;
  backdrop-filter: blur(12px); box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  font-size: 13px; max-width: 260px;
}
#tooltip .tt-title { font-weight: 700; font-size: 15px; color: var(--tooltip-title); margin-bottom: 6px; }
#tooltip .tt-row { display: flex; justify-content: space-between; padding: 2px 0; }
#tooltip .tt-label { color: var(--tooltip-label); }
#tooltip .tt-val { color: var(--tooltip-val); font-weight: 600; }

/* ─── Other Controls ─── */
.threshold-val { text-align: center; font-size: 18px; font-weight: 700; color: var(--threshold-color); margin-top: 2px; }
#search-box {
  width: 100%; background: var(--controls-input-bg); border: 1px solid var(--controls-input-border);
  color: var(--controls-text); padding: 8px 10px; border-radius: 6px; font-size: 14px; outline: none;
}
#search-box::placeholder { color: var(--search-placeholder); }
#search-box:focus { border-color: var(--slider-thumb); }
.legend { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.legend-item { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--legend-text); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }
.community-legend { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; max-height: 180px; overflow-y: auto; }
.community-item {
  display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px;
  cursor: pointer; font-size: 12px; color: var(--legend-text); transition: all 0.15s ease;
  border: 1px solid transparent;
}
.community-item:hover { background: var(--community-hover-bg); color: var(--controls-text); }
.community-item.active { background: var(--community-active-bg); border-color: var(--community-active-border); color: var(--controls-text); }
.community-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.community-count { margin-left: auto; font-size: 10px; color: var(--search-placeholder); font-weight: 600; }
.community-legend::-webkit-scrollbar { width: 4px; }
.community-legend::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 2px; }
.sim-controls { display: flex; gap: 8px; margin-top: 4px; }
.sim-btn {
  flex: 1; padding: 7px 0; border: 1px solid var(--controls-input-border); border-radius: 6px;
  background: var(--sim-btn-bg); color: var(--sim-btn-color); font-size: 12px; cursor: pointer;
  text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; text-align: center;
}
.sim-btn:hover { background: var(--sim-btn-hover-bg); border-color: var(--slider-thumb); }
.sim-btn.active { background: var(--sim-btn-active-bg); border-color: var(--slider-thumb); }
#alpha-bar { width: 100%; height: 4px; background: var(--alpha-bar-bg); border-radius: 2px; margin-top: 6px; overflow: hidden; }
#alpha-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #304090, #6080ff); border-radius: 2px; transition: width 0.1s; }

/* ─── Footer ─── */
.footer {
    background: #1a1d29;
    border-top: 1px solid #2a2f3e;
    padding: 12px 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 180;
}
[data-theme="light"] .footer {
    background: #ffffff;
    border-top: 1px solid #d0d7de;
}
[data-theme="light"] .footer-company,
[data-theme="light"] .footer-link {
    color: #656d76;
}
[data-theme="light"] .footer-link:hover {
    color: #1a1d29;
}
[data-theme="light"] .footer-social svg {
    fill: #656d76;
}
[data-theme="light"] .footer-social:hover svg {
    fill: #1a1d29;
}
.footer-content {
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
}
.footer-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.footer-company {
    color: #8b949e;
    font-weight: 500;
}
.footer-link {
    color: #8b949e;
    text-decoration: none;
    font-weight: 400;
    transition: color 0.2s ease;
}
.footer-link:hover {
    color: #ffffff;
}
.footer-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.footer-social {
    color: #8b949e;
    text-decoration: none;
    font-size: 16px;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.footer-social svg {
    width: 20px;
    height: 20px;
    fill: #8b949e;
    transition: fill 0.2s ease;
}
.footer-social:hover svg {
    fill: #ffffff;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .header-nav { display: none; }
    .hamburger { display: flex; }
    .footer-content {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    .footer-left {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px 16px;
    }
    .footer-right {
        gap: 14px;
    }
}
