:root {
    color-scheme: light dark;
    --page: #f7f7f5;
    --surface: #ffffff;
    --surface-subtle: #f0f1ee;
    --border: #d6d8d2;
    --text: #191b19;
    --muted: #666b65;
    --green: #4f9f64;
    --green-strong: #347b49;
    --gold: #e9b640;
    --danger: #b6372f;
    --focus: #76be88;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--page);
}

body {
    min-width: 320px;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    background: var(--page);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

button,
input {
    font: inherit;
    letter-spacing: 0;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.auth-page {
    display: grid;
    min-height: calc(100vh - 52px);
    min-height: calc(100dvh - 52px);
    place-items: center;
    padding: max(24px, env(safe-area-inset-top)) 20px 24px;
}

.auth-workspace {
    width: min(100%, 420px);
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 0 auto 14px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.55rem;
    font-weight: 700;
}

.auth-brand img {
    width: 46px;
    height: 46px;
    border-radius: 6px;
}

.session-check,
.processing,
.verifying-code {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 76px;
    color: var(--muted);
    font-weight: 700;
}

.auth-panel {
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.08);
}

.auth-heading {
    margin-bottom: 22px;
    text-align: center;
}

.auth-heading h1,
.code-heading h2,
.access-dialog h2 {
    margin: 0;
    font-size: 1.45rem;
    line-height: 1.2;
}

.auth-heading p,
.code-heading p,
.access-dialog header p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.5;
}

#sign-in-form,
.button-stack,
.code-step,
.access-dialog form {
    display: grid;
    gap: 14px;
}

.field {
    display: grid;
    gap: 7px;
}

.field > span {
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 700;
}

.field input {
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
    background: var(--surface);
    color: var(--text);
}

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

.primary-button,
.secondary-button,
.text-button {
    min-height: 46px;
    padding: 10px 16px;
    border-radius: 6px;
    font-weight: 800;
}

.primary-button {
    border: 1px solid var(--green);
    background: var(--green);
    color: #101711;
}

.primary-button:hover:not(:disabled) {
    border-color: var(--green-strong);
    background: var(--green-strong);
    color: #ffffff;
}

.secondary-button {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
}

.secondary-button:hover:not(:disabled) {
    border-color: var(--green);
    color: var(--green);
}

.text-button,
.inline-button {
    border: 0;
    background: transparent;
    color: var(--green);
    font-weight: 800;
}

.text-button {
    padding: 8px;
}

.inline-button {
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.form-error,
.form-status {
    min-height: 0;
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.4;
}

.form-error:not(:empty) {
    min-height: 20px;
    color: var(--danger);
}

.form-status {
    color: var(--green);
}

.processing {
    min-height: 58px;
    border-block: 1px solid var(--border);
}

.code-step {
    padding-top: 4px;
}

.code-heading {
    text-align: center;
}

.code-heading h2 {
    font-size: 1.2rem;
}

.supporting-text {
    font-size: 0.86rem;
}

.code-entry {
    position: relative;
    display: block;
    width: 100%;
}

#code-input {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    border: 0;
    outline: 0;
    opacity: 0;
    caret-color: transparent;
}

.code-digits {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 7px;
}

.code-digits > span {
    display: grid;
    aspect-ratio: 0.82;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-subtle);
    font-size: clamp(1.25rem, 5vw, 1.7rem);
    font-weight: 800;
}

.code-entry.is-focused .code-digits > span.is-active {
    border-color: var(--focus);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent);
}

.code-entry.is-invalid {
    animation: code-shake 220ms ease-in-out;
}

.code-entry.is-invalid .code-digits > span {
    border-color: var(--danger);
}

.verifying-code {
    position: absolute;
    inset: 0;
    z-index: 3;
    min-height: 0;
    border-radius: 6px;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    color: var(--text);
    font-size: 0.86rem;
}

.code-actions {
    display: grid;
    gap: 4px;
    text-align: center;
}

.code-actions p {
    margin: 0;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.5;
}

