/*
 * UCC CMS appearance system.
 * This file is intentionally loaded after all CMS page styles so semantic theme
 * tokens win over legacy light/dark declarations without altering public content.
 */
:root,
:root[data-theme="light"] {
    --cms-page-bg: #f4f7fb;
    --cms-surface: #ffffff;
    --cms-surface-secondary: #f8fafc;
    --cms-text-primary: #172033;
    --cms-text-secondary: #5d6b82;
    --cms-border: #d7deea;
    --cms-input-bg: #ffffff;
    --cms-input-text: #172033;
    --cms-toolbar-bg: #f1f5f9;
    --cms-hover-bg: #eaf1fb;
    --cms-primary: #1f5fbf;
    --cms-primary-contrast: #ffffff;
    --cms-danger: #b42332;
    --cms-danger-surface: #fce8eb;
    --cms-warning: #875d00;
    --cms-warning-surface: #fff4cc;
    --cms-success: #187342;
    --cms-success-surface: #ddf5e7;
    --cms-info: #155e75;
    --cms-info-surface: #dff3f8;
    --cms-focus-ring: rgba(31, 95, 191, 0.24);
    --cms-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
    --cms-backdrop: rgba(15, 23, 42, 0.55);
    --cms-placeholder: #78869b;
    --cms-topbar-bg: #17365f;
    --cms-topbar-text: #ffffff;
    --cms-image-canvas: #111827;
    --public-surface: var(--cms-surface);
    --public-surface-secondary: var(--cms-surface-secondary);
    --public-text-primary: var(--cms-text-primary);
    --public-text-secondary: var(--cms-text-secondary);
    --public-border: var(--cms-border);
    --public-primary: var(--cms-primary);
    --public-primary-text: var(--cms-primary-contrast);
    --public-hover-bg: var(--cms-hover-bg);

    --bs-body-bg: var(--cms-page-bg);
    --bs-body-color: var(--cms-text-primary);
    --bs-secondary-color: var(--cms-text-secondary);
    --bs-border-color: var(--cms-border);
    --bs-tertiary-bg: var(--cms-surface-secondary);
    --bs-primary: var(--cms-primary);
    --bs-link-color: var(--cms-primary);
    --bs-link-hover-color: #174a96;
}

:root[data-theme="dark"] {
    --cms-page-bg: #0f141c;
    --cms-surface: #171e28;
    --cms-surface-secondary: #202936;
    --cms-text-primary: #edf2f7;
    --cms-text-secondary: #aeb9c8;
    --cms-border: #344052;
    --cms-input-bg: #111822;
    --cms-input-text: #edf2f7;
    --cms-toolbar-bg: #202936;
    --cms-hover-bg: #293548;
    --cms-primary: #74a7ff;
    --cms-primary-contrast: #08111f;
    --cms-danger: #ff8b98;
    --cms-danger-surface: #48232a;
    --cms-warning: #ffd166;
    --cms-warning-surface: #41351e;
    --cms-success: #76d7a0;
    --cms-success-surface: #1d3c2d;
    --cms-info: #80d8ee;
    --cms-info-surface: #193744;
    --cms-focus-ring: rgba(116, 167, 255, 0.28);
    --cms-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
    --cms-backdrop: rgba(0, 0, 0, 0.72);
    --cms-placeholder: #8996a8;
    --cms-topbar-bg: #111822;
    --cms-topbar-text: #edf2f7;
    --cms-image-canvas: #080b10;

    --bs-body-bg: var(--cms-page-bg);
    --bs-body-color: var(--cms-text-primary);
    --bs-secondary-color: var(--cms-text-secondary);
    --bs-border-color: var(--cms-border);
    --bs-tertiary-bg: var(--cms-surface-secondary);
    --bs-primary: var(--cms-primary);
    --bs-link-color: var(--cms-primary);
    --bs-link-hover-color: #a9c8ff;
}

html[data-theme] {
    background: var(--cms-page-bg);
}

body.cms-theme {
    min-height: 100vh;
    background: var(--cms-page-bg);
    color: var(--cms-text-primary);
}

body.cms-theme .admin-workspace,
body.cms-theme .admin-workspace--superadmin,
body.cms-theme .admin-main--superadmin,
body.cms-theme .admin-modal-shell,
body.cms-theme .cms-auth-shell {
    background: var(--cms-page-bg);
    color: var(--cms-text-primary);
}

body.cms-theme .admin-topbar,
body.cms-theme .admin-topbar--superadmin {
    background: var(--cms-topbar-bg) !important;
    border-color: var(--cms-border);
    color: var(--cms-topbar-text);
    box-shadow: var(--cms-shadow);
}

body.cms-theme .admin-topbar :is(.navbar-brand, .btn-outline-light) {
    color: var(--cms-topbar-text);
}

body.cms-theme .admin-topbar .btn-outline-light {
    border-color: color-mix(in srgb, var(--cms-topbar-text) 55%, transparent);
}

body.cms-theme .admin-topbar .btn-outline-light:hover,
body.cms-theme .admin-topbar .btn-outline-light:focus-visible {
    background: color-mix(in srgb, var(--cms-topbar-text) 16%, transparent);
}

