
:where(body[class^="page-"], body[class*=" page-"]) .header {
    background: var(--gradient-dark);
    border-bottom: 3px solid var(--primary-blue);
    padding: 0 5%;
    height: var(--header-height, 82px);
    display: flex;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow);
}

:where(body[class^="page-"], body[class*=" page-"]) .header-page {
    position: relative;
}

:where(body[class^="page-"], body[class*=" page-"]) .back-btn {
    border: 1px solid rgba(0, 90, 156, 0.5);
    color: rgba(246, 249, 255, 0.9);
    background: rgba(3, 18, 38, 0.52);
    padding: 0 18px;
    min-height: 44px;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    flex: 0 0 auto;
    gap: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-decoration: none;
    min-width: 0;
    width: auto;
    line-height: 1;
    white-space: nowrap;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

:where(body[class^="page-"], body[class*=" page-"]) .back-btn:hover {
    background: rgba(5, 31, 62, 0.72);
    color: var(--white);
    transform: translateX(-2px);
    border-color: rgba(0, 200, 255, 0.42);
}

:where(body[class^="page-"], body[class*=" page-"]) .back-btn i {
    font-size: 1rem;
}

:where(body[class^="page-"], body[class*=" page-"]) .logo {
    display: flex;
    align-items: center;
    gap: 15px;
    min-width: 0;
}

:where(body[class^="page-"], body[class*=" page-"]) .logo-icon {
    min-width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    border: none;
    background: transparent;
    box-shadow: none;
    flex-shrink: 0;
}

:where(body[class^="page-"], body[class*=" page-"]) .site-logo {
    display: block;
    width: auto;
    height: 70px;
    object-fit: contain;
}

:where(body[class^="page-"], body[class*=" page-"]) .logo-icon-link {
    text-decoration: none;
    transition: color 0.3s ease;
}

:where(body[class^="page-"], body[class*=" page-"]) .logo-icon-link:hover {
    color: var(--text-primary);
}

:where(body[class^="page-"], body[class*=" page-"]) .logo-text-wrap {
    text-decoration: none;
    min-width: 0;
    display: block;
}

:where(body[class^="page-"], body[class*=" page-"]) .logo-text-wrap:hover .logo-text {
    color: var(--white);
}

:where(body[class^="page-"], body[class*=" page-"]) .logo-text {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

:where(body[class^="page-"], body[class*=" page-"]) .logo-subtext {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Панель пользователя */
:where(body[class^="page-"], body[class*=" page-"]) .user-panel {
    display: flex;
    align-items: center;
    gap: 20px;
}

:where(body[class^="page-"], body[class*=" page-"]) .header-spacer {
    min-width: 130px;
}

:where(body[class^="page-"], body[class*=" page-"]) .xp-badge {
    background: var(--gradient-blue);
    color: var(--white);
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 3px 10px rgba(0, 90, 156, 0.3);
    font-size: 0.95rem;
}

:where(body[class^="page-"], body[class*=" page-"]) .xp-badge i {
    font-size: 0.9rem;
}

:where(body[class^="page-"], body[class*=" page-"]) .user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--gradient-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: bold;
    cursor: pointer;
    border: 2px solid var(--secondary-blue);
    transition: transform 0.3s ease, border-color 0.3s ease;
    font-size: 1rem;
}

:where(body[class^="page-"], body[class*=" page-"]) .user-avatar:hover {
    transform: scale(1.1);
    border-color: var(--white);
}

/* Меню пользователя */
:where(body[class^="page-"], body[class*=" page-"]) .user-menu {
    position: absolute;
    top: 75px;
    right: 5%;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-heavy);
    min-width: 250px;
    z-index: 1001;
    display: none;
    overflow: hidden;
    border: 1px solid rgba(0, 90, 156, 0.3);
}

:where(body[class^="page-"], body[class*=" page-"]) .user-menu.active {
    display: block;
}

:where(body[class^="page-"], body[class*=" page-"]) .user-menu-item {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.3s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    font-size: 0.95rem;
}

:where(body[class^="page-"], body[class*=" page-"]) .user-menu-item:hover {
    background: var(--bg-hover);
}

:where(body[class^="page-"], body[class*=" page-"]) .user-menu-item:last-child {
    border-bottom: none;
    color: var(--accent-red);
}

:where(body[class^="page-"], body[class*=" page-"]) .user-menu-item i {
    width: 20px;
    font-size: 1.1rem;
}

:where(body[class^="page-"], body[class*=" page-"]) .user-info {
    padding: 15px 20px;
    background: rgba(0, 90, 156, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

:where(body[class^="page-"], body[class*=" page-"]) .user-name {
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 1rem;
    color: var(--text-primary);
}

:where(body[class^="page-"], body[class*=" page-"]) .user-email {
    font-size: 0.8rem;
    color: var(--text-secondary);
}


/* Unified top panel scale on pages with standard header */
:where(body[class^="page-"], body[class*=" page-"]) .header.header-page {
    min-height: var(--panel-min-height, 82px);
    height: auto;
    padding-inline: var(--panel-inline-padding, 5%);
    gap: 16px;
}

:where(body[class^="page-"], body[class*=" page-"]) .header.header-page .back-btn {
    min-height: 42px;
    padding: 0 18px;
    font-size: 0.96rem;
}

:where(body[class^="page-"], body[class*=" page-"]) .header.header-page .logo {
    min-width: 0;
    gap: 12px;
}

:where(body[class^="page-"], body[class*=" page-"]) .header.header-page .logo-icon {
    min-width: 48px;
    height: 48px;
}

:where(body[class^="page-"], body[class*=" page-"]) .header.header-page .site-logo {
    height: 64px;
}

:where(body[class^="page-"], body[class*=" page-"]) .header.header-page .logo-text {
    font-size: clamp(1.08rem, 1.45vw, 1.3rem);
    line-height: 1.15;
}

:where(body[class^="page-"], body[class*=" page-"]) .header.header-page .logo-subtext {
    font-size: 0.82rem;
}

:where(body[class^="page-"], body[class*=" page-"]) .header.header-page .xp-badge {
    min-height: 36px;
    padding: 7px 12px;
    font-size: 0.9rem;
}

:where(body[class^="page-"], body[class*=" page-"]) .header.header-page .user-panel {
    display: flex;
    align-items: center;
    gap: 14px;
}

:where(body[class^="page-"], body[class*=" page-"]) .header.header-page .user-avatar {
    width: 42px;
    height: 42px;
    font-size: 0.95rem;
}

:where(body[class^="page-"], body[class*=" page-"]) .header.header-page .header-spacer {
    min-width: 120px;
}

:where(body[class^="page-"], body[class*=" page-"]) .header.header-page.internal-header {
    --internal-header-height: 74px;
    position: sticky;
    top: 0;
    min-height: var(--internal-header-height);
    padding: 10px clamp(16px, 4vw, 48px);
    gap: clamp(10px, 1.3vw, 16px);
    border-bottom: 1px solid rgba(126, 190, 236, 0.22);
    background: linear-gradient(180deg, rgba(5, 19, 34, 0.96), rgba(4, 14, 27, 0.93));
    box-shadow: 0 14px 34px rgba(0, 5, 14, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.055);
    backdrop-filter: blur(24px) saturate(0.9);
    -webkit-backdrop-filter: blur(24px) saturate(0.9);
    transition: background 0.24s ease, box-shadow 0.24s ease, border-color 0.24s ease;
}

:where(body[class^="page-"], body[class*=" page-"]) .header.header-page.internal-header::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.065);
    background:
        radial-gradient(circle at 50% 0, rgba(53, 155, 218, 0.09), transparent 52%),
        linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.025), transparent);
}

