/* Shared appearance and language controls for the mobile web shells. */
@media (max-width: 768px) {
    html {
        --mobile-pref-surface: #fff;
        --mobile-pref-border: #e5e5e5;
        --mobile-pref-text: #222;
        --mobile-pref-light-fill: #e63946;
        --mobile-pref-light-text: #fff;
        --mobile-pref-dark-fill: #000;
        --mobile-pref-dark-text: #fff;
    }

    html[data-theme="dark"] {
        --mobile-pref-surface: #23262b;
        --mobile-pref-border: #43464a;
        --mobile-pref-text: #f5f5f5;
        --mobile-pref-light-fill: #1e2125;
        --mobile-pref-light-text: #c2c7cf;
        --mobile-pref-dark-fill: #3d292d;
        --mobile-pref-dark-text: #ff969b;
    }

    html body :is(.preferences-menu, .config-preference-group:has(.config-theme-switch), .header-user-dropdown__pref-row:has(.header-user-dropdown__theme), .sk-theme-toggle) {
        box-sizing: border-box;
        width: 240px !important;
        min-width: 0 !important;
        max-width: calc(100vw - 24px) !important;
        padding: 16px !important;
        border: 1px solid var(--mobile-pref-border) !important;
        border-radius: 12px !important;
        background: var(--mobile-pref-surface) !important;
        color: var(--mobile-pref-text) !important;
        box-shadow: 0 8px 24px #00000026 !important;
    }

    html body .header-user-dropdown__pref-row:has(.header-user-dropdown__theme) {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0 !important;
        margin: 8px 0 !important;
    }

    html body :is(.preference-label, .config-preference-label, .header-user-dropdown__pref-row:has(.header-user-dropdown__theme) > .header-user-dropdown__pref-label, .sidebar-flyout-title, .sk-theme-label) {
        display: block;
        margin: 0 0 10px !important;
        color: var(--mobile-pref-text) !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        line-height: 20px !important;
        text-transform: none !important;
        letter-spacing: normal !important;
        opacity: 1 !important;
    }

    html body :is(.theme-switch, .config-theme-switch, .header-user-dropdown__theme, .sidebar-flyout-button-row) {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        width: 100% !important;
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    html body :is(.theme-btn, .config-theme-btn, .header-user-dropdown__theme-btn, .sidebar-flyout-theme-btn, .sk-theme-btn) {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 6px !important;
        width: 100% !important;
        min-height: 40px !important;
        box-sizing: border-box !important;
        padding: 10px 16px !important;
        border: 0 !important;
        border-radius: 50px !important;
        font-size: 13px !important;
        font-weight: 600 !important;
        line-height: 20px !important;
        box-shadow: none !important;
    }

    html[data-theme] body :is([data-theme="light"].theme-btn, [data-theme="light"].config-theme-btn, [data-hum-theme="light"], [data-theme="light"].sidebar-flyout-theme-btn, [data-skala-theme="light"]) {
        background: var(--mobile-pref-light-fill) !important;
        color: var(--mobile-pref-light-text) !important;
    }

    html[data-theme] body :is([data-theme="dark"].theme-btn, [data-theme="dark"].config-theme-btn, [data-hum-theme="dark"], [data-theme="dark"].sidebar-flyout-theme-btn, [data-skala-theme="dark"]) {
        background: var(--mobile-pref-dark-fill) !important;
        color: var(--mobile-pref-dark-text) !important;
    }

    html[data-theme="dark"] body :is(.theme-btn.active, .config-theme-btn.active, .header-user-dropdown__theme-btn.is-active, .sidebar-flyout-theme-btn.active, .sk-theme-btn.active) {
        box-shadow: 0 4px 12px #0003 !important;
    }

    html body :is(.theme-btn, .config-theme-btn, .header-user-dropdown__theme-btn, .sidebar-flyout-theme-btn, .sk-theme-btn) :is(i, svg) {
        width: 16px !important;
        height: 16px !important;
        color: inherit !important;
        stroke: currentColor !important;
    }

    html body :is(.auth-language__toggle, .auth-language__menu) {
        background: var(--mobile-pref-surface) !important;
        border-color: var(--mobile-pref-border) !important;
        color: var(--mobile-pref-text) !important;
    }

    html body .sk-theme-toggle {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        max-width: 100% !important;
    }

    html body .sk-theme-label { margin-bottom: 2px !important; }

    html body .mobile-pref-language-label {
        display: none !important;
    }

    .mobile-pref-language {
        position: relative;
        width: 124px;
        max-width: 100%;
        margin-left: auto;
        color: var(--mobile-pref-text);
    }

    .mobile-pref-language__toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        width: 100%;
        min-height: 44px;
        padding: 6px 10px;
        border: 1px solid var(--mobile-pref-border);
        border-radius: 10px;
        background: var(--mobile-pref-surface);
        color: inherit;
        font: inherit;
        font-size: 14px;
        cursor: pointer;
    }

    .mobile-pref-language__toggle > svg {
        flex-shrink: 0;
        width: 16px;
        height: 16px;
    }

    html body .mobile-pref-language .fi {
        display: inline-block !important;
        flex: 0 0 auto !important;
        width: 22px !important;
        height: 22px !important;
        min-width: 0 !important;
        min-height: 0 !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        overflow: hidden !important;
        border-radius: 50% !important;
        background-position: center !important;
        background-size: cover !important;
        background-repeat: no-repeat !important;
        clip-path: circle(50%);
    }

    html body .mobile-pref-language .fi-br { background-image: url('../images/flags/br.png'); }
    html body .mobile-pref-language .fi-es { background-image: url('../images/flags/es.png'); }

    html body .mobile-pref-language__toggle > .fi {
        width: 28px !important;
        height: 28px !important;
    }

    html body .mobile-pref-language__menu {
        display: flex !important;
        position: absolute !important;
        top: calc(100% + 8px) !important;
        right: 0 !important;
        left: auto !important;
        z-index: 1200;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 4px !important;
        width: 100% !important;
        max-width: calc(100vw - 24px) !important;
        box-sizing: border-box;
        padding: 4px !important;
        border: 1px solid var(--mobile-pref-border) !important;
        border-radius: 12px !important;
        background: var(--mobile-pref-surface) !important;
        box-shadow: 0 8px 24px #0003;
    }

    html body .mobile-pref-language:not(.is-open) .mobile-pref-language__menu {
        display: none !important;
    }

    html body .mobile-pref-language__menu > button {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 6px !important;
        width: 100% !important;
        min-width: 0 !important;
        min-height: 44px !important;
        max-width: none !important;
        max-height: none !important;
        height: auto !important;
        aspect-ratio: auto !important;
        flex: 0 0 auto !important;
        box-sizing: border-box !important;
        padding: 6px 4px !important;
        border: 1px solid transparent !important;
        border-radius: 8px !important;
        background: transparent !important;
        color: var(--mobile-pref-text) !important;
        font: inherit;
        font-size: 12px !important;
        line-height: 1.3 !important;
        text-align: left !important;
        box-shadow: none !important;
        cursor: pointer;
    }

    html body .mobile-pref-language__menu > :is([data-locale="es"], [data-hum-locale="es"]) { order: 0; }
    html body .mobile-pref-language__menu > :is([data-locale="pt_BR"], [data-hum-locale="pt_BR"]) { order: 1; }

    html body .mobile-pref-language__menu > :is([data-locale-locked], [data-hum-locale-locked], .is-locked) {
        display: none !important;
    }

    html body .mobile-pref-language__menu > :is(.active, .is-active) {
        border-color: #b95760 !important;
        background: rgba(185, 87, 96, 0.12) !important;
        transform: none !important;
    }

    .mobile-pref-language__name {
        display: inline !important;
        min-width: 0;
        white-space: normal !important;
    }

    .mobile-pref-language button:focus-visible {
        outline: 2px solid #b95760;
        outline-offset: 3px;
    }
}

