/**
 * Tree of Skills — Login, Signup & Forgot Password UI
 * Scoped to .auth-modal and .auth-popup — does not affect rest of site.
 */

:root {
    --auth-primary: #0071dc;
    --auth-primary-dark: #005bb5;
    --auth-accent: #ffc221;
    --auth-navy: #031f42;
    --auth-purple: #3f3a64;
    --auth-surface: #ffffff;
    --auth-bg-soft: #f4f8fc;
    --auth-border: #dce6f0;
    --auth-text-muted: #5a6b7d;
    --auth-success: #0d9488;
    --auth-radius: 14px;
    --auth-radius-lg: 22px;
    --auth-shadow: 0 24px 64px rgba(3, 31, 66, 0.18), 0 8px 24px rgba(0, 113, 220, 0.08);
    --auth-font: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Overlay ── */
.popup-overlay {
    background: rgba(3, 31, 66, 0.55) !important;
    backdrop-filter: blur(12px) saturate(1.2);
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    z-index: 1200 !important;
    align-items: center !important;
    justify-content: center !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

body.auth-overlay-open {
    overflow: hidden;
    touch-action: none;
}

/* ── Modal shell ── */
.popup.auth-modal {
    font-family: var(--auth-font);
    display: none;
    flex-direction: column;
    width: min(100%, 460px);
    max-width: 460px;
    max-height: min(90dvh, 720px);
    padding: 0 !important;
    margin: 0 !important;
    border-radius: var(--auth-radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.85);
    box-shadow: var(--auth-shadow);
    overflow: hidden;
    background: var(--auth-surface);
    animation: authModalIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    flex-shrink: 0;
}

.popup.auth-modal[style*="display: block"],
.popup.auth-modal[style*="display: flex"] {
    display: flex !important;
}

.popup.auth-modal.auth-modal--wide {
    max-width: 520px;
    width: min(100%, 520px);
}

.popup.auth-modal .signup-step {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 0;
    flex: 1;
    align-items: stretch;
}

@keyframes authModalIn {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── Hero header ── */
.auth-modal__hero {
    position: relative;
    padding: 28px 28px 22px;
    text-align: center;
    background: linear-gradient(135deg, #e8f4fd 0%, #fff9e6 55%, #f4f8fc 100%);
    border-bottom: 1px solid var(--auth-border);
}

.auth-modal__hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 85% 15%, rgba(255, 194, 33, 0.25), transparent 45%),
                radial-gradient(circle at 10% 90%, rgba(0, 113, 220, 0.12), transparent 40%);
    pointer-events: none;
}

.auth-modal__logo {
    width: 52px;
    height: 52px;
    margin: 0 auto 12px;
    border-radius: 14px;
    background: var(--auth-surface);
    box-shadow: 0 4px 16px rgba(0, 113, 220, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.auth-modal__logo img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.auth-modal__icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--auth-primary), var(--auth-purple));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 8px 20px rgba(0, 113, 220, 0.35);
    position: relative;
    z-index: 1;
}

.auth-modal__hero h2 {
    position: relative;
    z-index: 1;
    margin: 0 0 6px !important;
    padding-bottom: 0 !important;
    font-size: 1.45rem !important;
    font-weight: 800 !important;
    letter-spacing: -0.02em;
    color: var(--auth-navy) !important;
}

.auth-modal__hero h2::after {
    display: none !important;
}

.auth-modal__subtitle {
    position: relative;
    z-index: 1;
    margin: 0;
    font-size: 0.9rem;
    color: var(--auth-text-muted);
    line-height: 1.5;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.auth-modal__body {
    padding: 22px 26px 8px;
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--auth-border) transparent;
}

.auth-modal__body::-webkit-scrollbar {
    width: 6px;
}

.auth-modal__body::-webkit-scrollbar-thumb {
    background: var(--auth-border);
    border-radius: 99px;
}

.auth-modal__footer {
    padding: 14px 26px 22px;
    text-align: center;
    border-top: 1px solid var(--auth-border);
    background: var(--auth-bg-soft);
    font-size: 0.88rem;
    color: var(--auth-text-muted);
}

.auth-link-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-weight: 700;
    color: var(--auth-primary);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s;
}