body.cms-theme .admin-topbar .container-fluid,
body.cms-theme .admin-topbar .ms-auto {
    flex-wrap: wrap;
}

body.cms-theme .admin-topbar .ms-auto {
    justify-content: flex-end;
}

body.cms-theme .superadmin-commandbar,
body.cms-theme .admin-sidebar,
body.cms-theme .admin-sidebar--superadmin {
    background: var(--cms-surface);
    border-color: var(--cms-border);
    color: var(--cms-text-primary);
}

body.cms-theme .superadmin-commandbar__title,
body.cms-theme .admin-sidebar__heading {
    color: var(--cms-text-secondary);
}

body.cms-theme .superadmin-commandbar__links a,
body.cms-theme .admin-sidebar .list-group-item,
body.cms-theme .admin-sidebar--superadmin .list-group-item {
    background: transparent;
    border-color: transparent;
    color: var(--cms-text-primary);
}

body.cms-theme .superadmin-commandbar__links a {
    border-color: var(--cms-border);
}

body.cms-theme .superadmin-commandbar__links a:hover,
body.cms-theme .admin-sidebar .list-group-item:hover,
body.cms-theme .admin-sidebar--superadmin .list-group-item:hover {
    background: var(--cms-hover-bg);
    border-color: var(--cms-border);
    color: var(--cms-primary);
}

body.cms-theme :is(
    .card,
    .module-card,
    .stat-card,
    .dashboard-page-preview,
    .admin-section-card,
    .admin-role-banner,
    .page-editor-nav,
    .page-appearance-preview,
    .department-post-composer,
    .department-dashboard-launchpad__card,
    .department-dashboard-module,
    .department-dashboard-refresh__quick-composer,
    .support-form,
    .support-method-card
):not(.feed-post-body *, .department-about-rich-text *, .content-body *) {
    background: var(--cms-surface);
    border-color: var(--cms-border);
    color: var(--cms-text-primary);
    box-shadow: var(--cms-shadow);
}

body.cms-theme :is(.card-header, .card-footer, .page-appearance-preview__header) {
    background: var(--cms-surface-secondary);
    border-color: var(--cms-border);
    color: var(--cms-text-primary);
}

body.cms-theme :is(.modal-content, .offcanvas, .popover, .toast) {
    background: var(--cms-surface);
    border-color: var(--cms-border);
    color: var(--cms-text-primary);
}

body.cms-theme :is(.modal-header, .modal-footer),
body.cms-theme :is(.dashboard-panel-modal, .department-section-modal) :is(.modal-header, .modal-body) {
    background: var(--cms-surface);
    border-color: var(--cms-border);
    color: var(--cms-text-primary);
}

body.cms-theme .modal-backdrop {
    --bs-backdrop-bg: var(--cms-backdrop);
}

body.cms-theme :is(.modal-title, h1, h2, h3, h4, h5, h6):not(.feed-post-body *, .department-about-rich-text *, .content-body *) {
    color: var(--cms-text-primary);
}

body.cms-theme :is(.text-muted, .form-text, .small.text-secondary):not(.feed-post-body *, .department-about-rich-text *, .content-body *) {
    color: var(--cms-text-secondary) !important;
}

body.cms-theme :is(.form-control, .form-select, .form-check-input, .input-group-text) {
    background-color: var(--cms-input-bg);
    border-color: var(--cms-border);
    color: var(--cms-input-text);
}

body.cms-theme :is(.form-control, .form-select)::placeholder {
    color: var(--cms-placeholder);
    opacity: 1;
}

body.cms-theme :is(.form-control, .form-select, .form-check-input):focus {
    background-color: var(--cms-input-bg);
    border-color: var(--cms-primary);
    color: var(--cms-input-text);
    box-shadow: 0 0 0 0.22rem var(--cms-focus-ring);
}

body.cms-theme .form-control:disabled,
body.cms-theme .form-select:disabled,
body.cms-theme .form-control[readonly],
body.cms-theme .form-control-plaintext {
    background-color: var(--cms-surface-secondary);
    color: var(--cms-text-secondary);
}

body.cms-theme :is(.dropdown-menu, .list-group, .list-group-item) {
    --bs-dropdown-bg: var(--cms-surface);
    --bs-dropdown-color: var(--cms-text-primary);
    --bs-dropdown-border-color: var(--cms-border);
    --bs-dropdown-link-color: var(--cms-text-primary);
    --bs-dropdown-link-hover-bg: var(--cms-hover-bg);
    --bs-dropdown-link-hover-color: var(--cms-primary);
    background-color: var(--cms-surface);
    border-color: var(--cms-border);
    color: var(--cms-text-primary);
}

body.cms-theme :is(.dropdown-item, .list-group-item-action) {
    color: var(--cms-text-primary);
}

body.cms-theme :is(.dropdown-item, .list-group-item-action):hover,
body.cms-theme :is(.dropdown-item, .list-group-item-action):focus {
    background: var(--cms-hover-bg);
    color: var(--cms-primary);
}

body.cms-theme :is(.table, .table-responsive) {
    --bs-table-bg: var(--cms-surface);
    --bs-table-color: var(--cms-text-primary);
    --bs-table-border-color: var(--cms-border);
    --bs-table-striped-bg: var(--cms-surface-secondary);
    --bs-table-striped-color: var(--cms-text-primary);
    --bs-table-hover-bg: var(--cms-hover-bg);
    --bs-table-hover-color: var(--cms-text-primary);
    background: var(--cms-surface);
    color: var(--cms-text-primary);
}

