/* Auth surfaces stay dark to match the embedded security verification. */
.hg-login {
    --login-background: #121212;
    --login-surface: #1b1a19;
    --login-field: #222120;
    --login-raised: #2b2928;
    --login-text: #f2efed;
    --login-muted: #b8b2ae;
    --login-subtle: #a49e99;
    --login-line: rgb(242 239 237 / 10%);
    --login-control-line: #73706d;
    --login-accent: #ff8068;
    --login-accent-hover: #ff9b88;
    --login-accent-ink: #160e0c;
    --login-error: #ffa398;
    --login-control-radius: 8px;
    --login-panel-radius: 16px;
    --login-focus-offset: 2px;
    --login-easing: cubic-bezier(.22, 1, .36, 1);

    --theme-base: var(--login-text);
    --theme-dark-base: var(--login-text);
    --theme-muted: var(--login-muted);
    --theme-dark-muted: var(--login-muted);
    --theme-primary: var(--login-accent);
    --theme-neutral: var(--login-control-line);
    --theme-background-secondary: var(--login-surface);
    --color-primary: var(--theme-primary);
    --color-base: var(--theme-base);
    --color-neutral: var(--theme-neutral);

    min-height: calc(100svh - 60px);
    padding: 20px 24px 40px;
    background: var(--login-background);
    color: var(--login-text);
    color-scheme: dark;
    font-family: var(--hg-font-sans, Manrope, system-ui, sans-serif);
}

html:has(.hg-login),
html body:has(.hg-login),
body:has(.hg-login) > .hg-legal-footer {
    background: #121212;
}

body:has(.hg-login) > .hg-legal-footer {
    color: #b8b2ae;
}

body:has(.hg-login) .hg-legal-footer a {
    color: inherit;
}

.hg-login .hg-login-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    max-width: 1120px;
    margin: 0 auto 24px;
}

.hg-login .hg-login-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--login-text);
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
}

.hg-login .hg-login-brand img {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
}

.hg-login .hg-login-back {
    color: var(--login-muted);
    font-size: .875rem;
    line-height: 20px;
    text-align: end;
}

.hg-login-frame {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    max-width: 560px;
    margin-inline: auto;
    overflow: hidden;
    background: var(--login-surface);
    border: 1px solid var(--login-line);
    border-radius: var(--login-panel-radius);
}

.hg-login-content {
    display: grid;
    align-self: center;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    width: 100%;
    min-width: 0;
    padding: 20px;
}

html body .hg-login :is(.hg-login-panel h1, .hg-login-art-copy h2, .petal-form-label,
                         .petal-auth-primary, .petal-auth-provider, [data-passkey-login]) {
    font-family: var(--hg-font-sans, Manrope, system-ui, sans-serif) !important;
}

html body .hg-login .hg-login-panel > h1 {
    margin: 0;
    color: var(--login-text);
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 36px;
    letter-spacing: normal;
    overflow-wrap: anywhere;
}

.hg-login-panel > h1 + p {
    margin: 8px 0 20px;
    color: var(--login-muted);
    font-size: .9375rem;
    line-height: 24px;
}

.hg-login-art {
    display: none;
    min-width: 0;
    background: #171716;
}

.hg-login-art img {
    display: block;
    width: min(82%, 440px);
    height: auto;
    object-fit: contain;
}

.hg-login .hg-login-content form[data-petal-auth-form] {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.hg-login #login > fieldset > label {
    margin-bottom: 4px;
}

.hg-login #login [data-passkey-status]:empty {
    display: none;
}

.hg-login .petal-form-label {
    color: var(--login-text) !important;
    font-size: .8125rem;
    font-weight: 500;
    line-height: 20px;
}

html body .hg-login .hg-login-content .petal-form-input-base {
    min-height: 44px;
    padding: 8px 12px !important;
    border: 1px solid var(--login-control-line) !important;
    border-radius: var(--login-control-radius) !important;
    background: var(--login-field) !important;
    color: var(--login-text) !important;
    font-size: 1rem !important;
    line-height: 24px;
    box-shadow: none !important;
}

