:root {
    --app-bg: #f4f6fb;
    --shell-bg: #ffffff;
    --line: #e6eaf2;
    --line-strong: #dbe3f0;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #3b82f6;
    --primary-soft: #e8f1ff;
    --primary-strong: #2563eb;
    --accent-tint: rgba(59, 130, 246, 0.11);
    --bg-top: #eef4ff;
    --bg-mid: #f6f8fc;
    --bg-bottom: #eef3fb;
    --focus: rgba(59, 130, 246, 0.12);
    --shadow: 0 18px 56px rgba(15, 23, 42, 0.1);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; padding: 0; }
body {
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background:
        radial-gradient(circle at top, var(--accent-tint), transparent 30%),
        linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 44%, var(--bg-bottom) 100%);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }

.auth-page {
    min-height: 100dvh;
    overflow-x: hidden;
}

.auth-page__bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 78% 12%, rgba(59, 130, 246, 0.14), transparent 24%),
        radial-gradient(circle at 18% 76%, rgba(46, 168, 156, 0.10), transparent 24%);
}

.auth-wrap {
    position: relative;
    z-index: 1;
    min-height: 100dvh;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 18px 14px 28px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
}

.auth-back {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 7px 10px;
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(219, 227, 240, 0.88);
    text-decoration: none;
    font-size: 13px;
    font-weight: 650;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    padding: 16px;
    border: 1px solid rgba(219, 227, 240, 0.92);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 14px;
}

.auth-brand__mark {
    width: 40px;
    height: 40px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 800;
    letter-spacing: -0.04em;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-strong) 100%);
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.18);
}

.auth-brand__title {
    font-size: 19px;
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.auth-brand__sub {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.35;
}

.auth-tabs,
.auth-segment {
    display: grid;
    gap: 6px;
    padding: 4px;
    border-radius: 16px;
    background: #f2f6fc;
    border: 1px solid #e6edf7;
}

.auth-tabs { grid-template-columns: repeat(3, 1fr); margin-bottom: 13px; }
.auth-segment { grid-template-columns: repeat(2, 1fr); margin: 0 0 13px; }

.auth-tab,
.auth-segment__btn {
    min-height: 35px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #586579;
    font-size: 13px;
    font-weight: 750;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.auth-tab.is-active,
.auth-segment__btn.is-active {
    background: #fff;
    color: var(--primary-strong);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.07);
}

.auth-screen { display: none; }
.auth-screen.is-active { display: block; animation: authFade 0.16s ease; }
@keyframes authFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.auth-screen h1,
.auth-signed h1 {
    margin: 4px 0 5px;
    font-size: 24px;
    line-height: 1.12;
    letter-spacing: -0.03em;
}

.auth-lead,
.auth-muted {
    margin: 0 0 14px;
    color: var(--muted);
    font-size: 13.5px;
    line-height: 1.45;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 11px;
}

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

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-field span {
    font-size: 13px;
    font-weight: 700;
}

.auth-field input,
.auth-field select {
    width: 100%;
    height: 43px;
    font-size: 16px;
    border: 1px solid #dbe5f2;
    border-radius: 13px;
    padding: 0 13px;
    outline: none;
    color: var(--text);
    background: #fbfcff;
}

.auth-field select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #7b8797 50%), linear-gradient(135deg, #7b8797 50%, transparent 50%);
    background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

.auth-field input:focus,
.auth-field select:focus,
.auth-code__digit:focus {
    border-color: #bfd6ff;
    box-shadow: 0 0 0 3px var(--focus);
}

.auth-btn {
    width: 100%;
    min-height: 44px;
    border: 0;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #fff;
    font-weight: 800;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-strong) 100%);
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.18);
}

.auth-btn:disabled { opacity: 0.68; box-shadow: none; }
.auth-btn--ghost {
    color: var(--primary-strong);
    background: var(--primary-soft);
    box-shadow: none;
}

.auth-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 12px;
    margin-top: 13px;
}