body.cms-theme .table > :not(caption) > * > * {
    background-color: var(--bs-table-bg);
    border-color: var(--cms-border);
    color: var(--cms-text-primary);
}

body.cms-theme :is(.nav-tabs, .nav-pills) {
    --bs-nav-link-color: var(--cms-text-secondary);
    --bs-nav-link-hover-color: var(--cms-primary);
    border-color: var(--cms-border);
}

body.cms-theme .nav-tabs .nav-link.active {
    background: var(--cms-surface);
    border-color: var(--cms-border) var(--cms-border) var(--cms-surface);
    color: var(--cms-text-primary);
}

body.cms-theme .pagination {
    --bs-pagination-bg: var(--cms-surface);
    --bs-pagination-color: var(--cms-primary);
    --bs-pagination-border-color: var(--cms-border);
    --bs-pagination-hover-bg: var(--cms-hover-bg);
    --bs-pagination-hover-border-color: var(--cms-border);
    --bs-pagination-disabled-bg: var(--cms-surface-secondary);
    --bs-pagination-disabled-color: var(--cms-text-secondary);
}

body.cms-theme :is(.bg-light, .bg-light-subtle, .text-bg-light) {
    background-color: var(--cms-surface-secondary) !important;
    color: var(--cms-text-primary) !important;
}

body.cms-theme :is(.border, .border-top, .border-bottom, .border-start, .border-end) {
    border-color: var(--cms-border) !important;
}

body.cms-theme .alert-success { background: var(--cms-success-surface); border-color: var(--cms-success); color: var(--cms-success); }
body.cms-theme .alert-danger { background: var(--cms-danger-surface); border-color: var(--cms-danger); color: var(--cms-danger); }
body.cms-theme .alert-warning { background: var(--cms-warning-surface); border-color: var(--cms-warning); color: var(--cms-warning); }
body.cms-theme .alert-info { background: var(--cms-info-surface); border-color: var(--cms-info); color: var(--cms-info); }

body.cms-theme :is(.badge.text-bg-light, .badge.bg-light) {
    background: var(--cms-surface-secondary) !important;
    border: 1px solid var(--cms-border);
    color: var(--cms-text-primary) !important;
}

body.cms-theme .badge.text-bg-dark {
    background: var(--cms-text-primary) !important;
    color: var(--cms-surface) !important;
}

body.cms-theme .rich-text-editor,
body.cms-theme .rich-text-editor__toolbar,
body.cms-theme .rich-text-editor__image-help {
    background: var(--cms-toolbar-bg);
    border-color: var(--cms-border);
    color: var(--cms-text-secondary);
}

body.cms-theme .rich-text-editor__toolbar button,
body.cms-theme .rich-text-editor__format {
    background: var(--cms-surface);
    border-color: var(--cms-border);
    color: var(--cms-text-primary);
}

body.cms-theme .rich-text-editor__toolbar button:hover {
    background: var(--cms-hover-bg);
    border-color: var(--cms-primary);
    color: var(--cms-primary);
}

body.cms-theme .rich-text-editor__surface {
    background: var(--cms-input-bg);
    color: var(--cms-input-text);
}

body.cms-theme .rich-text-editor__surface:empty::before {
    color: var(--cms-placeholder);
}

/* Both current Feed Post Composer variants now follow the selected CMS theme. */
body.cms-theme .feed-post-composer-modal {
    --composer-bg: var(--cms-surface);
    --composer-panel: var(--cms-surface-secondary);
    --composer-border: var(--cms-border);
    --composer-muted: var(--cms-text-secondary);
    background: var(--cms-surface);
    border-color: var(--cms-border);
    color: var(--cms-text-primary);
    box-shadow: var(--cms-shadow);
}

body.cms-theme .feed-post-composer-modal :is(.form-label, .form-check-label, h2),
body.cms-theme .feed-post-composer-modal .rich-text-editor__surface,
body.cms-theme .feed-post-composer-modal .image-sequence-upload__item {
    color: var(--cms-text-primary);
}

body.cms-theme .feed-post-composer-modal :is(.form-control, .form-select, textarea),
body.cms-theme .feed-post-composer-modal .rich-text-editor,
body.cms-theme .feed-post-composer-modal .rich-text-editor__toolbar,
body.cms-theme .feed-post-composer-modal .rich-text-editor__format,
body.cms-theme .feed-post-composer-modal .rich-text-editor__toolbar button,
body.cms-theme .feed-post-composer-modal .image-sequence-upload__item {
    background: var(--cms-surface-secondary);
    border-color: var(--cms-border);
    color: var(--cms-input-text);
}

body.cms-theme .feed-post-composer-modal .form-select {
    color-scheme: normal;
}

body.cms-theme .department-dashboard-refresh__composer-prompt,
body.cms-theme .department-dashboard-refresh__composer-modal .modal-content,
body.cms-theme .department-inline-post-form--modal :is(.rich-text-editor, .rich-text-editor__toolbar, .image-sequence-upload, .department-inline-post-form__footer),
body.cms-theme .department-inline-post-form--modal :is(.rich-text-editor__toolbar button, .rich-text-editor__format) {
    background: var(--cms-surface-secondary);
    border-color: var(--cms-border);
    color: var(--cms-text-primary);
}