.auth-link-btn:hover {
    color: var(--auth-primary-dark);
}

.auth-modal__close {
    top: 14px !important;
    right: 14px !important;
    width: 36px !important;
    height: 36px !important;
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid var(--auth-border) !important;
    color: var(--auth-navy) !important;
    font-size: 1.35rem !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    z-index: 10;
}

.auth-modal__close:hover {
    background: #fff !important;
    color: var(--auth-primary) !important;
    transform: scale(1.05) rotate(90deg);
}

/* ── Signup type cards ── */
.auth-modal .signup-options {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: stretch;
    gap: 14px;
    width: 100%;
    margin-top: 8px;
    padding-bottom: 8px;
}

.auth-modal .signup-option-btn {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    width: auto;
    height: auto;
    min-height: 148px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 2px solid var(--auth-border);
    border-radius: var(--auth-radius);
    background: var(--auth-surface);
    padding: 22px 12px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.auth-modal .signup-option-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(145deg, rgba(0, 113, 220, 0.06), rgba(255, 194, 33, 0.08));
    opacity: 0;
    transition: opacity 0.3s;
}

.auth-modal .signup-option-btn:hover {
    border-color: var(--auth-primary);
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(0, 113, 220, 0.15);
    background: var(--auth-surface);
}

.auth-modal .signup-option-btn:hover::before {
    opacity: 1;
}

.auth-modal .signup-option-btn i {
    font-size: 2.25rem;
    color: var(--auth-primary);
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
    transition: transform 0.3s;
}

.auth-modal .signup-option-btn:hover i {
    transform: scale(1.08);
}

.auth-modal .signup-option-btn span {
    font-size: 1rem;
    font-weight: 700;
    color: var(--auth-navy);
    position: relative;
    z-index: 1;
}

.auth-modal .signup-option-btn small {
    display: block;
    margin-top: 6px;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--auth-text-muted);
    position: relative;
    z-index: 1;
}

/* ── Form fields ── */
.auth-modal .form-group {
    margin-bottom: 14px;
}

.auth-modal .form-group label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--auth-navy);
    margin-bottom: 7px;
}

.auth-input-wrap {
    position: relative;
}

.auth-input-wrap > i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--auth-text-muted);
    font-size: 0.95rem;
    pointer-events: none;
    transition: color 0.2s;
}

.auth-input-wrap input,
.auth-input-wrap select,
.auth-input-wrap textarea {
    padding-left: 42px !important;
}

.auth-input-wrap:focus-within > i {
    color: var(--auth-primary);
}

.auth-modal .form-group input,
.auth-modal .form-group select,
.auth-modal .form-group textarea {
    border: 1.5px solid var(--auth-border);
    border-radius: 12px;
    background: var(--auth-bg-soft);
    height: 48px;
    font-size: 0.95rem;
    font-family: var(--auth-font);
    box-shadow: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.auth-modal .form-group textarea {
    height: 88px;
    padding-top: 12px;
}

.auth-modal .form-group input:hover,
.auth-modal .form-group select:hover,
.auth-modal .form-group textarea:hover {
    border-color: #b8cfe6;
    background: #fff;
}

.auth-modal .form-group input:focus,
.auth-modal .form-group select:focus,
.auth-modal .form-group textarea:focus {
    border-color: var(--auth-primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(0, 113, 220, 0.12);
    transform: none;
}

/* ── Gender pills ── */
.auth-modal .gender-options label {
    border: 1.5px solid var(--auth-border);
    border-radius: 12px;
    background: var(--auth-bg-soft);
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    height: 46px;
    text-transform: none;
    letter-spacing: 0;
}

.auth-modal .gender-options label:has(input:checked) {
    border-color: var(--auth-primary);
    background: rgba(0, 113, 220, 0.08);
    color: var(--auth-primary);
}

/* ── Info callout ── */
.auth-callout {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
    margin: 16px 0;
    border-radius: 12px;
    background: linear-gradient(135deg, #eef6ff, #fffbf0);
    border: 1px solid rgba(0, 113, 220, 0.15);
    font-size: 0.85rem;
    color: var(--auth-text-muted);
    line-height: 1.55;
}

.auth-callout i {
    color: var(--auth-primary);
    font-size: 1.1rem;
    margin-top: 2px;
    flex-shrink: 0;
}

.auth-callout strong {
    color: var(--auth-navy);
}

/* ── Login method segmented control ── */
.auth-modal .login-method-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    margin: 16px 0 18px;
    padding: 4px;
    background: var(--auth-bg-soft);
    border: 1px solid var(--auth-border);
    border-radius: 14px;
}

.auth-modal .toggle-label {
    justify-content: center;
    padding: 10px 12px;
    border: none !important;
    border-radius: 10px !important;
    box-shadow: none !important;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--auth-text-muted);
    transition: all 0.25s;
}

.auth-modal .toggle-label input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
}