html body .hg-login .hg-login-content .petal-form-input-base::placeholder {
    color: var(--login-subtle);
    opacity: 1;
}

html body .hg-login .hg-login-content .petal-form-input-base:not(:focus) {
    text-overflow: ellipsis;
}

html body .hg-login .hg-login-content .petal-form-input-base:focus {
    border-color: var(--login-accent) !important;
    outline: 2px solid var(--login-accent) !important;
    outline-offset: var(--login-focus-offset);
}

html body .hg-login .hg-login-content .petal-form-input-base[aria-invalid="true"] {
    border-color: var(--login-error) !important;
}

html body .hg-login .hg-login-content .petal-form-input-base:autofill {
    box-shadow: 0 0 0 100px var(--login-field) inset !important;
    -webkit-text-fill-color: var(--login-text);
}

.hg-login :is(.petal-form-error, [data-hg-identity-error], .otp-field__error) {
    color: var(--login-error) !important;
}

.hg-login .petal-auth-options {
    flex-wrap: wrap;
    gap: 4px 12px;
    justify-content: space-between;
    min-height: 24px;
}

.hg-login .petal-auth-options > a {
    margin-inline-start: 0;
}

.hg-login .petal-form-checkbox {
    accent-color: var(--login-accent);
}

.hg-login .petal-form-checkbox:checked {
    background-color: var(--login-accent) !important;
    border-color: var(--login-accent) !important;
}

.hg-login .petal-auth-link {
    color: var(--login-accent) !important;
    font-size: .875rem;
    text-underline-offset: 3px;
}

html body .hg-login .hg-login-content :is(.petal-auth-primary, [data-passkey-login], .petal-auth-provider) {
    min-height: 44px;
    padding: 8px 16px;
    border-radius: var(--login-control-radius) !important;
    font-size: .875rem;
    font-weight: 600;
    line-height: 20px;
    text-align: center;
    box-shadow: none !important;
    transform: none !important;
    transition: background-color 140ms var(--login-easing), color 140ms var(--login-easing),
        border-color 140ms var(--login-easing);
}

html body .hg-login .hg-login-content .petal-auth-primary {
    border: 1px solid transparent !important;
    background: var(--login-accent) !important;
    color: var(--login-accent-ink) !important;
}

html body .hg-login .hg-login-content .petal-auth-primary:hover:not(:disabled) {
    background: var(--login-accent-hover) !important;
}

html body .hg-login .hg-login-content :is([data-passkey-login], .petal-auth-provider) {
    border: 1px solid var(--login-control-line) !important;
    background: var(--login-field) !important;
    color: var(--login-text) !important;
}

html body .hg-login .hg-login-content [data-passkey-login]:hover:not(:disabled),
html body .hg-login .hg-login-content .petal-auth-provider:hover {
    background: var(--login-raised) !important;
}

.hg-login .petal-auth-provider img:first-child {
    display: none;
}

.hg-login .petal-auth-provider img:nth-child(2) {
    display: inline-block;
}

.hg-login :is([data-passkey-status], .petal-auth-oauth .text-xs, .otp-field__hint) {
    color: var(--login-muted);
}

.hg-login :is([data-passkey-scope], .petal-auth-oauth) {
    margin-top: 0;
}

.hg-login :is(a, button, input[type="checkbox"], input[type="radio"], summary):focus-visible {
    outline: 2px solid var(--login-accent) !important;
    outline-offset: var(--login-focus-offset);
}

html body .hg-login .hg-login-content .otp-field__input {
    max-width: none;
    min-height: 44px;
    border: 1px solid var(--login-control-line);
    border-radius: var(--login-control-radius) !important;
    background: var(--login-field);
    color: var(--login-text);
}

html body .hg-login .hg-login-content .otp-field__input:focus {
    outline: 2px solid var(--login-accent) !important;
    outline-offset: var(--login-focus-offset);
}

.hg-login .hg-auth-languages {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: .875rem;
    line-height: 20px;
    color: var(--login-muted);
}

.hg-auth-languages a[aria-current] {
    color: var(--login-text);
    font-weight: 600;
}