body.cms-theme .department-dashboard-refresh__composer-modal .modal-header,
body.cms-theme .department-inline-post-form--modal :is(.form-label, .form-check-label, .form-text),
body.cms-theme .department-dashboard-refresh__composer-modal .modal-header p,
body.cms-theme .department-dashboard-refresh__post-options small {
    border-color: var(--cms-border);
    color: var(--cms-text-secondary);
}

body.cms-theme .department-dashboard-tabs button,
body.cms-theme .page-editor-nav__item,
body.cms-theme .admin-evidence-chip,
body.cms-theme .admin-role-banner__meta span {
    background: var(--cms-surface-secondary);
    border-color: var(--cms-border);
    color: var(--cms-text-primary);
}

body.cms-theme .department-dashboard-tabs button:hover,
body.cms-theme .department-dashboard-tabs button.is-active,
body.cms-theme .page-editor-nav__item:hover,
body.cms-theme .page-editor-nav__item.is-active {
    background: var(--cms-hover-bg);
    border-color: var(--cms-primary);
    color: var(--cms-primary);
}

body.cms-theme .cms-support-footer {
    background: var(--cms-surface);
    border-color: var(--cms-border) !important;
    color: var(--cms-text-secondary);
}

body.cms-theme .image-cropper-frame {
    background: var(--cms-image-canvas);
    border-color: var(--cms-border);
}

.cms-appearance-menu {
    min-width: 240px;
    padding: 0.8rem;
}

.cms-appearance-control {
    display: grid;
    gap: 0.45rem;
    margin: 0;
    padding: 0;
    border: 0;
}

.cms-appearance-control legend {
    margin-bottom: 0.45rem;
    color: var(--cms-text-primary);
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.cms-appearance-control label {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0;
    padding: 0.42rem 0.5rem;
    border-radius: 7px;
    color: var(--cms-text-primary);
    cursor: pointer;
}

.cms-appearance-control label:hover {
    background: var(--cms-hover-bg);
}

.cms-appearance-control input {
    accent-color: var(--cms-primary);
}

.public-theme-switch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-width: 112px;
    padding: 0.25rem;
    touch-action: pan-y;
    user-select: none;
}

.public-theme-menu-toggle {
    display: inline-flex;
    width: 38px;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    padding: 0.5rem !important;
    border-radius: 999px;
}

.public-theme-menu-toggle::after {
    display: none;
}

.public-theme-menu-toggle__icon {
    display: none;
    width: 19px;
    height: 19px;
}

.public-theme-menu-toggle__icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

[data-theme="light"] .public-theme-menu-toggle__icon--sun,
[data-theme="dark"] .public-theme-menu-toggle__icon--moon {
    display: inline-flex;
}

.public-theme-switch__control {
    position: relative;
    display: inline-flex;
    margin: 0;
    cursor: pointer;
    touch-action: manipulation;
}

.public-theme-switch__input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.public-theme-switch__track {
    position: relative;
    display: block;
    width: 52px;
    height: 28px;
    border: 1px solid var(--public-border);
    border-radius: 999px;
    background: var(--public-surface-secondary);
    transition: background-color 180ms ease, border-color 180ms ease;
}

.public-theme-switch__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--public-primary);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.24);
    transition: transform 180ms ease, background-color 180ms ease;
}

.public-theme-switch__input:checked + .public-theme-switch__track {
    border-color: var(--public-primary);
    background: var(--public-primary);
}

.public-theme-switch__input:checked + .public-theme-switch__track .public-theme-switch__thumb {
    transform: translateX(24px);
    background: var(--public-primary-text);
}

.public-theme-switch__input:focus-visible + .public-theme-switch__track {
    outline: 3px solid var(--public-primary);
    outline-offset: 3px;
}

.public-theme-switch__icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    align-items: center;
    justify-content: center;
    color: var(--public-text-secondary);
    transition: color 180ms ease, opacity 180ms ease;
}

.public-theme-switch__icon svg {
    width: 100%;
    height: 100%;
}

[data-theme="light"] .public-theme-switch__icon--sun {
    color: var(--public-primary);
    opacity: 1;
}

[data-theme="light"] .public-theme-switch__icon--moon,
[data-theme="dark"] .public-theme-switch__icon--sun {
    opacity: 0.55;
}

[data-theme="dark"] .public-theme-switch__icon--moon {
    color: var(--public-primary);
    opacity: 1;
}

/* Public interactive controls: theme labels, icons, hover, active, and selected states. */
body.cms-public-theme .btn-primary {
    --bs-btn-color: var(--cms-primary-contrast);
    --bs-btn-bg: var(--cms-primary);
    --bs-btn-border-color: var(--cms-primary);
    --bs-btn-hover-color: var(--cms-primary-contrast);
    --bs-btn-hover-bg: color-mix(in srgb, var(--cms-primary) 88%, var(--cms-text-primary));
    --bs-btn-hover-border-color: color-mix(in srgb, var(--cms-primary) 88%, var(--cms-text-primary));
    --bs-btn-focus-shadow-rgb: 31, 95, 191;
    --bs-btn-active-color: var(--cms-primary-contrast);
    --bs-btn-active-bg: color-mix(in srgb, var(--cms-primary) 80%, var(--cms-text-primary));
    --bs-btn-active-border-color: color-mix(in srgb, var(--cms-primary) 80%, var(--cms-text-primary));
    --bs-btn-disabled-color: var(--cms-primary-contrast);
    --bs-btn-disabled-bg: var(--cms-primary);
    --bs-btn-disabled-border-color: var(--cms-primary);
}

