/* FormLoop authentication shell and forms */
body.auth-body {
    display: grid;
    place-items: center;
    height: 100%;
    padding: clamp(0px, 2.4vh, 26px);
    overflow: hidden;
    overscroll-behavior: none;
    background: var(--paper);
}

.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.04fr) minmax(0, 0.96fr);
    width: min(1060px, 100%);
    height: min(742px, 100%);
    max-height: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

/* Brand panel */
.auth-aside {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: clamp(28px, 3.4vw, 46px);
    overflow: hidden;
    background: #1a2a22;
    color: #eef3ea;
}

.auth-aside::after {
    position: absolute;
    top: -130px;
    left: -110px;
    width: 320px;
    height: 320px;
    border: 1px solid rgba(238, 243, 234, 0.14);
    border-radius: 50%;
    content: "";
}

.auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
    min-height: 44px;
    border-radius: var(--radius-sm);
    color: inherit;
    font: 700 var(--fs-lg)/1 var(--font-display);
    letter-spacing: -1.1px;
}

.auth-brand .brand-mark {
    width: 30px;
    height: 30px;
    flex: none;
    color: #a9c4a5;
}

.auth-aside .brand-dot {
    color: #d3ac6b;
}

.auth-aside-copy {
    position: relative;
    z-index: 1;
    margin-top: auto;
    padding-top: 40px;
}

.aside-kicker,
.auth-kicker {
    color: var(--accent-ink);
    font-size: var(--fs-sm);
    font-weight: 700;
}

.auth-aside .aside-kicker {
    color: #d3ac6b;
}

.auth-aside-copy h2 {
    max-width: 14ch;
    margin: 8px 0 16px;
    font: 700 var(--fs-xl)/1.1 var(--font-display);
    letter-spacing: -1.5px;
}

.auth-aside-copy p {
    max-width: 31ch;
    color: rgba(238, 243, 234, 0.82);
    font-size: var(--fs-base);
    line-height: 1.6;
}

.auth-ring-art {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: clamp(20px, 4.4vh, 40px);
}

.auth-ring {
    position: relative;
    width: clamp(82px, 9vw, 112px);
    height: clamp(82px, 9vw, 112px);
    flex: none;
    border: clamp(16px, 1.8vw, 22px) solid rgba(238, 243, 234, 0.17);
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(238, 243, 234, 0.2), 0 18px 44px rgba(10, 22, 15, 0.24);
}

.auth-ring::after {
    position: absolute;
    inset: 26%;
    border: 1px solid rgba(211, 172, 107, 0.5);
    border-radius: 50%;
    background: rgba(211, 172, 107, 0.12);
    content: "";
}

.auth-ring-tag {
    color: rgba(238, 243, 234, 0.75);
    font-size: var(--fs-sm);
    font-weight: 700;
    line-height: 1.8;
}

/* Form card */
.auth-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: clamp(26px, 3.6vw, 46px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
}

.auth-card > * {
    flex: 0 0 auto;
}

/* Auto margins centre the card content without clipping its top edge when
   the form is taller than the viewport. */
.auth-card::before,
.auth-card::after {
    flex: 0 0 auto;
    height: 0;
    content: "";
}

.auth-card::before {
    margin-top: auto;
}

.auth-card::after {
    margin-bottom: auto;
}

.auth-brand-mobile {
    display: none;
    margin-bottom: 24px;
    color: var(--ink);
}

.auth-brand-mobile .brand-mark {
    color: var(--muted);
}

.auth-brand-mobile .brand-dot {
    color: var(--accent);
}

.auth-card h1 {
    margin: 8px 0 8px;
    color: var(--ink);
    font: 700 var(--fs-xl)/1.13 var(--font-display);
    letter-spacing: -1px;
}

.auth-intro {
    max-width: 38ch;
    margin-bottom: 16px;
    color: var(--muted);
    font-size: var(--fs-base);
    line-height: 1.55;
}

/* Notices */
.auth-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 16px;
    padding: 8px 16px;
    border: 1px solid color-mix(in srgb, var(--success) 30%, var(--surface));
    border-left: 3px solid var(--success);
    border-radius: var(--radius-sm);
    background: var(--success-bg);
    color: var(--success);
    font-size: var(--fs-base);
    line-height: 1.45;
}

.auth-note .icon-sm {
    width: 14px;
    height: 14px;
    flex: none;
    margin-top: 1px;
}

.auth-note.is-neutral {
    border-color: var(--line);
    border-left-color: var(--line-strong);
    background: var(--surface-2);
    color: var(--muted);
}

.error-summary {
    max-height: 132px;
    margin-bottom: 16px;
    padding: 16px 16px;
    border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--surface));
    border-left: 4px solid var(--danger);
    border-radius: var(--radius-sm);
    background: var(--danger-bg);
    color: var(--danger);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.error-summary h2 {
    margin-bottom: 8px;
    font-size: var(--fs-base);
    font-weight: 700;
}

.error-summary ul {
    display: grid;
    gap: 4px;
    padding-left: 16px;
    margin: 0;
    font-size: var(--fs-base);
    line-height: 1.45;
}

