* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Plus Jakarta Sans', sans-serif; }

.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    background: linear-gradient(180deg, #1a1a2e 0%, #16162a 100%);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    padding: 0 24px;
    height: 48px;
    box-shadow: 0 1px 8px rgba(0,0,0,0.3);
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.top-nav .logo {
    display: flex;
    align-items: center;
    margin-right: 32px;
    text-decoration: none;
    color: #fff;
    white-space: nowrap;
}

.top-nav .logo img {
    height: 22px;
}

.top-nav .logo .logo-divider {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.15);
    margin: 0 14px;
}

.top-nav .logo .logo-label {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255,255,255,0.5);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.top-nav .tabs {
    display: flex;
    gap: 0;
    height: 100%;
    align-items: stretch;
}

.top-nav .tab {
    display: flex;
    align-items: center;
    padding: 0 18px;
    font-size: 13px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 500;
    color: rgba(255,255,255,0.4);
    cursor: pointer;
    border: none;
    background: none;
    position: relative;
    transition: color 0.2s, background 0.2s;
    white-space: nowrap;
}

.top-nav .tab:hover {
    color: rgba(255,255,255,0.9);
    background: rgba(255,255,255,0.04);
}

.top-nav .tab.active {
    color: #fff;
}

.top-nav .tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 12px;
    right: 12px;
    height: 2px;
    background: linear-gradient(90deg, #6366f1, #818cf8);
    border-radius: 2px 2px 0 0;
}

#app {
    margin-top: 48px;
    height: calc(100vh - 48px);
}