body.cms-public-theme .btn-outline-primary {
    --bs-btn-color: var(--cms-primary);
    --bs-btn-border-color: var(--cms-primary);
    --bs-btn-hover-color: var(--cms-primary-contrast);
    --bs-btn-hover-bg: var(--cms-primary);
    --bs-btn-hover-border-color: var(--cms-primary);
    --bs-btn-active-color: var(--cms-primary-contrast);
    --bs-btn-active-bg: var(--cms-primary);
    --bs-btn-active-border-color: var(--cms-primary);
    --bs-btn-disabled-color: var(--cms-primary);
    --bs-btn-disabled-border-color: var(--cms-primary);
}

body.cms-public-theme .btn-outline-secondary {
    --bs-btn-color: var(--cms-text-secondary);
    --bs-btn-border-color: var(--cms-border);
    --bs-btn-hover-color: var(--cms-text-primary);
    --bs-btn-hover-bg: var(--cms-hover-bg);
    --bs-btn-hover-border-color: var(--cms-primary);
    --bs-btn-active-color: var(--cms-primary);
    --bs-btn-active-bg: var(--cms-hover-bg);
    --bs-btn-active-border-color: var(--cms-primary);
    --bs-btn-disabled-color: var(--cms-text-secondary);
    --bs-btn-disabled-border-color: var(--cms-border);
}

body.cms-public-theme .btn-light {
    --bs-btn-color: var(--cms-text-primary);
    --bs-btn-bg: var(--cms-surface-secondary);
    --bs-btn-border-color: var(--cms-border);
    --bs-btn-hover-color: var(--cms-primary);
    --bs-btn-hover-bg: var(--cms-hover-bg);
    --bs-btn-hover-border-color: var(--cms-primary);
    --bs-btn-active-color: var(--cms-primary);
    --bs-btn-active-bg: var(--cms-hover-bg);
    --bs-btn-active-border-color: var(--cms-primary);
    --bs-btn-disabled-color: var(--cms-text-secondary);
    --bs-btn-disabled-bg: var(--cms-surface-secondary);
    --bs-btn-disabled-border-color: var(--cms-border);
}

body.cms-public-theme :is(
    .btn[aria-pressed="true"],
    .btn[aria-selected="true"],
    .btn.is-active,
    .btn-check:checked + .btn-outline-primary
) {
    border-color: var(--cms-primary);
    background: var(--cms-primary);
    color: var(--cms-primary-contrast);
}

body.cms-public-theme :is(.nav-pills, .nav-tabs) .nav-link.active {
    border-color: var(--cms-primary);
    background: var(--cms-primary);
    color: var(--cms-primary-contrast);
}

body.cms-public-theme .dropdown-menu {
    --bs-dropdown-link-active-bg: var(--cms-primary);
    --bs-dropdown-link-active-color: var(--cms-primary-contrast);
}

body.cms-public-theme .pagination {
    --bs-pagination-active-bg: var(--cms-primary);
    --bs-pagination-active-border-color: var(--cms-primary);
    --bs-pagination-active-color: var(--cms-primary-contrast);
}

body.cms-public-theme :is(
    .home-announcement-readmore__button,
    .home-announcement-readmore__link,
    .department-read-more__button,
    .leadership-profile-layout .profile-inline-more,
    .page-content-modal__content .profile-inline-more
) {
    color: var(--cms-primary);
}

body.cms-public-theme :is(
    .home-announcement-readmore__button,
    .home-announcement-readmore__link,
    .department-read-more__button,
    .leadership-profile-layout .profile-inline-more,
    .page-content-modal__content .profile-inline-more
):is(:hover, :focus-visible) {
    color: var(--cms-text-primary);
}

body.cms-public-theme :is(
    .department-v2__topbar-link,
    .department-v2__outline-btn
) {
    border-color: var(--cms-primary);
    background: var(--cms-surface);
    color: var(--cms-primary);
}

body.cms-public-theme :is(
    .department-v2__topbar-link,
    .department-v2__outline-btn
):is(:hover, :focus-visible) {
    border-color: var(--cms-primary);
    background: var(--cms-hover-bg);
    color: var(--cms-text-primary);
}

body.cms-public-theme .department-v2__section-action {
    border: 1px solid var(--cms-primary);
    background: var(--cms-primary);
    color: var(--cms-primary-contrast);
}

body.cms-public-theme .department-v2__section-action:is(:hover, :focus-visible, :active) {
    background: color-mix(in srgb, var(--cms-primary) 84%, var(--cms-text-primary));
    color: var(--cms-primary-contrast);
}

body.cms-public-theme .courses-directory__hero :is(.courses-directory__eyebrow, h1, p) {
    color: #ffffff;
}

