/*
 * Auth pages — Mist Graphite
 * Source of design rules: /DESIGN.md
 */

:root {
    --auth-bg: #DDE2DF;
    --auth-surface: #F6F7F4;
    --auth-text: #1F2523;
    --auth-accent: #3F6656;
    --auth-muted: #5F6863;
    --auth-surface-subtle: #ECEFED;
    --auth-border: #C8D0CB;
    --auth-danger: #9A4B3F;
    --auth-warning: #7D6028;
    --auth-shadow: 0 20px 60px rgba(31, 37, 35, 0.08);
    --auth-radius-sm: 6px;
    --auth-radius-md: 12px;
    --auth-radius-lg: 18px;
    --auth-radius-xl: 28px;
    --auth-font-heading: "Manrope", "IBM Plex Sans", system-ui, sans-serif;
    --auth-font-ui: "IBM Plex Sans", system-ui, sans-serif;
    --auth-font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

body.ldr-login-page,
body.ldr-register-page,
body.ldr-change-password-page {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    background:
        radial-gradient(circle at 12% 8%, rgba(63, 102, 86, 0.13), transparent 32rem),
        radial-gradient(circle at 88% 88%, rgba(31, 37, 35, 0.08), transparent 28rem),
        var(--auth-bg);
    color: var(--auth-text);
    font-family: var(--auth-font-ui);
    scrollbar-color: rgba(63, 102, 86, 0.72) rgba(31, 37, 35, 0.10);
    scrollbar-width: thin;
}

html:has(body.ldr-login-page),
html:has(body.ldr-register-page),
html:has(body.ldr-change-password-page) {
    background: var(--auth-bg);
}

body.ldr-login-page::-webkit-scrollbar,
body.ldr-register-page::-webkit-scrollbar,
body.ldr-change-password-page::-webkit-scrollbar,
.ldr-auth-form-panel::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

body.ldr-login-page::-webkit-scrollbar-track,
body.ldr-register-page::-webkit-scrollbar-track,
body.ldr-change-password-page::-webkit-scrollbar-track,
.ldr-auth-form-panel::-webkit-scrollbar-track {
    background: rgba(31, 37, 35, 0.08);
}

body.ldr-login-page::-webkit-scrollbar-thumb,
body.ldr-register-page::-webkit-scrollbar-thumb,
body.ldr-change-password-page::-webkit-scrollbar-thumb,
.ldr-auth-form-panel::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: rgba(63, 102, 86, 0.72);
    background-clip: padding-box;
}

body.ldr-login-page::-webkit-scrollbar-thumb:hover,
body.ldr-register-page::-webkit-scrollbar-thumb:hover,
body.ldr-change-password-page::-webkit-scrollbar-thumb:hover,
.ldr-auth-form-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(31, 37, 35, 0.86);
    background-clip: padding-box;
}

body.ldr-login-page *,
body.ldr-register-page *,
body.ldr-change-password-page * {
    box-sizing: border-box;
}

.ldr-auth-page-shell {
    width: min(1120px, calc(100% - 32px));
    min-height: calc(100vh - 32px);
    margin: 16px auto;
    display: grid;
    gap: 16px;
    align-items: stretch;
}

.ldr-auth-page-shell-wide {
    width: min(1180px, calc(100% - 32px));
}

.ldr-auth-brand-panel,
.ldr-auth-form-panel {
    position: relative;
    overflow: hidden;
    border-radius: var(--auth-radius-xl);
}

.ldr-auth-brand-panel {
    min-height: 280px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background: var(--auth-text);
    color: var(--auth-surface);
    isolation: isolate;
}

.ldr-auth-brand-panel::before,
.ldr-auth-brand-panel::after {
    content: "";
    position: absolute;
    border-radius: 999px;
    z-index: -1;
}

.ldr-auth-brand-panel::before {
    width: 280px;
    height: 280px;
    right: -80px;
    top: -70px;
    background: rgba(63, 102, 86, 0.62);
}

.ldr-auth-brand-panel::after {
    width: 190px;
    height: 190px;
    left: -54px;
    bottom: 32px;
    border: 1px solid rgba(246, 247, 244, 0.18);
}

.ldr-auth-brand-mark {
    width: 56px;
    height: 56px;
    margin-bottom: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--auth-radius-lg);
    background: rgba(246, 247, 244, 0.10);
    color: var(--auth-surface);
    font-size: 1.35rem;
}

