.auth-widget {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    position: relative;
    z-index: 40;
    margin-bottom: -8px;
}

.auth-widget button,
.auth-widget input {
    font: inherit;
}

.auth-actions,
.auth-account {
    background: rgba(255, 255, 255, 0.82);
    border: var(--glass-border, 1px solid rgba(255, 255, 255, 0.8));
    border-radius: 999px;
    box-shadow: var(--shadow-soft, 0 10px 40px -10px rgba(0,0,0,0.08));
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.auth-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
}

.auth-buy-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    border-radius: 999px;
    padding: 8px 12px;
    color: var(--primary, #0984e3);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 900;
    white-space: nowrap;
}

.auth-buy-link:hover,
.auth-buy-link:focus-visible {
    background: rgba(9, 132, 227, 0.08);
    outline: none;
}

.auth-btn {
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 9px 16px;
    cursor: pointer;
    color: var(--text-main, #2d3436);
    background: rgba(223, 230, 233, 0.72);
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.auth-btn:hover,
.auth-btn:focus-visible {
    transform: translateY(-1px);
    outline: none;
    box-shadow: 0 6px 14px rgba(9, 132, 227, 0.18);
}

.auth-btn.primary,
.auth-submit {
    background: var(--primary, #0984e3);
    color: #fff;
    border-color: var(--primary, #0984e3);
    box-shadow: 0 4px 12px var(--primary-glow, rgba(9, 132, 227, 0.4));
}

.auth-account {
    position: relative;
}

.auth-profile {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    border: 0;
    border-radius: 999px;
    padding: 6px 14px 6px 6px;
    background: transparent;
    color: var(--text-main, #2d3436);
    cursor: pointer;
}

.auth-profile:focus-visible {
    outline: 2px solid rgba(9, 132, 227, 0.35);
    outline-offset: 3px;
}

.auth-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    background: linear-gradient(135deg, #0984e3 0%, #00b894 100%);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 900;
    box-shadow: 0 6px 14px rgba(9, 132, 227, 0.25);
}

.auth-username {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.94rem;
    font-weight: 800;
}

.auth-popover {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: min(286px, calc(100vw - 40px));
    padding: 14px;
    border: var(--glass-border, 1px solid rgba(255, 255, 255, 0.8));
    border-radius: var(--radius-md, 16px);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 18px 42px -18px rgba(45, 52, 54, 0.32);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}

.auth-account:hover .auth-popover,
.auth-account:focus-within .auth-popover,
.auth-account.is-open .auth-popover {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.auth-popover::before {
    content: "";
    position: absolute;
    top: -7px;
    right: 24px;
    width: 14px;
    height: 14px;
    background: rgba(255, 255, 255, 0.94);
    border-left: var(--glass-border, 1px solid rgba(255, 255, 255, 0.8));
    border-top: var(--glass-border, 1px solid rgba(255, 255, 255, 0.8));
    transform: rotate(45deg);
}

.auth-quota-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px;
    border-radius: 14px;
    background: rgba(9, 132, 227, 0.08);
    border: 1px solid rgba(9, 132, 227, 0.12);
}

.auth-quota-label {
    color: var(--text-sub, #636e72);
    font-size: 0.82rem;
    font-weight: 700;
}

.auth-quota-value {
    color: var(--primary, #0984e3);
    font-size: 1.24rem;
    font-weight: 900;
}

.auth-popover-actions {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.auth-popover-btn {
    display: block;
    width: 100%;
    border: 1px solid rgba(9, 132, 227, 0.14);
    border-radius: 13px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--text-main, #2d3436);
    cursor: pointer;
    text-align: left;
    font-size: 0.9rem;
    font-weight: 800;
    transition: transform 0.2s ease, background 0.2s ease;
}

.auth-popover-link {
    text-decoration: none;
    color: var(--primary, #0984e3);
}

.auth-popover-btn:hover,
.auth-popover-btn:focus-visible {
    background: rgba(9, 132, 227, 0.08);
    transform: translateY(-1px);
    outline: none;
}

.auth-popover-btn.muted {
    color: var(--text-sub, #636e72);
}

.auth-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(45, 52, 54, 0.32);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.18s ease;
}

.auth-modal.is-open {
    opacity: 1;
}

.auth-dialog {
    width: min(420px, 100%);
    border: var(--glass-border, 1px solid rgba(255, 255, 255, 0.8));
    border-radius: var(--radius-lg, 24px);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 28px 70px -28px rgba(45, 52, 54, 0.42);
    padding: 22px;
    position: relative;
    transform: translateY(8px) scale(0.98);
    transition: transform 0.18s ease;
}

.auth-modal.is-open .auth-dialog {
    transform: translateY(0) scale(1);
}

.auth-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(9, 132, 227, 0.14);
    border-radius: 50%;
    background: rgba(223, 230, 233, 0.62);
    color: var(--text-main, #2d3436);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.auth-close:hover,
.auth-close:focus-visible {
    outline: none;
    background: rgba(9, 132, 227, 0.08);
}

.auth-title {
    padding-right: 36px;
    margin: 0 0 6px;
    color: var(--text-main, #2d3436);
    font-size: 1.55rem;
    font-weight: 900;
    letter-spacing: 0;
}

.auth-subtitle {
    margin: 0 0 18px;
    color: var(--text-sub, #636e72);
    font-size: 0.92rem;
    line-height: 1.5;
}

.auth-form {
    display: grid;
    gap: 12px;
}

.auth-field {
    display: grid;
    gap: 6px;
}

.auth-field label {
    color: var(--text-main, #2d3436);
    font-size: 0.82rem;
    font-weight: 800;
}

.auth-field input {
    width: 100%;
    min-height: 44px;
    border: 1px solid rgba(9, 132, 227, 0.2);
    border-radius: 12px;
    padding: 11px 12px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-main, #2d3436);
    font-size: 0.96rem;
}

.auth-field input:focus {
    outline: none;
    border-color: rgba(9, 132, 227, 0.65);
    box-shadow: 0 0 0 4px rgba(9, 132, 227, 0.08);
}

.auth-submit {
    min-height: 46px;
    border-radius: 999px;
    border: 1px solid var(--primary, #0984e3);
    cursor: pointer;
    font-size: 0.98rem;
    font-weight: 900;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.auth-submit:hover,
.auth-submit:focus-visible {
    transform: translateY(-1px);
    filter: brightness(1.04);
    outline: none;
}

.auth-feedback {
    min-height: 20px;
    color: var(--text-sub, #636e72);
    font-size: 0.84rem;
    line-height: 1.45;
}

.auth-feedback.error {
    color: var(--danger, #d63031);
}

.auth-feedback.success {
    color: var(--success, #00b894);
}

.auth-switch-line {
    margin-top: 14px;
    color: var(--text-sub, #636e72);
    font-size: 0.88rem;
    text-align: center;
}

.auth-purchase-line {
    margin-top: 12px;
    color: var(--text-sub, #636e72);
    font-size: 0.88rem;
    text-align: center;
}

.auth-purchase-line a,
.picmore-purchase-link {
    color: var(--primary, #0984e3);
    font-weight: 900;
    text-decoration: none;
}

.auth-purchase-line a:hover,
.auth-purchase-line a:focus-visible,
.picmore-purchase-link:hover,
.picmore-purchase-link:focus-visible {
    text-decoration: underline;
    outline: none;
}

.auth-switch {
    border: 0;
    background: transparent;
    color: var(--primary, #0984e3);
    cursor: pointer;
    font-weight: 900;
}

.auth-switch:focus-visible {
    outline: 2px solid rgba(9, 132, 227, 0.3);
    outline-offset: 3px;
    border-radius: 6px;
}

.auth-modal[hidden],
.auth-actions[hidden],
.auth-account[hidden],
.auth-field[hidden],
.auth-switch-line[hidden] {
    display: none !important;
}

@media (max-width: 768px) {
    .auth-widget {
        justify-content: center;
        margin-bottom: -4px;
    }

    .auth-actions,
    .auth-account {
        width: 100%;
        max-width: 420px;
    }

    .auth-actions {
        justify-content: flex-end;
    }

    .auth-buy-link {
        padding-inline: 10px;
    }

    .auth-profile {
        width: 100%;
        justify-content: flex-start;
    }

    .auth-username {
        max-width: calc(100vw - 130px);
    }

    .auth-popover {
        right: 50%;
        transform: translate(50%, -4px);
    }

    .auth-account:hover .auth-popover,
    .auth-account:focus-within .auth-popover,
    .auth-account.is-open .auth-popover {
        transform: translate(50%, 0);
    }

    .auth-popover::before {
        right: 50%;
        margin-right: -7px;
    }
}