@media (min-width: 769px) {
    .mobile-pref-language { display: contents; }
    .mobile-pref-language__toggle, .mobile-pref-language__name { display: none; }
}

.mobile-account-settings-toggle,
.mobile-account-settings-panel,
.mobile-account-settings-label,
.mobile-account-settings-current-mode {
    display: none;
}

@media (max-width: 768px) {
    html {
        --mobile-account-settings-card: #f0f1f3;
        --mobile-account-settings-muted: #737373;
        --mobile-account-settings-inactive: #00000014;
    }

    html[data-theme="dark"] {
        --mobile-account-settings-card: #1e2125;
        --mobile-account-settings-muted: #b5b5b5;
        --mobile-account-settings-inactive: #ffffff14;
    }

    html body .mobile-account-settings-toggle {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        min-height: 44px;
        padding: 10px 12px;
        box-sizing: border-box;
        border: 0;
        border-radius: 8px;
        background: transparent;
        color: var(--mobile-pref-text);
        font: inherit;
        font-size: 14px;
        text-align: left;
        cursor: pointer;
    }

    .mobile-account-settings-toggle > svg {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
    }

    .mobile-account-settings-toggle > span {
        flex: 1;
    }

    .mobile-account-settings-toggle .mobile-account-settings-arrow {
        width: 14px;
        height: 14px;
        transition: transform 0.18s ease;
    }

    .mobile-account-settings-toggle[aria-expanded="true"] .mobile-account-settings-arrow {
        transform: rotate(180deg);
    }

    .mobile-account-settings-toggle:hover {
        background: var(--mobile-account-settings-inactive);
    }

    html body .mobile-account-settings-toggle:focus-visible {
        outline: 2px solid var(--brand, #ff5757);
        outline-offset: 2px;
    }

    html body .mobile-account-settings-panel {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 12px 0 6px;
        margin: 0 6px;
        border-top: 1px solid var(--mobile-pref-border);
    }

    html body .mobile-account-settings-panel[hidden],
    html body .mobile-account-settings-old-divider,
    html body .mobile-account-settings-panel .header-user-dropdown__pref-row > .header-user-dropdown__pref-label {
        display: none !important;
    }

    html body .mobile-account-settings-panel .header-user-dropdown__pref-row {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding: 12px !important;
        box-sizing: border-box;
        border: 0 !important;
        border-radius: 10px !important;
        background: var(--mobile-account-settings-card) !important;
        box-shadow: none !important;
    }

    html body .mobile-account-settings-panel .mobile-account-settings-label {
        display: block;
        color: var(--mobile-pref-text);
        font-size: 12px;
        font-weight: 600;
        line-height: 18px;
        text-transform: none;
        letter-spacing: normal;
    }

    html body .mobile-account-settings-panel .mobile-account-settings-current-mode {
        display: block;
        color: var(--mobile-account-settings-muted);
        font-size: 11px;
        line-height: 16px;
    }

    html body .mobile-account-settings-panel .header-user-dropdown__pref-row.mobile-account-settings-appearance {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto;
        column-gap: 12px !important;
        row-gap: 2px !important;
        align-items: center !important;
    }

    .mobile-account-settings-appearance > .mobile-account-settings-label {
        grid-column: 1;
        grid-row: 1;
    }

    .mobile-account-settings-appearance > .mobile-account-settings-current-mode {
        grid-column: 1;
        grid-row: 2;
    }

    html body .mobile-account-settings-panel .header-user-dropdown__theme {
        display: flex !important;
        flex-direction: row !important;
        grid-column: 2;
        grid-row: 1 / span 2;
        align-items: center !important;
        gap: 6px !important;
        width: auto !important;
    }

    html[data-theme] body .mobile-account-settings-panel .header-user-dropdown__theme-btn[data-hum-theme] {
        flex: 0 0 36px;
        width: 36px !important;
        min-width: 36px !important;
        max-width: 36px !important;
        height: 36px !important;
        min-height: 36px !important;
        padding: 8px !important;
        border-radius: 50% !important;
        background: var(--mobile-account-settings-inactive) !important;
        color: var(--mobile-account-settings-muted) !important;
        box-shadow: none !important;
    }

    html[data-theme] body .mobile-account-settings-panel .header-user-dropdown__theme-btn[data-hum-theme].is-active {
        background: var(--brand, #ff5757) !important;
        color: #fff !important;
    }

    html body .mobile-account-settings-panel .header-user-dropdown__theme-btn > span {
        display: none !important;
    }

    html body .mobile-account-settings-panel .mobile-pref-language {
        width: 100%;
        max-width: 100%;
        margin: 0;
    }

    html body .mobile-account-settings-panel .mobile-pref-language__toggle {
        width: 100%;
        min-height: 40px;
        padding: 8px 10px;
        gap: 8px;
        border-radius: 8px;
    }

    html body .mobile-account-settings-panel .mobile-pref-language__toggle > .fi {
        order: -1;
        width: 22px !important;
        height: 22px !important;
    }

    .mobile-account-settings-panel .mobile-pref-language__current-label {
        flex: 1;
        min-width: 0;
        font-size: 12px;
        text-align: left;
    }
}