.auth-links--single { justify-content: flex-start; }
.auth-link {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--primary-strong);
    font-size: 13px;
    font-weight: 750;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.auth-link:disabled { color: #94a3b8; text-decoration: none; }
.auth-link--back { display: inline-flex; margin-top: 12px; }

.auth-message {
    display: none;
    margin: 0 0 12px;
    border-radius: 13px;
    padding: 10px 11px;
    font-size: 13px;
    line-height: 1.4;
    border: 1px solid #e3eaf4;
    background: #f8fbff;
    color: #445468;
}

.auth-message.is-visible { display: block; }
.auth-message--err { border-color: #f2c6cb; background: #fff5f6; color: #a43948; }
.auth-message--ok { border-color: #c8ead4; background: #f2fbf5; color: #1f7a3e; }
.auth-debug { display: block; margin-top: 4px; opacity: 0.78; font-size: 12px; }

.auth-coach-fields {
    display: none;
    flex-direction: column;
    gap: 11px;
    padding: 11px;
    border: 1px solid #e6edf7;
    border-radius: 16px;
    background: #f8fbff;
}

.auth-coach-fields.is-active { display: flex; }

.auth-step-icon,
.auth-signed__icon {
    width: 46px;
    height: 46px;
    border-radius: 17px;
    display: grid;
    place-items: center;
    color: var(--primary-strong);
    background: var(--primary-soft);
    font-size: 19px;
    margin-bottom: 10px;
}

.auth-code {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 7px;
    margin: 15px 0 13px;
}

.auth-code__digit {
    width: 100%;
    height: 48px;
    border: 1px solid #dbe5f2;
    border-radius: 14px;
    outline: none;
    text-align: center;
    font-size: 21px;
    font-weight: 800;
    background: #fbfcff;
}

.auth-code__digit.is-error {
    border-color: #ef9ca7;
    background: #fff5f6;
}

.auth-resend {
    margin-top: 12px;
    min-height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

.auth-resend .js-resend-btn { display: none; }
.auth-resend.is-ready .js-resend-countdown { display: none; }
.auth-resend.is-ready .js-resend-btn { display: inline; }

.auth-signed { text-align: left; }
.auth-actions--signed { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 14px; }

@media (max-width: 430px) {
    .auth-wrap { justify-content: flex-start; padding: 12px 10px 20px; }
    .auth-card { border-radius: 22px; padding: 14px; }
    .auth-tabs { gap: 4px; }
    .auth-tab { font-size: 12.5px; min-height: 34px; }
    .auth-grid { grid-template-columns: 1fr; }
    .auth-code { gap: 5px; }
    .auth-code__digit { height: 44px; border-radius: 12px; font-size: 20px; }
    .auth-screen h1, .auth-signed h1 { font-size: 22px; }
}

/* step19-fix1: one clean step at a time for code/password screens */
.auth-stage-flow .auth-brand,
.auth-stage-flow .auth-tabs,
.auth-stage-flow .js-auth-message:not(.auth-message--err) {
    display: none !important;
}

.auth-stage-flow .auth-card {
    max-width: 390px;
    padding: 18px;
}

.auth-stage-flow .auth-screen.is-active {
    text-align: center;
}

.auth-stage-flow .auth-step-icon {
    margin: 0 auto 10px;
    width: 40px;
    height: 40px;
    border-radius: 15px;
    font-size: 17px;
}

.auth-stage-flow .auth-screen h1 {
    margin: 2px 0 6px;
    font-size: 22px;
}

.auth-lead--center {
    text-align: center;
    margin-bottom: 12px;
    overflow-wrap: anywhere;
}

.auth-stage-flow .auth-code {
    margin: 14px auto 12px;
    max-width: 330px;
    gap: 8px;
}

.auth-stage-flow .auth-code__digit {
    height: 46px;
    border-radius: 13px;
    font-size: 21px;
}

.auth-stage-flow .auth-btn {
    max-width: 330px;
    margin-left: auto;
    margin-right: auto;
}

.auth-stage-flow .auth-resend {
    margin-top: 10px;
    min-height: 20px;
    font-size: 12.5px;
}

.auth-stage-flow .auth-link--back {
    margin-top: 10px;
    justify-content: center;
}

.auth-stage-password .auth-form {
    max-width: 330px;
    margin: 0 auto;
    text-align: left;
}

.auth-stage-password .auth-form .auth-btn {
    max-width: none;
}

@media (max-width: 430px) {
    .auth-stage-flow .auth-card { padding: 16px; }
    .auth-stage-flow .auth-code { gap: 6px; max-width: 310px; }
    .auth-stage-flow .auth-code__digit { height: 43px; font-size: 20px; }
}

/* step19-fix2: page layout, clean registration choice, no modal feeling */
.auth-wrap {
    max-width: 980px;
    justify-content: flex-start;
    padding: 26px 16px 34px;
}

.auth-card {
    max-width: 720px;
    margin-top: 12px;
    padding: 22px;
    border-radius: 26px;
    box-shadow: 0 10px 34px rgba(15, 23, 42, 0.07);
}

.auth-brand {
    margin-bottom: 18px;
}

.auth-tabs {
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 18px;
}

.auth-screen.is-active {
    max-width: 460px;
    margin-left: auto;
    margin-right: auto;
}

.auth-screen[data-screen="register"].is-active {
    max-width: 560px;
}

.auth-screen h1,
.auth-signed h1 {
    margin-top: 2px;
}

.auth-lead,
.auth-muted {
    margin-bottom: 16px;
}

.auth-register-choice {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 14px 0 12px;
}

.auth-register-choice.is-hidden {
    display: none;
}

.auth-choice-card {
    width: 100%;
    min-height: 136px;
    padding: 16px;
    border: 1px solid #e1e9f5;
    border-radius: 20px;
    background: #fbfdff;
    color: var(--text);
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.auth-choice-card:hover,
.auth-choice-card.is-active {
    border-color: #b9d3ff;
    background: #f6faff;
    box-shadow: 0 12px 26px rgba(37, 99, 235, 0.10);
    transform: translateY(-1px);
}

.auth-choice-card__icon {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: var(--primary-strong);
    background: var(--primary-soft);
}

.auth-choice-card__title {
    font-size: 16px;
    font-weight: 850;
    letter-spacing: -0.02em;
}

.auth-choice-card__text {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.auth-register-form {
    display: none;
    max-width: 460px;
    margin: 0 auto;
}

.auth-register-form.is-active {
    display: flex;
}

.auth-form-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #e6edf7;
    border-radius: 16px;
    background: #f8fbff;
}

.auth-form-top__label {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.2;
}

.auth-form-top__title {
    margin-top: 2px;
    font-size: 15px;
    font-weight: 850;
}

.auth-stage-flow .auth-wrap {
    max-width: 720px;
    justify-content: flex-start;
}

.auth-stage-flow .auth-card {
    max-width: 520px;
    margin-top: 22px;
}

.auth-stage-flow .auth-screen.is-active {
    max-width: 390px;
}

@media (max-width: 640px) {
    .auth-wrap {
        padding: 12px 10px 24px;
    }
    .auth-card {
        max-width: none;
        padding: 16px;
        border-radius: 22px;
    }
    .auth-register-choice {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .auth-choice-card {
        min-height: 104px;
        padding: 14px;
    }
    .auth-tabs {
        margin-bottom: 14px;
    }
}


/* step19-fix3: auth page is a clean full page, not a modal/card stack */
.auth-tabs,
.auth-tabs[hidden] {
    display: none !important;
}

body {
    background: #f5f6f9;
}

.auth-page__bg {
    display: none;
}

.auth-wrap {
    max-width: 100%;
    min-height: 100dvh;
    padding: 30px clamp(14px, 4vw, 54px) 42px;
    justify-content: flex-start;
    gap: 18px;
}

.auth-back {
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 6px 0;
    border-radius: 0;
    font-size: 16px;
    color: #6b7280;
}

.auth-card {
    width: 100%;
    max-width: none;
    margin: 14px auto 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
}

.auth-brand {
    justify-content: center;
    margin: 0 auto 28px;
}

.auth-screen.is-active,
.auth-screen[data-screen="register"].is-active,
.auth-signed {
    width: min(100%, 430px);
    max-width: 430px;
    margin-left: auto;
    margin-right: auto;
}

.auth-screen[data-screen="register"].is-active {
    width: min(100%, 540px);
    max-width: 540px;
}

.auth-screen h1,
.auth-signed h1 {
    margin: 0 0 8px;
    font-size: 27px;
    text-align: center;
}

.auth-lead,
.auth-muted {
    margin: 0 0 18px;
    text-align: center;
    font-size: 14px;
}

.auth-form {
    gap: 13px;
}

.auth-message.is-visible {
    width: min(100%, 430px);
    margin-left: auto;
    margin-right: auto;
}

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

.auth-links--single {
    justify-content: center;
}

.auth-register-choice {
    width: min(100%, 520px);
    margin: 18px auto 12px;
    gap: 12px;
}

.auth-choice-card {
    min-height: 112px;
    padding: 14px;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.045);
}

.auth-choice-card__text {
    display: none;
}

.auth-register-form {
    width: min(100%, 430px);
    max-width: 430px;
}

.auth-form-top {
    padding: 0 0 6px;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.auth-segment {
    display: none;
}

.auth-coach-fields {
    background: transparent;
    border: 0;
    padding: 0;
}

.auth-stage-flow .auth-wrap {
    max-width: 100%;
    padding-top: 30px;
}

.auth-stage-flow .auth-card {
    max-width: none;
    margin-top: 42px;
    padding: 0;
}

.auth-stage-flow .auth-screen.is-active {
    width: min(100%, 720px);
    max-width: 720px;
}

.auth-stage-flow .auth-screen h1 {
    font-size: 28px;
    margin-bottom: 10px;
}

.auth-stage-flow .auth-code {
    width: min(100%, 560px);
    max-width: 560px;
    margin: 34px auto 22px;
    gap: 10px;
}

.auth-stage-flow .auth-code__digit {
    height: 62px;
    border-radius: 17px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.045);
    font-size: 24px;
}

.auth-stage-flow .auth-btn {
    width: min(100%, 360px);
}

.auth-stage-flow .auth-resend {
    margin-top: 18px;
    font-size: 14px;
}

.auth-stage-flow .auth-link--back {
    display: none;
}

.auth-stage-password .auth-screen.is-active {
    width: min(100%, 430px);
    max-width: 430px;
}

.auth-stage-password .auth-form {
    max-width: 430px;
}

@media (max-width: 640px) {
    .auth-wrap {
        padding: 18px 14px 28px;
    }
    .auth-brand {
        margin-bottom: 18px;
    }
    .auth-screen h1,
    .auth-signed h1,
    .auth-stage-flow .auth-screen h1 {
        font-size: 23px;
    }
    .auth-register-choice {
        grid-template-columns: 1fr;
    }
    .auth-stage-flow .auth-card {
        margin-top: 26px;
    }
    .auth-stage-flow .auth-code {
        gap: 7px;
        margin-top: 24px;
        max-width: 360px;
    }
    .auth-stage-flow .auth-code__digit {
        height: 48px;
        border-radius: 14px;
        font-size: 21px;
    }
}

/* step19-fix4: simpler route page and cleaner one-step screens */
.auth-wrap {
    padding-top: 28px;
    padding-bottom: 34px;
}
.auth-brand {
    margin-bottom: 20px;
}
.auth-brand__mark {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    font-size: 16px;
}
.auth-brand__title {
    font-size: 17px;
}
.auth-brand__sub {
    display: none;
}
.auth-screen.is-active,
.auth-screen[data-screen="register"].is-active,
.auth-signed {
    width: min(100%, 400px);
    max-width: 400px;
}
.auth-screen[data-screen="register"].is-active {
    width: min(100%, 500px);
    max-width: 500px;
}
.auth-screen h1,
.auth-signed h1 {
    font-size: 25px;
    margin-bottom: 7px;
}
.auth-lead,
.auth-muted {
    font-size: 13.5px;
    margin-bottom: 16px;
}
.auth-links {
    gap: 10px 14px;
}
.auth-links .auth-link {
    white-space: nowrap;
}
.auth-register-choice {
    max-width: 440px;
}
.auth-choice-card {
    min-height: 92px;
    padding: 13px;
    box-shadow: none;
}
.auth-choice-card__icon {
    width: 34px;
    height: 34px;
    border-radius: 12px;
}
.auth-choice-card__title {
    font-size: 15px;
}
.auth-form-top__label,
.auth-form-top__title {
    display: none;
}
.auth-form-top {
    justify-content: center;
    padding: 0;
}
.auth-stage-flow .auth-brand,
.auth-stage-password .auth-brand {
    display: none !important;
}
.auth-stage-flow .auth-card,
.auth-stage-password .auth-card {
    margin-top: 34px;
}
.auth-stage-flow .auth-screen.is-active,
.auth-stage-password .auth-screen.is-active {
    max-width: 520px;
    width: min(100%, 520px);
}
.auth-stage-flow .auth-step-icon {
    display: none;
}
.auth-stage-flow .auth-screen h1,
.auth-stage-password .auth-screen h1 {
    font-size: 28px;
    margin-top: 22px;
}
.auth-stage-flow .auth-lead,
.auth-stage-password .auth-lead {
    font-size: 15px;
    margin-bottom: 28px;
}
.auth-stage-flow .auth-code {
    width: min(100%, 470px);
    max-width: 470px;
    gap: 10px;
    margin-top: 0;
    margin-bottom: 24px;
}
.auth-stage-flow .auth-code__digit {
    height: 58px;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 8px 20px rgba(15,23,42,.04);
}
.auth-stage-flow .auth-btn {
    max-width: 280px;
}
.auth-stage-flow .auth-resend {
    margin-top: 16px;
}
.auth-stage-flow .auth-link--back,
.auth-stage-password .auth-link--back {
    display: inline-flex;
    margin-left: auto;
    margin-right: auto;
}
@media (max-width: 560px) {
    .auth-wrap { padding: 18px 14px 28px; }
    .auth-register-choice { grid-template-columns: 1fr; }
    .auth-stage-flow .auth-code { gap: 7px; }
    .auth-stage-flow .auth-code__digit { height: 48px; border-radius: 14px; }
    .auth-stage-flow .auth-screen h1,
    .auth-stage-password .auth-screen h1 { font-size: 24px; }
}
