.top-bar {
    background: linear-gradient(115deg, #75a9e2 0%, #5e91cc 55%, #507cad 100%);
    color: #fff;
    padding: 18px 20px;
    text-align: center;
    border-bottom: 3px solid #3f6798;
    box-shadow: 0 5px 16px rgba(42, 77, 117, 0.16);
    
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}

.button-container {
    grid-column: 3;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.auth-icon {
    width: 18px;
    height: 18px;
    margin-right: 5px;
    object-fit: contain;
    vertical-align: middle;
    filter: invert(38%) sepia(51%) saturate(650%) hue-rotate(174deg) brightness(88%) contrast(90%);
}

.post-author-line,
.profile-name-line,
.admin-user-name {
    align-items: center;
    display: inline-flex;
    gap: 7px;
    min-width: 0;
    white-space: nowrap;
}

.profile-heading-line {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.role-badge {
    align-items: center;
    display: inline-flex;
    flex: 0 0 auto;
    height: 17px;
    justify-content: center;
    margin-left: 2px;
    width: 17px;
    white-space: nowrap;
}

.role-badge img {
    height: 16px;
    object-fit: contain;
    width: 16px;
}

.role-badge.admin {
    color: #315f91;
}

.role-badge.admin img {
    filter: invert(38%) sepia(51%) saturate(650%) hue-rotate(174deg) brightness(88%) contrast(90%);
}

.role-badge.moderator {
    color: #347342;
}

.role-badge.moderator img {
    filter: invert(43%) sepia(56%) saturate(650%) hue-rotate(83deg) brightness(88%) contrast(90%);
}

.sub-bar {
    background: #fff;
    color: #fff;
    padding: 10px 16px;
    text-align: center;
    font-family: "Comic Sans MS", sans-serif;
    font-size: 10px;
    box-shadow: 0 3px 10px rgba(35, 61, 90, 0.08);
    
    /* Added flexbox to keep items evenly spaced and centered */
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0px; /* gap is controlled by the divider margins */
}

.sub-bar a {
    color: #345d8c;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    margin: 0;
    font-family: "Comic Sans MS", sans-serif;
    font-size: 16px;
    font-weight: bold;
    padding: 4px 0;
    line-height: 1; /* Ensures text height stays uniform */
    transition: color 0.16s ease;
}

.sub-bar a + a::before {
    border-left: 1px solid #c7d5e5;
    content: "";
    height: 16px;
    margin: 0 16px;
    display: inline-block;
}

.sub-bar a:hover {
    color: #1f4775;
    text-decoration: underline;
}

.sub-bar a:focus-visible {
    outline: 2px solid #d49f00;
    outline-offset: 2px;
}

@media (max-width: 640px) {
    .top-bar {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 12px;
    }

    .long-logo {
        grid-column: auto;
        max-width: min(280px, calc(100vw - 40px));
    }

    .button-container {
        align-items: center;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
        width: 100%;
    }

    .button-container > a {
        flex: 0 1 120px;
        min-width: 110px;
        padding-left: 10px;
        padding-right: 10px;
        width: auto;
    }

    .sub-bar {
        padding: 8px 10px;
        gap: 4px; /* Slightly tighter gap on mobile if wrapping occurs */
    }

    .sub-bar a {
        font-size: 15px;
        padding: 4px 0;
    }

    .sub-bar a + a::before {
        height: 14px;
        margin: 0 12px;
    }
}

/* Stamps balance (Gobrix currency) at the top of the account buttons */
.stamp-balance {
    align-items: center;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #b9cce1;
    border-radius: 999px;
    box-shadow: 0 3px 0 #d3dfec;
    box-sizing: border-box;
    color: #345d8c;
    display: inline-flex;
    font-family: "Comic Sans MS", sans-serif;
    font-size: 14px;
    gap: 6px;
    justify-content: center;
    padding: 4px 14px 4px 6px;
    white-space: nowrap;
}

.stamp-balance strong {
    color: #243c5a;
    font-variant-numeric: tabular-nums;
}

.stamp-icon {
    height: 26px;
    width: 26px;
}

/* My Gifts count in the account menu */
.gift-count { background: #d4572a; border-radius: 9px; color: #fff; font-size: 11px; font-weight: bold; line-height: 18px; margin-left: auto; min-width: 18px; padding: 0 5px; text-align: center; }
.account-button.has-gift::after { background: #d4572a; border: 2px solid #fff; border-radius: 50%; content: ""; height: 8px; position: absolute; right: 2px; top: 2px; width: 8px; }
.account-button { position: relative; }