.auth-modal .toggle-label:has(input:checked) {
    background: var(--auth-surface);
    color: var(--auth-primary);
    box-shadow: 0 2px 10px rgba(0, 113, 220, 0.12) !important;
}

.auth-modal .toggle-label:hover:not(:has(input:checked)) {
    background: rgba(255, 255, 255, 0.6);
    transform: none;
}

/* ── Password field ── */
.auth-modal .password-input-wrapper input {
    padding-right: 48px !important;
}

.auth-modal .toggle-password {
    right: 10px;
    width: 36px;
    height: 36px;
    border-radius: 10px;
}

.auth-modal .forgot-password-link {
    margin-top: 8px;
    font-size: 0.82rem;
    font-weight: 600;
}

/* ── OTP step ── */
.auth-otp-block {
    text-align: center;
    padding: 4px 0;
    width: 100%;
}

/* Neutralize legacy styles.css OTP box (#loginOTPStep blue border box) */
.auth-modal #loginOTPStep,
.auth-modal #centerOTPStep,
.auth-modal #schoolOTPStep,
.auth-modal #forgotStep2 {
    margin-top: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    text-align: center !important;
}

.auth-modal #loginOTP,
.auth-modal #centerOTP,
.auth-modal #schoolOTP,
.auth-modal #forgotOTP {
    width: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
    letter-spacing: normal !important;
    transform: none !important;
}

.auth-otp-panel {
    width: 100%;
    max-width: 340px;
    margin: 0 auto;
    padding: 4px 16px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
}

.auth-otp-label {
    margin: 0 0 18px;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.55;
    color: var(--auth-navy);
    text-align: center;
}

.auth-otp-label strong {
    color: var(--auth-primary);
    font-weight: 700;
}

/* 6 equal digit boxes — centered grid */
.auth-otp-cells {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: clamp(6px, 2vw, 10px);
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    justify-content: center;
}

.auth-otp-cell {
    width: 100%;
    min-width: 0;
    height: clamp(44px, 11vw, 52px);
    padding: 0;
    margin: 0;
    text-align: center;
    font-family: var(--auth-font);
    font-size: clamp(1.15rem, 4vw, 1.4rem);
    font-weight: 700;
    line-height: 1;
    color: var(--auth-navy);
    background: var(--auth-bg-soft);
    border: 2px solid var(--auth-border);
    border-radius: 12px;
    box-sizing: border-box;
    caret-color: var(--auth-primary);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s, transform 0.15s;
    appearance: none;
    -webkit-appearance: none;
}

.auth-otp-cell:hover {
    border-color: #b8cfe6;
    background: #fff;
}

.auth-otp-cell:focus {
    outline: none;
    border-color: var(--auth-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0, 113, 220, 0.14);
    transform: scale(1.04);
}

.auth-otp-cell.is-filled {
    border-color: var(--auth-primary);
    background: #fff;
}

.auth-otp-cell.is-complete {
    border-color: #0d9488;
}

.auth-otp-master {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.auth-modal .otp-timer {
    margin-top: 14px;
    font-size: 0.82rem;
    color: var(--auth-text-muted);
    font-weight: 500;
    text-align: center;
    width: 100%;
}

.auth-otp-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
    width: 100%;
    max-width: 340px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 16px;
    box-sizing: border-box;
}

