.auth-dialog {
    width: min(94vw, 35rem);
    max-height: min(88dvh, 48rem);
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 1.1rem;
    background: #fff;
    color: var(--color-ink);
    box-shadow: 0 2rem 6rem rgb(7 27 22 / .42);
}

.auth-dialog:not([open]) { display: none; }
.auth-dialog::backdrop { background: rgb(7 27 22 / .58); backdrop-filter: blur(4px); }
.auth-dialog__content { max-height: min(88dvh, 48rem); padding: clamp(1.5rem, 5vw, 2.8rem); overflow: auto; overscroll-behavior: contain; }
.auth-dialog__content .auth-card { width: 100%; }
.auth-dialog__content .auth-card h2 { padding-right: 2.5rem; font-size: clamp(1.8rem, 5vw, 2.5rem); }
.auth-dialog__content .auth-form { margin-top: 1.35rem; }
.auth-dialog__content .auth-security { margin-bottom: 0; }
.auth-form .auth-remember { grid-template-columns: 1.3rem minmax(0, 1fr); gap: .65rem; font-weight: 400; }
.auth-remember strong, .auth-remember small { display: block; }
.auth-remember strong { color: var(--color-ink); font-size: .72rem; }
.auth-remember small { margin-top: .08rem; color: var(--color-muted); font-size: .62rem; font-weight: 400; line-height: 1.45; }
.auth-dialog__close { width: 2.5rem; height: 2.5rem; padding: 0; position: absolute; z-index: 2; top: .9rem; right: .9rem; border: 0; border-radius: 50%; display: grid; place-items: center; background: var(--color-soft); color: var(--color-forest); font-size: 1.35rem; cursor: pointer; transition: background .2s, transform .2s; }
.auth-dialog__close:hover, .auth-dialog__close:focus-visible { background: var(--color-sage-soft); transform: rotate(4deg); }
.auth-dialog__loading, .auth-dialog__error { min-height: 14rem; margin: 0; display: grid; place-items: center; color: var(--color-muted); text-align: center; }
.auth-dialog__error { color: #8d372e; }
.auth-dialog.is-loading .auth-dialog__content { opacity: .62; pointer-events: none; }
.auth-dialog .button[disabled] { cursor: wait; opacity: .7; }
.auth-registration-success { text-align: center; }
.auth-registration-success h1,
.auth-registration-success h2 { margin-top: .45rem; }
.auth-success-mark { width: 4rem; height: 4rem; margin: 0 auto 1rem; border-radius: 50%; display: grid; place-items: center; background: var(--color-forest); color: #fff; font-size: 1.7rem; font-weight: 800; box-shadow: 0 .75rem 2rem rgb(14 72 58 / .2); }
.auth-verification-note { margin: 1.35rem 0; padding: 1rem 1.1rem; border: 1px solid #cfddd5; border-radius: .85rem; display: grid; gap: .35rem; background: #f4f8f4; text-align: left; line-height: 1.55; }
.auth-verification-note span { color: var(--color-muted); }
.auth-verification-note b { color: var(--color-forest); overflow-wrap: anywhere; }
.auth-resend-form { margin-top: .85rem; }
.auth-resend-form button { padding: .35rem; border: 0; background: transparent; color: var(--color-forest); font: inherit; font-size: .82rem; text-decoration: underline; text-underline-offset: .2em; cursor: pointer; }
.auth-resend-status { color: var(--color-success); font-size: .84rem; }
.auth-password-field { display: grid; gap: .38rem; }
.registration-email-status { min-height: 1.1rem; color: var(--color-muted); font-size: .68rem; font-weight: 600; line-height: 1.45; }
.registration-email-status:empty { display: none; }
.registration-email-status[data-state="checking"] { color: var(--color-muted); }
.registration-email-status[data-state="available"] { color: var(--color-success); }
.registration-email-status[data-state="unavailable"] { margin-top: .15rem; padding: .62rem .72rem; border: 1px solid #dbaaa3; border-radius: .58rem; display: flex; align-items: center; gap: .52rem; background: #fff2f0; color: #7f2f28; font-size: .73rem; font-weight: 750; box-shadow: 0 .2rem .7rem rgb(127 47 40 / .08); }
.registration-email-status[data-state="unavailable"]::before { width: 1.2rem; height: 1.2rem; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; background: #9a3f34; color: white; content: '!'; font-size: .72rem; font-weight: 900; line-height: 1; }
.password-requirements { margin-top: .05rem; color: var(--color-muted); font-weight: 400; }
.password-requirements > span:first-child { display: block; margin-bottom: .35rem; font-size: .63rem; }
.password-requirements ul { margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .32rem .7rem; list-style: none; }
.password-requirements li { min-width: 0; display: flex; align-items: center; gap: .38rem; color: #747b76; font-size: .64rem; line-height: 1.35; transition: color .16s ease; }
.password-requirements li::before { width: 1.05rem; height: 1.05rem; border: 1px solid #b9c2bc; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; color: #8a948e; background: #f7f8f5; content: '·'; font-size: .8rem; font-weight: 800; line-height: 1; transition: border-color .16s ease, background-color .16s ease, color .16s ease; }
.password-requirements li.is-met { color: var(--color-success); }
.password-requirements li.is-met::before { border-color: var(--color-success); background: var(--color-success); color: white; content: '✓'; font-size: .64rem; }
.logout-dialog { width: min(92vw, 31rem); }
.logout-dialog .auth-dialog__content { padding: 2.15rem; }
.logout-dialog .eyebrow { color: var(--color-terra); }
.logout-dialog h2 { margin: .5rem 2.5rem .65rem 0; font-size: clamp(1.55rem, 4vw, 2rem); line-height: 1.15; }
.logout-dialog p { margin: 0; color: var(--color-muted); line-height: 1.65; }
.logout-dialog__actions { margin-top: 1.6rem; display: flex; justify-content: flex-end; gap: .65rem; }

@media (max-width: 600px) {
    .auth-dialog { width: 100vw; max-width: none; max-height: 94dvh; margin: auto 0 0; border-radius: 1rem 1rem 0 0; }
    .auth-dialog__content { max-height: 94dvh; padding: 1.65rem 1.15rem max(1.75rem, env(safe-area-inset-bottom)); }
    .auth-dialog__close { top: .7rem; right: .7rem; }
    .auth-dialog__content .auth-form__row { grid-template-columns: 1fr; }
    .password-requirements ul { grid-template-columns: 1fr; }
    .logout-dialog .auth-dialog__content { padding: 1.65rem 1.15rem max(1.5rem, env(safe-area-inset-bottom)); }
    .logout-dialog__actions { flex-direction: column-reverse; }
    .logout-dialog__actions .button { width: 100%; }
}

@media (prefers-reduced-motion: no-preference) {
    .auth-dialog[open] { animation: auth-dialog-enter .22s ease-out; }
    @keyframes auth-dialog-enter { from { opacity: 0; transform: translateY(.75rem) scale(.985); } }
}
