.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    height: 60px;
}

.navbar-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
    width: 100%;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 20px;
}

.navbar-brand {
    text-decoration: none;
    display: flex;
    align-items: center;
    line-height: 0;
    flex-shrink: 0;
}

.navbar-logo {
    height: 40px;
    width: auto;
    display: block;
    border-radius: 8px;
}

.navbar-menu {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    gap: 10px;
}

.nav-item {
    position: relative;
    flex-shrink: 0;
}

.nav-item > a,
.nav-item > a.nav-item-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.25em;
    width: max-content;
    max-width: 100%;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    letter-spacing: -0.01em;
    color: var(--text-dark);
    text-decoration: none;
    border: none;
    background: transparent;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:not(.nav-item--dropdown) > a {
    gap: 0;
}

.nav-item:hover > a,
.nav-item:focus-within > a {
    background: rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .nav-item:hover > a,
[data-theme="dark"] .nav-item:focus-within > a {
    background: rgba(255, 255, 255, 0.1);
}

.nav-item.is-active > a {
    background: transparent;
    color: var(--text-dark);
}

.nav-item-label {
    flex: 0 0 auto;
}

.nav-chevron {
    flex: 0 0 auto;
    display: block;
    margin: 0;
    opacity: 0.65;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 220px;
    max-width: min(320px, 90vw);
    padding: 6px 0;
    margin: 0;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
    z-index: 1100;
}

@media (hover: hover) and (pointer: fine) {
    .nav-item--dropdown:hover .nav-dropdown,
    .nav-item--dropdown:focus-within .nav-dropdown {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateY(0);
    }

    .nav-item--dropdown:hover .nav-chevron,
    .nav-item--dropdown:focus-within .nav-chevron {
        transform: translateY(3px);
        opacity: 1;
    }
}

.nav-item--dropdown.is-open .nav-dropdown {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.nav-item--dropdown.is-open .nav-chevron {
    transform: translateY(3px);
    opacity: 1;
}

.nav-dropdown-scroll {
    max-height: min(60vh, 420px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.nav-dropdown-link {
    display: block;
    padding: 8px 14px;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.35;
    color: var(--text-medium);
    text-decoration: none;
    transition: background 0.12s ease, color 0.12s ease;
}

.nav-dropdown-link:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-dark);
}

[data-theme="dark"] .nav-dropdown-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-dark);
}

.nav-dropdown-link--article {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-dropdown-footer {
    display: block;
    padding: 10px 14px;
    margin-top: 4px;
    border-top: 1px solid var(--border-light);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary-blue, #3b82f6);
    text-decoration: none;
}

.nav-dropdown-footer:hover {
    background: rgba(59, 130, 246, 0.08);
}

.theme-toggle {
    width: 36px;
    height: 36px;
    margin-left: auto;
    border-radius: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease;
    color: var(--text-medium);
    position: relative;
    z-index: 10;
}

.theme-toggle:hover {
    color: var(--text-dark);
    background: rgba(0, 0, 0, 0.06);
    transform: none;
}

[data-theme="dark"] .theme-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

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

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

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

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

@media (max-width: 900px) {
    .navbar-container {
        gap: 12px;
        padding: 0 12px;
    }

    .navbar-menu {
        gap: 6px;
    }

    .nav-item > a,
    .nav-item > a.nav-item-trigger {
        padding: 6px 10px;
        font-size: 0.8125rem;
    }

    .nav-dropdown {
        min-width: 200px;
        max-width: min(300px, calc(100vw - 24px));
    }

    .nav-item--dropdown:last-of-type .nav-dropdown,
    .nav-item--dropdown:nth-last-of-type(2) .nav-dropdown {
        left: auto;
        right: 0;
    }
}

@media (max-width: 768px) {
    .navbar-logo {
        height: 32px;
    }

    .navbar-menu {
        gap: 4px;
    }

    .nav-item > a,
    .nav-item > a.nav-item-trigger {
        padding: 6px 8px;
        font-size: 0.75rem;
    }

    .nav-chevron {
        width: 12px;
        height: 12px;
    }

    .nav-item-label--long {
        display: none;
    }
}

@media (max-width: 480px) {
    .navbar-container {
        padding: 0 8px;
        gap: 8px;
    }

    .navbar-logo {
        height: 28px;
    }

    .nav-item > a,
    .nav-item > a.nav-item-trigger {
        padding: 5px 6px;
        font-size: 0.68rem;
    }

    .theme-toggle {
        width: 30px;
        height: 30px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .nav-chevron,
    .nav-dropdown {
        transition: none;
    }
}
