:root {
    --auth-bg: #f7f8fb;
    --auth-surface: #ffffff;
    --auth-surface-soft: #f3f5f8;
    --auth-text: #111827;
    --auth-muted: #667085;
    --auth-border: #d9dee7;
    --auth-primary: #2563eb;
    --auth-primary-hover: #1d4ed8;
    --auth-primary-soft: #eff6ff;
    --auth-success: #16a34a;
    --auth-radius: 8px;
}

html {
    font-size: 14px;
    letter-spacing: 0;
}

body.auth-shell {
    min-height: 100vh;
    margin: 0;
    color: var(--auth-text);
    background: var(--auth-bg);
    font-family: "Noto Sans SC", "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 32px 14px;
}

.auth-card {
    width: min(100%, 420px);
    padding: 24px;
    background: var(--auth-surface);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
}

.brand-header {
    margin-bottom: 20px;
    text-align: center;
}

.auth-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-bottom: 12px;
    color: #ffffff;
    background: var(--auth-primary);
    border-radius: var(--auth-radius);
    font-size: 1.15rem;
}

.auth-title {
    margin: 0 0 6px;
    color: var(--auth-text);
    font-size: 1.35rem;
    font-weight: 900;
    line-height: 1.3;
}

.auth-subtitle {
    margin: 0;
    color: var(--auth-muted);
    font-size: 0.94rem;
    line-height: 1.55;
}

.form-floating > .form-control,
.form-floating > .form-control-plaintext {
    min-height: 48px;
    color: var(--auth-text);
    background: var(--auth-surface);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
}

.form-floating > label {
    color: var(--auth-muted);
}

.form-control:focus {
    color: var(--auth-text);
    background: var(--auth-surface);
    border-color: var(--auth-primary);
    box-shadow: 0 0 0 3px #dbeafe;
}

.auth-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 14px 0 16px;
}

.form-check {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 24px;
    margin: 0;
    padding: 0;
    color: var(--auth-muted);
    font-size: 0.92rem;
}

.form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--auth-primary);
    cursor: pointer;
}

.form-check label {
    cursor: pointer;
    user-select: none;
}

.btn {
    border-radius: var(--auth-radius) !important;
    font-weight: 700;
}

.btn-primary,
.auth-submit {
    min-height: 44px;
    color: #ffffff;
    background: var(--auth-primary);
    border-color: var(--auth-primary);
}

.btn-primary:hover,
.auth-submit:hover {
    color: #ffffff;
    background: var(--auth-primary-hover);
    border-color: var(--auth-primary-hover);
}

.btn-outline-primary {
    color: var(--auth-primary);
    border-color: var(--auth-border);
    background: var(--auth-surface);
}

.btn-outline-primary:hover {
    color: #ffffff;
    background: var(--auth-primary);
    border-color: var(--auth-primary);
}

.auth-code-btn {
    min-height: 48px;
    padding: 0 8px;
    white-space: nowrap;
}

.btn-gradient {
    color: #ffffff;
    background: var(--auth-primary);
    border-color: var(--auth-primary);
}

.text-link {
    color: var(--auth-primary);
    text-decoration: none;
    font-weight: 700;
}

.text-link:hover {
    color: var(--auth-primary-hover);
    text-decoration: underline;
}

.divider {
    position: relative;
    text-align: center;
    color: var(--auth-muted);
}

.divider::before,
.divider::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--auth-border);
}

.divider::before {
    left: 0;
}

.divider::after {
    right: 0;
}

.image-code,
.prompt-image-code {
    width: 100%;
    height: 48px;
    object-fit: contain;
    cursor: pointer;
    background: var(--auth-surface-soft);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
}

.prompt-image-code {
    max-width: 260px;
}

a {
    text-decoration: none;
}

@media (max-width: 575.98px) {
    html {
        font-size: 13px;
    }

    .auth-wrapper {
        align-items: flex-start;
        padding-top: 24px;
    }

    .auth-card {
        padding: 18px;
    }

    .auth-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }
}

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