body.cms-public-theme :is(.home-info, .home-facebook-layout, .home-contact-card, .fb-dark-post) {
    border-color: var(--cms-border);
    background: var(--cms-surface);
    color: var(--cms-text-primary);
}

body.cms-public-theme .home-contact-card {
    background: var(--cms-surface-secondary);
}

body.cms-public-theme .home-contact-card :is(h3, .home-contact-card__line) {
    color: var(--cms-text-primary);
}

body.cms-public-theme .home-contact-card__line a {
    color: var(--cms-primary);
}

body.cms-public-theme .home-cover .home-cover-events h2,
body.cms-public-theme .home-cover-events__eyebrow,
body.cms-public-theme .home-cover-events__summary,
body.cms-public-theme .home-cover-events__counts span {
    color: #ffffff;
}

body.cms-public-theme .fb-dark-post :is(
    .fb-dark-post__author,
    .fb-dark-post__author-link,
    .fb-dark-post__title,
    .fb-dark-post__title a,
    .fb-dark-post__text
) {
    color: var(--cms-text-primary);
}

body.cms-public-theme .fb-dark-post :is(
    .fb-dark-post__meta,
    .fb-dark-post__more,
    .fb-dark-post__stats
) {
    color: var(--cms-text-secondary);
}

body.cms-public-theme .fb-dark-post__dot {
    background: var(--cms-text-secondary);
}

body.cms-public-theme .fb-dark-post__stats {
    border-color: var(--cms-border);
}

body.cms-public-theme .fb-dark-post__views {
    border-color: var(--cms-border);
    background: var(--cms-surface-secondary);
    color: var(--cms-text-secondary);
}

body.cms-public-theme .fb-dark-post :is(.fb-eye-icon, .fb-read-link, .fb-share-link) {
    color: var(--cms-primary);
}

body.cms-public-theme .fb-dark-post :is(
    .fb-dark-post__author-link,
    .fb-dark-post__more,
    .fb-read-link,
    .fb-share-link
):is(:hover, :focus-visible) {
    color: var(--cms-primary);
}

body.cms-public-theme .department-public {
    color: var(--cms-text-primary);
}

body.cms-public-theme :is(
    .department-public__header,
    .department-public__section-nav,
    .department-public__contact-card,
    .department-public__mobile-menu,
    .department-public__mobile-menu-list button,
    .department-public__mobile-menu-list a
) {
    border-color: var(--cms-border);
    background: var(--cms-surface);
    color: var(--cms-text-primary);
}

body.cms-public-theme .department-public__identity :is(h1, p),
body.cms-public-theme .department-public__contact-head h2,
body.cms-public-theme .department-public__contact-list dd,
body.cms-public-theme .department-public__contact-icon {
    color: var(--cms-text-primary);
}

body.cms-public-theme .department-public__meta span {
    border-color: var(--cms-border);
    background: var(--cms-surface-secondary);
    color: var(--cms-text-secondary);
}

body.cms-public-theme .department-public__nav-button {
    color: var(--cms-text-primary);
}

body.cms-public-theme .department-public__nav-button:is(:hover, :focus-visible, [aria-expanded="true"]),
body.cms-public-theme .department-public__mobile-menu-list :is(button, a):hover {
    background: var(--cms-hover-bg);
    color: var(--cms-primary);
}

body.cms-public-theme .department-public__contact-list a:hover {
    color: var(--cms-primary);
}

body.cms-public-theme .department-public__contact-empty {
    color: var(--cms-text-secondary);
}

body.cms-public-theme :is(
    .template-profile-header,
    .template-intro,
    .template-evidence-panel,
    .template-empty-feed,
    .template-feed-wall,
    .template-quick-tabs a,
    .content-block,
    .trustees-album__header,
    .trustee-album-card
) {
    border-color: var(--cms-border);
    background: var(--cms-surface);
    color: var(--cms-text-primary);
}

body.cms-public-theme .template-evidence-panel {
    background: var(--cms-surface-secondary);
}

body.cms-public-theme :is(
    .template-profile-title h1,
    .template-profile-title p,
    .template-evidence-panel h2,
    .template-section-heading h2,
    .trustees-album__eyebrow,
    .trustees-album__title,
    .trustees-album__subtitle
) {
    color: var(--cms-text-primary);
}

body.cms-public-theme :is(
    .template-profile-meta span,
    .template-profile-meta a
) {
    border-color: var(--cms-border);
    background: var(--cms-surface-secondary);
    color: var(--cms-text-secondary);
}

body.cms-public-theme :is(
    .template-evidence-panel p,
    .template-section-heading p,
    .template-empty-feed
) {
    color: var(--cms-text-secondary);
}

body.cms-public-theme .template-quick-tabs a:hover {
    border-color: var(--cms-primary);
    background: var(--cms-primary);
    color: var(--cms-primary-contrast);
}

body.cms-public-theme .leadership-profile-layout .profile-card {
    border-color: var(--cms-border);
    background: var(--cms-surface);
    color: var(--cms-text-primary);
}

body.cms-public-theme .leadership-profile-layout :is(
    .leadership-page-title,
    .profile-card .card-title
) {
    color: var(--cms-text-primary);
}

