:root {
    color-scheme: light;
    --auth-canvas: #f7f8f5;
    --auth-surface: #fff;
    --auth-ink: #172b23;
    --auth-muted: #58675e;
    --auth-line: #c8d0c8;
    --auth-accent: #176b4b;
    --auth-accent-hover: #105439;
    --auth-button-ink: #fff;
    --auth-error: #943c2f;
    --auth-error-surface: #fff0eb;
    --auth-info-surface: #eaf3ec;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--auth-canvas);
    color: var(--auth-ink);
    font-synthesis: none;
    text-rendering: optimizeLegibility;
}

:root[data-bs-theme="dark"] {
    color-scheme: dark;
    --auth-canvas: #121b17;
    --auth-surface: #1b2922;
    --auth-ink: #edf3ec;
    --auth-muted: #a9b8ac;
    --auth-line: #45574b;
    --auth-accent: #79d9ac;
    --auth-accent-hover: #98e6be;
    --auth-button-ink: #112a1d;
    --auth-error: #ffb7a6;
    --auth-error-surface: #34231f;
    --auth-info-surface: #20382a;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; background: var(--auth-canvas); }
button, input { font: inherit; }
a { color: var(--auth-accent); text-underline-offset: 4px; }
button, a, input, summary { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.auth-shell {
    max-width: 1160px;
    min-height: 100vh;
    min-height: 100svh;
    margin: 0 auto;
    padding: 24px 40px 48px;
}
.auth-header { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.auth-brand { display: inline-flex; align-items: center; min-height: 44px; }
.auth-brand img { display: block; width: 114px; height: 38px; }
.auth-back {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    gap: 9px;
    padding: 0 4px;
    color: var(--auth-muted);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 550;
}
.auth-back:hover { color: var(--auth-ink); }
.auth-main { width: 100%; padding: clamp(64px, 12vh, 116px) 0 36px; }
.auth-panel { width: 100%; max-width: 408px; margin: 0 auto; }
.auth-heading { margin-bottom: 30px; }
.auth-heading h1 { margin: 0 0 12px; font-size: clamp(1.8rem, 3vw, 2.05rem); font-weight: 650; line-height: 1.16; letter-spacing: -.04em; }
.auth-heading p { margin: 0; color: var(--auth-muted); font-size: .94rem; line-height: 1.6; }
.auth-recipient { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin: 12px 0 0; }
.auth-recipient strong { font-size: 1rem; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.auth-recipient .auth-link { margin: 0; }
.auth-field { margin-bottom: 22px; }
.auth-label { display: block; margin: 0 0 9px; font-size: .875rem; font-weight: 600; }
.auth-input {
    display: block;
    width: 100%;
    min-height: 56px;
    padding: 14px 16px;
    border: 1px solid var(--auth-line);
    border-radius: 10px;
    background: var(--auth-surface);
    color: var(--auth-ink);
    font-size: 1rem;
    line-height: 1.5;
    outline: none;
}
.auth-input::placeholder { color: var(--auth-muted); opacity: .68; }
.auth-input:focus { border-color: var(--auth-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--auth-accent) 13%, transparent); }
.auth-phone { position: relative; }
.auth-phone-prefix { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); padding-right: 14px; border-right: 1px solid var(--auth-line); color: var(--auth-muted); font-size: 1rem; font-weight: 550; pointer-events: none; }
.auth-phone .auth-input { padding-left: 89px; }
.auth-hint { min-height: 20px; margin: 8px 0 0; color: var(--auth-muted); font-size: .81rem; line-height: 1.5; }
.auth-hint[data-state="ready"] { color: var(--auth-accent); }
.auth-hint[data-state="invalid"] { color: var(--auth-error); }
.auth-code { max-width: 196px; padding-left: 24px; font-size: 1.65rem; letter-spacing: .34em; text-align: center; font-variant-numeric: tabular-nums; }
.auth-primary {
    display: inline-flex;
    width: 100%;
    min-height: 54px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 18px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--auth-accent);
    color: var(--auth-button-ink);
    font-size: .94rem;
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none;
    cursor: pointer;
}
.auth-primary:hover { background: var(--auth-accent-hover); }
.auth-primary:disabled { opacity: .58; cursor: wait; }
.auth-link, .auth-text-button { display: inline-flex; min-height: 44px; align-items: center; font-size: .875rem; font-weight: 550; }
.auth-text-button { padding: 0; border: 0; background: transparent; color: var(--auth-accent); text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }
.auth-text-button:disabled { color: var(--auth-muted); opacity: .7; text-decoration: none; cursor: default; }
.auth-resend { display: flex; flex-wrap: wrap; align-items: center; gap: 0 14px; margin-top: 12px; }
.auth-resend form { margin: 0; }
.auth-resend-status { font-size: .81rem; color: var(--auth-muted); line-height: 1.5; }
.auth-feedback { margin: 0 0 22px; padding: 12px 14px; border-left: 3px solid var(--auth-accent); border-radius: 0 6px 6px 0; background: var(--auth-info-surface); color: var(--auth-ink); font-size: .875rem; line-height: 1.55; overflow-wrap: anywhere; }
.auth-feedback.is-error { border-color: var(--auth-error); color: var(--auth-error); background: var(--auth-error-surface); }
.auth-option { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--auth-line); }
.auth-option summary { width: fit-content; min-height: 44px; padding: 10px 0; color: var(--auth-accent); font-size: .875rem; font-weight: 550; cursor: pointer; }
.auth-option form { margin-top: 14px; }
.auth-option .auth-link { margin-top: 4px; }
.auth-secondary { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--auth-line); }
.auth-secondary p { margin: 0; color: var(--auth-muted); font-size: .875rem; line-height: 1.6; }
.auth-providers { display: flex; flex-wrap: wrap; gap: 0 24px; }
.auth-password-field { position: relative; }
.auth-password-field .auth-input { padding-right: 91px; }
.auth-password-toggle { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); min-width: 64px; min-height: 44px; padding: 0 6px; border: 0; border-radius: 5px; background: transparent; color: var(--auth-muted); font-size: .81rem; font-weight: 550; cursor: pointer; }
.auth-password-toggle:hover { color: var(--auth-accent); }
.auth-recovery-link { margin-top: 5px; }
:where(a, button, summary):focus-visible { outline: 2px solid var(--auth-accent); outline-offset: 4px; border-radius: 4px; }

@media (max-width: 600px) {
    .auth-shell { padding: 16px 24px 32px; }
    .auth-brand img { width: 102px; height: 34px; }
    .auth-header { gap: 16px; }
    .auth-main { padding: 50px 0 24px; }
    .auth-heading { margin-bottom: 28px; }
    .auth-heading h1 { font-size: 1.8rem; }
}
@media (max-width: 350px) { .auth-shell { padding-right: 18px; padding-left: 18px; } }
@media (max-height: 620px) { .auth-main { padding-top: 28px; } }
@media (prefers-reduced-motion: no-preference) {
    .auth-primary, .auth-input { transition: background-color .15s ease, border-color .15s ease; }
}