/* BestCodex Design System v2 */
body.auth-shell {
    color: var(--bc-text);
    background: var(--bc-bg);
    font-family: var(--bc-font-sans);
    font-size: var(--bc-text-md);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.auth-wrapper {
    min-height: 100dvh;
    padding: clamp(24px, 5vw, 56px) 16px;
}

.auth-card {
    position: relative;
    width: min(100%, 448px);
    padding: 28px;
    background: var(--bc-surface);
    border: 1px solid var(--bc-border);
    border-top: 3px solid var(--bc-primary);
    border-radius: var(--bc-radius);
    box-shadow: var(--bc-shadow-sm);
}

.brand-header {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    column-gap: 14px;
    align-items: center;
    margin-bottom: 24px;
    text-align: left;
}

.auth-brand-mark {
    grid-row: 1 / span 2;
    width: 44px;
    height: 44px;
    margin: 0;
    color: #ffffff;
    background: var(--bc-slate-900);
    border-radius: var(--bc-radius);
    box-shadow: none;
    font-size: 18px;
}

.auth-title {
    margin: 0;
    color: var(--bc-foreground);
    font-size: var(--bc-text-xl);
    font-weight: 800;
    letter-spacing: 0;
    line-height: var(--bc-leading-tight);
}

.auth-subtitle {
    margin: 4px 0 0;
    color: var(--bc-muted);
    font-size: var(--bc-text-sm);
    line-height: var(--bc-leading-normal);
}

.form-floating {
    position: relative;
}

.form-floating > .form-control,
.form-floating > .form-control-plaintext {
    min-height: 48px;
    color: var(--bc-text);
    background: #ffffff;
    border: 1px solid var(--bc-border);
    border-radius: var(--bc-radius);
    box-shadow: none;
}

.form-floating > .form-control:hover {
    border-color: var(--bc-slate-300);
}

.form-floating > .form-control:focus,
.form-control:focus {
    color: var(--bc-text);
    background: #ffffff;
    border-color: var(--bc-primary);
    box-shadow: 0 0 0 3px var(--bc-ring);
}

.form-floating > label,
.form-floating > .form-label {
    color: var(--bc-muted);
    font-weight: 500;
}

.auth-row {
    margin: 16px 0 18px;
}

.form-check {
    color: var(--bc-muted);
    font-size: var(--bc-text-sm);
}

.form-check input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: var(--bc-primary);
}

.btn,
.btn-lg {
    border-radius: var(--bc-radius) !important;
    font-weight: 700;
    letter-spacing: 0;
}

.btn-primary,
.auth-submit {
    min-height: var(--bc-button-height-lg);
    color: #ffffff;
    background: var(--bc-primary);
    border-color: var(--bc-primary);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

.btn-primary:hover,
.auth-submit:hover {
    color: #ffffff;
    background: var(--bc-primary-hover);
    border-color: var(--bc-primary-hover);
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
    transform: translateY(-1px);
}

.btn-primary:active,
.auth-submit:active {
    transform: translateY(0);
}

.btn-outline-primary,
.auth-code-btn {
    color: var(--bc-primary);
    background: #ffffff;
    border-color: var(--bc-border);
    box-shadow: none;
}

.btn-outline-primary:hover,
.auth-code-btn:hover {
    color: var(--bc-primary-hover);
    background: var(--bc-primary-soft);
    border-color: #bfccdc;
}

.text-link {
    color: var(--bc-primary);
    font-weight: 700;
    text-decoration: none;
}

.text-link:hover {
    color: var(--bc-primary-hover);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.image-code,
.prompt-image-code {
    height: 48px;
    background: var(--bc-slate-50);
    border: 1px solid var(--bc-border);
    border-radius: var(--bc-radius);
}

.divider {
    color: var(--bc-muted);
}

.divider::before,
.divider::after {
    background: var(--bc-border-soft);
}

@media (max-width: 575.98px) {
    body.auth-shell {
        font-size: 14px;
    }

    .auth-wrapper {
        align-items: flex-start;
        padding: 18px 12px;
    }

    .auth-card {
        padding: 22px 18px;
        box-shadow: var(--bc-shadow-xs);
    }

    .brand-header {
        grid-template-columns: 40px minmax(0, 1fr);
        column-gap: 12px;
        margin-bottom: 20px;
    }

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

    .auth-title {
        font-size: 20px;
    }
}