.auth-otp-actions .submit-btn {
    margin-top: 0;
}

.auth-otp-cancel {
    width: 100%;
    margin-top: 2px;
    padding: 11px 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--auth-text-muted);
    font-family: var(--auth-font);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}

.auth-otp-cancel:hover {
    color: var(--auth-primary);
    background: rgba(0, 113, 220, 0.06);
}

.auth-modal__footer--otp {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding-top: 16px;
    padding-bottom: 20px;
}

.auth-otp-cancel--footer {
    width: auto;
    padding: 8px 16px;
    font-size: 0.9rem;
    color: var(--auth-primary);
}

.auth-footer-muted {
    font-size: 0.78rem;
    color: var(--auth-text-muted);
    text-align: center;
    line-height: 1.4;
}

/* ── Buttons ── */
.auth-modal .submit-btn {
    margin-top: 16px;
    padding: 14px 24px;
    border-radius: 12px;
    font-family: var(--auth-font);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: linear-gradient(135deg, var(--auth-primary) 0%, #005bb5 100%);
    box-shadow: 0 6px 20px rgba(0, 113, 220, 0.35);
    border: none;
    color: #fff;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    line-height: 1.2;
    text-align: center;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
}

/* Full-width primary actions (not paired Back + Submit rows) */
.auth-modal #loginMobileStep > .submit-btn,
.auth-modal #forgotStep3 > .submit-btn,
.auth-modal .auth-otp-actions .submit-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-modal .submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(0, 113, 220, 0.4);
    background: linear-gradient(135deg, var(--auth-primary-dark) 0%, #004a94 100%);
}

.auth-modal .resend-btn {
    width: 100%;
    margin-top: 0;
    padding: 12px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.88rem;
    border: 1.5px dashed var(--auth-border);
    background: transparent;
    color: var(--auth-text-muted);
    cursor: pointer;
    box-sizing: border-box;
}

.auth-modal .resend-btn:hover:not(:disabled) {
    border-color: var(--auth-primary);
    color: var(--auth-primary);
    background: rgba(0, 113, 220, 0.04);
}

/* Back + Submit row — 50/50 grid (overrides styles.css flex/width conflicts) */
.relevel-page .popup.auth-modal .form-buttons,
.auth-modal .form-buttons {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    grid-auto-rows: auto;
    align-items: stretch !important;
    justify-items: stretch !important;
    width: 100% !important;
    margin-top: 20px !important;
    gap: 12px !important;
    flex-direction: unset !important;
}

.relevel-page .popup.auth-modal .form-buttons .back-btn,
.relevel-page .popup.auth-modal .form-buttons .submit-btn,
.auth-modal .form-buttons .back-btn,
.auth-modal .form-buttons .submit-btn {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    flex: none !important;
    margin-top: 0 !important;
    min-height: 48px !important;
    height: auto !important;
    padding: 13px 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.88rem !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    border-radius: 12px !important;
    cursor: pointer !important;
    box-sizing: border-box !important;
    appearance: none !important;
    -webkit-appearance: none !important;
}

.relevel-page .popup.auth-modal .form-buttons .back-btn,
.auth-modal .form-buttons .back-btn {
    font-weight: 600 !important;
    border: 1.5px solid var(--auth-border) !important;
    background: var(--auth-surface) !important;
    color: var(--auth-navy) !important;
    box-shadow: none !important;
    transition: border-color 0.2s, color 0.2s, background 0.2s, transform 0.2s !important;
}

.relevel-page .popup.auth-modal .form-buttons .back-btn:hover,
.auth-modal .form-buttons .back-btn:hover {
    border-color: var(--auth-primary) !important;
    color: var(--auth-primary) !important;
    background: rgba(0, 113, 220, 0.06) !important;
    transform: translateY(-1px) !important;
}

.relevel-page .popup.auth-modal .form-buttons .submit-btn:not(.resend-btn),
.auth-modal .form-buttons .submit-btn {
    background: linear-gradient(135deg, var(--auth-primary) 0%, #005bb5 100%) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 4px 16px rgba(0, 113, 220, 0.3) !important;
}

.relevel-page .popup.auth-modal .form-buttons .submit-btn:not(.resend-btn):hover,
.auth-modal .form-buttons .submit-btn:hover {
    background: linear-gradient(135deg, var(--auth-primary-dark) 0%, #004a94 100%) !important;
    box-shadow: 0 8px 22px rgba(0, 113, 220, 0.38) !important;
    transform: translateY(-1px) !important;
}

/* Standalone back btn (outside form-buttons) */
.auth-modal .back-btn {
    border-radius: 12px;
    font-family: var(--auth-font);
    font-weight: 600;
    border: 1.5px solid var(--auth-border);
    background: var(--auth-surface);
    box-shadow: none;
    cursor: pointer;
    box-sizing: border-box;
}

.auth-modal .back-btn:hover {
    border-color: var(--auth-primary);
    color: var(--auth-primary);
    background: rgba(0, 113, 220, 0.04);
}

/* ── Terms ── */
.auth-modal .terms-group {
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--auth-bg-soft);
    border: 1px solid var(--auth-border);
}

.auth-modal .terms-group label {
    text-transform: none;
    font-size: 0.85rem !important;
    font-weight: 500 !important;
    letter-spacing: 0;
}

/* ── Forgot password stepper ── */
.auth-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 20px;
    padding: 0 8px;
}

.auth-stepper__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
    max-width: 90px;
    position: relative;
}

