/**
 * Login / register popup ÃƒÆ’Ã‚Â¢ÃƒÂ¢Ã¢â‚¬Å¡Ã‚Â¬ÃƒÂ¢Ã¢â€šÂ¬Ã¯Â¿Â½ brand teal (#01a89b), overrides legacy .modal
 */
#popup.auth-popup-modal {
    --auth-brand: #01a89b;
    --auth-brand-mid: #019a8e;
    --auth-brand-dark: #018577;
    --auth-brand-light: #2ec4b6;
    --auth-brand-glow: rgba(1, 168, 155, 0.35);
}

#popup.auth-popup-modal .modal-bg {
    background: rgba(8, 10, 14, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#popup.auth-popup-modal .auth-modal-card {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    width: min(420px, calc(100vw - 32px));
    margin: 0 !important;
    overflow: visible;
    border-radius: 16px;
    background: linear-gradient(165deg, #232733 0%, #181b22 48%, #14161c 100%);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.65),
        0 0 0 1px rgba(0, 0, 0, 0.35) inset;
    overflow: hidden;
}

#popup.auth-popup-modal .auth-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 5;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: #c5c8d1;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

#popup.auth-popup-modal .auth-modal-close:hover {
    background: rgba(1, 168, 155, 0.2);
    color: #fff;
}

#popup.auth-popup-modal .auth-modal-header {
    text-align: center;
    padding: 28px 28px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: linear-gradient(180deg, rgba(1, 168, 155, 0.12) 0%, transparent 100%);
}

#popup.auth-popup-modal .auth-modal-logo {
    display: inline-block;
    line-height: 0;
}

#popup.auth-popup-modal .auth-modal-logo img {
    max-height: 44px;
    width: auto;
    max-width: 220px;
    height: auto;
}

#popup.auth-popup-modal .auth-modal-beta {
    display: inline-block;
    margin-top: 10px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--auth-brand-light);
    background: rgba(1, 168, 155, 0.15);
    border: 1px solid rgba(1, 168, 155, 0.35);
}

#popup.auth-popup-modal .auth-modal-form {
    display: none;
    padding: 24px 28px 28px;
    box-sizing: border-box;
    overflow-y: auto;
    max-height: min(560px, calc(100vh - 200px));
}

#popup.auth-popup-modal .auth-modal-form form {
    margin: 0;
}

#popup.auth-popup-modal .auth-modal-fields {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

#popup.auth-popup-modal .auth-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #9aa0ae;
}

#popup.auth-popup-modal .auth-field input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    margin: 0;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.35);
    color: #f0f2f6;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: none;
}

#popup.auth-popup-modal .auth-field input::placeholder {
    color: #6b7280;
}

#popup.auth-popup-modal .auth-field input:focus {
    border-color: rgba(1, 168, 155, 0.55);
    box-shadow: 0 0 0 3px rgba(1, 168, 155, 0.18);
}

#popup.auth-popup-modal .display-message {
    margin-bottom: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.45;
    background: rgba(192, 57, 43, 0.2);
    border: 1px solid rgba(231, 76, 60, 0.35);
    color: #f5b7b1;
}

#popup.auth-popup-modal .auth-modal-alert {
    margin-bottom: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.45;
}

#popup.auth-popup-modal .auth-modal-alert[hidden] {
    display: none !important;
}

#popup.auth-popup-modal .auth-modal-alert--error {
    background: rgba(192, 57, 43, 0.22);
    border: 1px solid rgba(231, 76, 60, 0.4);
    color: #f5b7b1;
}

#popup.auth-popup-modal .auth-modal-alert--success {
    background: rgba(1, 168, 155, 0.18);
    border: 1px solid rgba(1, 168, 155, 0.45);
    color: #b8f5ec;
}

#popup.auth-popup-modal .auth-modal-card--shake form {
    animation: auth-modal-shake-inner 0.45s ease;
}

@keyframes auth-modal-shake-inner {
    0%,
    100% {
        transform: translateX(0);
    }
    20% {
        transform: translateX(-8px);
    }
    40% {
        transform: translateX(8px);
    }
    60% {
        transform: translateX(-5px);
    }
    80% {
        transform: translateX(5px);
    }
}

/* Override legacy .button fixed height so label + icon align */
#popup.auth-popup-modal .auth-modal-submit {
    position: relative;
    width: 100%;
    margin-top: 8px;
    padding: 14px 18px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #fff;
    height: auto !important;
    min-height: 48px;
    line-height: 1.25;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(180deg, var(--auth-brand-light) 0%, var(--auth-brand) 42%, var(--auth-brand-dark) 100%);
    box-shadow:
        0 4px 20px var(--auth-brand-glow),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);
    transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}

#popup.auth-popup-modal .auth-modal-submit:hover {
    filter: brightness(1.05);
    box-shadow:
        0 6px 26px var(--auth-brand-glow),
        inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

#popup.auth-popup-modal .auth-modal-submit:active {
    transform: translateY(1px);
}

#popup.auth-popup-modal .auth-modal-submit .icon-right-open {
    margin: 0;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-size: 16px;
}

#popup.auth-popup-modal .auth-modal-submit-label {
    display: inline-flex;
    align-items: center;
    line-height: 1.2;
}

#popup.auth-popup-modal form.auth-modal-form--loading .auth-modal-submit {
    cursor: wait;
}

#popup.auth-popup-modal form.auth-modal-form--loading .auth-modal-submit .icon-right-open,
#popup.auth-popup-modal form.auth-modal-form--loading .auth-modal-submit .auth-modal-submit-label {
    opacity: 0.35;
}

#popup.auth-popup-modal form.auth-modal-form--loading .auth-modal-submit::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 22px;
    height: 22px;
    margin: -11px 0 0 -11px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: auth-modal-spin 0.65s linear infinite;
}

@keyframes auth-modal-spin {
    to {
        transform: rotate(360deg);
    }
}

#popup.auth-popup-modal .auth-modal-lost {
    margin-top: 18px;
    text-align: center;
}

#popup.auth-popup-modal .auth-modal-lost a {
    font-size: 13px;
    color: #8b93a5;
    text-decoration: none;
    transition: color 0.2s;
}

#popup.auth-popup-modal .auth-modal-lost a:hover {
    color: var(--auth-brand-light);
}

#popup.auth-popup-modal .auth-modal-switch {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    text-align: center;
    font-size: 13px;
    color: #8b93a5;
    line-height: 1.6;
}

#popup.auth-popup-modal .auth-modal-switch a {
    color: var(--auth-brand-light);
    font-weight: 700;
    text-decoration: none;
    margin-left: 4px;
}

#popup.auth-popup-modal .auth-modal-switch a:hover {
    color: #5eead4;
    text-decoration: underline;
}

@media only screen and (max-width: 659px) {
    #popup.auth-popup-modal .auth-modal-card {
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        transform: none;
        width: 100%;
        max-width: none;
        min-height: 100%;
        border-radius: 0;
        border-left: none;
        border-right: none;
        display: flex;
        flex-direction: column;
    }

    #popup.auth-popup-modal .auth-modal-form {
        flex: 1;
        padding-bottom: max(28px, env(safe-area-inset-bottom));
        max-height: none;
    }
}