.ldr-auth-kicker {
    margin: 0 0 12px;
    color: var(--auth-accent);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ldr-auth-brand-panel .ldr-auth-kicker {
    color: rgba(246, 247, 244, 0.74);
}

.ldr-auth-brand-panel h1,
.ldr-auth-form-header h2 {
    margin: 0;
    font-family: var(--auth-font-heading);
    letter-spacing: -0.04em;
    color: inherit;
}

.ldr-auth-brand-panel h1 {
    max-width: 640px;
    font-size: clamp(2.3rem, 8vw, 4.8rem);
    line-height: 0.95;
}

.ldr-auth-lead {
    max-width: 560px;
    margin: 20px 0 0;
    color: rgba(246, 247, 244, 0.76);
    font-size: clamp(1rem, 2vw, 1.18rem);
    line-height: 1.55;
}

.ldr-auth-proof-list {
    display: grid;
    gap: 12px;
    margin-top: 32px;
}

.ldr-auth-proof-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    max-width: 620px;
    color: rgba(246, 247, 244, 0.78);
    line-height: 1.45;
}

.ldr-auth-proof-item i {
    width: 20px;
    margin-top: 3px;
    color: rgba(246, 247, 244, 0.7);
}

.ldr-auth-form-panel {
    padding: 28px;
    background: var(--auth-surface);
    box-shadow: var(--auth-shadow);
}

.ldr-auth-mobile-compact {
    display: none;
}

.ldr-auth-form-header {
    margin-bottom: 24px;
}

.ldr-auth-form-header h2 {
    font-size: clamp(1.8rem, 6vw, 2.55rem);
    line-height: 1.05;
    color: var(--auth-text);
}

.ldr-auth-form-header p:not(.ldr-auth-kicker) {
    margin: 12px 0 0;
    color: var(--auth-muted);
    line-height: 1.5;
}

.ldr-auth-security-note,
.ldr-security-warning,
.ldr-danger-alert,
.ldr-password-requirements,
.ldr-acknowledge-box,
.ldr-browser-hint {
    border-radius: var(--auth-radius-lg);
    background: var(--auth-surface-subtle);
}

.ldr-auth-security-note,
.ldr-security-warning,
.ldr-danger-alert {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 16px;
    margin-bottom: 22px;
    color: var(--auth-muted);
    line-height: 1.5;
}

.ldr-auth-security-note i,
.ldr-security-warning i,
.ldr-danger-alert i {
    margin-top: 3px;
    color: var(--auth-accent);
}

.ldr-auth-security-note strong,
.ldr-security-warning strong,
.ldr-danger-alert strong {
    display: block;
    margin-bottom: 3px;
    color: var(--auth-text);
    font-weight: 700;
}

.ldr-auth-security-note span {
    display: block;
}

.ldr-auth-security-note-warning i,
.ldr-security-warning i {
    color: var(--auth-warning);
}

.ldr-danger-alert {
    background: rgba(154, 75, 63, 0.09);
    color: var(--auth-text);
}

.ldr-danger-alert i,
.ldr-danger-alert strong {
    color: var(--auth-danger);
}

.alert {
    position: relative;
    margin-bottom: 14px;
    padding: 14px 44px 14px 16px;
    border-radius: var(--auth-radius-md);
    background: rgba(125, 96, 40, 0.10);
    color: var(--auth-text);
}

.alert-success {
    background: rgba(63, 102, 86, 0.12);
}

.alert-info {
    background: rgba(31, 37, 35, 0.08);
}

.btn-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: auto;
    height: auto;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    opacity: 0.55;
}

.btn-close:hover {
    opacity: 1;
}

.ldr-auth-form {
    display: grid;
    gap: 18px;
}

.form-group {
    margin: 0;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--auth-text);
    font-size: 0.92rem;
    font-weight: 700;
}