:where(body[class^="page-"], body[class*=" page-"]) .header.header-page.internal-header .back-btn,
:where(body[class^="page-"], body[class*=" page-"]) .header.header-page.internal-header .user-panel {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
}

:where(body[class^="page-"], body[class*=" page-"]) .header.header-page.internal-header .back-btn {
    min-height: 44px;
    min-width: auto;
    border-color: rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: rgba(7, 24, 42, 0.72);
    color: rgba(246, 249, 255, 0.82);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

:where(body[class^="page-"], body[class*=" page-"]) .header.header-page.internal-header .back-btn:hover {
    background: rgba(6, 19, 37, 0.58);
    color: var(--white);
    transform: translateX(-2px);
}

:where(body[class^="page-"], body[class*=" page-"]) .internal-header ~ .user-menu {
    position: fixed;
    top: calc(var(--internal-header-height, 74px) + 10px);
    right: clamp(14px, 4vw, 48px);
    z-index: 1100;
}

:where(body[class^="page-"], body[class*=" page-"]) .internal-page-nav {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(8px, 0.9vw, 12px);
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    scrollbar-width: none;
}

:where(body[class^="page-"], body[class*=" page-"]) .internal-page-nav::-webkit-scrollbar {
    display: none;
}

:where(body[class^="page-"], body[class*=" page-"]) .internal-nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 48px;
    padding: 0 20px;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    color: rgba(246, 249, 255, 0.9);
    font-size: clamp(0.92rem, 1vw, 1.02rem);
    font-weight: 760;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
    transition:
        color 0.22s ease,
        background 0.22s ease,
        border-color 0.22s ease,
        box-shadow 0.22s ease,
        transform 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
}

