body.auth-page {
    position: relative;
    display: grid;
    min-height: 100vh;
    min-height: 100dvh;
    padding: clamp(1rem, 3vw, 2.5rem);
    overflow-x: hidden;
    background: var(--bg-body);
}

body.auth-page::before {
    content: none;
}

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

.auth-skip-link {
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 20;
    padding: 0.65rem 0.85rem;
    border-radius: 0.55rem;
    background: var(--bg-card);
    color: var(--text-primary);
    transform: translateY(-180%);
}

.auth-skip-link:focus { transform: translateY(0); }

.auth-shell {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(22rem, 29rem);
    width: min(100%, 70rem);
    min-height: min(43rem, calc(100dvh - clamp(2rem, 6vw, 5rem)));
    margin: auto;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-dialog);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

.auth-story {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
    padding: clamp(2rem, 5vw, 4.5rem);
    overflow: hidden;
    background: var(--bg-body);
}

.auth-story::after {
    content: none;
}

.auth-brand {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 0.7rem;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 750;
    letter-spacing: -0.02em;
}

.auth-brand img {
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 0.72rem;
    box-shadow: none;
}

.auth-story-copy {
    position: relative;
    z-index: 1;
    max-width: 35rem;
    margin: clamp(3rem, 10vh, 7rem) 0 2rem;
}

.auth-story .auth-eyebrow { text-align: left; }

.auth-story h1 {
    max-width: 13ch;
    margin: 0 0 1.2rem;
    font-size: clamp(2rem, 3.4vw, 3rem);
    line-height: 1.15;
    letter-spacing: -0.03em;

    font-weight: 500;
}

.auth-story-copy > p:last-child {
    max-width: 35rem;
    margin: 0;
    color: var(--text-secondary);
    font-size: clamp(0.96rem, 1.5vw, 1.08rem);
}

.auth-benefits {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.auth-benefits li {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--text-secondary);
    font-size: 0.86rem;
}

.auth-benefits li > span:first-child {
    display: grid;
    place-items: center;
    width: 1.35rem;
    height: 1.35rem;
    flex: 0 0 1.35rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--success) 13%, transparent);
    color: var(--success);
    font-size: 0.68rem;
    font-weight: 800;
}

.auth-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    padding: clamp(1.5rem, 4vw, 3rem);
    background: var(--bg-card);
}

.auth-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.65rem;
    min-height: 2.4rem;
    margin: 0 0 clamp(1.4rem, 4vh, 2.6rem);
}

.auth-language {
    display: inline-flex;
    padding: 0.2rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--bg-body);
}

.auth-language button,
.auth-theme-button {
    border: 0;
    color: var(--text-muted);
    cursor: pointer;
    font: inherit;
}

.auth-language button {
    min-width: 2.25rem;
    min-height: 1.8rem;
    border-radius: 999px;
    background: transparent;
    font-size: 0.68rem;
    font-weight: 750;
}

.auth-language button[aria-pressed="true"] {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.auth-theme-button {
    display: grid;
    place-items: center;
    width: 2.4rem;
    height: 2.4rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--bg-body);
}

.auth-theme-button svg {
    width: 1rem;
    height: 1rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

:root.dark-mode .auth-theme-moon,
:root:not(.dark-mode) .auth-theme-sun { display: none; }

.auth-card-header { margin-bottom: 1.5rem; }
.auth-card-header .auth-eyebrow { text-align: left; }

.auth-card-header h2 {
    margin: 0 0 0.45rem;
    font-size: clamp(1.65rem, 3vw, 2rem);
}

.auth-card-header > p:last-child {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.auth-form { display: grid; gap: 1rem; }

.auth-field { display: grid; gap: 0.42rem; }

.auth-field label,
.auth-label-row {
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 650;
}

.auth-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.auth-label-row a { font-size: 0.75rem; font-weight: 600; }

.auth-field input {
    width: 100%;
    min-height: 3rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 0.72rem;
    outline: none;
    background: var(--bg-body);
    color: var(--text-primary);
    font: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.auth-field input:hover { border-color: var(--border-hover); }

.auth-field input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 18%, transparent);
}

.auth-field small {
    color: var(--text-muted);
    font-size: 0.72rem;
    line-height: 1.4;
}

.auth-password-control { position: relative; }
.auth-password-control input { padding-right: 4.6rem; }

.auth-password-toggle {
    position: absolute;
    top: 50%;
    right: 0.55rem;
    min-width: 3.45rem;
    min-height: 2rem;
    padding: 0 0.45rem;
    border: 0;
    border-radius: 0.45rem;
    background: transparent;
    color: var(--primary-color);
    cursor: pointer;
    font: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    transform: translateY(-50%);
}

.auth-caps-lock { color: var(--warning) !important; }

.auth-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.78rem;
    line-height: 1.45;
}