.form-group small {
    display: block;
    margin-top: 8px;
    color: var(--auth-muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

.ldr-form-control {
    width: 100%;
    min-height: 48px;
    padding: 13px 14px;
    border: 1px solid transparent;
    border-radius: var(--auth-radius-md);
    background: var(--auth-surface-subtle);
    color: var(--auth-text);
    font: 1rem/1.4 var(--auth-font-ui);
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.ldr-form-control::placeholder {
    color: rgba(95, 104, 99, 0.78);
}

.ldr-form-control:focus {
    outline: 3px solid rgba(63, 102, 86, 0.32);
    outline-offset: 2px;
    border-color: var(--auth-accent);
    background: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(63, 102, 86, 0.16);
}

.ldr-form-control.is-invalid {
    border-color: var(--auth-danger);
    box-shadow: 0 0 0 3px rgba(154, 75, 63, 0.12);
}

.ldr-form-control.is-valid {
    border-color: rgba(63, 102, 86, 0.62);
}

.ldr-error-message {
    display: none;
    margin-top: 8px;
    color: var(--auth-danger);
    font-size: 0.9rem;
    line-height: 1.35;
}

.ldr-error-message.show {
    display: block;
}

.ldr-checkbox-label {
    display: flex;
    gap: 12px;
    align-items: center;
    min-height: 44px;
    color: var(--auth-muted);
    font-size: 0.95rem;
    line-height: 1.45;
    cursor: pointer;
}

.ldr-checkbox-label input[type="checkbox"] {
    width: 22px;
    height: 22px;
    margin: 0;
    flex: 0 0 auto;
    accent-color: var(--auth-accent);
}

.ldr-checkbox-label:focus-within {
    border-radius: var(--auth-radius-sm);
    outline: 3px solid rgba(63, 102, 86, 0.20);
    outline-offset: 3px;
}

.ldr-checkbox-label strong {
    color: var(--auth-danger);
    font-weight: 700;
}

.ldr-remember-row {
    margin-top: -2px;
}

.btn {
    width: 100%;
    min-height: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 13px 18px;
    border: 0;
    border-radius: var(--auth-radius-md);
    background: var(--auth-accent);
    color: #FFFFFF;
    font: 700 1rem/1.2 var(--auth-font-ui);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.16s ease, transform 0.16s ease;
}

.btn:hover {
    background: var(--auth-text);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:focus-visible,
.ldr-auth-links a:focus-visible,
.btn-close:focus-visible,
.ldr-checkbox-label input[type="checkbox"]:focus-visible {
    outline: 3px solid rgba(63, 102, 86, 0.28);
    outline-offset: 3px;
}

.ldr-auth-links {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--auth-border);
    color: var(--auth-muted);
    text-align: center;
}

.ldr-auth-links p {
    margin: 0 0 14px;
}

.ldr-auth-links a {
    color: var(--auth-accent);
    font-weight: 700;
    text-decoration: none;
}

.ldr-auth-links a:hover {
    color: var(--auth-text);
}

.ldr-browser-hint {
    display: inline-flex;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    color: var(--auth-muted);
    font-size: 0.9rem;
    text-align: left;
}

.ldr-password-requirements {
    padding: 16px;
    color: var(--auth-muted);
}

.ldr-password-requirements strong {
    display: block;
    margin-bottom: 10px;
    color: var(--auth-text);
}

.ldr-password-requirements ul {
    margin: 0;
    padding-left: 20px;
}

.ldr-password-requirements li {
    margin: 0 0 6px;
    line-height: 1.45;
}

.ldr-acknowledge-box {
    padding: 16px;
    background: rgba(154, 75, 63, 0.08);
}

.ldr-checkbox-label.is-invalid span {
    color: var(--auth-danger);
}

.ldr-password-strength {
    height: 6px;
    margin-top: 10px;
    border-radius: 999px;
    background: var(--auth-border);
    overflow: hidden;
}

.ldr-password-strength::before {
    content: "";
    display: block;
    height: 100%;
    width: 33%;
    border-radius: inherit;
    background: var(--auth-danger);
}

.ldr-password-strength.ldr-strength-medium::before {
    width: 66%;
    background: var(--auth-warning);
}

.ldr-password-strength.ldr-strength-strong::before {
    width: 100%;
    background: var(--auth-accent);
}

/* Legacy change-password page keeps existing structure but receives the same palette. */
body.ldr-change-password-page {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ldr-change-password-container {
    width: min(450px, calc(100% - 32px));
    padding: 28px;
    border-radius: var(--auth-radius-xl);
    background: var(--auth-surface);
    box-shadow: var(--auth-shadow);
}

.ldr-change-password-header {
    margin-bottom: 24px;
    text-align: center;
}

.ldr-change-password-header h1 {
    margin: 0 0 8px;
    color: var(--auth-text);
    font-family: var(--auth-font-heading);
    letter-spacing: -0.03em;
}

.ldr-change-password-header p,
.ldr-process-info {
    color: var(--auth-muted);
}

.ldr-warning-box,
.ldr-process-info {
    padding: 14px;
    margin-bottom: 18px;
    border-radius: var(--auth-radius-md);
    background: var(--auth-surface-subtle);
}

@media (min-width: 900px) {
    .ldr-auth-page-shell {
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        margin: 0;
        grid-template-columns: minmax(0, 2fr) minmax(360px, 1fr);
        gap: 0;
    }

    .ldr-auth-page-shell-wide {
        grid-template-columns: minmax(0, 0.9fr) minmax(430px, 0.82fr);
    }

    .ldr-auth-brand-panel,
    .ldr-auth-form-panel {
        min-height: 100vh;
        min-height: 100dvh;
        border-radius: 0;
        padding: clamp(40px, 4.5vw, 72px);
    }

    .ldr-auth-brand-panel {
        justify-content: center;
    }

    .ldr-auth-form-panel {
        align-self: stretch;
        display: flex;
        flex-direction: column;
        justify-content: center;
        overflow-y: auto;
        box-shadow: -18px 0 44px rgba(31, 37, 35, 0.07);
    }

    .ldr-auth-form-header,
    .ldr-auth-security-note,
    .ldr-auth-alerts,
    .ldr-auth-form,
    .ldr-auth-links {
        width: 100%;
        max-width: 430px;
        margin-left: auto;
        margin-right: auto;
    }
}

@media (max-width: 640px) {
    :root {
        --mobile-auth-density: clamp(0.92, calc(100dvh / 780), 1);
        --mobile-auth-edge: clamp(18px, 5vw, 24px);
    }

    body.ldr-login-page,
    body.ldr-register-page {
        min-height: 100dvh;
        height: auto;
        overflow-x: hidden;
        overflow-y: auto;
        background:
            radial-gradient(circle at 50% 0%, rgba(63, 102, 86, 0.10), transparent 22rem),
            var(--auth-bg);
    }

    .ldr-auth-page-shell {
        width: 100%;
        min-height: 100dvh;
        height: auto;
        margin: 0;
        display: grid;
        grid-template-rows: 1fr;
        place-items: start center;
        gap: 0;
        padding:
            max(env(safe-area-inset-top), 16px)
            var(--mobile-auth-edge)
            max(env(safe-area-inset-bottom), 16px);
        background: transparent;
    }

    .ldr-auth-brand-panel {
        display: none;
    }

    .ldr-auth-form-panel {
        width: min(100%, 420px);
        max-height: none;
        min-height: auto;
        margin: 16px auto;
        padding: clamp(24px, 6vw, 32px);
        display: flex;
        flex-direction: column;
        justify-content: center;
        overflow: visible;
        overscroll-behavior: contain;
        border: 1px solid var(--auth-border);
        border-radius: 24px;
        background: rgba(246, 247, 244, 0.94);
        box-shadow: 0 18px 50px rgba(31, 37, 35, 0.12);
    }

    .ldr-auth-mobile-compact {
        display: block;
        margin: 0 0 10px;
        color: var(--auth-accent);
        font-size: 0.88rem;
        font-weight: 800;
        letter-spacing: 0.10em;
        text-transform: uppercase;
    }

    .ldr-auth-form-header {
        margin-bottom: 24px;
    }

    .ldr-auth-form-header .ldr-auth-kicker,
    .ldr-auth-form-header p:not(.ldr-auth-kicker),
    .ldr-auth-security-note,
    .ldr-security-warning,
    .ldr-danger-alert,
    .ldr-browser-hint,
    .form-group small,
    .ldr-password-requirements {
        display: none;
    }

    .ldr-auth-form-header h2 {
        font-size: clamp(1.45rem, 6vw, 1.9rem);
        line-height: 1.12;
        letter-spacing: -0.035em;
    }

    .ldr-auth-form {
        gap: 18px;
    }

    .form-group {
        margin-bottom: 0;
    }

    .form-group label {
        margin-bottom: 8px;
        color: var(--auth-text);
        font-size: 0.94rem;
        font-weight: 650;
    }

    .ldr-form-control {
        height: 54px;
        min-height: 54px;
        padding: 0 16px;
        border: 1px solid var(--auth-border);
        border-radius: 14px;
        background: #FFFFFF;
        color: var(--auth-text);
        font-size: 16px;
        line-height: 1.2;
    }

    .ldr-form-control:focus {
        border-color: var(--auth-accent);
        box-shadow: 0 0 0 4px rgba(63, 102, 86, 0.14);
    }

    .ldr-checkbox-label {
        gap: 11px;
        font-size: 0.96rem;
        line-height: 1.35;
    }

    .ldr-checkbox-label input[type="checkbox"] {
        width: 22px;
        height: 22px;
    }

    .ldr-acknowledge-box {
        padding: 12px;
        border-radius: 14px;
    }

    .btn {
        height: 54px;
        min-height: 54px;
        padding: 0 18px;
        border-radius: 14px;
        font-size: 1rem;
        font-weight: 750;
        box-shadow: 0 10px 24px rgba(63, 102, 86, 0.22);
    }

    .ldr-auth-links {
        margin-top: 22px;
        padding-top: 18px;
    }

    .ldr-auth-links p {
        margin-bottom: 0;
        font-size: 0.96rem;
    }

    .alert {
        margin-bottom: 14px;
        padding: 12px 40px 12px 14px;
        font-size: 0.92rem;
    }

    .ldr-password-strength {
        height: 5px;
        margin-top: 8px;
    }
}

@media (max-width: 640px) and (max-height: 760px) {
    .ldr-auth-form-panel {
        padding: 22px;
    }

    .ldr-auth-form-header {
        margin-bottom: 18px;
    }

    .ldr-auth-form-header h2 {
        font-size: 1.38rem;
    }

    .ldr-auth-form {
        gap: 14px;
    }

    .ldr-form-control,
    .btn {
        height: 50px;
        min-height: 50px;
    }

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