/* The member's display preferences (Account > Settings).

   Loaded by layouts.portal on every member app page, last of the shell's
   sheets. Every rule is keyed on an attribute PortalChrome's memberDisplay
   puts on <html>, so a member who never chose anything -- and every guest page,
   which carries none of them -- renders exactly as before:

     data-theme="dark"        the dark theme (a "system" choice is resolved to
                              light or dark by the layout's boot script)
     data-display-size        compact | default | large
     data-reduce-motion       present when the member turned motion off

   Also the Settings page's own pickers (.md-*): the theme cards, the accent
   swatches and the size segment. See App\Support\MemberDisplay.

   The portal's guest pages load this sheet too, for their dark theme only: see
   "guest pages" at the end, keyed on data-theme without data-theme-pref. */

/* ============================================================ pickers */

.md-fieldset {
    min-width: 0;
    margin: 0 0 22px;
    padding: 0;
    border: 0;
}

.md-legend {
    display: flex;
    align-items: center;
    gap: 6px;
    width: auto;
    margin: 0 0 10px;
    color: var(--pp-ink, #1f2a3d);
    font-size: 14px;
    font-weight: 600;
}

/* Visually hidden, still focusable and announced: the card is the control. */
.md-theme__input,
.md-swatch__input,
.md-segment__input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* --- theme cards */

.md-themes {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 8px;
}

.md-theme {
    position: relative;
    margin: 0;
    cursor: pointer;
}

.md-theme__card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    height: 100%;
    padding: 10px 10px 12px;
    border: 1.5px solid var(--pp-border, #dee5ee);
    border-radius: 14px;
    background: var(--md-card, #fff);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.md-theme:hover .md-theme__card {
    border-color: var(--pp-accent-line, #b6c4d8);
}

.md-theme__input:checked + .md-theme__card {
    border-color: var(--md-accent, var(--brand-color, #087b48));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--md-accent, var(--brand-color, #087b48)) 18%, transparent);
}

.md-theme__input:focus-visible + .md-theme__card {
    outline: 3px solid var(--md-accent, var(--brand-color, #087b48));
    outline-offset: 2px;
}

/* A miniature page: a header bar and two text lines on the theme's ground. */
.md-theme__preview {
    display: flex;
    flex-direction: column;
    gap: 6px;
    height: 64px;
    padding: 8px;
    border-radius: 9px;
    overflow: hidden;
}

.md-theme__preview--light {
    background: #f5f6fa;
    box-shadow: inset 0 0 0 1px #e4e7ee;
}

.md-theme__preview--dark {
    background: #15171c;
    box-shadow: inset 0 0 0 1px #2c313a;
}

.md-theme__preview--system {
    background: linear-gradient(115deg, #f5f6fa 0 50%, #15171c 50% 100%);
    box-shadow: inset 0 0 0 1px #c9d0db;
}

.md-theme__bar {
    width: 55%;
    height: 10px;
    border-radius: 5px;
    background: var(--brand-color, #087b48);
}

.md-theme__line {
    height: 6px;
    border-radius: 3px;
    background: #c9d0db;
}

.md-theme__preview--dark .md-theme__line {
    background: #3a404b;
}

.md-theme__preview--system .md-theme__line {
    background: linear-gradient(115deg, #c9d0db 0 50%, #3a404b 50% 100%);
}

.md-theme__line--short {
    width: 65%;
}

.md-theme__name {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 2px;
    color: var(--pp-ink, #1f2a3d);
    font-size: 14px;
    font-weight: 600;
}

.md-theme__name i {
    color: var(--pp-muted, #667085);
}

.md-theme__hint {
    color: var(--pp-muted, #667085);
    font-size: 12px;
    line-height: 1.4;
}

.md-check {
    position: absolute;
    top: 14px;
    right: 14px;
    color: var(--md-accent, var(--brand-color, #087b48));
    font-size: 18px;
    background: #fff;
    border-radius: 50%;
    opacity: 0;
    transform: scale(.6);
    transition: opacity .15s ease, transform .15s ease;
}

.md-theme__input:checked + .md-theme__card .md-check {
    opacity: 1;
    transform: none;
}

/* --- accent swatches */

.md-swatches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 10px 8px;
    margin-bottom: 8px;
}

.md-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 4px 2px;
    cursor: pointer;
}

.md-swatch__chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--swatch);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
    transition: transform .15s ease, box-shadow .15s ease;
}

/* The platform's colour, marked as the default rather than as one more hue. */
.md-swatch__chip--default {
    background:
        linear-gradient(135deg, transparent 0 46%, rgba(255, 255, 255, .85) 46% 54%, transparent 54% 100%),
        var(--swatch);
}

.md-swatch:hover .md-swatch__chip {
    transform: scale(1.08);
}

.md-swatch__tick {
    color: #fff;
    font-size: 15px;
    opacity: 0;
    transition: opacity .15s ease;
}

.md-swatch__input:checked + .md-swatch__chip {
    box-shadow:
        0 0 0 3px var(--md-card, #fff),
        0 0 0 5px var(--swatch);
}

.md-swatch__input:checked + .md-swatch__chip--default {
    background: var(--swatch);
}

.md-swatch__input:checked + .md-swatch__chip .md-swatch__tick {
    opacity: 1;
}

.md-swatch__input:focus-visible + .md-swatch__chip {
    outline: 3px solid var(--pp-ink, #1f2a3d);
    outline-offset: 5px;
}

.md-swatch__name {
    max-width: 100%;
    color: var(--pp-muted, #667085);
    font-size: 12px;
    line-height: 1.2;
    text-align: center;
    overflow-wrap: anywhere;
}

.md-swatch__input:checked ~ .md-swatch__name {
    color: var(--pp-ink, #1f2a3d);
    font-weight: 600;
}

/* --- size segment */

.md-segment {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
    padding: 4px;
    border: 1px solid var(--pp-border, #dee5ee);
    border-radius: 12px;
    background: var(--pp-surface, #f5f8fc);
}

.md-segment__option {
    margin: 0;
    cursor: pointer;
}

.md-segment__face {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 9px;
    color: var(--pp-muted, #667085);
    font-size: 14px;
    font-weight: 500;
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.md-segment__option:hover .md-segment__face {
    color: var(--pp-ink, #1f2a3d);
}

.md-segment__input:checked + .md-segment__face {
    background: var(--md-card, #fff);
    color: var(--pp-ink, #1f2a3d);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
}

.md-segment__input:focus-visible + .md-segment__face {
    outline: 3px solid var(--md-accent, var(--brand-color, #087b48));
    outline-offset: 1px;
}

.md-segment__glyph {
    font-weight: 700;
    line-height: 1;
}

.md-segment__glyph--compact { font-size: 12px; }
.md-segment__glyph--default { font-size: 15px; }
.md-segment__glyph--large { font-size: 19px; }

@media (max-width: 575.98px) {
    .md-themes {
        grid-template-columns: minmax(0, 1fr);
    }

    .md-theme__card {
        display: grid;
        grid-template-columns: 88px minmax(0, 1fr);
        grid-template-rows: auto auto;
        column-gap: 12px;
        align-items: center;
    }

    .md-theme__preview {
        grid-row: span 2;
        height: 56px;
    }

    .md-segment {
        display: flex;
        flex-wrap: nowrap;
    }

    .md-segment__option {
        flex: 1 1 0;
    }

    .md-segment__face {
        justify-content: center;
        width: 100%;
        padding: 0 8px;
    }
}

/* ======================================================= display size */

/* The open page is scaled as a whole: the portal's sheets size text in
   pixels, so a root font size would leave most of it unchanged. The rail,
   panel and header keep their size, so navigation never moves. The factor is
   named once because the portalled Select2 list below has to wear it too. */
html[data-display-size="compact"] .mx-body {
    --md-content-zoom: .9;
}

html[data-display-size="large"] .mx-body {
    --md-content-zoom: 1.12;
}

/* Zoom scales fixed lengths too, so the sheet's centred cap
   (--mx-content-max, member-app.css) would shrink on Compact and grow on Large,
   and the column would no longer line up with the trail and footer. The cap is
   divided by the same factor, so every size keeps the same column edges; a
   percentage width already resolves against the unzoomed sheet and needs no
   correction. */
html[data-display-size="compact"] .mx-body .mx-content,
html[data-display-size="large"] .mx-body .mx-content {
    zoom: var(--md-content-zoom);
    max-width: calc(var(--mx-content-max, 1440px) / var(--md-content-zoom));
}

/* Select2 draws its list at the end of <body>, outside the .mx-content the
   display size zooms. It measures the field in the zoom's own pixels and then
   writes that number onto the portalled list, where a pixel is a pixel: on
   Compact the list comes out 10% wider than its field and hangs off the page,
   on Large 12% narrower. Give the list the content's zoom so it keeps the
   field's width, and its labels wrap inside that measure. The list is also
   drawn above the field when there is no room below; anchoring the scale at
   the bottom there keeps it flush against the field instead of leaving a gap. */
html[data-display-size="compact"] .mx-body .select2-dropdown,
html[data-display-size="large"] .mx-body .select2-dropdown {
    transform: scale(var(--md-content-zoom));
    transform-origin: top left;
}

html[data-display-size="compact"] .mx-body .select2-dropdown--above,
html[data-display-size="large"] .mx-body .select2-dropdown--above {
    transform-origin: bottom left;
}

/* ===================================================== reduced motion */

html[data-reduce-motion] *,
html[data-reduce-motion] *::before,
html[data-reduce-motion] *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
}

/* ========================================================== dark theme */

html[data-theme="dark"] {
    color-scheme: dark;
}

html[data-theme="dark"] .mx-body {
    --dk-page: color-mix(in srgb, var(--brand-color, #087b48) 4%, #111317);
    --dk-card: #1a1d23;
    --dk-raise: #22262d;
    --dk-field: #15181d;
    --dk-line: #2c313a;
    --dk-line-strong: #3b414c;
    --dk-ink: #e7e9ee;
    --dk-muted: #9ca3af;
    --dk-on-accent: #0b0d10;

    /* The accent lifted toward white so it reads as text on a dark sheet; a
       filled control takes the dark label (--dk-on-accent) instead of white. */
    --pp-blue: color-mix(in srgb, var(--brand-color, #087b48) 62%, #ffffff);
    --pp-blue-strong: color-mix(in srgb, var(--brand-color, #087b48) 48%, #ffffff);
    --pp-ink: var(--dk-ink);
    --pp-muted: var(--dk-muted);
    --pp-border: var(--dk-line);
    --pp-field-border: var(--dk-line-strong);
    --pp-surface: var(--dk-raise);
    --pp-chip: #272c35;
    --pp-accent-wash: color-mix(in srgb, var(--brand-color, #087b48) 16%, #1a1d23);
    --pp-accent-line: color-mix(in srgb, var(--brand-color, #087b48) 45%, #1a1d23);

    --ink: var(--dk-ink);
    --muted: var(--dk-muted);
    --surface: color-mix(in srgb, var(--brand-color, #087b48) 12%, #1a1d23);
    --line: var(--dk-line);
    --line-strong: var(--dk-line-strong);
    --plate: var(--dk-raise);
    --field: var(--dk-field);
    --placeholder: #6b7280;
    --accent: var(--pp-blue);

    --mx-page: var(--dk-page);
    --mx-line: var(--dk-line);

    --md-card: var(--dk-card);
    --md-accent: var(--pp-blue);

    color: var(--dk-ink);
}

html[data-theme="dark"] .mx-body .mx-main {
    background:
        radial-gradient(900px 420px at 0% -10%, color-mix(in srgb, var(--mx-brand) 12%, transparent) 0%, transparent 60%),
        var(--mx-page);
}

/* --- surfaces: the cards and sheets the light theme paints white */
html[data-theme="dark"] .mx-body :is(
    .pp-panel, .pp-card, .pp-account, .pp-tabs, .pp-sidebar, .pp-rail__card,
    .pp-tag, .pp-upload, .pp-entry__logo, .pp-photo, .pp-gallery__add, .pp-gallery__preview,
    .pp-field--media .pp-upload__frame, .pp-team-card, .pp-stats__export, .member-writer__note,
    .pp-button--ghost, .pp-btn--secondary, .pp-btn--danger,
    .mx-search-page__group, .mx-search-page__empty, .mx-user__menu, .mx-find__results,
    .card-link, .install-app, .install-app__help, .card-dismiss__menu, .card-link-modal__dialog,
    .card-link__button:not(.card-link__button--primary), .member-card,
    .inbox-row, .inbox-empty, .inbox-message, .inbox-reply, .inbox-reply-form,
    .portal-card, .card, .modal-content, .dropdown-menu, .list-group-item
) {
    background-color: var(--dk-card);
    border-color: var(--dk-line);
    color: var(--dk-ink);
}

/* Backgrounds the light theme set with the shorthand (gradients included). */
html[data-theme="dark"] .mx-body :is(.pp-panel, .pp-card, .card-link, .install-app, .portal-card) {
    background-image: none;
}

/* White plates a logo or QR code sits on stay white: the image needs it. */
html[data-theme="dark"] .mx-body :is(.pp-social__qr, .card-link__qr, .card-link-modal__qr, .pp-social__icon) {
    background: #fff;
}

html[data-theme="dark"] .mx-body :is(.pp-gallery__drop, .pp-stats__range-link.is-active, .pp-seat-meter) {
    background-color: var(--dk-raise);
    border-color: var(--dk-line-strong);
}

html[data-theme="dark"] .mx-body :is(.pp-add__trigger, .pp-empty, .pp-photo__frame, .pp-upload, .inbox-empty) {
    border-color: var(--dk-line-strong);
}

/* Contacts (portal-contacts.css) and the card page's buttons (portal-card.css)
   paint these white with a literal, which no token above can reach. */
html[data-theme="dark"] .mx-body :is(
    .contacts-stat, .contacts-search__button, .contacts-action, .contacts-cancel,
    .contacts-add--ghost, .card-btn
) {
    background-color: var(--dk-card);
    color: var(--dk-ink);
}

html[data-theme="dark"] .mx-body :is(.contacts-action, .contacts-cancel, .contacts-add--ghost):hover {
    background-color: var(--pp-accent-wash);
    color: var(--pp-blue-strong);
}

html[data-theme="dark"] .mx-body .card-btn:hover:not(:disabled) {
    background-color: var(--dk-raise);
    color: var(--pp-blue-strong);
}

html[data-theme="dark"] .mx-body .contacts-event__icon {
    background-color: var(--dk-raise);
}

html[data-theme="dark"] .mx-body .contacts-search__input {
    background-color: var(--dk-field);
    color: var(--dk-ink);
}

/* Amber "due" badge: a dark amber wash with light amber text (8.9:1). */
html[data-theme="dark"] .mx-body .contacts-badge--due {
    background-color: #3a2a0c;
    color: #fcd34d;
}

/* A captured card photo keeps its white plate: the scan needs it. */
html[data-theme="dark"] .mx-body .contacts-capture-note__image {
    background-color: #fff;
}

/* --- text that the light theme pinned to a grey */
html[data-theme="dark"] .mx-body .mx-content :is(h1, h2, h3, h4, h5, h6, label, legend, dt, th) {
    color: var(--dk-ink);
}

html[data-theme="dark"] .mx-body .mx-content :is(.text-muted, .form-text, small, .inbox-head p,
    .inbox-row__top time, .inbox-row__meta, .inbox-row__summary, .inbox-hint, .inbox-back,
    .inbox-detail__contact, .inbox-thread h3, .inbox-reply .inbox-reply__meta, .inbox-empty p, .inbox-tab) {
    color: var(--dk-muted) !important;
}

html[data-theme="dark"] .mx-body .mx-content a:not([class]) {
    color: var(--pp-blue);
}

html[data-theme="dark"] .mx-body .mx-content .inbox-tab.is-active {
    border-color: var(--pp-blue);
    color: var(--pp-blue) !important;
}

html[data-theme="dark"] .mx-body .inbox-tabs {
    border-color: var(--dk-line);
}

html[data-theme="dark"] .mx-body .mx-content :is(.table, table) {
    color: var(--dk-ink);
}

html[data-theme="dark"] .mx-body .mx-content :is(.table th, .table td, table th, table td, hr) {
    border-color: var(--dk-line);
}

/* --- filled accent controls: lifted accent, dark label */
html[data-theme="dark"] .mx-body :is(
    .pp-btn--primary, .pp-btn--primary:hover, .pp-button, .pp-button:hover,
    .mx-btn--primary, .mx-btn--primary:hover, .pp-tab.is-active, .pp-tab.is-active:hover,
    .inbox-submit, .inbox-submit:hover, .member-submit
) {
    color: var(--dk-on-accent);
}

/* The home page's buttons (portal-home.css). */
html[data-theme="dark"] .mx-body .home-btn:not(.home-btn--primary) {
    background: var(--dk-card);
}

html[data-theme="dark"] .mx-body .home-btn--primary,
html[data-theme="dark"] .mx-body .home-btn--primary:is(:hover, :focus-visible) {
    color: var(--dk-on-accent);
}

html[data-theme="dark"] .mx-body .inbox-submit {
    border-color: var(--pp-blue);
    background: var(--pp-blue);
}

html[data-theme="dark"] .mx-body .inbox-submit:hover {
    border-color: var(--pp-blue-strong);
    background: var(--pp-blue-strong);
}

html[data-theme="dark"] .mx-body .pp-tab.is-active .pp-team-count {
    background: rgba(0, 0, 0, .18);
    color: var(--dk-on-accent);
}

html[data-theme="dark"] .mx-body .pp-btn--danger:hover {
    background: #3a1d1c;
}

/* --- form fields */
html[data-theme="dark"] .mx-body .mx-content :is(.form-control, select, textarea,
    input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]):not([type="file"])),
html[data-theme="dark"] .mx-body .select2-container--default .select2-selection--single,
html[data-theme="dark"] .mx-body .select2-container--default .select2-selection--multiple {
    border-color: var(--dk-line-strong);
    background-color: var(--dk-field);
    color: var(--dk-ink);
}

html[data-theme="dark"] .mx-body .mx-content :is(.form-control, input, textarea)::placeholder {
    color: #6b7280;
}

html[data-theme="dark"] .mx-body .mx-content :is(.form-control:disabled, .form-control[readonly]) {
    background-color: var(--dk-raise);
    color: var(--dk-muted);
}

html[data-theme="dark"] .mx-body .select2-container--default .select2-selection__rendered {
    color: var(--dk-ink);
}

/* Select2 draws its dropdown at the end of <body>, outside .mx-content. */
html[data-theme="dark"] .select2-dropdown {
    border-color: var(--dk-line-strong, #3b414c);
    background: #1a1d23;
    color: #e7e9ee;
}

html[data-theme="dark"] .select2-search--dropdown .select2-search__field {
    border-color: #3b414c;
    background: #15181d;
    color: #e7e9ee;
}

html[data-theme="dark"] .select2-results__option[aria-selected="true"],
html[data-theme="dark"] .select2-results__option--selected {
    background: #272c35;
}

html[data-theme="dark"] .select2-results__option--highlighted[aria-selected],
html[data-theme="dark"] .select2-results__option--highlighted.select2-results__option--selectable {
    background: color-mix(in srgb, var(--brand-color, #087b48) 62%, #ffffff);
    color: #0b0d10;
}

html[data-theme="dark"] .mx-body .pp-switch__track {
    background: #3b414c;
}

/* --- the panel's user form (Personal, Company, Password), whose tokens sit
   on its own ids and so outrank the shell's */
html[data-theme="dark"] :is(#whole_company, #whole_basic, #whole_password) {
    --create-ink: #e7e9ee;
    --create-muted: #9ca3af;
    --create-border: #2c313a;
    --create-surface: #1a1d23;
}

html[data-theme="dark"] :is(#whole_company, #whole_basic) :is(.user-create__section, .user-create__footer,
    .user-create__preview, .user-create__optional, .phone-field, .form-control,
    .user-create__button--secondary, .user-create__button--upload) {
    border-color: #3b414c;
    background-color: #1a1d23;
    color: #e7e9ee;
}

html[data-theme="dark"] :is(#whole_company, #whole_basic) :is(.form-control, .phone-field,
    .select2-container--default .select2-selection--single,
    .select2-container--default .select2-selection--multiple) {
    border-color: #3b414c;
    background-color: #15181d;
    color: #e7e9ee;
}

html[data-theme="dark"] :is(#whole_company, #whole_basic) .select2-container--default .select2-selection__rendered {
    color: #e7e9ee;
}

html[data-theme="dark"] :is(#whole_company, #whole_basic) :is(.user-create__photo, .user-create__section-icon) {
    background: #272c35;
}

html[data-theme="dark"] :is(#whole_company, #whole_basic) :is(.user-create__button--secondary:hover, .user-create__button--upload:hover) {
    background: #272c35;
}

html[data-theme="dark"] :is(#whole_company, #whole_basic) .user-create__button--primary {
    color: #0b0d10;
}

html[data-theme="dark"] :is(#whole_company, #whole_basic) .user-create__button--primary:hover {
    background: var(--pp-blue-strong);
}

html[data-theme="dark"] #whole_basic :is(.note-editor .note-toolbar, .note-statusbar) {
    background: #22262d;
}

html[data-theme="dark"] #whole_basic .note-toolbar .note-btn {
    border-color: #3b414c;
    background: #1a1d23;
    color: #e7e9ee;
}

html[data-theme="dark"] #whole_basic .note-editor .note-editable {
    background: #15181d;
    color: #e7e9ee;
}

/* --- notices */
html[data-theme="dark"] .mx-body .portal-alert {
    border-color: color-mix(in srgb, var(--brand-color, #087b48) 40%, #1a1d23);
    background: color-mix(in srgb, var(--brand-color, #087b48) 14%, #1a1d23);
    color: var(--dk-ink);
}

html[data-theme="dark"] .mx-body .portal-alert--error {
    border-color: #5c2a27;
    background: #2a1716;
    color: #f3c4bf;
}

html[data-theme="dark"] .mx-body .portal-alert--warning {
    border-color: #5a4520;
    background: #2a2215;
    color: #f1d9a6;
}

html[data-theme="dark"] .mx-body .pp-status--active { background: #163323; color: #8ee0ad; }
html[data-theme="dark"] .mx-body .pp-status--pending { background: #33280f; color: #f2c66d; }
html[data-theme="dark"] .mx-body .pp-status--expired { background: #3a1b18; color: #f2a59c; }

html[data-theme="dark"] .mx-body .inbox-badge--new,
html[data-theme="dark"] .mx-body .inbox-head__count { background: #3a1b18; color: #f2a59c; }
html[data-theme="dark"] .mx-body .inbox-badge--read { background: #1d2740; color: #a9c0f5; }
html[data-theme="dark"] .mx-body .inbox-badge--replied { background: #163323; color: #8ee0ad; }

/* --- the account menu and the search results, which open over the page */
html[data-theme="dark"] .mx-body :is(.mx-user__item, .mx-find__item, .mx-search-page__item) {
    color: var(--dk-ink);
}

html[data-theme="dark"] .mx-body :is(.mx-user__item:hover, .mx-user__item:focus-visible,
    .mx-find__item:hover, .mx-find__item.is-active, .mx-find__all:hover, .mx-find__all.is-active,
    .mx-search-page__item:hover) {
    background: color-mix(in srgb, var(--mx-brand) 16%, #1a1d23);
    color: var(--dk-ink);
}

html[data-theme="dark"] .mx-body :is(.mx-find__icon, .mx-search-page__icon) {
    background: color-mix(in srgb, var(--mx-brand) 22%, #1a1d23);
}

html[data-theme="dark"] .mx-body .mx-find__text mark {
    background: color-mix(in srgb, var(--mx-brand) 40%, #1a1d23);
    color: var(--dk-ink);
}

html[data-theme="dark"] .mx-body :is(.mx-user__item--danger:hover, .mx-user__item--danger:focus-visible) {
    background: #2a1716;
}

/* The theme card's tick sits on the card's own ground. */
html[data-theme="dark"] .mx-body .md-check {
    background: var(--dk-card);
}
/* ======================================================= header switch */

.mx-theme {
    position: relative;
    flex: 0 0 auto;
}

.mx-theme__trigger {
    list-style: none;
    cursor: pointer;
}

.mx-theme__trigger::-webkit-details-marker {
    display: none;
}

/* On a phone the header gives its width to the search field, so the switch
   moves into the account menu: member-app.css hides the header's copy at that
   width and the menu's copy below takes over. */
.mx-theme--menu {
    display: none;
    padding: 6px 0;
    border-top: 1px solid var(--mx-line, #e4e7ee);
}

.mx-theme--menu form {
    margin: 0;
}

/* The account menu marks keyboard focus with an outline, so its theme rows do
   the same rather than the popover's background-only hint. */
.mx-theme--menu .mx-theme__option:focus-visible {
    outline: 2px solid var(--pp-blue);
    outline-offset: -2px;
}

@media (max-width: 767.98px) {
    .mx-theme--menu {
        display: block;
    }
}

.mx-theme__trigger:hover,
.mx-theme[open] .mx-theme__trigger {
    background: rgba(255, 255, 255, .1);
    color: #fff;
}

/* The glyph for the look in force: a sun on light, a moon on dark. */
.mx-theme__glyph--dark,
html[data-theme="dark"] .mx-theme__glyph--light {
    display: none;
}

html[data-theme="dark"] .mx-theme__glyph--dark {
    display: inline-block;
}

.mx-theme__menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 90;
    width: 200px;
    margin: 0;
    padding: 6px;
    border: 1px solid var(--mx-line, #e4e7ee);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 18px 44px rgba(15, 23, 42, .16);
    color: var(--pp-ink, #1f2a3d);
}

.mx-theme__title {
    margin: 4px 10px 6px;
    color: var(--pp-muted, #667085);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.mx-theme__option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 0 10px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--pp-ink, #1f2a3d);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}

.mx-theme__option > i:first-child {
    width: 18px;
    color: var(--pp-muted, #667085);
    text-align: center;
}

.mx-theme__option:hover,
.mx-theme__option:focus-visible {
    background: color-mix(in srgb, var(--mx-brand, #087b48) 8%, #ffffff);
    outline: none;
}

.mx-theme__tick {
    margin-left: auto;
    color: var(--mx-brand, #087b48);
    opacity: 0;
}

.mx-theme__option[aria-pressed="true"] {
    font-weight: 600;
}

.mx-theme__option[aria-pressed="true"] > i:first-child,
.mx-theme__option[aria-pressed="true"] .mx-theme__tick {
    color: color-mix(in srgb, var(--mx-brand, #087b48) 80%, #0b0c10);
    opacity: 1;
}

html[data-theme="dark"] .mx-theme__menu {
    border-color: #2c313a;
    background: #1a1d23;
    box-shadow: 0 18px 44px rgba(0, 0, 0, .5);
    color: #e7e9ee;
}

html[data-theme="dark"] .mx-theme__option {
    color: #e7e9ee;
}

html[data-theme="dark"] .mx-theme__option:hover,
html[data-theme="dark"] .mx-theme__option:focus-visible {
    background: color-mix(in srgb, var(--mx-brand, #087b48) 16%, #1a1d23);
}

html[data-theme="dark"] .mx-theme__option[aria-pressed="true"] > i:first-child,
html[data-theme="dark"] .mx-theme__option[aria-pressed="true"] .mx-theme__tick {
    color: color-mix(in srgb, var(--mx-brand, #087b48) 62%, #ffffff);
}

/* ================================================================ fade */

/* A theme change fades for a moment (theme-switch.js adds the class for
   450ms, and never when motion is reduced). Colour properties only, so
   nothing moves. */
html.md-theme-fade,
html.md-theme-fade *,
html.md-theme-fade *::before,
html.md-theme-fade *::after {
    transition:
        background-color .35s ease,
        background .35s ease,
        color .35s ease,
        border-color .35s ease,
        fill .35s ease,
        box-shadow .35s ease !important;
    transition-delay: 0s !important;
}

/* ===================================================== light workspace */

/* An explicit Light (or System on a light device) makes the whole
   workspace light: header, icon rail, side panel and phone tab bar. A member
   who never chose ("classic") keeps the original dark shell. */
html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body {
    --mx-frame: color-mix(in srgb, var(--mx-brand) 5%, #e8ebf1);
    --mx-panel: #ffffff;
    --mx-panel-raise: #f2f4f8;
    --mx-panel-line: #e4e7ee;
    --mx-panel-ink: #1f2a3d;
    --mx-panel-muted: #667085;
    --mx-lift: color-mix(in srgb, var(--mx-brand) 82%, #0b0c10);
    --mx-active: color-mix(in srgb, var(--mx-brand) 10%, #ffffff);
    --mx-header-bg: #ffffff;
    --md-shell-ink: #344054;
    --md-shell-hover: rgba(15, 23, 42, .06);
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body :is(.mx-main, .mx-panel) {
    border: 1px solid #e1e5ec;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

/* header */
html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-header {
    border-bottom-color: #e4e7ee;
    color: var(--mx-panel-ink);
    box-shadow: 0 1px 0 rgba(15, 23, 42, .02);
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body :is(.mx-header__menu, .mx-hicon, .mx-user__trigger, .mx-workspace) {
    color: var(--md-shell-ink);
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body :is(.mx-header__menu:hover, .mx-hicon:hover,
    .mx-user__trigger:hover, .mx-user[open] .mx-user__trigger, .mx-workspace:hover,
    .mx-theme__trigger:hover, .mx-theme[open] .mx-theme__trigger) {
    background: var(--md-shell-hover);
    color: var(--mx-panel-ink);
}

/* The header's wordmark: the light shell's white header takes the file cut for
   white surfaces, so the dark-surface file member-app.css prints is hidden. */
html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-workspace__logo--light {
    display: block;
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-workspace__logo--dark {
    display: none;
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-user__trigger img {
    box-shadow: 0 0 0 2px #e4e7ee;
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-find__field > i {
    color: #667085;
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-find__field input {
    border-color: #e4e7ee;
    background: #f2f4f8;
    color: var(--mx-panel-ink);
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-find__field input::placeholder {
    color: #667085;
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-find__field input:hover {
    background: #eceff4;
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-find__field input:focus {
    border-color: color-mix(in srgb, var(--mx-brand) 55%, #ffffff);
    background: #ffffff;
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-find__kbd {
    border-color: #d0d5dd;
    color: #667085;
}

/* icon rail */
html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body :is(.mx-rail, .mx-rail__item, .mx-rail__expand) {
    color: var(--md-shell-ink);
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body :is(.mx-rail__item:hover, .mx-rail__expand:hover) {
    color: var(--mx-panel-ink);
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body :is(.mx-rail__item:hover .mx-rail__icon, .mx-rail__expand:hover) {
    background: rgba(15, 23, 42, .07);
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-rail__item.is-active {
    color: var(--mx-lift);
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-rail__item.is-active .mx-rail__icon {
    background: var(--mx-brand);
    color: #fff;
    box-shadow: 0 6px 14px color-mix(in srgb, var(--mx-brand) 30%, transparent);
}

/* side panel */
html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body :is(.mx-panel__close:hover, .mx-plan__link:hover, .mx-me:hover) {
    color: var(--mx-panel-ink);
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-me:hover {
    background: #e9edf3;
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-me__avatar {
    box-shadow: 0 0 0 1px #e4e7ee;
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-status {
    color: #a86a00;
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-status.is-live {
    color: #15803d;
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body :is(.mx-panel .pp-nav__link:hover,
    .mx-panel .pp-nav__link:focus-visible, .mx-menu__item:hover, .mx-result:hover, .mx-result:focus-visible, .mx-result.is-first) {
    background: rgba(15, 23, 42, .05);
    color: var(--mx-panel-ink);
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body :is(.mx-panel .pp-nav__link.is-active, .mx-panel .pp-nav__link.is-active:hover) {
    color: var(--mx-lift);
    font-weight: 600;
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-tile {
    background: color-mix(in srgb, var(--mx-brand) 10%, #ffffff);
    color: var(--mx-lift);
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-menu {
    box-shadow: 0 16px 36px rgba(15, 23, 42, .14);
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-panel {
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-scrim {
    background: rgba(15, 23, 42, .35);
}

/* phone tab bar */
html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-tabbar {
    border-top-color: #e4e7ee;
    background: #ffffff;
    box-shadow: 0 -6px 20px rgba(15, 23, 42, .06);
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-tabbar__item {
    color: #667085;
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body :is(.mx-tabbar__item:hover, .mx-tabbar__item.is-active) {
    color: var(--mx-lift);
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-tabbar__item.is-active .mx-tabbar__icon {
    background: var(--mx-brand);
    color: #fff;
}

/* The drawer's circle on the white bar: a quiet disc until the open page is one
   the drawer holds, when the active-tab rule above fills it with the brand. */
html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-tabbar__item--menu .mx-tabbar__icon {
    border-color: #e4e7ee;
    background: #f2f4f8;
    color: #667085;
}

html[data-theme="light"]:not([data-theme-pref="classic"]) .mx-body .mx-tabbar__item--menu.is-active .mx-tabbar__icon {
    border-color: transparent;
}

/* ====================================================== dark workspace */

/* The shell is already dark; on the dark theme its brand-tinted gutter is
   calmed to a near-neutral so the header, rail, panel and page read as one
   surface family, with the accent kept for what is chosen. */
html[data-theme="dark"] .mx-body {
    --mx-frame: color-mix(in srgb, var(--mx-brand) 10%, #0b0c0f);
    --mx-panel: #15171c;
    --mx-panel-raise: #1e2127;
    --mx-header-bg: #0f1013;
    --mx-active: color-mix(in srgb, var(--mx-brand) 28%, #15171c);
    --mx-lift: color-mix(in srgb, var(--mx-brand) 55%, #ffffff);
}

html[data-theme="dark"] .mx-body :is(.mx-main, .mx-panel) {
    border: 1px solid rgba(255, 255, 255, .05);
}

html[data-theme="dark"] .mx-body .mx-main {
    box-shadow: 0 1px 0 rgba(255, 255, 255, .02) inset;
}

/* Cards lift off the page with a hairline rather than a shadow. */
html[data-theme="dark"] .mx-body .mx-content :is(.pp-panel, .pp-card, .card-link, .install-app, .pp-team-card) {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .02), 0 8px 24px rgba(0, 0, 0, .25);
}

/* ========================================================= guest pages */

/* The portal's guest pages -- signup, the member sign-in and its password
   reset, SSO, register and the payment pages -- carry no member preference, so
   layouts.portal gives them partials.theme-boot instead: data-theme follows the
   visitor's stored choice or the device, and data-theme-pref is never set.
   Every rule below is keyed on that pair, so a signed-in member's page (which
   always carries data-theme-pref) is untouched, and the light theme is the
   pages' own sheets exactly as they were.

   The palette is the member app's dark one above; the page sheets' own tokens
   (portal-member.css, portal-join.css, portal-profile.css, member-card-link.css)
   are re-pointed where they are declared, and only the colours those sheets
   hard-code are restated. A filled accent control takes the lifted accent with
   the dark label, as on the member app. */

html[data-theme="dark"]:not([data-theme-pref]) {
    --gd-page: color-mix(in srgb, var(--brand-color, #1148c7) 4%, #111317);
    --gd-card: #1a1d23;
    --gd-raise: #22262d;
    --gd-field: #15181d;
    --gd-line: #2c313a;
    --gd-line-strong: #3b414c;
    /* A field's edge holds 3:1 against both the card and the field. */
    --gd-field-line: #646b78;
    --gd-field-line-hover: #7a8190;
    --gd-ink: #e7e9ee;
    --gd-muted: #9ca3af;
    --gd-placeholder: #8b93a1;
    --gd-on-accent: #0b0d10;
    --gd-accent: color-mix(in srgb, var(--brand-color, #1148c7) 62%, #ffffff);
    --gd-accent-strong: color-mix(in srgb, var(--brand-color, #1148c7) 48%, #ffffff);
    --gd-danger: #f2a59c;
    --gd-danger-wash: #2a1716;
    --gd-danger-line: #5c2a27;

    /* portal-member.css: sign-in, forgot password, code, new password. Its
       accent falls back to the shipped green, so the lift does too. */
    --ink: var(--gd-ink);
    --muted: var(--gd-muted);
    --surface: color-mix(in srgb, var(--brand-color, #087b48) 10%, #1a1d23);
    --line: var(--gd-line);
    --line-strong: var(--gd-line-strong);
    --plate: var(--gd-field);
    --field: var(--gd-field);
    --placeholder: var(--gd-placeholder);
    --accent: color-mix(in srgb, var(--brand-color, #087b48) 62%, #ffffff);
    --accent-dark: color-mix(in srgb, var(--brand-color, #087b48) 48%, #ffffff);
    --danger: var(--gd-danger);

    /* portal-profile.css: the payment pages. */
    --pp-ink: var(--gd-ink);
    --pp-muted: var(--gd-muted);
    --pp-blue: color-mix(in srgb, var(--brand-color, #087b48) 62%, #ffffff);
    --pp-blue-strong: color-mix(in srgb, var(--brand-color, #087b48) 48%, #ffffff);
    --pp-accent-wash: color-mix(in srgb, var(--brand-color, #087b48) 16%, #1a1d23);
    --pp-accent-line: color-mix(in srgb, var(--brand-color, #087b48) 45%, #1a1d23);
    --pp-border: var(--gd-line);
    --pp-field-border: var(--gd-field-line);
    --pp-surface: var(--gd-raise);
    --pp-chip: #272c35;
    --pp-danger: var(--gd-danger);
    --pp-required: var(--gd-danger);
}

/* --- the layout's own shell (layouts.portal) */
html[data-theme="dark"]:not([data-theme-pref]) body {
    background: var(--gd-page);
    color: var(--gd-ink);
}

html[data-theme="dark"]:not([data-theme-pref]) .portal-head--sticky {
    background: var(--gd-page);
    border-bottom-color: rgba(255, 255, 255, .06);
}

html[data-theme="dark"]:not([data-theme-pref]) .portal-brand img:not(.portal-brand__logo--dark) {
    display: none;
}

html[data-theme="dark"]:not([data-theme-pref]) .portal-brand__logo--dark {
    display: block;
}

html[data-theme="dark"]:not([data-theme-pref]) .text-muted {
    color: var(--gd-muted) !important;
}

html[data-theme="dark"]:not([data-theme-pref]) a:not([class]) {
    color: var(--gd-accent);
}

html[data-theme="dark"]:not([data-theme-pref]) .portal-lang__select {
    border-color: var(--gd-field-line);
    background: var(--gd-field);
    color: var(--gd-ink);
}

html[data-theme="dark"]:not([data-theme-pref]) .member-link-btn {
    border-color: color-mix(in srgb, var(--gd-accent) 45%, #1a1d23);
    background: var(--gd-card);
    color: var(--gd-accent);
}

html[data-theme="dark"]:not([data-theme-pref]) .member-link-btn:hover {
    border-color: var(--gd-accent);
    background: color-mix(in srgb, var(--brand-color, #1148c7) 14%, #1a1d23);
    color: var(--gd-accent);
}

html[data-theme="dark"]:not([data-theme-pref]) .member-link-btn:focus-visible {
    outline-color: var(--gd-accent);
}

html[data-theme="dark"]:not([data-theme-pref]) :is(.portal-menu-toggle, .portal-menu-close) {
    border-color: var(--gd-line-strong);
    background: var(--gd-card);
    color: var(--gd-ink);
}

@media (max-width: 767.98px) {
    html[data-theme="dark"]:not([data-theme-pref]) .portal-menu--drawer {
        background: var(--gd-card);
        color: var(--gd-ink);
        box-shadow: -20px 0 48px rgba(0, 0, 0, .5);
    }

    html[data-theme="dark"]:not([data-theme-pref]) .portal-menu__title {
        color: var(--gd-muted);
    }

    html[data-theme="dark"]:not([data-theme-pref]) .portal-menu--drawer .portal-head__actions {
        border-top-color: var(--gd-line);
    }

    html[data-theme="dark"]:not([data-theme-pref]) .portal-menu-backdrop {
        background: rgba(0, 0, 0, .55);
    }
}

html[data-theme="dark"]:not([data-theme-pref]) :is(.portal-card, .card) {
    border-color: var(--gd-line);
    background-color: var(--gd-card);
    color: var(--gd-ink);
}

html[data-theme="dark"]:not([data-theme-pref]) .portal-card {
    box-shadow: 0 0 0 1px var(--gd-line);
}

html[data-theme="dark"]:not([data-theme-pref]) .portal-card .portal-card__hint {
    color: var(--gd-muted);
}

html[data-theme="dark"]:not([data-theme-pref]) .portal-row {
    border-color: var(--gd-line);
}

html[data-theme="dark"]:not([data-theme-pref]) .portal-add {
    border-top-color: var(--gd-line-strong);
}

html[data-theme="dark"]:not([data-theme-pref]) .preset-package,
html[data-theme="dark"]:not([data-theme-pref]) .join .preset-package {
    border-color: color-mix(in srgb, var(--brand-color, #1148c7) 35%, #1a1d23);
    background: color-mix(in srgb, var(--brand-color, #1148c7) 12%, #1a1d23);
}

/* Notices: the status, the refusal and the warning. */
html[data-theme="dark"]:not([data-theme-pref]) .portal-alert {
    border-color: color-mix(in srgb, var(--brand-color, #1148c7) 40%, #1a1d23);
    background: color-mix(in srgb, var(--brand-color, #1148c7) 14%, #1a1d23);
    color: var(--gd-ink);
}

html[data-theme="dark"]:not([data-theme-pref]) .portal-alert > i {
    color: var(--gd-accent);
}

html[data-theme="dark"]:not([data-theme-pref]) .portal-alert--error {
    border-color: var(--gd-danger-line);
    background: var(--gd-danger-wash);
    color: #f3c4bf;
}

html[data-theme="dark"]:not([data-theme-pref]) .portal-alert--error > i {
    color: var(--gd-danger);
}

html[data-theme="dark"]:not([data-theme-pref]) .portal-alert--warning {
    border-color: #5a4520;
    background: #2a2215;
    color: #f1d9a6;
}

html[data-theme="dark"]:not([data-theme-pref]) .portal-alert--warning > i {
    color: #f2c66d;
}

/* SweetAlert2, which answers a status or a refusal on these pages. */
html[data-theme="dark"]:not([data-theme-pref]) .swal2-popup {
    background: var(--gd-card);
    color: var(--gd-ink);
}

html[data-theme="dark"]:not([data-theme-pref]) :is(.swal2-title, .swal2-html-container) {
    color: var(--gd-ink);
}

/* --- the install offer under every portal page (member-card-link.css) */
html[data-theme="dark"]:not([data-theme-pref]) .install-app {
    --card-link-ink: var(--gd-ink);
    --card-link-muted: var(--gd-muted);
    --card-link-border: var(--gd-line);
    --card-link-surface: var(--gd-raise);
    --card-link-chip: #272c35;
    --card-link-accent: var(--gd-accent);
    border-color: var(--gd-line);
    background: var(--gd-card);
    color: var(--gd-ink);
}

html[data-theme="dark"]:not([data-theme-pref]) :is(.install-app__help, .card-dismiss__menu) {
    border-color: var(--gd-line);
    background-color: var(--gd-card);
}

html[data-theme="dark"]:not([data-theme-pref]) .install-app__help[open] {
    background-color: var(--gd-raise);
}

html[data-theme="dark"]:not([data-theme-pref]) .card-dismiss__menu {
    --card-link-ink: var(--gd-ink);
    --card-link-muted: var(--gd-muted);
    --card-link-border: var(--gd-line);
    --card-link-chip: #272c35;
    box-shadow: 0 18px 44px rgba(0, 0, 0, .5);
}

html[data-theme="dark"]:not([data-theme-pref]) .install-app__button,
html[data-theme="dark"]:not([data-theme-pref]) .install-app__button:hover {
    border-color: transparent;
    background: var(--gd-accent);
    color: var(--gd-on-accent);
}

html[data-theme="dark"]:not([data-theme-pref]) .install-app__button:hover {
    background: var(--gd-accent-strong);
}

html[data-theme="dark"]:not([data-theme-pref]) :is(.install-app__button, .install-app__help-summary, .install-app__help-option input,
    .card-dismiss__toggle, .card-dismiss__option):focus-visible {
    outline-color: var(--gd-ink);
}

/* --- signup and register (portal-join.css). The join form declares its own
   palette on .join, with the blue it falls back to. */
html[data-theme="dark"]:not([data-theme-pref]) .join {
    --ink: var(--gd-ink);
    --muted: var(--gd-muted);
    --accent: var(--gd-accent);
    --surface: color-mix(in srgb, var(--brand-color, #1148c7) 10%, #1a1d23);
    --line: var(--gd-line);
    --danger: var(--gd-danger);
}

html[data-theme="dark"]:not([data-theme-pref]) .join-top-link:hover {
    background: var(--gd-raise);
    color: var(--gd-accent);
}

html[data-theme="dark"]:not([data-theme-pref]) .join-top-link {
    color: var(--gd-ink);
}

html[data-theme="dark"]:not([data-theme-pref]) .join-top-button {
    border-color: var(--gd-line-strong);
    background: var(--gd-card);
    color: var(--gd-ink);
}

html[data-theme="dark"]:not([data-theme-pref]) .join-top-button:hover {
    border-color: var(--gd-accent);
    background: color-mix(in srgb, var(--brand-color, #1148c7) 14%, #1a1d23);
    color: var(--gd-accent);
}

html[data-theme="dark"]:not([data-theme-pref]) .join-top-button:focus-visible {
    outline-color: var(--gd-accent);
}

html[data-theme="dark"]:not([data-theme-pref]) .join-form {
    border-color: var(--gd-line);
    background: var(--gd-card);
    box-shadow: 0 24px 48px -38px rgba(0, 0, 0, .9);
}

html[data-theme="dark"]:not([data-theme-pref]) .join-form .form-control,
html[data-theme="dark"]:not([data-theme-pref]) .join-form .select2-container .select2-selection--single,
html[data-theme="dark"]:not([data-theme-pref]) .phone-field {
    border-color: var(--gd-field-line);
    background: var(--gd-field);
    color: var(--gd-ink);
}

html[data-theme="dark"]:not([data-theme-pref]) .join-form .form-control:focus,
html[data-theme="dark"]:not([data-theme-pref]) .join-form .select2-container--focus .select2-selection--single,
html[data-theme="dark"]:not([data-theme-pref]) .join-form .select2-container--open .select2-selection--single,
html[data-theme="dark"]:not([data-theme-pref]) .phone-field:focus-within {
    border-color: var(--gd-accent);
    background: var(--gd-field);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--gd-accent) 25%, transparent);
}

/* Inside the phone field the prefix and the number are the field's own fill. */
html[data-theme="dark"]:not([data-theme-pref]) .phone-field .form-control,
html[data-theme="dark"]:not([data-theme-pref]) .phone-field .select2-container .select2-selection--single,
html[data-theme="dark"]:not([data-theme-pref]) .phone-field .form-control:focus,
html[data-theme="dark"]:not([data-theme-pref]) .phone-field .select2-container--focus .select2-selection--single,
html[data-theme="dark"]:not([data-theme-pref]) .phone-field .select2-container--open .select2-selection--single {
    background: transparent;
    box-shadow: none;
}

html[data-theme="dark"]:not([data-theme-pref]) .phone-field__country {
    border-right-color: var(--gd-line-strong);
}

html[data-theme="dark"]:not([data-theme-pref]) .join-form .form-control[readonly] {
    background: var(--gd-raise);
    color: var(--gd-muted);
}

html[data-theme="dark"]:not([data-theme-pref]) .join-form .form-control.is-invalid,
html[data-theme="dark"]:not([data-theme-pref]) .phone-field--invalid {
    border-color: var(--gd-danger);
    background: var(--gd-danger-wash);
}

html[data-theme="dark"]:not([data-theme-pref]) :is(.join-form .form-control, .phone-field__number)::placeholder,
html[data-theme="dark"]:not([data-theme-pref]) .join-form .select2-container .select2-selection--single .select2-selection__placeholder {
    color: var(--gd-placeholder);
}

html[data-theme="dark"]:not([data-theme-pref]) .join-select2-dropdown {
    --join-accent: var(--gd-accent);
    --join-line: var(--gd-line-strong);
    box-shadow: 0 18px 40px -20px rgba(0, 0, 0, .8);
}

html[data-theme="dark"]:not([data-theme-pref]) .join-select2-dropdown .select2-search--dropdown .select2-search__field {
    border-color: var(--gd-field-line);
    background: var(--gd-field);
    color: var(--gd-ink);
}

html[data-theme="dark"]:not([data-theme-pref]) .join-select2-dropdown .select2-results__option--highlighted[aria-selected] {
    color: var(--gd-on-accent);
}

html[data-theme="dark"]:not([data-theme-pref]) .join-account--blocked {
    border-color: var(--gd-danger-line);
    background: var(--gd-danger-wash);
}

html[data-theme="dark"]:not([data-theme-pref]) .join .info-tip__bubble {
    background: var(--gd-raise);
    box-shadow: 0 0 0 1px var(--gd-line-strong), 0 6px 20px rgba(0, 0, 0, .5);
    color: var(--gd-ink);
}

html[data-theme="dark"]:not([data-theme-pref]) :is(.join-photo, .join-gift) {
    background: linear-gradient(160deg, var(--gd-field) 0%, var(--surface) 100%);
}

html[data-theme="dark"]:not([data-theme-pref]) .join-photo__frame {
    border-color: var(--gd-field-line);
    background: var(--gd-field);
}

html[data-theme="dark"]:not([data-theme-pref]) .join-tag {
    background: var(--gd-card);
}

html[data-theme="dark"]:not([data-theme-pref]) .join-button:not(.join-button--ghost):not(.join-button--text) {
    border-color: var(--gd-accent);
    background: var(--gd-accent);
    color: var(--gd-on-accent);
}

html[data-theme="dark"]:not([data-theme-pref]) .join-button:not(.join-button--ghost):not(.join-button--text):hover:not(:disabled) {
    border-color: var(--gd-accent-strong);
    background: var(--gd-accent-strong);
    color: var(--gd-on-accent);
}

html[data-theme="dark"]:not([data-theme-pref]) .join-button--ghost {
    border-color: var(--gd-line-strong);
    background: var(--gd-card);
    color: var(--gd-ink);
}

html[data-theme="dark"]:not([data-theme-pref]) .join-button--ghost:hover:not(:disabled) {
    border-color: var(--gd-accent);
    background: var(--gd-card);
    color: var(--gd-accent);
}

html[data-theme="dark"]:not([data-theme-pref]) :is(.join-trial__gift, .join-gift__prompt) {
    border-color: color-mix(in srgb, var(--brand-color, #1148c7) 35%, #1a1d23);
    background: color-mix(in srgb, var(--brand-color, #1148c7) 12%, #1a1d23);
    color: var(--gd-ink);
}

html[data-theme="dark"]:not([data-theme-pref]) :is(.join-gift__applied, .join-gift__applied i) {
    color: #6fd39b;
}

/* The plan cards and the audience switch on the signup forms. */
html[data-theme="dark"]:not([data-theme-pref]) .signup-plan__body {
    border-color: var(--gd-line-strong);
    background: var(--gd-card);
}

html[data-theme="dark"]:not([data-theme-pref]) .signup-plan:hover .signup-plan__body {
    border-color: color-mix(in srgb, var(--gd-accent) 55%, #1a1d23);
    background: var(--gd-card);
}

html[data-theme="dark"]:not([data-theme-pref]) .signup-plan input:checked + .signup-plan__body {
    border-color: var(--gd-accent);
    background: color-mix(in srgb, var(--brand-color, #1148c7) 16%, #1a1d23);
    box-shadow: 0 0 0 1px var(--gd-accent);
}

html[data-theme="dark"]:not([data-theme-pref]) .signup-plan__tick {
    border-color: var(--gd-field-line);
    background: var(--gd-field);
}

html[data-theme="dark"]:not([data-theme-pref]) .signup-plan input:checked + .signup-plan__body .signup-plan__tick {
    border-color: var(--gd-accent);
    background: var(--gd-accent);
    color: var(--gd-on-accent);
}

html[data-theme="dark"]:not([data-theme-pref]) .signup-audience {
    border-color: var(--gd-line-strong);
    background: var(--gd-card);
}

html[data-theme="dark"]:not([data-theme-pref]) .signup-audience__option {
    color: var(--gd-muted);
}

html[data-theme="dark"]:not([data-theme-pref]) .signup-audience__option:hover {
    background: var(--gd-raise);
    color: var(--gd-ink);
}

html[data-theme="dark"]:not([data-theme-pref]) .signup-audience__option.is-active,
html[data-theme="dark"]:not([data-theme-pref]) .signup-audience__option.is-active:hover {
    background: var(--gd-accent);
    color: var(--gd-on-accent);
}

html[data-theme="dark"]:not([data-theme-pref]) .signup-audience__option:focus-visible {
    outline-color: var(--gd-accent);
}

/* --- the member sign-in, its code and the new password (portal-member.css) */
html[data-theme="dark"]:not([data-theme-pref]) .member-card {
    border-color: var(--gd-line);
    background: var(--gd-card);
    box-shadow: 0 32px 64px -46px rgba(0, 0, 0, .9);
}

html[data-theme="dark"]:not([data-theme-pref]) :is(.member-control input, .member-code input, .member-code.is-mirrored .member-code__seg) {
    border-color: var(--gd-field-line);
}

html[data-theme="dark"]:not([data-theme-pref]) :is(.member-control input, .member-code input):hover {
    border-color: var(--gd-field-line-hover);
}

html[data-theme="dark"]:not([data-theme-pref]) :is(.member-control input, .member-code input):focus {
    border-color: var(--accent);
    background: var(--gd-field);
}

html[data-theme="dark"]:not([data-theme-pref]) .member-code.is-mirrored input:focus,
html[data-theme="dark"]:not([data-theme-pref]) .member-code.is-mirrored input.is-invalid {
    background: transparent;
}

html[data-theme="dark"]:not([data-theme-pref]) :is(.member-control input, .member-code input).is-invalid {
    border-color: var(--gd-danger);
    background: var(--gd-danger-wash);
}

html[data-theme="dark"]:not([data-theme-pref]) .member-code.is-mirrored .member-code__seg.is-filled {
    border-color: var(--gd-field-line-hover);
    background: var(--gd-raise);
}

html[data-theme="dark"]:not([data-theme-pref]) .member-code input.is-invalid ~ .member-code__rail .member-code__seg {
    border-color: var(--gd-danger-line);
    background: var(--gd-danger-wash);
}

html[data-theme="dark"]:not([data-theme-pref]) .member-code input.is-invalid ~ .member-code__rail .member-code__seg.is-filled {
    border-color: var(--gd-danger);
    background: var(--gd-danger-wash);
}

html[data-theme="dark"]:not([data-theme-pref]) .member-submit {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--gd-on-accent);
}

html[data-theme="dark"]:not([data-theme-pref]) .member-submit:hover:not(:disabled) {
    border-color: var(--accent-dark);
    background: var(--accent-dark);
    color: var(--gd-on-accent);
}

html[data-theme="dark"]:not([data-theme-pref]) .member-submit__spinner {
    border-color: rgba(11, 13, 16, .3);
    border-top-color: var(--gd-on-accent);
}

html[data-theme="dark"]:not([data-theme-pref]) .member-steps li::before,
html[data-theme="dark"]:not([data-theme-pref]) .member-target > i {
    background: var(--gd-card);
}

/* --- the payment pages (portal-profile.css) */
html[data-theme="dark"]:not([data-theme-pref]) body:has(.pp) {
    background:
        radial-gradient(1100px 520px at 12% -12%, color-mix(in srgb, var(--brand-color, #087b48) 12%, transparent) 0%, transparent 60%),
        var(--gd-page);
}

html[data-theme="dark"]:not([data-theme-pref]) :is(.pp-panel, .pp-account, .pp-card) {
    border-color: var(--gd-line);
    background-color: var(--gd-card);
    background-image: none;
}

html[data-theme="dark"]:not([data-theme-pref]) .pp-button,
html[data-theme="dark"]:not([data-theme-pref]) .pp-button:hover {
    color: var(--gd-on-accent);
}

html[data-theme="dark"]:not([data-theme-pref]) .pp-button--ghost,
html[data-theme="dark"]:not([data-theme-pref]) .pp-button--ghost:hover {
    color: var(--gd-ink);
}

html[data-theme="dark"]:not([data-theme-pref]) .pp-button--ghost {
    background: var(--gd-card);
}

html[data-theme="dark"]:not([data-theme-pref]) .pp-empty {
    border-color: var(--gd-line-strong);
}

html[data-theme="dark"]:not([data-theme-pref]) .pp-summary code {
    background: var(--pp-chip);
    color: var(--gd-ink);
}