/* --- Hamburger (mobile-only trigger) ------------------------------ */
.hamburger {
    display: none;
    width: 44px;
    height: 44px;
    padding: 0;
    margin-right: 4px;
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255,255,255,0.9);
    align-items: center;
    justify-content: center;
}
.hamburger:hover { color: #fff; }
.hamburger svg { display: block; }
.hamburger .icon-close { display: none; }
body.mobile-menu-open .hamburger .icon-menu { display: none; }
body.mobile-menu-open .hamburger .icon-close { display: block; }

/* Mobile dropdown panel holding the top-level tabs ----------------- */
.mobile-menu {
    display: none;
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 15000;
    background: rgba(12,12,20,0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    flex-direction: column;
    padding: 12px 16px 24px;
    overflow-y: auto;
    animation: mobile-menu-in 0.18s ease-out;
}
body.mobile-menu-open .mobile-menu { display: flex; }
@keyframes mobile-menu-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.mobile-menu .tab {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 16px 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    color: rgba(255,255,255,0.78);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 8px;
    text-align: left;
}
.mobile-menu .tab:hover,
.mobile-menu .tab:focus-visible {
    background: rgba(255,255,255,0.06);
    color: #fff;
    outline: none;
}
.mobile-menu .tab.active {
    color: #fff;
    border-color: rgba(99,102,241,0.6);
    background: linear-gradient(90deg, rgba(99,102,241,0.18), rgba(129,140,248,0.08));
}
.mobile-menu .tab.active::after { display: none; }
.mobile-menu .tab[data-private="1"]::before {
    content: '🔒';
    margin-right: 10px;
    opacity: 0.8;
}
.mobile-menu-auth {
    margin-top: 12px;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.mobile-menu-auth .auth-user {
    color: rgba(255,255,255,0.7);
    font-size: 13px;
    word-break: break-all;
}
.mobile-menu-auth .auth-btn {
    padding: 10px 18px;
    font-size: 13px;
}

/* --- Breakpoints --------------------------------------------------- */
/* Tablet + mobile (≤ 900px): hamburger drives navigation.
   .tabs in the top-bar are hidden and rendered inside .mobile-menu. */
@media (max-width: 900px) {
    .top-nav {
        padding: 0 12px;
        height: 48px;
    }
    .top-nav .logo {
        margin-right: 6px;
    }
    .top-nav .tabs {
        display: none;
    }
    .hamburger {
        display: inline-flex;
    }
    .auth-area {
        margin-left: auto;
        gap: 8px;
    }
    /* Desktop auth info stays visible but compacted on tablet widths,
       and gets hidden entirely on phones (moved into the panel). */
    .auth-user {
        font-size: 12px;
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (max-width: 600px) {
    .top-nav .logo .logo-divider,
    .top-nav .logo .logo-label {
        display: none;
    }
    .top-nav .logo img { height: 20px; }
    .auth-area .auth-btn,
    .auth-area .auth-user {
        display: none;
    }
    #app {
        margin-top: 48px;
        height: calc(100vh - 48px);
    }
    .mobile-menu-auth { display: flex; }
}

@media (min-width: 601px) {
    .mobile-menu-auth { display: none; }
}

/* Skeleton loader — shown before Scalar hydrates and during tab switches */
.skeleton-loader {
    display: flex;
    position: absolute;
    inset: 0;
    background: #0e0f1a;
    z-index: 10;
    pointer-events: none;
    animation: skeleton-fade-in 0.2s ease-in;
}
.skeleton-loader.hidden {
    display: none;
}
.skeleton-sidebar {
    flex: 0 0 280px;
    padding: 24px 16px;
    border-right: 1px solid rgba(255,255,255,0.06);
}
.skeleton-main {
    flex: 1;
    padding: 40px 48px;
    max-width: 900px;
}
.skeleton-line,
.skeleton-heading,
.skeleton-paragraph,
.skeleton-card {
    background: linear-gradient(
        90deg,
        rgba(255,255,255,0.04) 0%,
        rgba(255,255,255,0.08) 50%,
        rgba(255,255,255,0.04) 100%
    );
    background-size: 200% 100%;
    border-radius: 4px;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
.skeleton-line {
    height: 14px;
    margin-bottom: 14px;
    width: 100%;
}
.skeleton-line--sm {
    width: 40%;
    height: 12px;
    margin-top: 18px;
}
.skeleton-heading {
    height: 32px;
    width: 55%;
    margin-bottom: 20px;
}
.skeleton-paragraph {
    height: 14px;
    width: 90%;
    margin-bottom: 10px;
}
.skeleton-paragraph--short {
    width: 65%;
    margin-bottom: 32px;
}
.skeleton-card {
    height: 180px;
    width: 100%;
    margin-bottom: 20px;
    border-radius: 10px;
}
@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@keyframes skeleton-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@media (max-width: 768px) {
    .skeleton-sidebar { display: none; }
    .skeleton-main { padding: 24px 20px; }
}

.login-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 20000;
    align-items: center;
    justify-content: center;
}
.login-overlay.visible { display: flex; }
.login-card {
    background: #1e1e2e;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 40px;
    width: 380px;
    max-width: 90vw;
}
.login-card h2 { color: #fff; font-size: 18px; margin-bottom: 24px; text-align: center; }
.login-card input {
    width: 100%;
    padding: 10px 14px;
    margin-bottom: 12px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    outline: none;
}
.login-card input:focus { border-color: #6366f1; }
.login-card input::placeholder { color: rgba(255,255,255,0.3); }
.login-card .login-btn {
    width: 100%;
    padding: 10px;
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
}
.login-card .login-btn:hover { background: #5558e6; }
.login-error { color: #ef4444; font-size: 12px; margin-bottom: 12px; display: none; text-align: center; }
.auth-area {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}
.auth-user {
    color: rgba(255,255,255,0.5);
    font-size: 12px;
}
.auth-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.6);
    padding: 4px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}
.auth-btn:hover {
    border-color: rgba(255,255,255,0.4);
    color: rgba(255,255,255,0.9);
}
.tab[data-private] {
    border-left: 2px solid rgba(99,102,241,0.4);
}

body.hide-intro-card .introduction-card,
body.hide-intro-card .sticky-cards,
body.hide-intro-card .scalar-reference-intro-server,
body.hide-intro-card .scalar-reference-intro-auth,
body.hide-intro-card .scalar-reference-intro-clients {
    display: none !important;
}

.ext-links {
    display: flex;
    gap: 0;
    align-items: stretch;
    height: 100%;
}
.top-nav .ext-link {
    display: flex;
    align-items: center;
    padding: 0 18px;
    font-size: 13px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 500;
    color: rgba(255,255,255,0.4);
    text-decoration: none;
    background: none;
    border: none;
    white-space: nowrap;
    transition: color 0.2s, background 0.2s;
}
.top-nav .ext-link:hover {
    color: rgba(255,255,255,0.9);
    background: rgba(255,255,255,0.04);
}
.top-nav .ext-link span[aria-hidden="true"] {
    margin-left: 4px;
    font-size: 11px;
    opacity: 0.6;
}
@media (max-width: 960px) {
    .ext-links { display: none; }
}
.mobile-ext-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}
.mobile-ext-links .ext-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 16px 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    color: rgba(255,255,255,0.78);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
}
.mobile-ext-links .ext-link:hover,
.mobile-ext-links .ext-link:focus-visible {
    background: rgba(255,255,255,0.06);
    color: #fff;
    outline: none;
}