.auth-stepper__dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--auth-bg-soft);
    border: 2px solid var(--auth-border);
    color: var(--auth-text-muted);
    transition: all 0.3s;
}

.auth-stepper__item.is-active .auth-stepper__dot {
    background: var(--auth-primary);
    border-color: var(--auth-primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 113, 220, 0.35);
}

.auth-stepper__item.is-done .auth-stepper__dot {
    background: var(--auth-success);
    border-color: var(--auth-success);
    color: #fff;
}

.auth-stepper__label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--auth-text-muted);
    text-align: center;
}

.auth-stepper__item.is-active .auth-stepper__label {
    color: var(--auth-primary);
}

.auth-stepper__line {
    flex: 1;
    height: 2px;
    background: var(--auth-border);
    margin: 0 -4px;
    margin-bottom: 22px;
    max-width: 40px;
}

/* ── Auth gate popup (logo click) ── */
.auth-popup {
    background: rgba(3, 31, 66, 0.55) !important;
    backdrop-filter: blur(12px);
}

.auth-popup-content {
    padding: 0 !important;
    border-radius: var(--auth-radius-lg) !important;
    overflow: hidden;
    max-width: 400px !important;
    border: 1px solid rgba(255, 255, 255, 0.85);
    box-shadow: var(--auth-shadow) !important;
}

.auth-popup-content .auth-modal__hero {
    padding-bottom: 26px;
}

.auth-popup-content h2 {
    position: relative;
    z-index: 1;
    font-size: 1.5rem !important;
    font-weight: 800 !important;
    color: var(--auth-navy) !important;
    margin-bottom: 8px !important;
}

.auth-popup-content > p {
    position: relative;
    z-index: 1;
    font-size: 0.92rem !important;
    color: var(--auth-text-muted) !important;
    margin-bottom: 0 !important;
    padding: 0 28px 20px;
}

.auth-popup-content .auth-buttons {
    padding: 0 24px 28px;
    flex-direction: column;
    gap: 10px;
}

