:root {
    color-scheme: light;
    --auth-vvh: 100svh;
    --auth-ink: var(--anora-ink, #121316);
    --auth-muted: var(--anora-muted, #646a73);
    --auth-faint: #8d939c;
    --auth-canvas: #f5f7f8;
    --auth-surface: #ffffff;
    --auth-line: rgba(18, 22, 29, .12);
    --auth-line-strong: rgba(18, 22, 29, .2);
    --auth-mint: var(--anora-mint, #08a88d);
    --auth-blue: var(--anora-blue, #3867f3);
    --auth-violet: var(--anora-violet, #7a61ed);
    --auth-danger: var(--anora-danger, #c93f55);
    --auth-font: var(--anora-font, -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Helvetica, Arial, sans-serif);
}

*, *::before, *::after { box-sizing: border-box; }

html {
    width: 100%;
    height: 100%;
    min-width: 320px;
    overflow: hidden;
    background: var(--auth-canvas);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body.anora-auth-page {
    width: 100%;
    height: var(--auth-vvh, 100svh);
    min-height: 100svh;
    margin: 0;
    overflow: hidden;
    overscroll-behavior: none;
    color: var(--auth-ink);
    background: var(--auth-canvas);
    font-family: var(--auth-font);
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }
a { color: inherit; }
svg, img { display: block; }
[hidden] { display: none !important; }

.auth-brand {
    display: inline-flex;
    width: 168px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    margin-bottom: 22px;
}

.auth-brand img { width: 100%; height: auto; }

.auth-shell {
    display: grid;
    width: 100%;
    height: var(--auth-vvh, 100svh);
    min-height: 100svh;
    place-items: center;
    padding: max(16px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    overflow: hidden;
}

.auth-stack {
    display: flex;
    width: 100%;
    max-height: 100%;
    align-items: center;
    flex-direction: column;
    justify-content: center;
    animation: auth-fade-in 420ms ease-out both;
}

.auth-card {
    position: relative;
    width: min(100%, 470px);
    max-height: calc(var(--auth-vvh, 100svh) - max(112px, calc(env(safe-area-inset-top) + env(safe-area-inset-bottom) + 94px)));
    padding: clamp(24px, 4.2vh, 38px);
    overflow: hidden;
    border: 1px solid var(--auth-line);
    border-radius: 24px;
    background: var(--auth-surface);
    box-shadow: 0 24px 80px rgba(38, 46, 58, .08), 0 2px 10px rgba(38, 46, 58, .035);
}

.auth-card--wide { width: min(100%, 560px); }
.auth-card--scroll { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #cfd4d8 transparent; }

.auth-card-header { margin-bottom: 22px; }

.auth-card h1 {
    margin: 0;
    color: var(--auth-ink);
    font-size: clamp(30px, 5vw, 39px);
    font-weight: 650;
    letter-spacing: -.048em;
    line-height: 1.03;
}

.auth-card-header > p,
.auth-copy {
    margin: 12px 0 0;
    color: var(--auth-muted);
    font-size: 14px;
    line-height: 1.55;
}

.auth-form { display: grid; gap: 15px; }
.auth-field { display: grid; min-width: 0; gap: 7px; }
.auth-field label,
.auth-field > span { color: #343940; font-size: 13px; font-weight: 650; }

.auth-input-wrap { position: relative; min-width: 0; }
.auth-field input {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 11px 13px;
    border: 1px solid var(--auth-line-strong);
    border-radius: 13px;
    outline: 0;
    color: var(--auth-ink);
    background: #fbfcfc;
    transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.auth-input-wrap input[type="password"],
.auth-input-wrap input[data-auth-password] { padding-right: 48px; }
.auth-field input::placeholder { color: #a3a8ae; }
.auth-field input:focus { border-color: var(--auth-blue); background: #fff; box-shadow: 0 0 0 4px rgba(56, 103, 243, .1); }
.auth-field input:disabled { color: #8f959c; background: #f1f3f4; }

.auth-password-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    display: grid;
    width: 38px;
    height: 38px;
    padding: 0;
    place-items: center;
    transform: translateY(-50%);
    border: 0;
    border-radius: 10px;
    color: #737982;
    background: transparent;
    cursor: pointer;
}
.auth-password-toggle:hover { color: var(--auth-ink); background: #f0f2f3; }
.auth-password-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.auth-password-toggle span { display: block; }

.auth-button {
    display: inline-flex;
    width: 100%;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 11px 16px;
    border: 1px solid var(--auth-ink);
    border-radius: 13px;
    color: #fff;
    background: var(--auth-ink);
    font-size: 14px;
    font-weight: 690;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}
.auth-button:hover:not(:disabled) { transform: translateY(-1px); background: #282b31; border-color: #282b31; }
.auth-button:active:not(:disabled) { transform: translateY(0); }
.auth-button:disabled { cursor: wait; opacity: .48; }
.auth-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.auth-button--secondary { border-color: var(--auth-line-strong); color: #292d33; background: #fff; }
.auth-button--secondary:hover:not(:disabled) { border-color: #aeb4ba; background: #f7f8f9; }
.auth-button--text { width: auto; min-height: 40px; border-color: transparent; color: #4b5159; background: transparent; }
.auth-button--text:hover:not(:disabled) { border-color: transparent; color: var(--auth-ink); background: #f2f4f5; }

.auth-divider { display: flex; align-items: center; gap: 12px; margin: 17px 0 13px; color: #8d939a; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; flex: 1; background: var(--auth-line); }

.auth-status { min-height: 18px; margin: 9px 0 0; color: var(--auth-muted); font-size: 13px; line-height: 1.45; }
.auth-status:empty { display: none; }
.auth-status[data-state="pending"] { color: var(--auth-blue); }
.auth-status[data-state="success"] { color: var(--auth-mint); }
.auth-status[data-state="error"] { color: var(--auth-danger); }

.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 16px;
    padding: 11px 12px;
    border: 1px solid #d9dee1;
    border-radius: 13px;
    color: #4d535b;
    background: #f6f8f8;
    font-size: 13px;
    line-height: 1.45;
}
.auth-alert svg { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.auth-alert--danger, .auth-alert.error { border-color: #f0c9d0; color: #9b2f43; background: #fff4f6; }
.auth-alert--success, .auth-alert.ok { border-color: #bfe3da; color: #08715f; background: #f0faf7; }
.auth-alert--warning { border-color: #efdcb8; color: #895716; background: #fff9ef; }
.auth-alert[hidden] { display: none !important; }

.auth-meta {
    margin: 0 0 15px;
    padding: 11px 12px;
    border: 1px solid var(--auth-line);
    border-radius: 13px;
    color: #596069;
    background: #f7f9f9;
    font-size: 13px;
    line-height: 1.5;
}
.auth-meta strong { color: #282d33; font-weight: 680; }
.auth-note { margin: -2px 0 0; color: #777e86; font-size: 13px; line-height: 1.45; }
.auth-actions { display: flex; align-items: center; gap: 10px; margin-top: 17px; }
.auth-actions .auth-button { flex: 1 1 auto; }

.auth-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 17px;
    color: #858b92;
    font-size: 13px;
}
.auth-footer a { color: #4e555d; font-weight: 620; text-decoration: none; }
.auth-footer a:hover { color: var(--auth-ink); text-decoration: underline; text-underline-offset: 3px; }
.auth-footer--split { width: 100%; justify-content: space-between; }
.auth-footer--split a:last-child { text-align: right; }

.auth-fieldset { display: grid; gap: 14px; margin: 0; padding: 0; border: 0; }
.auth-fieldset:disabled { opacity: .58; }

.auth-steps { margin: 14px 0; padding-left: 22px; color: var(--auth-muted); font-size: 13px; line-height: 1.5; }
.auth-steps li + li { margin-top: 5px; }
.auth-secret { padding: 11px 12px; border: 1px solid var(--auth-line-strong); border-radius: 13px; color: var(--auth-ink); background: #f7f9f9; font: 670 14px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .06em; overflow-wrap: anywhere; }
.auth-inline-link { display: inline-flex; margin-top: 9px; color: #2858df; font-size: 13px; font-weight: 650; text-decoration: none; }
.auth-inline-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.auth-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 14px; }
.auth-code { padding: 8px 10px; border: 1px solid var(--auth-line); border-radius: 10px; color: #2b3036; background: #f7f9f9; font: 660 13px/1.25 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .035em; }
.auth-codes + .auth-form { margin-top: 16px; }

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

:focus-visible { outline: 3px solid rgba(56, 103, 243, .34); outline-offset: 3px; }

@media (max-width: 620px) {
    .auth-brand { width: 142px; margin-bottom: 16px; }
    .auth-shell { padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
    .auth-card { max-height: calc(var(--auth-vvh, 100svh) - max(82px, calc(env(safe-area-inset-top) + env(safe-area-inset-bottom) + 66px))); padding: 22px 20px; border-radius: 20px; }
    .auth-card-header { margin-bottom: 18px; }
    .auth-card h1 { font-size: clamp(28px, 9vw, 35px); }
    .auth-card-header > p, .auth-copy { margin-top: 9px; font-size: 13px; }
    .auth-form { gap: 12px; }
    .auth-field input { min-height: 46px; font-size: 16px; }
    .auth-button { min-height: 46px; }
    .auth-footer { margin-top: 13px; }
}

@media (max-width: 430px) {
    .auth-actions { align-items: stretch; flex-direction: column; }
    .auth-actions .auth-button { width: 100%; }
    .auth-codes { grid-template-columns: 1fr 1fr; }
    .auth-footer--split { gap: 8px; font-size: 13px; }
}

@media (max-height: 700px) {
    .auth-brand { width: 128px; margin-bottom: 12px; }
    .auth-shell { padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
    .auth-card { max-height: calc(var(--auth-vvh, 100svh) - max(78px, calc(env(safe-area-inset-top) + env(safe-area-inset-bottom) + 62px))); padding-top: 19px; padding-bottom: 19px; }
    .auth-card-header { margin-bottom: 14px; }
    .auth-card h1 { font-size: clamp(27px, 5vw, 34px); }
    .auth-card-header > p, .auth-copy { margin-top: 7px; line-height: 1.42; }
    .auth-form, .auth-fieldset { gap: 10px; }
    .auth-field { gap: 5px; }
    .auth-field input { min-height: 43px; padding-top: 9px; padding-bottom: 9px; }
    .auth-button { min-height: 43px; }
    .auth-divider { margin: 12px 0 9px; }
    .auth-alert { margin-bottom: 11px; padding-top: 8px; padding-bottom: 8px; }
    .auth-meta { margin-bottom: 10px; padding-top: 8px; padding-bottom: 8px; }
    .auth-actions { margin-top: 12px; }
    .auth-footer { margin-top: 10px; }
}

@media (max-width: 430px) and (max-height: 620px) {
    .auth-account-setup-page .auth-card { padding: 14px 16px; border-radius: 18px; }
    .auth-account-setup-page .auth-card-header { margin-bottom: 8px; }
    .auth-account-setup-page .auth-card-header > p { display: none; }
    .auth-account-setup-page .auth-card h1 { font-size: 26px; }
    .auth-account-setup-page .auth-meta { margin-bottom: 8px; padding: 6px 9px; line-height: 1.3; }
    .auth-account-setup-page .auth-form,
    .auth-account-setup-page .auth-fieldset { gap: 7px; }
    .auth-account-setup-page .auth-field { gap: 3px; }
    .auth-account-setup-page .auth-field input { min-height: 39px; padding-top: 7px; padding-bottom: 7px; }
    .auth-account-setup-page .auth-password-toggle { width: 34px; height: 34px; }
    .auth-account-setup-page .auth-note { line-height: 1.25; }
    .auth-account-setup-page .auth-button { min-height: 39px; padding-top: 8px; padding-bottom: 8px; }
    .auth-account-setup-page #setup-client-status { margin-top: 7px; margin-bottom: 0; padding: 7px 9px; line-height: 1.3; }
    .auth-account-setup-page .auth-footer { display: none; }
}

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