.hg-auth-languages a:not([aria-current]) {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.hg-login--centered {
    min-height: 100svh;
    padding: 0;
}

.hg-login--centered .hg-login-frame {
    min-height: 100svh;
    max-width: none;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.hg-login--centered .hg-login-content {
    align-self: stretch;
    grid-template-rows: auto minmax(min-content, 1fr) auto;
    width: min(100%, 504px);
    margin-inline: auto;
    padding: 16px 16px max(20px, env(safe-area-inset-bottom));
}

.hg-login--centered .hg-login-header {
    margin: 0;
    max-width: none;
}

.hg-login--centered .hg-login-panel {
    align-self: start;
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--login-line);
    border-radius: var(--login-panel-radius);
    background: var(--login-surface);
}

.hg-login--centered .hg-login-content #login {
    row-gap: 12px;
}

.hg-login--centered .hg-login-method-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--login-subtle);
    font-size: .8125rem;
    line-height: 16px;
}

.hg-login--centered .hg-login-method-divider::before,
.hg-login--centered .hg-login-method-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--login-line);
}

.hg-login--centered .hg-login-help {
    margin: 16px 0 0;
    color: var(--login-muted);
    font-size: .875rem;
    line-height: 20px;
}

.hg-login--centered .hg-login-bottom {
    display: grid;
    gap: 12px;
    padding-block-start: 12px;
    border-block-start: 1px solid var(--login-line);
}

.hg-login--centered .hg-login-bottom .hg-legal-footer {
    padding: 0 !important;
    color: var(--login-muted);
    background: transparent;
}

.hg-login--centered .hg-login-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 12px;
}

.hg-login--centered .petal-auth-providers {
    grid-template-columns: minmax(0, 1fr);
}

.hg-login--centered .hg-login-otp .otp-field__input {
    padding-inline: 12px;
    letter-spacing: .38em;
    font-variant-numeric: tabular-nums;
}

.hg-login--centered .hg-login-otp .otp-field__input::placeholder {
    color: var(--login-muted);
    opacity: 1;
}

.hg-login--centered .hg-login-recovery {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--login-line);
}

.hg-login--centered .hg-login-recovery summary {
    cursor: pointer;
    color: var(--login-accent);
    font-size: .875rem;
    font-weight: 600;
}

.hg-login--centered .hg-login-recovery form {
    margin-top: 16px;
}

.hg-login--centered .hg-login-otp button:disabled {
    opacity: .7;
    cursor: wait;
}

@media (max-width: 400px) {
    .hg-login:not(.hg-login--centered) {
        padding-inline: 12px;
    }

    .hg-login:not(.hg-login--centered) .hg-login-content {
        padding-inline: 12px;
    }
}

@media (max-width: 374px) {
    .hg-login--centered .hg-login-content,
    .hg-login--centered .hg-login-panel {
        padding-inline: 12px;
    }
}

/* Leave at least 300px for the embedded flexible verification on narrow screens. */
@media (max-width: 349px) {
    .hg-login:not(.hg-login--centered),
    .hg-login--centered .hg-login-content {
        padding-inline: 8px;
    }

    .hg-login:not(.hg-login--centered) .hg-login-frame,
    .hg-login--centered .hg-login-panel {
        border: 0;
        border-radius: 0;
        background: transparent;
    }

    .hg-login:not(.hg-login--centered) .hg-login-content,
    .hg-login--centered .hg-login-panel {
        padding-inline: 0;
    }
}

@media (min-width: 640px) {
    .hg-login-content {
        padding: 32px;
    }

    .hg-login--centered .hg-login-panel {
        padding: 24px;
    }
}