.auth-popup-content .auth-btn {
    width: 100%;
    padding: 14px 20px;
    border-radius: 12px;
    font-family: var(--auth-font);
    font-weight: 700;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.auth-popup-content .login-btn {
    background: linear-gradient(135deg, var(--auth-primary), var(--auth-primary-dark));
    color: #fff;
    box-shadow: 0 6px 20px rgba(0, 113, 220, 0.35);
}

.auth-popup-content .login-btn:hover {
    transform: translateY(-2px);
}

.auth-popup-content .signup-btn {
    background: var(--auth-surface);
    color: var(--auth-navy);
    border: 1.5px solid var(--auth-border);
}

.auth-popup-content .signup-btn:hover {
    border-color: var(--auth-primary);
    color: var(--auth-primary);
}

.auth-popup-content .close-popup {
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--auth-border);
    color: var(--auth-navy);
    font-size: 1.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.auth-popup-content .close-popup:hover {
    color: var(--auth-primary);
    transform: rotate(90deg);
}

/* ── Responsive ── */
.auth-modal .password-input-wrapper.auth-input-wrap input {
    padding-left: 42px !important;
    padding-right: 48px !important;
}

.auth-modal .login-method-toggle .toggle-label span i {
    margin-right: 6px;
    font-size: 0.85rem;
    opacity: 0.85;
}

/* Signup option small text layout */
.auth-modal .signup-option-btn span {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.auth-modal .signup-option-btn span small {
    font-weight: 500;
    line-height: 1.3;
}

/* Override legacy styles.css .popup rules inside auth modals */
.popup.auth-modal h2::after {
    display: none !important;
}

.popup.auth-modal h2 {
    margin-bottom: 6px !important;
    padding-bottom: 0 !important;
}

@media (max-width: 768px) {
    .popup-overlay {
        padding: 12px !important;
    }

    .popup.auth-modal,
    .popup.auth-modal.auth-modal--wide {
        width: 100% !important;
        max-width: min(100%, 440px) !important;
        max-height: min(88dvh, 680px) !important;
        border-radius: 20px !important;
    }

    .auth-modal__hero {
        padding: 24px 20px 18px;
    }

    .auth-modal__hero h2 {
        font-size: 1.3rem !important;
    }

    .auth-modal__subtitle {
        font-size: 0.85rem;
        max-width: 280px;
    }

    .auth-modal__body {
        padding: 18px 18px 8px;
    }

    .auth-modal__footer {
        padding: 12px 18px max(18px, env(safe-area-inset-bottom));
    }

    .auth-modal .form-group input,
    .auth-modal .form-group select,
    .auth-modal .form-group textarea {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .popup.auth-modal,
    .popup.auth-modal.auth-modal--wide {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 92dvh !important;
        border-radius: 18px !important;
    }

    .auth-modal__hero {
        padding: 20px 18px 16px;
    }

    .auth-modal__logo {
        width: 48px;
        height: 48px;
        margin-bottom: 10px;
    }

    .auth-modal__logo img {
        width: 36px;
        height: 36px;
    }

    .auth-modal__body {
        padding: 16px 16px 6px;
    }

    .auth-modal__footer {
        padding: 12px 16px max(16px, env(safe-area-inset-bottom));
    }

    .auth-modal__close {
        top: 10px !important;
        right: 10px !important;
        width: 34px !important;
        height: 34px !important;
        font-size: 1.25rem !important;
    }

    .auth-modal .signup-options {
        flex-direction: row !important;
        align-items: stretch !important;
        gap: 10px;
    }

    .auth-modal .signup-option-btn {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        max-width: none !important;
        min-height: 128px;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        padding: 16px 10px;
        gap: 0;
    }

    .auth-modal .signup-option-btn i {
        margin-bottom: 10px;
        font-size: 1.65rem;
    }

    .auth-modal .signup-option-btn span {
        align-items: center !important;
    }

    .auth-modal .signup-option-btn small {
        font-size: 0.68rem;
    }

    .auth-otp-panel,
    .auth-otp-actions {
        max-width: 100%;
        padding-left: 8px;
        padding-right: 8px;
    }

    .auth-otp-cells {
        gap: 6px;
    }

    .auth-otp-cell {
        height: 44px;
        font-size: 1.1rem;
        border-radius: 10px;
    }

    .auth-modal .form-buttons {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }

    .auth-modal .form-buttons .back-btn,
    .auth-modal .form-buttons .submit-btn {
        min-height: 46px !important;
        font-size: 0.82rem !important;
        padding: 12px 8px !important;
    }
}