.error-summary a {
    color: inherit;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.error-summary a:hover {
    text-decoration-thickness: 2px;
}

/* Form fields */
.auth-form {
    display: grid;
    gap: 16px;
}

.field {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.field label {
    color: var(--ink-2);
    font-size: var(--fs-sm);
    font-weight: 700;
}

.field-input {
    position: relative;
    min-width: 0;
}

.field input {
    width: 100%;
    min-height: 48px;
    padding: 8px 16px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font-size: var(--fs-base);
}

.field.has-toggle input {
    padding-right: 50px;
}

.field input::placeholder {
    color: var(--muted-2);
}

.field input:focus-visible {
    border-color: var(--primary);
    outline: 3px solid var(--focus-soft);
    outline-offset: 0;
}

.field input[aria-invalid="true"] {
    border-color: var(--danger);
    background: var(--danger-bg);
}

.field input[aria-invalid="true"]:focus-visible {
    outline-color: color-mix(in srgb, var(--danger) 25%, transparent);
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 5px;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    transform: translateY(-50%);
}

.password-toggle:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.password-toggle .icon-sm {
    width: 17px;
    height: 17px;
}

.password-toggle [hidden] {
    display: none;
}

.field-error {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    color: var(--danger);
    font-size: var(--fs-sm);
    font-weight: 700;
    line-height: 1.4;
}

.field-error .icon-sm {
    width: 13px;
    height: 13px;
    flex: none;
    margin-top: 1px;
}

.form-options {
    display: flex;
    justify-content: flex-end;
    margin-top: -4px;
    font-size: var(--fs-base);
}

.form-options a,
.auth-alt a,
.auth-links a {
    border-radius: var(--radius-sm);
    color: var(--primary);
    font-weight: 700;
    text-underline-offset: 3px;
}

.form-options a:hover,
.auth-alt a:hover,
.auth-links a:hover {
    text-decoration: underline;
}

.auth-submit {
    width: 100%;
    min-height: 48px;
    margin-top: 4px;
    border-radius: var(--radius-sm);
    font-size: var(--fs-base);
}

.auth-alt {
    margin-top: 16px;
    color: var(--muted);
    font-size: var(--fs-base);
    text-align: center;
}

.auth-links {
    display: grid;
    gap: 8px;
    margin-top: 16px;
    font-size: var(--fs-base);
    text-align: center;
}

.auth-links a:first-child {
    font-size: var(--fs-sm);
    font-weight: 700;
}

/* Simulated inbox */
.inbox-message {
    display: grid;
    gap: 8px;
    margin-top: 16px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.inbox-message p {
    color: var(--ink-2);
    font-size: var(--fs-base);
    line-height: 1.45;
}

.inbox-message strong {
    font-weight: 700;
}

.reset-code {
    padding: 8px 8px;
    border: 1px dashed var(--ring);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--primary-strong);
    font-family: var(--font-mono);
    font-size: var(--fs-lg);
    font-weight: 700;
    letter-spacing: 0.15em;
    text-align: center;
}

.fine-print {
    color: var(--muted);
    font-size: var(--fs-sm);
    line-height: 1.45;
}

.inbox-message .btn {
    width: 100%;
    margin-top: 4px;
}

/* Desktops with a short viewport */
@media (min-width: 861px) and (max-height: 780px) {
    .auth-card {
        padding-top: 24px;
        padding-bottom: 24px;
    }

    .auth-intro {
        margin-bottom: 16px;
    }

    .auth-form {
        gap: 8px;
    }

    .field input,
    .auth-submit {
        min-height: 46px;
    }

    .auth-aside-copy {
        padding-top: 24px;
    }

    .auth-aside-copy h2 {
        font-size: var(--fs-xl);
    }

    .auth-ring-art {
        margin-top: 16px;
    }
}

/* Phones and narrow tablets */
@media (max-width: 860px) {
    body.auth-body {
        padding: 0;
    }

    .auth-shell {
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
        height: 100vh;
        height: 100dvh;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .auth-aside {
        display: none;
    }

    .auth-brand-mobile {
        display: inline-flex;
    }

    .auth-card {
        padding: max(20px, calc(env(safe-area-inset-top) + 12px))
            20px
            max(20px, calc(env(safe-area-inset-bottom) + 14px));
    }

    .auth-card h1 {
        font-size: var(--fs-xl);
    }

    .auth-intro {
        margin-bottom: 16px;
    }

    .field input,
    .auth-submit {
        min-height: 50px;
    }

    .error-summary {
        max-height: 118px;
    }
}

@media (max-width: 400px) {
    .auth-card {
        padding-right: 16px;
        padding-left: 16px;
    }

    .auth-brand-mobile {
        margin-bottom: 16px;
        font-size: var(--fs-lg);
    }

    .auth-brand-mobile .brand-mark {
        width: 26px;
        height: 26px;
    }
}

/* Error-heavy forms: tighten rhythm so the submit action stays visible. */
.auth-card:has(.error-summary) {
    padding-top: clamp(20px, 2.6vw, 34px);
    padding-bottom: clamp(20px, 2.6vw, 34px);
}

.auth-card:has(.error-summary) .auth-intro {
    display: none;
}

.auth-card:has(.error-summary) .auth-form {
    gap: 8px;
}

.auth-card:has(.error-summary) .field {
    gap: 4px;
}

.auth-card:has(.error-summary) .field-error {
    font-size: var(--fs-sm);
}

.auth-card:has(.error-summary) .error-summary {
    margin-bottom: 16px;
    padding: 8px 16px;
}

.auth-card:has(.error-summary) .auth-alt {
    margin-top: 16px;
}

/* Compact phones */
@media (max-width: 860px) and (max-height: 720px) {
    .auth-card h1 {
        font-size: var(--fs-xl);
        letter-spacing: -0.7px;
    }

    .auth-intro {
        margin-bottom: 16px;
        font-size: var(--fs-base);
    }

    .auth-brand-mobile {
        margin-bottom: 16px;
    }

    .auth-form {
        gap: 8px;
    }

    .field {
        gap: 8px;
    }

    .field input,
    .auth-submit {
        min-height: 46px;
    }

    .auth-note,
    .error-summary {
        margin-bottom: 16px;
    }

    .auth-alt,
    .auth-links {
        margin-top: 16px;
    }
}