body.cms-public-theme .leadership-profile-layout .profile-card :is(
    .text-muted,
    .profile-inline-content
) {
    color: var(--cms-text-secondary) !important;
}

.cms-auth-appearance {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10;
    width: min(250px, calc(100vw - 2rem));
    padding: 0.85rem;
    background: var(--cms-surface);
    border: 1px solid var(--cms-border);
    border-radius: 10px;
    box-shadow: var(--cms-shadow);
}

@media (max-width: 767.98px) {
    .cms-auth-appearance {
        position: static;
        margin: 1rem auto 0;
    }
}

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

/*
 * Dashboard normalization
 *
 * Dashboard styles predate the appearance system and deliberately assigned
 * independent light/dark palettes. These higher-specificity mappings make the
 * entire CMS dashboard follow the selected appearance while retaining cover
 * images, logos, brand accents, status colors, and post-content formatting.
 */
body.cms-theme .superadmin-control-center {
    color: var(--cms-text-primary);
}

body.cms-theme :is(
    .superadmin-hero,
    .superadmin-metric-card,
    .superadmin-panel,
    .superadmin-module-card,
    .superadmin-watch-item,
    .superadmin-activity-item > div,
    .superadmin-clear-state,
    .superadmin-orbit__core,
    .superadmin-orbit__node,
    .dashboard-page-preview
) {
    background: var(--cms-surface);
    border-color: var(--cms-border);
    color: var(--cms-text-primary);
    box-shadow: var(--cms-shadow);
}

body.cms-theme .dashboard-page-preview {
    --preview-bg: var(--cms-surface) !important;
    --preview-text: var(--cms-text-primary) !important;
    --preview-muted: var(--cms-text-secondary) !important;
}

body.cms-theme :is(
    .superadmin-hero h1,
    .superadmin-metric-card__value,
    .superadmin-panel__head h2,
    .superadmin-module-card strong,
    .superadmin-watch-item,
    .superadmin-activity-item strong,
    .superadmin-clear-state,
    .superadmin-orbit__core span,
    .superadmin-orbit__node
) {
    color: var(--cms-text-primary);
}

body.cms-theme :is(
    .superadmin-hero p,
    .superadmin-metric-card__label,
    .superadmin-metric-card__detail,
    .superadmin-module-card small,
    .superadmin-watch-item span,
    .superadmin-watch-item small,
    .superadmin-activity-item time,
    .superadmin-clear-state span,
    .superadmin-orbit__core small
) {
    color: var(--cms-text-secondary);
}

body.cms-theme :is(.superadmin-pill-action, .superadmin-module-card__status) {
    background: var(--cms-surface-secondary);
    border-color: var(--cms-border);
    color: var(--cms-primary);
}

body.cms-theme :is(.superadmin-pill-action, .superadmin-module-card):hover {
    background: var(--cms-hover-bg);
    border-color: var(--cms-primary);
    color: var(--cms-primary);
}

body.cms-theme .superadmin-module-card:hover :is(strong, small) {
    color: var(--cms-primary);
}

body.cms-theme .admin-page-dashboard {
    --page-bg: var(--cms-page-bg) !important;
    --page-text: var(--cms-text-primary) !important;
    --page-muted: var(--cms-text-secondary) !important;
    --department-refresh-border: var(--cms-border) !important;
    background: var(--cms-page-bg);
    border-color: var(--cms-border);
    color: var(--cms-text-primary);
}

body.cms-theme .admin-page-dashboard--department-v2,
body.cms-theme .admin-page-dashboard .department-dashboard-v2__main,
body.cms-theme .admin-page-dashboard .department-dashboard-workspace,
body.cms-theme .admin-page-dashboard .department-dashboard-panels,
body.cms-theme .admin-page-dashboard .admin-page-dashboard__section-stack {
    background: var(--cms-page-bg);
    color: var(--cms-text-primary);
}

body.cms-theme .admin-page-dashboard :is(
    .template-profile-header,
    .template-profile-identity,
    .department-dashboard-refresh__section-nav,
    .department-dashboard-refresh__contact,
    .admin-page-dashboard__section,
    .page-managed-section,
    .department-dashboard-module,
    .department-dashboard-manager,
    .department-outline-item-editor,
    .dynamic-outline__item,
    .department-faculty-dashboard-card,
    .department-dashboard-approved-feed,
    .feed-post-stream-container
):not(.feed-post-body *, .department-about-rich-text *, .content-body *) {
    background: var(--cms-surface);
    border-color: var(--cms-border);
    color: var(--cms-text-primary);
}

body.cms-theme .admin-page-dashboard :is(
    .admin-page-dashboard__section-head,
    .department-dashboard-module__head,
    .department-post-composer__publishing,
    .department-outline-item-editor__head
) {
    border-color: var(--cms-border);
    color: var(--cms-text-primary);
}

body.cms-theme .admin-page-dashboard :is(
    .template-profile-title h1,
    .department-dashboard-refresh__contact-head h2,
    .department-dashboard-refresh__contact-list dd,
    .department-dashboard-refresh__contact-icon,
    .admin-page-dashboard__section-head h2,
    .department-dashboard-module__head h2,
    .department-dashboard-module__head h3
) {
    color: var(--cms-text-primary);
}