:where(body[class^="page-"], body[class*=" page-"]) .internal-nav-link i {
    color: currentColor;
    font-size: 1rem;
}

:where(body[class^="page-"], body[class*=" page-"]) .internal-nav-link:hover,
:where(body[class^="page-"], body[class*=" page-"]) .internal-nav-link:focus-visible {
    color: var(--white);
    background: rgba(6, 19, 37, 0.64);
    border-color: rgba(255, 255, 255, 0.24);
    outline: none;
    transform: translateY(-1px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 12px 24px rgba(0, 0, 0, 0.14);
}

:where(body[class^="page-"], body[class*=" page-"]) .internal-nav-link.is-active {
    color: var(--white);
    background: rgba(0, 111, 176, 0.72);
    border-color: rgba(0, 200, 255, 0.58);
    box-shadow: 0 0 0 1px rgba(0, 200, 255, 0.08) inset, 0 12px 28px rgba(0, 90, 156, 0.24);
}

:where(body[class^="page-"], body[class*=" page-"]) .internal-nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 28px;
    padding: 0 9px;
    border-radius: 999px;
    background: #ffd166;
    color: #07111f;
    font-size: 0.76rem;
    font-weight: 900;
    line-height: 1;
}

@media (max-width: 992px) {
    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page {
        padding-inline: clamp(14px, 3vw, 24px);
    }

    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page .logo-text {
        font-size: 1.06rem;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page .header-spacer {
        min-width: 0;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page.internal-header {
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 10px;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .internal-page-nav {
        order: 3;
        flex-basis: 100%;
        justify-content: flex-start;
        gap: 10px;
        padding: 2px 0;
    }
}

@media (max-width: 768px) {
    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page {
        min-height: auto;
        padding: 12px clamp(12px, 3vw, 18px);
        gap: 10px;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page .site-logo {
        height: 54px;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page .logo-text {
        font-size: 1rem;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page.internal-header {
        padding: 8px 12px;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .internal-nav-link {
        min-height: 46px;
        padding: 0 17px;
        font-size: 0.92rem;
    }
}

@media (max-width: 520px) {
    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page > .back-btn {
        width: 42px;
        min-width: 42px;
        padding: 0;
        gap: 0;
        overflow: hidden;
        font-size: 0;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page > .back-btn i {
        font-size: 1rem;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page.internal-header {
        padding: 6px 10px;
        gap: 6px;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page.internal-header .back-btn {
        min-height: 40px;
        width: 40px;
        min-width: 40px;
        padding-inline: 0;
        font-size: 0;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page.internal-header .back-btn i {
        margin: 0;
        font-size: 1rem;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page.internal-header .xp-badge {
        min-width: 40px;
        min-height: 32px;
        padding-inline: 10px;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page.internal-header .xp-badge span {
        display: none;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page.internal-header .user-panel {
        gap: 6px;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page.internal-header .user-avatar {
        width: 38px;
        height: 38px;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .internal-page-nav {
        order: 3;
        flex: 1 0 100%;
        justify-content: flex-start;
        gap: 7px;
        padding: 0;
        border-radius: 0;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .internal-nav-link {
        min-height: 40px;
        padding: 0 14px;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .internal-nav-link i {
        font-size: 0.96rem;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .internal-nav-badge {
        min-width: 32px;
        min-height: 28px;
        padding: 0 9px;
        font-size: 0.76rem;
    }
}

@media (max-width: 640px) {
    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page.internal-header .logo-subtext {
        display: none;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page.internal-header .logo-text {
        font-size: 0.95rem;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page.internal-header .logo {
        gap: 7px;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page.internal-header .user-panel {
        gap: 6px;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page.internal-header .xp-badge {
        min-height: 36px;
        padding: 7px 10px;
        font-size: 0.82rem;
    }

    :where(body[class^="page-"], body[class*=" page-"]) .header.header-page.internal-header .user-avatar {
        width: 38px;
        height: 38px;
    }
}
