.topbar {
    display: grid;
    grid-template-columns: auto minmax(360px, 1fr) auto;
    align-items: center;
    gap: 28px;
    margin-bottom: 60px;
    padding: 14px 0 18px;
    border-bottom: 1px solid color-mix(in srgb, var(--border-color) 78%, transparent);
    position: relative;
}

.topbar::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: -1px;
    width: min(360px, 34vw);
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--teal), var(--coral));
    opacity: 0.65;
}

.nav-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    padding: 5px;
    border: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
    border-radius: 999px;
    background: color-mix(in srgb, var(--bg-primary) 76%, transparent);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.nav-links a {
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 750;
    text-decoration: none;
    white-space: nowrap;
    transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
    background: var(--teal-muted);
    color: var(--teal);
}

.nav-links a:hover {
    transform: translateY(-1px);
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
}

.btn-theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid color-mix(in srgb, var(--border-color) 78%, transparent);
    border-radius: 999px;
    background: color-mix(in srgb, var(--bg-primary) 74%, transparent);
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
    transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.btn-theme-toggle:hover {
    border-color: var(--teal);
    background: var(--teal-muted);
    color: var(--teal);
    transform: translateY(-1px);
}

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

body.light-mode .theme-icon-sun,
body:not(.light-mode) .theme-icon-moon {
    display: none !important;
}

body.light-mode .theme-icon-moon,
body:not(.light-mode) .theme-icon-sun {
    display: block !important;
}

.beta-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid color-mix(in srgb, var(--border-color) 78%, transparent);
    border-radius: 999px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    background: color-mix(in srgb, var(--bg-primary) 72%, transparent);
}

body.light-mode .beta-badge {
    background: rgba(255, 255, 255, 0.65);
}

.beta-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--teal);
    box-shadow: 0 0 10px var(--teal-glow);
}

.btn-nav-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 18px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--teal) 0%, #00b7a5 56%, var(--coral) 160%);
    color: #061014;
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 12px 26px rgba(0, 150, 136, 0.2);
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.btn-nav-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 34px rgba(0, 150, 136, 0.28);
}

footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 24px;
    margin-top: 80px;
    padding-top: 28px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 13px;
}

.footer-social-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.footer-social-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 999px;
    opacity: 0.76;
    text-decoration: none;
    transition: opacity 160ms ease, transform 160ms ease;
}

.footer-social-links a:hover {
    opacity: 1;
    transform: translateY(-3px) scale(1.04);
}

.footer-social-links img {
    width: 51px;
    height: 51px;
    display: block;
    object-fit: contain;
}

.footer-social-links a:first-child img {
    filter: invert(1);
}

body.light-mode .footer-social-links a:first-child img {
    filter: none;
}

.footer-links {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 18px;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
}

.footer-links a:hover,
.footer-links a[aria-current="page"] {
    color: var(--teal);
}

@media (max-width: 1180px) {
    .topbar {
        grid-template-columns: auto 1fr;
    }

    .nav-links {
        justify-self: end;
    }

    .header-actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }
}

@media (max-width: 980px) {
    .topbar {
        grid-template-columns: 1fr;
        align-items: flex-start;
        gap: 14px;
    }

    .nav-links,
    .header-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .nav-links {
        border-radius: 18px;
        overflow-x: auto;
        justify-content: flex-start;
        scrollbar-width: none;
    }

    .nav-links::-webkit-scrollbar {
        display: none;
    }

    .header-actions {
        flex-wrap: wrap;
        grid-column: auto;
    }

    footer {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
    }

    .footer-links {
        justify-content: center;
    }
}

@media (max-width: 640px) {
    .nav-links {
        width: 100%;
        overflow-x: visible;
        flex-wrap: wrap;
    }

    .nav-links a {
        padding: 8px 10px;
    }

    .beta-badge {
        display: none;
    }

    .btn-theme-toggle {
        order: 2;
    }

    .btn-nav-cta {
        order: 1;
    }

    .footer-social-links {
        gap: 10px;
        flex-wrap: wrap;
    }

    .footer-social-links a {
        width: 56px;
        height: 56px;
    }

    footer {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
    }

    .footer-links {
        justify-content: center;
    }
}
