:root {
    --bg: #0b0f19;
    --fg: #e2e8f0;
    --muted: #94a3b8;
    --primary: #8b5cf6;
    --secondary: #ec4899;
    --accent: #22d3ee;
    --card: rgba(30, 41, 59, 0.7);
    --border: rgba(139, 92, 246, 0.3);
    --glass: rgba(148, 163, 184, 0.05);
    --nav-width: 300px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--fg);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Background Gradients */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 15% 20%, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 85% 80%, rgba(236, 72, 153, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(34, 211, 238, 0.05) 0%, transparent 70%);
    z-index: -1;
}

/* Hero Section */
.hero {
    padding: 6rem 1rem 4rem;
    text-align: center;
    position: relative;
}

.hero-inner {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.logo {
    width: 80px;
    height: auto;
    margin-bottom: 2rem;
    filter: drop-shadow(0 0 20px rgba(139, 92, 246, 0.5));
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
}

.hero p {
    color: var(--muted);
    font-size: 1.1rem;
    margin-bottom: 2.5rem;
}

/* Search */
.search-container {
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

#search {
    width: 100%;
    padding: 1.25rem 1.5rem;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 16px;
    color: #fff;
    font-size: 1rem;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

#search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1), 0 0 20px rgba(139, 92, 246, 0.2);
}

/* Hero CTA */
.hero-cta {
    margin-top: 2rem;
}

.markdown-btn {
    display: inline-block;
    color: #fff;
    border: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    background: var(--glass);
    text-decoration: none;
    transition: all 0.3s ease;
    font-weight: 500;
}

.markdown-btn:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--primary);
    transform: translateY(-2px);
}

/* Layout - Stable Grid */
.main-wrapper {
    display: grid;
    grid-template-columns: var(--nav-width) 1fr;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 2rem 4rem;
    gap: 3rem;
    align-items: start;
}

/* Top Navigation Bar */
.top-nav {
    position: sticky;
    top: 0;
    background: rgba(11, 15, 25, 0.95);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    padding: 0 2rem;
}

.top-nav-inner {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 1rem 0;
    /* scrollbar-width removed for compatibility - using webkit styles below */
}

.top-nav-inner::-webkit-scrollbar {
    height: 8px;
}

.top-nav-inner::-webkit-scrollbar-track {
    background: rgba(139, 92, 246, 0.05);
    border-radius: 4px;
}

.top-nav-inner::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 4px;
    transition: background 0.3s ease;
}

.top-nav-inner::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #a78bfa, #ec4899);
}

.top-nav a {
    display: inline-flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.top-nav a:hover {
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary);
    border-color: var(--border);
}

.top-nav a.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    font-weight: 600;
}

/* Sidebar */
.sidebar {
    position: sticky;
    top: 2rem;
    height: calc(100vh - 4rem);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 1.5rem;
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    overflow-y: auto;
}

.sidebar h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin: 1.5rem 0 1rem;
    padding-left: 1rem;
}

.sidebar nav a {
    display: block;
    padding: 0.75rem 1rem;
    color: #cbd5e1;
    text-decoration: none;
    border-radius: 12px;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    margin-bottom: 0.25rem;
}

.sidebar nav a:hover {
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary);
}

.sidebar nav a.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff !important;
    font-weight: 600;
}

/* Main navigation links - distinct from subsections */
.sidebar nav a.main-nav-link {
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    margin-top: 0.5rem;
}

.sidebar nav a.main-nav-link:hover {
    background: rgba(139, 92, 246, 0.15);
    color: var(--primary);
}

.sidebar nav a.sub {
    padding-left: 2rem;
    font-size: 0.85rem;
    color: var(--muted);
}

/* Search match highlighting */
.sidebar nav a.search-match {
    background: rgba(139, 92, 246, 0.15);
    border-left: 3px solid var(--primary);
}

.highlight {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-weight: 600;
}

/* Global Scrollbar Styling */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: rgba(139, 92, 246, 0.05);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 6px;
    border: 2px solid rgba(11, 15, 25, 0.5);
    transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #a78bfa, #ec4899);
}

/* Sidebar Scrollbar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 3px;
    border: none;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.5);
}

/* Content */
.content {
    min-width: 0;
}

article section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: clamp(1.5rem, 5vw, 3rem);
    margin-bottom: 3rem;
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    transition: transform 0.3s ease;
}

article section:hover {
    border-color: rgba(139, 92, 246, 0.5);
}

article h2 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

article h2::before {
    content: '';
    width: 4px;
    height: 1.5rem;
    background: linear-gradient(180deg, var(--primary), var(--secondary));
    border-radius: 2px;
}

article p {
    margin-bottom: 1.5rem;
    color: #cbd5e1;
}

article ul,
article ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

article li {
    margin-bottom: 0.5rem;
    color: #cbd5e1;
}

article code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-family: 'Fira Code', monospace;
    font-size: 0.9em;
    color: var(--accent);
}

/* Role Cards */
.role-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.role-card {
    background: var(--glass);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--border);
}

.role-title {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.role-primary {
    color: var(--primary);
}

.role-secondary {
    color: var(--secondary);
}

.role-desc {
    font-size: 0.9rem;
    margin-bottom: 0;
}

/* Mobile Toggle */
.mobile-toggle {
    display: none;
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 30px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    border: none;
    box-shadow: 0 10px 25px rgba(139, 92, 246, 0.5);
    z-index: 1000;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Responsive */
@media (max-width: 1024px) {
    :root {
        --nav-width: 250px;
    }

    .main-wrapper {
        gap: 1.5rem;
        padding: 0 1rem 4rem;
    }
}

@media (max-width: 980px) {
    .main-wrapper {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
        position: fixed;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        z-index: 999;
        border-radius: 0;
        padding-top: 5rem;
    }

    .sidebar.open {
        display: block;
        animation: slideIn 0.3s ease;
    }

    @keyframes slideIn {
        from {
            transform: translateX(-100%);
        }

        to {
            transform: translateX(0);
        }
    }

    .mobile-toggle {
        display: flex;
    }
}

.fade-in {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

.fade-in.show {
    opacity: 1;
    transform: translateY(0);
}

.highlight {
    background: rgba(139, 92, 246, 0.2);
    padding: 0 4px;
    border-radius: 4px;
    font-weight: 600;
}