/* Modern auth / OTP modal — stepwise */

.auth-modal {
    position: fixed;
    inset: 0;
    z-index: 230;
    display: grid;
    place-items: center;
    padding: 20px;
}

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

.auth-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.48);
    animation: auth-fade-in 200ms ease both;
}

.auth-modal__card {
    position: relative;
    z-index: 1;
    width: min(100%, 420px);
    padding: 28px 24px 22px;
    border-radius: 24px;
    background: var(--chat-bg-elevated, #fff);
    border: 1px solid var(--chat-border-strong, rgba(0, 0, 0, 0.08));
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.22);
    animation: auth-card-in 260ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
    overflow: hidden;
}

@keyframes auth-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes auth-card-in {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes auth-step-in {
    from { opacity: 0; transform: translateX(18px); }
    to { opacity: 1; transform: translateX(0); }
}

.auth-modal__close {
    position: absolute;
    top: 14px;
    inset-inline-end: 14px;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--chat-text-muted, #8b8b8b);
}

.auth-modal__close:hover {
    background: var(--chat-bg-hover, rgba(0, 0, 0, 0.05));
    color: var(--chat-text, #111);
}

.auth-modal__brand {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.04em;
    text-transform: lowercase;
    color: var(--chat-brand, #0f172a);
    margin-bottom: 12px;
}

.auth-progress {
    display: inline-flex;
    gap: 6px;
    margin-bottom: 18px;
}

.auth-progress__dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.14);
    transition: width 180ms ease, background 180ms ease;
}

.auth-progress__dot.is-active {
    width: 22px;
    background: #0f172a;
}

.auth-progress__dot.is-done {
    background: #94a3b8;
}

html[data-theme="dark"] .auth-progress__dot {
    background: rgba(255, 255, 255, 0.16);
}

html[data-theme="dark"] .auth-progress__dot.is-active {
    background: #f8fafc;
}

.auth-steps {
    position: relative;
}

.auth-step {
    display: none;
    grid-template-columns: 1fr;
    gap: 14px;
}

.auth-step.is-active {
    display: grid;
    animation: auth-step-in 240ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.auth-step[hidden] {
    display: none !important;
}

.auth-modal__title {
    margin: 0;
    font-size: 24px;
    font-weight: 650;
    letter-spacing: -0.03em;
    color: var(--chat-text, #111);
}

.auth-modal__subtitle {
    margin: 0;
    font-size: 14px;
    line-height: 1.45;
    color: var(--chat-text-secondary, #667085);
}

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

.auth-field__label {
    font-size: 13px;
    font-weight: 600;
    color: var(--chat-text-secondary, #667085);
}

.auth-field__input {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid var(--chat-border-strong, rgba(0, 0, 0, 0.12));
    background: var(--chat-bg-main, #fff);
    color: var(--chat-text, #111);
    font-size: 16px;
    outline: none;
    box-sizing: border-box;
}

.auth-field__input:focus {
    border-color: #0f172a;
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.12);
}

.auth-modal__primary {
    min-height: 48px;
    border-radius: 14px;
    background: #0f172a;
    color: #fff;
    font-size: 15px;
    font-weight: 650;
    transition: transform 140ms ease, opacity 140ms ease;
}

.auth-modal__primary:hover { opacity: 0.92; }
.auth-modal__primary:active { transform: scale(0.985); }

.auth-modal__primary:disabled,
.auth-resend__btn:disabled {
    opacity: 0.45;
    pointer-events: none;
}

html[data-theme="dark"] .auth-modal__primary {
    background: #f8fafc;
    color: #0f172a;
}

.auth-modal__error {
    margin: 0;
    font-size: 13px;
    color: var(--chat-danger, #dc2626);
}

.auth-email-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--chat-bg-hover, #f4f4f5);
}

.auth-email-row__value {
    font-size: 14px;
    font-weight: 600;
    color: var(--chat-text, #111);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-email-row__edit {
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 650;
    color: #2563eb;
}

.auth-otp {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.auth-otp__digit {
    width: 100%;
    aspect-ratio: 1;
    max-height: 64px;
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    border-radius: 14px;
    border: 1px solid var(--chat-border-strong, rgba(0, 0, 0, 0.12));
    background: var(--chat-bg-main, #fff);
    color: var(--chat-text, #111);
    outline: none;
}

.auth-otp__digit:focus {
    border-color: #0f172a;
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.12);
}

.auth-resend {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 40px;
}

.auth-resend__btn {
    font-size: 13.5px;
    font-weight: 650;
    color: var(--chat-text, #111);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.auth-timer {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--chat-text-secondary, #667085);
    font-size: 13px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.auth-timer__ring {
    width: 28px;
    height: 28px;
    transform: rotate(-90deg);
}

.auth-timer__track,
.auth-timer__progress {
    fill: none;
    stroke-width: 3;
}

.auth-timer__track { stroke: rgba(15, 23, 42, 0.1); }

.auth-timer__progress {
    stroke: #0f172a;
    stroke-linecap: round;
    stroke-dasharray: 97.4;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 200ms linear;
}

html[data-theme="dark"] .auth-timer__track { stroke: rgba(255, 255, 255, 0.12); }
html[data-theme="dark"] .auth-timer__progress { stroke: #f8fafc; }

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

@media (max-width: 480px) {
    .auth-modal__card {
        width: 100%;
        border-radius: 20px;
        padding: 24px 18px 18px;
    }

    .auth-otp { gap: 8px; }
}