body.cms-theme .admin-page-dashboard :is(
    .template-profile-title p,
    .department-dashboard-refresh__contact-list dt,
    .department-custom-section-panel__eyebrow,
    .department-dashboard-side__title
) {
    color: var(--cms-text-secondary);
}

body.cms-theme .admin-page-dashboard--department-v2 .template-profile-logo {
    border-color: var(--cms-surface);
}

body.cms-theme .department-dashboard-refresh__section-nav,
body.cms-theme .department-dashboard-refresh__more .dropdown-menu {
    background: var(--cms-surface);
    border-color: var(--cms-border);
    color: var(--cms-text-primary);
}

body.cms-theme .department-dashboard-refresh__nav-button {
    background: transparent;
    color: var(--cms-text-primary);
}

body.cms-theme .department-dashboard-refresh__nav-button:hover,
body.cms-theme .department-dashboard-refresh__nav-button.is-active,
body.cms-theme .department-dashboard-refresh__contact-head button:hover {
    background: var(--cms-hover-bg);
    color: var(--cms-primary);
}

body.cms-theme .department-dashboard-refresh__nav-button--utility,
body.cms-theme .department-dashboard-refresh__contact-head button {
    color: var(--cms-text-secondary);
}

body.cms-theme .department-dashboard-refresh__contact-list div {
    border-color: var(--cms-border);
}

body.cms-theme .department-dashboard-refresh__quick-composer,
body.cms-theme .feed-post-compact-composer {
    background: var(--cms-surface);
    border: 1px solid var(--cms-border);
    color: var(--cms-text-primary);
    box-shadow: var(--cms-shadow);
}

body.cms-theme :is(.department-dashboard-refresh__quick-composer, .feed-post-compact-composer):hover,
body.cms-theme :is(.department-dashboard-refresh__quick-composer, .feed-post-compact-composer):focus-visible {
    background: var(--cms-hover-bg);
    border-color: var(--cms-primary);
    color: var(--cms-primary);
}

body.cms-theme :is(.department-dashboard-refresh__composer-avatar, .feed-post-compact-composer__avatar) {
    background: var(--cms-surface-secondary);
    border-color: var(--cms-border);
    color: var(--cms-text-primary);
}

body.cms-theme :is(.department-dashboard-refresh__composer-prompt, .feed-post-compact-composer__prompt) {
    background: var(--cms-surface-secondary);
    color: var(--cms-text-secondary);
}

body.cms-theme .department-dashboard-refresh__composer-image,
body.cms-theme .feed-post-compact-composer__image {
    color: var(--cms-success);
}

body.cms-theme .department-dashboard-refresh__composer-modal .modal-content,
body.cms-theme .department-inline-post-form--modal,
body.cms-theme .feed-post-composer-modal--embedded {
    background: var(--cms-surface);
    border-color: var(--cms-border);
    color: var(--cms-text-primary);
    box-shadow: var(--cms-shadow);
}

body.cms-theme .department-dashboard-refresh__composer-modal :is(.modal-header, .modal-body),
body.cms-theme .feed-post-composer-modal--embedded :is(.feed-post-composer-modal__header, .feed-post-composer-modal__identity) {
    background: var(--cms-surface);
    border-color: var(--cms-border);
    color: var(--cms-text-primary);
}

body.cms-theme .feed-post-composer-modal--embedded :is(.feed-post-composer-modal__header h1, .feed-post-composer-modal__page strong),
body.cms-theme .department-inline-post-form--modal .rich-text-editor__surface,
body.cms-theme .department-inline-post-form--modal :is(.form-label, .form-check-label) {
    color: var(--cms-text-primary);
}

body.cms-theme .feed-post-composer-modal--embedded .feed-post-composer-modal__eyebrow,
body.cms-theme .department-dashboard-refresh__composer-modal .modal-header p,
body.cms-theme .department-inline-post-form--modal .form-text,
body.cms-theme .department-dashboard-refresh__post-options small {
    color: var(--cms-text-secondary);
}

body.cms-theme .department-inline-post-form--modal :is(
    .rich-text-editor,
    .rich-text-editor__toolbar,
    .image-sequence-upload,
    .department-inline-post-form__footer
),
body.cms-theme .feed-post-composer-modal--embedded :is(
    .rich-text-editor,
    .rich-text-editor__toolbar,
    .image-sequence-upload,
    .image-sequence-upload__dropzone,
    .image-sequence-upload__item
) {
    background: var(--cms-surface-secondary);
    border-color: var(--cms-border);
    color: var(--cms-text-primary);
}

body.cms-theme .department-inline-post-form--modal :is(.rich-text-editor__toolbar button, .rich-text-editor__format),
body.cms-theme .feed-post-composer-modal--embedded :is(.rich-text-editor__toolbar button, .rich-text-editor__format) {
    background: var(--cms-surface);
    border-color: var(--cms-border);
    color: var(--cms-text-primary);
}

body.cms-theme .feed-post-composer-modal__close {
    background: var(--cms-surface-secondary);
    border: 1px solid var(--cms-border);
    color: var(--cms-text-primary);
}

body.cms-theme .feed-post-composer-modal__close:hover {
    background: var(--cms-hover-bg);
    color: var(--cms-primary);
}