.access-support {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.access-support > p {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.access-support .form-status {
    flex-basis: 100%;
}

.auth-footer {
    min-height: 52px;
    padding: 14px 20px max(14px, env(safe-area-inset-bottom));
    color: var(--muted);
    font-size: 0.76rem;
    text-align: center;
}

.access-dialog {
    width: min(calc(100% - 32px), 480px);
    max-height: calc(100dvh - 32px);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}

.access-dialog::backdrop {
    background: rgba(0, 0, 0, 0.68);
}

.access-dialog form {
    padding: 22px;
}

.access-dialog header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.icon-button {
    display: grid;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: transparent;
    color: var(--text);
    font-size: 1.5rem;
    line-height: 1;
}

.dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.seed-loader {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.seed {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 48%;
    animation: seed-dance 1.15s ease-in-out infinite;
}

.seed-corn {
    left: 3px;
    top: 8px;
    background: var(--gold);
}

.seed-soybean {
    left: 21px;
    top: 3px;
    background: var(--green);
    animation-delay: 140ms;
}

.seed-small {
    left: 38px;
    top: 11px;
    width: 10px;
    height: 10px;
    animation-delay: 280ms;
}

@keyframes seed-dance {
    0%,
    100% {
        transform: translateY(2px) rotate(-8deg);
    }
    50% {
        transform: translateY(-5px) rotate(8deg);
    }
}

@keyframes code-shake {
    0%,
    100% {
        transform: translateX(0);
    }
    30% {
        transform: translateX(-5px);
    }
    70% {
        transform: translateX(5px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .seed,
    .code-entry.is-invalid {
        animation: none;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        --page: #181918;
        --surface: #232423;
        --surface-subtle: #1c1d1c;
        --border: #3d403d;
        --text: #f4f5f2;
        --muted: #b3b7b1;
        --green: #82c48f;
        --green-strong: #5eaa70;
        --danger: #ff8276;
        --focus: #82c48f;
    }

    .primary-button {
        color: #142117;
    }

    .auth-panel {
        box-shadow: 0 18px 52px rgba(0, 0, 0, 0.3);
    }
}

@media (max-width: 520px) {
    .auth-page {
        place-items: start center;
        padding-inline: 14px;
    }

    .auth-brand {
        margin-bottom: 10px;
        font-size: 1.7rem;
    }

    .auth-panel {
        padding: 20px 16px;
    }

    .access-support {
        flex-wrap: wrap;
    }

    .dialog-actions {
        grid-template-columns: 1fr;
    }
}

/* Keep the isolated sign-in shell visually identical to the portal-next login. */
body {
    --page: #1a1a1a;
    --surface: #242424;
    --surface-subtle: #2a2a2a;
    --border: #3a3a3a;
    --text: #f5f5f3;
    --muted: #a0a0a0;
    --green: #7fb685;
    --green-strong: #6aa772;
    --gold: #e8b44c;
    --danger: #e26f56;
    --focus: #7fb685;
    background:
        radial-gradient(circle at 18% 12%, rgba(232, 180, 76, 0.12), transparent 26rem),
        radial-gradient(circle at 84% 18%, rgba(127, 182, 133, 0.08), transparent 24rem),
        var(--page);
}

html {
    background: #1a1a1a;
}

.auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    place-items: center;
    padding: clamp(1.25rem, 3vw, 2.5rem) 1rem;
}

.auth-workspace {
    display: grid;
    width: min(36rem, 100%);
    justify-items: center;
    gap: clamp(0.75rem, 2vh, 1.15rem);
}

.auth-brand {
    width: 100%;
    margin: 0;
}

.auth-brand img {
    width: clamp(11.5rem, 42vw, 15rem);
    height: auto;
    max-height: none;
    border-radius: 0;
    filter: invert(1) brightness(1.8) contrast(0.92);
}

.session-check,
.auth-panel {
    width: min(33.5rem, 100%);
    border: 1px solid var(--border);
    border-radius: 0.8rem;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 22px 68px rgba(0, 0, 0, 0.28);
}

.session-check {
    min-height: 8.5rem;
    padding: 1.5rem;
}

.auth-panel {
    padding: clamp(1.35rem, 4vw, 2rem);
}

.auth-heading {
    display: grid;
    gap: 0.65rem;
    margin-bottom: clamp(1rem, 2.5vw, 1.35rem);
}

.section-kicker {
    margin: 0;
    color: var(--green);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.auth-heading h1 {
    color: var(--text);
    font-size: clamp(2.05rem, 6vw, 3rem);
    line-height: 1.02;
    font-weight: 760;
    letter-spacing: 0;
}

.auth-heading p:not(.section-kicker) {
    margin: 0;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.55;
}

#sign-in-form {
    gap: 0.8rem;
    text-align: left;
}

.field {
    gap: 0.45rem;
}

.field > span {
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 600;
}

.field input {
    min-height: 3.25rem;
    border-color: var(--border);
    border-radius: 0.45rem;
    background: var(--surface-subtle);
    color: var(--text);
    font-size: 1rem;
    font-weight: 500;
    box-shadow: none;
}

.field input:focus {
    border-color: color-mix(in srgb, var(--green) 58%, var(--border));
    box-shadow: 0 0 0 0.22rem color-mix(in srgb, var(--green) 16%, transparent);
}

.primary-button,
.secondary-button,
.text-button {
    min-height: 3.05rem;
    border-radius: 0.5rem;
    font-size: 0.98rem;
    font-weight: 720;
    box-shadow: none;
}

.primary-button {
    border-color: var(--green);
    background: var(--green);
    color: #1a1a1a;
}

.primary-button:hover:not(:disabled) {
    border-color: var(--green-strong);
    background: var(--green-strong);
    color: #1a1a1a;
}

.secondary-button {
    border-color: var(--border);
    color: var(--text);
}

.text-button,
.inline-button {
    color: var(--green);
}

.button-stack {
    gap: 0.8rem;
}

.passkey-login-entry {
    display: grid;
    gap: 0.55rem;
}

.auth-divider {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.75rem;
    color: var(--muted);
    font-size: 0.78rem;
}

.auth-divider::before,
.auth-divider::after {
    height: 1px;
    background: var(--border);
    content: "";
}

.passkey-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    width: 100%;
}

.passkey-button svg {
    flex: 0 0 1.25rem;
    width: 1.25rem;
    height: 1.25rem;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.passkey-login-entry p {
    margin: 0;
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.4;
    text-align: center;
}

.processing,
.verifying-code {
    border-color: var(--border);
    border-radius: 0.55rem;
    background: var(--surface-subtle);
    color: var(--text);
}

.processing {
    min-height: 4.75rem;
    border: 1px solid var(--border);
}

.access-support {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.8rem;
    margin-top: clamp(1rem, 2.5vw, 1.35rem);
    padding: 0.95rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    text-align: center;
}

.access-support > p {
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.55;
}

.access-support .secondary-button {
    width: 100%;
}

.auth-panel.is-code-mode {
    width: min(33.5rem, 100%);
    padding: clamp(1.25rem, 3vw, 1.7rem);
}

.auth-panel.is-code-mode .auth-heading,
.auth-panel.is-code-mode .access-support {
    display: none;
}

.auth-panel.is-code-mode #sign-in-form {
    gap: 0.95rem;
}

.code-step {
    gap: 1rem;
    padding: 0;
}

.code-heading h2 {
    color: var(--text);
    font-size: clamp(1.1rem, 2vw, 1.28rem);
    font-weight: 650;
}

.code-heading p {
    color: var(--muted);
}

.code-heading #code-destination {
    color: var(--text);
    font-size: clamp(1.1rem, 2vw, 1.28rem);
    font-weight: 650;
}

.code-digits {
    grid-template-columns: repeat(6, minmax(2.45rem, 3.1rem));
    justify-content: center;
    gap: 0.55rem;
}

.code-digits > span {
    width: 100%;
    height: 3.45rem;
    min-height: 3.45rem;
    aspect-ratio: auto;
    border-color: var(--border);
    border-radius: 0.55rem;
    background: var(--surface-subtle);
    color: var(--text);
    box-shadow: none;
}

.code-entry.is-focused .code-digits > span.is-active {
    border-color: var(--green);
    box-shadow: 0 0 0 0.22rem color-mix(in srgb, var(--green) 16%, transparent);
}

.verifying-code {
    border: 1px solid var(--border);
}

.code-actions p {
    color: var(--muted);
}

.access-dialog {
    border-color: var(--border);
    border-radius: 0.8rem;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 24px 72px rgba(0, 0, 0, 0.42);
}

.access-dialog::backdrop {
    background: color-mix(in srgb, var(--page) 72%, transparent);
    backdrop-filter: blur(10px);
}

.access-dialog form {
    gap: 0.9rem;
    padding: clamp(1.25rem, 4vw, 1.8rem);
}

.access-dialog h2 {
    color: var(--text);
    font-size: clamp(1.65rem, 4vw, 2.2rem);
    line-height: 1.05;
    font-weight: 760;
    letter-spacing: 0;
}

.access-dialog header p {
    color: var(--muted);
}

.icon-button {
    border-color: var(--border);
    color: var(--text);
}

.auth-footer {
    display: none;
}

.seed-loader {
    display: inline-flex;
    align-items: flex-end;
    justify-content: center;
    gap: 0.22rem;
    width: auto;
    min-width: 2.2rem;
    height: 1.45rem;
}

.seed {
    position: static;
    display: block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 52% 48% 54% 46%;
    box-shadow: inset -0.06rem -0.08rem 0.12rem rgba(75, 48, 17, 0.18), 0 0.1rem 0.18rem rgba(69, 47, 19, 0.12);
    transform: translateY(0) rotate(-16deg);
    transform-origin: 50% 85%;
    animation: seed-dance 920ms ease-in-out infinite;
}

.seed-corn {
    background:
        radial-gradient(circle at 35% 24%, rgba(255, 247, 188, 0.88) 0 18%, transparent 19%),
        linear-gradient(145deg, #f6c94b 0%, #d59421 72%, #a86919 100%);
}

.seed-soybean {
    width: 0.52rem;
    height: 0.52rem;
    border-radius: 50% 48% 52% 50%;
    background:
        radial-gradient(circle at 34% 24%, rgba(255, 244, 206, 0.75) 0 17%, transparent 18%),
        linear-gradient(145deg, #d4ad68 0%, #a16f35 100%);
    animation-delay: 90ms;
}

.seed-small {
    width: 0.43rem;
    height: 0.43rem;
    animation-delay: 180ms;
}

@media (max-width: 760px) {
    .auth-page {
        place-items: center;
        padding: 0.9rem 0.5rem;
    }

    .auth-workspace {
        width: min(100%, 33.5rem);
        gap: 0.75rem;
    }

    .auth-brand img {
        width: min(13rem, 58vw);
    }

    .auth-panel {
        padding: 1rem;
    }

    .auth-heading h1 {
        font-size: clamp(1.75rem, 10vw, 2.45rem);
    }

    .code-digits {
        grid-template-columns: repeat(6, minmax(2rem, 1fr));
        gap: 0.38rem;
    }

    .code-digits > span {
        height: 3.15rem;
        min-height: 3.15rem;
        font-size: 1.28rem;
    }
}