.auth-checkbox input {
    width: 1rem;
    height: 1rem;
    margin: 0.08rem 0 0;
    accent-color: var(--primary-color);
}

.auth-primary-button,
.auth-google-button {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    width: 100%;
    min-height: 3rem;
    padding: 0.7rem 1rem;
    border-radius: 0.72rem;
    cursor: pointer;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 700;
    transition: transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.auth-primary-button {
    border: 1px solid transparent;
    background: var(--primary-color);
    color: var(--color-on-brand);
    box-shadow: 0 10px 28px color-mix(in srgb, var(--primary-color) 19%, transparent);
}



.auth-primary-button:hover:not(:disabled),
.auth-google-button:hover { transform: translateY(-1px); }

.auth-primary-button:disabled {
    cursor: wait;
    opacity: 0.72;
}

.auth-primary-button.is-loading .auth-button-spinner { display: block; }

.auth-button-spinner {
    display: none;
    width: 0.95rem;
    height: 0.95rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: auth-spin 700ms linear infinite;
}

.auth-alternative {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.25rem 0;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
}

.auth-alternative::before,
.auth-alternative::after {
    content: '';
    height: 1px;
    flex: 1;
    background: var(--border-color);
}

.auth-google-button {
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    color: var(--text-primary);
    text-decoration: none;
}

.auth-google-button:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.auth-google-mark {
    display: grid;
    place-items: center;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background: conic-gradient(from -45deg, #4285f4 0 25%, #34a853 0 50%, #fbbc05 0 75%, #ea4335 0);
    color: white;
    font-size: 0.72rem;
    font-weight: 900;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.auth-message {
    min-height: 0;
    margin: 1rem 0 0;
    padding: 0.72rem 0.8rem;
    border: 1px solid color-mix(in srgb, var(--primary-color) 36%, var(--border-color));
    border-radius: 0.65rem;
    background: color-mix(in srgb, var(--primary-color) 8%, transparent);
    color: var(--text-primary);
    text-align: left;
    font-size: 0.78rem;
    line-height: 1.45;
}

.auth-message.is-success {
    border-color: color-mix(in srgb, var(--success) 42%, var(--border-color));
    background: color-mix(in srgb, var(--success) 8%, transparent);
}

.auth-message.is-error {
    border-color: color-mix(in srgb, var(--danger) 45%, var(--border-color));
    background: color-mix(in srgb, var(--danger) 8%, transparent);
}

.auth-message.is-warning {
    border-color: color-mix(in srgb, var(--warning) 42%, var(--border-color));
    background: color-mix(in srgb, var(--warning) 8%, transparent);
}

.auth-switch-copy {
    margin: 1.25rem 0 0;
    color: var(--text-muted);
    text-align: center;
    font-size: 0.78rem;
}

.auth-switch-copy a { font-weight: 700; }
.auth-otp-form { animation: auth-fade-in 220ms ease-out; }

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 3px;
}

@keyframes auth-spin { to { transform: rotate(360deg); } }
@keyframes auth-fade-in { from { opacity: 0; transform: translateY(0.3rem); } }

@media (max-width: 780px) {
    body.auth-page { padding: 0; align-items: stretch; }

    .auth-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        width: 100%;
        min-height: 100dvh;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .auth-story {
        min-height: auto;
        padding: 1.2rem 1.25rem;
        border-bottom: 1px solid var(--border-color);
    }

    .auth-story-copy,
    .auth-benefits { display: none; }

    .auth-card {
        justify-content: flex-start;
        padding: 1.25rem max(1.25rem, env(safe-area-inset-right)) calc(1.5rem + env(safe-area-inset-bottom));
    }

    .auth-toolbar { margin-bottom: 1.5rem; }
}

@media (max-width: 380px) {
    .auth-card { padding-inline: 1rem; }
    .auth-card-header h2 { font-size: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    .auth-page *,
    .auth-page *::before,
    .auth-page *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
