:root {
  --mi-surface: #fff;
  --mi-surface-soft: #e6f1fa;
  --mi-text: #14283a;
  --mi-muted: #536575;
  --mi-border: #cbddeb;
  --mi-link: #0d4d80;
}

[data-bs-theme="dark"] {
  --mi-surface: #212a35;
  --mi-surface-soft: #293747;
  --mi-text: #e5edf7;
  --mi-muted: #b0bfce;
  --mi-border: #475b70;
  --mi-link: #94cfff;
  --ink: var(--mi-text);
  --primary-light: var(--mi-surface-soft);
  --bs-body-bg: #151d27;
  --bs-body-color: var(--mi-text);
  --bs-secondary-color: var(--mi-muted);
  --bs-link-color: var(--mi-link);
  --bs-link-color-rgb: 148, 207, 255;
  --bs-link-hover-color: #baddff;
  --bs-link-hover-color-rgb: 186, 221, 255;
  --bs-border-color: var(--mi-border);
  --calendar-sunday-bg: #273240;
  --calendar-holiday-bg: #423920;
  --calendar-today-border: #94cfff;
  --calendar-grid-line: var(--mi-border);
}

.mi-theme-selector {
  position: fixed;
  z-index: 1045;
  max-width: calc(100vw - 2rem);
  font: 600 .9rem/1.5 system-ui, sans-serif;
  color: var(--mi-text);
}
.mi-theme-selector[data-position^="bottom"] { bottom: max(1rem, env(safe-area-inset-bottom)); }
.mi-theme-selector[data-position^="top"] { top: max(1rem, env(safe-area-inset-top)); }
.mi-theme-selector[data-position$="right"] { right: max(1rem, env(safe-area-inset-right)); }
.mi-theme-selector[data-position$="left"] { left: max(1rem, env(safe-area-inset-left)); }
.mi-theme-selector summary {
  display: flex;
  align-items: center;
  padding: .6rem .9rem;
  border: 1px solid #0d4d80;
  border-radius: .5rem;
  background: #0d4d80;
  color: #fff;
  box-shadow: 0 .25rem .75rem #0003;
  cursor: grab;
  list-style: none;
  touch-action: none;
  user-select: none;
}
.mi-theme-selector[data-dragging] summary { cursor: grabbing; }
.mi-theme-selector summary::-webkit-details-marker { display: none; }
.mi-theme-selector summary::after { content: ""; display: inline-block; margin-left: .6rem; border: .3rem solid transparent; border-top-color: currentColor; transform: translateY(.15rem); }
.mi-theme-selector summary:hover { background: #093a61; }
.mi-theme-selector :focus-visible { outline: 3px solid #ffc83d; outline-offset: 3px; }
.mi-theme-icon { flex-shrink: 0; width: 1em; height: 1em; fill: currentColor; }
.mi-theme-options {
  position: absolute;
  min-width: 10rem;
  padding: .35rem;
  border: 1px solid var(--mi-border);
  border-radius: .5rem;
  background: var(--mi-surface);
  box-shadow: 0 .5rem 1rem #0003;
}
.mi-theme-selector[data-position^="bottom"] .mi-theme-options { bottom: calc(100% + .5rem); }
.mi-theme-selector[data-position^="top"] .mi-theme-options { top: calc(100% + .5rem); }
.mi-theme-selector[data-position$="right"] .mi-theme-options { right: 0; }
.mi-theme-selector[data-position$="left"] .mi-theme-options { left: 0; }
.mi-theme-options button {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  padding: .4rem .7rem;
  border: 0;
  border-radius: .25rem;
  background: transparent;
  color: var(--mi-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.mi-theme-options button:hover { background: var(--mi-surface-soft); }
.mi-theme-options button[aria-pressed="true"] { background: #0d4d80; color: #fff; }
.mi-theme-options button[aria-pressed="true"]::after { content: "\2713"; margin-left: auto; }
.mi-theme-corner { display: grid; gap: .25rem; padding: .4rem .7rem; font-size: .8rem; }
.mi-theme-corner select {
  width: 100%;
  padding: .2rem;
  border: 1px solid var(--mi-border);
  border-radius: .25rem;
  background: var(--mi-surface);
  color: var(--mi-text);
  font: inherit;
}
.mi-theme-status { max-width: 15rem; margin: .5rem 0 0; padding: .5rem; border: 1px solid var(--mi-border); border-radius: .5rem; background: var(--mi-surface); font-size: .8rem; }
.mi-theme-status[hidden] { display: none; }

/* Custom surfaces sit outside Bootstrap's component color variables. */
[data-bs-theme="dark"] body { background: var(--bs-body-bg); color: var(--mi-text); }
[data-bs-theme="dark"] .navbar { background: rgb(21 29 39 / 95%); }
[data-bs-theme="dark"] .navbar-brand img { filter: brightness(0) invert(1); }
[data-bs-theme="dark"] .navbar-brand,
[data-bs-theme="dark"] .nav-link { color: var(--mi-text); }
[data-bs-theme="dark"] .btn-outline-primary { --bs-btn-color: var(--mi-link); }
[data-bs-theme="dark"] .section-title,
[data-bs-theme="dark"] .time-card .when,
[data-bs-theme="dark"] .document-modal :is(.modal-title, h2, a, .document-loading, .document-brand p),
[data-bs-theme="dark"] .church-calendar-link a,
[data-bs-theme="dark"] .pill { color: var(--mi-link); }
[data-bs-theme="dark"] :is(.time-card, .pill, .church-calendar-frame, .hero-schedule, .bible-content, .media-playback-controls, .media-player:fullscreen, .media-player.is-mini-player:not(:fullscreen)) { background: var(--mi-surface); border-color: var(--mi-border); }
[data-bs-theme="dark"] .church-calendar { background: var(--mi-surface-soft); }
[data-bs-theme="dark"] .wave path { fill: var(--bs-body-bg); }
[data-bs-theme="dark"] .btn-pop { color: #14283a; }
[data-bs-theme="dark"] .account-modal .modal-header,
[data-bs-theme="dark"] #loginModal .modal-header,
[data-bs-theme="dark"] .document-modal :is(.modal-header, .modal-footer) { background: var(--mi-surface-soft); }
[data-bs-theme="dark"] :is(.account-modal, #loginModal) .modal-title { color: var(--mi-link); }
[data-bs-theme="dark"] :is(.media-brightness, .media-volume, .media-player) { background: var(--mi-surface-soft); }
[data-bs-theme="dark"] :is(.media-brightness > i, .media-volume > i, .media-volume-toggle, .media-recording-title, .media-clear-field, .bible-verse-number) { color: var(--mi-link); }
[data-bs-theme="dark"] .media-transport .btn { --bs-btn-color: var(--mi-link); }
[data-bs-theme="dark"] .media-transport .btn-primary { --bs-btn-color: #14283a; }
[data-bs-theme="dark"] .media-volume-toggle:hover { background: var(--mi-surface); }
[data-bs-theme="dark"] .bible-footnotes { color: var(--mi-muted); }
[data-bs-theme="dark"] .bible-content mark { color: #14283a; }
[data-bs-theme="dark"] #mi-media .media-results { background: var(--mi-surface); border-color: var(--mi-border); }
[data-bs-theme="dark"] .admin-users-results table { --bs-table-striped-bg: #253140; --bs-table-hover-bg: #30455a; --bs-table-hover-color: var(--mi-text); --bs-table-border-color: var(--mi-border); }
[data-bs-theme="dark"] #mi-media .media-results table { --bs-table-striped-bg: #253140; --bs-table-hover-bg: #30455a; --bs-table-hover-color: var(--mi-text); --bs-table-border-color: var(--mi-border); }
[data-bs-theme="dark"] .media-results tbody td:nth-child(3) { color: var(--mi-link); }
[data-bs-theme="dark"] :is(.admin-users-results, .admin-user-editor, .admin-role-users) { background: var(--mi-surface); }
[data-bs-theme="dark"] .admin-users-results { --admin-search-bg: var(--mi-surface-soft); }
[data-bs-theme="dark"] .admin-verification-controls { background: var(--mi-surface-soft); }
[data-bs-theme="dark"] .admin-content > h1,
[data-bs-theme="dark"] .admin-user-editor .nav-link { color: var(--mi-text); }
[data-bs-theme="dark"] .admin-content .btn-outline-primary { --bs-btn-color: var(--mi-link); }
[data-bs-theme="dark"] .bg-white { background-color: var(--mi-surface) !important; }

[data-bs-theme="dark"] :is(.schedule, .schedule-only .schedule-header, .calendar-wrap, .month-day, .event-dialog) { background: var(--mi-surface); color: var(--mi-text); }
[data-bs-theme="dark"] :is(.schedule-header, .schedule-day) { border-color: var(--mi-border); }
[data-bs-theme="dark"] :is(.schedule-date, .schedule-time, .schedule-date .meta, .schedule-empty, .month-day-dialog-time) { color: var(--mi-muted); }
[data-bs-theme="dark"] :is(.month-picker select, .month-nav a, .month-more, .month-dialog-title, .schedule-header a, .event-dialog a) { color: var(--mi-link); }
[data-bs-theme="dark"] :is(.month-weekday, .schedule-event-btn:hover, .month-picker select:hover) { background: var(--mi-surface-soft); color: var(--mi-text); }
[data-bs-theme="dark"] .month-day.is-sunday { background: var(--calendar-sunday-bg); }
[data-bs-theme="dark"] .month-day.is-holiday { background: var(--calendar-holiday-bg); }
[data-bs-theme="dark"] .month-day.is-outside { color: var(--mi-muted); }
[data-bs-theme="dark"] .month-event { color: var(--mi-text); background: transparent; }
[data-bs-theme="dark"] :is(.month-event.is-all-day, .schedule-event-btn.is-all-day) { background: color-mix(in srgb, var(--month-event-color, var(--schedule-event-color)) 25%, var(--mi-surface)); }
[data-bs-theme="dark"] .calendar-loading { background: rgb(21 29 39 / 90%); color: var(--mi-text); }
[data-bs-theme="dark"] .event-dialog .close { color: var(--mi-text); }

[data-bs-theme="dark"] :is(.mi-bss-reference, .mi-bss-reference-fields select, .mi-bss-toggle-controls) { background: var(--mi-surface); border-color: var(--mi-border); color: var(--mi-text); }
[data-bs-theme="dark"] .mi-bss-toggle-controls:hover { background: var(--mi-surface-soft); }
[data-bs-theme="dark"] .mi-bss-help,
[data-bs-theme="dark"] .mi-bss-help a { color: var(--mi-muted); }
[data-bs-theme="dark"] #mi-bss-reference-status[data-error="true"] { color: #ff9a9a; }
[data-bs-theme="dark"] #biblesupersearch_container { color: var(--mi-text); }
[data-bs-theme="dark"] #biblesupersearch_container :is(input, select, textarea, button, .bss_section, .bss_dialog, .bss_pseudo_autocomplete, .bss_strongs_hover) { background-color: var(--mi-surface); color: var(--mi-text); border-color: var(--mi-border); }
[data-bs-theme="dark"] #biblesupersearch_container a { color: var(--mi-link); }
[data-bs-theme="dark"] #biblesupersearch_container :is(.bss_dialog_container, .bss_dialog_content, .bss_strongs_head, .bss_strongs_tvm, .bss_item:nth-child(odd), .biblesupersearch_bible_selector option.bss_label) { background: var(--mi-surface); color: var(--mi-text); }
[data-bs-theme="dark"] #biblesupersearch_container .bss_red_letter { color: #ff9090; }

[data-bs-theme="light"] body:has(.mp-app) { background: #f5f9fc; color: #14283a; }
[data-bs-theme="light"] :is(.mp-workspace, .mp-transport, .mp-app button) { background: #fff; color: #14283a; border-color: #cbddeb; }
[data-bs-theme="light"] .mp-timeline-header { background: #e6f1fa; color: #14283a; }
[data-bs-theme="light"] :is(.mp-comments, #mp-status, .mp-empty) { color: #536575; }
[data-bs-theme="light"] :is(.mp-eyebrow, .mp-empty > i) { color: #0d4d80; }
[data-bs-theme="light"] .mp-playhead::before { background: #14283a; }
[data-bs-theme="light"] .mp-wave { background: repeating-linear-gradient(90deg, transparent 0, transparent calc(10% - 1px), #14283a12 calc(10% - 1px), #14283a12 10%); }