@media (min-width: 1024px) {
    .hg-login:not(.hg-login--centered) {
        padding: 24px 40px 48px;
    }

    .hg-login-frame {
        grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
        max-width: 1120px;
    }

    .hg-login-content {
        padding: 40px;
    }

    html body .hg-login .hg-login-panel > h1 {
        font-size: 2rem;
        line-height: 40px;
    }

    .hg-login-art {
        display: grid;
        justify-items: center;
        align-content: start;
        padding-block: 24px 0;
        border-inline-start: 1px solid var(--login-line);
    }

    .hg-login-frame:has(#register) .hg-login-art img {
        mask-image: linear-gradient(#000 88%, transparent);
    }

    .hg-login--centered .hg-login-frame {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        max-width: none;
    }

    .hg-login--centered .hg-login-content {
        padding: 24px 24px 20px;
    }

    .hg-login--centered .hg-login-panel {
        align-self: center;
        padding: 28px;
    }

    .hg-login--centered .hg-login-art {
        align-self: start;
        grid-template-rows: auto minmax(0, 1fr);
        height: calc(100svh - 32px);
        margin: 16px 16px 16px 0;
        padding: 0;
        overflow: hidden;
        border: 1px solid var(--login-line);
        border-radius: var(--login-panel-radius);
    }

    .hg-login--centered .hg-login-art-copy {
        position: relative;
        z-index: 1;
        justify-self: stretch;
        padding: 40px 40px 16px;
    }

    .hg-login--centered .hg-login-art-copy h2 {
        max-width: 26ch;
        margin: 0;
        color: var(--login-text);
        font-size: 2rem;
        font-weight: 600;
        line-height: 40px;
        letter-spacing: normal;
        text-wrap: balance;
    }

    .hg-login--centered .hg-login-art-copy p {
        max-width: 44ch;
        margin: 12px 0 0;
        color: var(--login-muted);
        font-size: .9375rem;
        line-height: 24px;
    }

    .hg-login--centered .hg-login-art img {
        align-self: end;
        width: min(76%, 448px);
        height: 100%;
        min-height: 0;
        max-height: 560px;
        object-position: center bottom;
    }
}

.hg-login--minimal {
    --login-background: #101010;
    --login-field: #242424;
    --login-text: #f6f6f6;
    --login-muted: #aaa;
    --login-subtle: #a3a3a3;
    --login-control-line: #656565;
    --login-accent: #f6f6f6;
    --login-accent-hover: #dedede;
    --login-accent-ink: #121212;
}

html:has(.hg-login--minimal),
html body:has(.hg-login--minimal) {
    background: #101010;
}

.hg-login--minimal .hg-login-frame {
    grid-template-columns: minmax(0, 1fr);
}

.hg-login--minimal .hg-login-content {
    grid-template-rows: minmax(min-content, 1fr) auto;
    gap: 24px;
    width: min(100%, 388px);
    padding: 24px 16px max(16px, env(safe-area-inset-bottom));
}

.hg-login--minimal .hg-login-panel {
    align-self: center;
    padding: 0;
    border: 0;
    background: transparent;
}

.hg-login--minimal .hg-login-header {
    justify-content: center;
    margin-bottom: 24px;
}

.hg-login--minimal .hg-login-brand img {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
}

html body .hg-login--minimal .hg-login-panel > h1 {
    font-size: 1.375rem;
    line-height: 28px;
    text-align: center;
}

.hg-login--minimal .hg-login-panel > h1 + p {
    margin: 8px 0 24px;
    font-size: .875rem;
    line-height: 20px;
    text-align: center;
}

html body .hg-login--minimal .hg-login-forgot {
    color: var(--login-muted) !important;
    font-size: .8125rem;
}

.hg-login--minimal .hg-login-forgot:hover {
    text-decoration: underline;
}

.hg-login--minimal .hg-login-help {
    margin-top: 20px;
    text-align: center;
}

.hg-login--minimal .hg-login-bottom {
    padding: 0;
    border: 0;
}

.hg-login--minimal .hg-login-meta {
    justify-content: center;
    gap: 8px 16px;
}

.hg-login--minimal .hg-login-meta :is(a, nav) {
    font-size: .8125rem;
}

@media (max-width: 349px) {
    .hg-login--minimal .hg-login-content { padding-inline: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    html body .hg-login .hg-login-content :is(.petal-auth-primary, [data-passkey-login], .petal-auth-provider) {
        transition: none;
    }
}
