:root[data-theme-mode="light"],
:root:not([data-theme-mode]) {
  color-scheme: light;
  --site-primary: var(--palette-primary);
  --site-primary-hover: var(--palette-primary-hover);
  --site-secondary: var(--palette-secondary, var(--palette-primary-hover));
  --site-link: var(--palette-link);
  --site-link-hover: var(--palette-link-hover);
  --site-bg: var(--palette-bg);
  --site-surface: var(--palette-surface);
  --site-surface-alt: var(--palette-surface-alt);
  --site-text: var(--palette-text);
  --site-heading: var(--palette-heading, var(--palette-text));
  --site-muted: var(--palette-muted);
  --site-border: var(--palette-border);
  --site-header-text: var(--palette-header-text);
  --site-focus: var(--palette-link);

  --body-color: var(--site-text);
  --body-color-rgb: var(--palette-text-rgb);
  --body-bg: var(--site-bg);
  --body-bg-rgb: var(--palette-bg-rgb);
  --heading-color: var(--site-heading);
  --emphasis-color: var(--site-text);
  --secondary-color: var(--site-muted);
  --tertiary-color: var(--site-muted);
  --secondary-bg: var(--site-surface-alt);
  --tertiary-bg: var(--site-surface);
  --border-color: var(--site-border);
  --primary: var(--site-primary);
  --primary-rgb: var(--palette-primary-rgb);
  --link-color: var(--site-link);
  --link-color-rgb: var(--palette-link-rgb);
  --link-hover-color: var(--site-link-hover);
  --link-hover-color-rgb: var(--palette-link-hover-rgb);
  --cassiopeia-color-primary: var(--site-primary);
  --cassiopeia-color-link: var(--site-link);
  --cassiopeia-color-hover: var(--site-primary-hover);
  --template-bg-light: var(--site-bg);
  --template-text-dark: var(--site-text);
  --template-text-light: #fff;
  --template-link-color: var(--site-link);
  --template-special-color: var(--site-primary);
  --card-bg: var(--site-surface);
  --card-border-color: var(--site-border);
  --table-color: var(--site-text);
  --table-bg: var(--site-surface);
  --table-border-color: var(--site-border);

  --bs-body-bg: var(--site-bg);
  --bs-body-bg-rgb: var(--palette-bg-rgb);
  --bs-body-color: var(--site-text);
  --bs-body-color-rgb: var(--palette-text-rgb);
  --bs-emphasis-color: var(--site-text);
  --bs-secondary-color: var(--site-muted);
  --bs-secondary-bg: var(--site-surface-alt);
  --bs-tertiary-bg: var(--site-surface);
  --bs-border-color: var(--site-border);
  --bs-primary: var(--site-primary);
  --bs-primary-rgb: var(--palette-primary-rgb);
  --bs-link-color: var(--site-link);
  --bs-link-color-rgb: var(--palette-link-rgb);
  --bs-link-hover-color: var(--site-link-hover);
  --bs-link-hover-color-rgb: var(--palette-link-hover-rgb);
  --bs-card-bg: var(--site-surface);
  --bs-card-color: var(--site-text);
  --bs-card-border-color: var(--site-border);
  --bs-form-control-bg: var(--site-surface);
}

:root[data-theme-mode="dark"] {
  color-scheme: dark;
  --site-primary: var(--palette-primary);
  --site-primary-hover: var(--palette-primary-hover);
  --site-secondary: var(--palette-secondary, var(--palette-primary-hover));
  --site-link: var(--palette-link);
  --site-link-hover: var(--palette-link-hover);
  --site-bg: var(--palette-bg);
  --site-surface: var(--palette-surface);
  --site-surface-alt: var(--palette-surface-alt);
  --site-text: var(--palette-text);
  --site-heading: var(--palette-heading, var(--palette-text));
  --site-muted: var(--palette-muted);
  --site-border: var(--palette-border);
  --site-header-text: var(--palette-header-text);
  --site-focus: var(--palette-link);

  --body-color: var(--site-text);
  --body-color-rgb: var(--palette-text-rgb);
  --body-bg: var(--site-bg);
  --body-bg-rgb: var(--palette-bg-rgb);
  --heading-color: var(--site-heading);
  --emphasis-color: var(--site-text);
  --secondary-color: var(--site-muted);
  --tertiary-color: var(--site-muted);
  --secondary-bg: var(--site-surface-alt);
  --tertiary-bg: var(--site-surface);
  --border-color: var(--site-border);
  --primary: var(--site-primary);
  --primary-rgb: var(--palette-primary-rgb);
  --link-color: var(--site-link);
  --link-color-rgb: var(--palette-link-rgb);
  --link-hover-color: var(--site-link-hover);
  --link-hover-color-rgb: var(--palette-link-hover-rgb);
  --cassiopeia-color-primary: var(--site-primary);
  --cassiopeia-color-link: var(--site-link);
  --cassiopeia-color-hover: var(--site-primary-hover);
  --template-bg-light: var(--site-bg);
  --template-text-dark: var(--site-text);
  --template-text-light: #fff;
  --template-link-color: var(--site-link);
  --template-special-color: var(--site-primary);
  --card-bg: var(--site-surface);
  --card-border-color: var(--site-border);
  --table-color: var(--site-text);
  --table-bg: var(--site-surface);
  --table-border-color: var(--site-border);

  --success-bg-subtle: #173c2c;
  --success-text-emphasis: #b8e4c5;
  --success-border-subtle: #286341;
  --info-bg-subtle: #183541;
  --info-text-emphasis: #b6e3ef;
  --info-border-subtle: #2b6477;
  --warning-bg-subtle: #45351b;
  --warning-text-emphasis: #f5d894;
  --warning-border-subtle: #735321;
  --danger-bg-subtle: #492321;
  --danger-text-emphasis: #f1b8b2;
  --danger-border-subtle: #7d3731;

  --bs-body-bg: var(--site-bg);
  --bs-body-bg-rgb: var(--palette-bg-rgb);
  --bs-body-color: var(--site-text);
  --bs-body-color-rgb: var(--palette-text-rgb);
  --bs-emphasis-color: var(--site-text);
  --bs-secondary-color: var(--site-muted);
  --bs-secondary-bg: var(--site-surface-alt);
  --bs-tertiary-bg: var(--site-surface);
  --bs-border-color: var(--site-border);
  --bs-primary: var(--site-primary);
  --bs-primary-rgb: var(--palette-primary-rgb);
  --bs-link-color: var(--site-link);
  --bs-link-color-rgb: var(--palette-link-rgb);
  --bs-link-hover-color: var(--site-link-hover);
  --bs-link-hover-color-rgb: var(--palette-link-hover-rgb);
  --bs-card-bg: var(--site-surface);
  --bs-card-color: var(--site-text);
  --bs-card-border-color: var(--site-border);
  --bs-form-control-bg: var(--site-surface);
}

html,
body {
  background-color: var(--site-bg);
  color: var(--site-text);
}

/* Palettes with a second brand hue blend it into the footer; the others keep their own gradient. */
.footer {
  background-image: linear-gradient(135deg, var(--site-primary) 0%, var(--site-secondary) 100%);
}

/* Sidebars read as a column of their own: a tinted panel running from the header down to the footer. */
.has-sidebar-tint :is(.container-sidebar-left, .container-sidebar-right) {
  padding-inline: clamp(.5rem, 1vw, .75rem);
  border-inline: 1px solid var(--site-border);
  border-radius: 0 0 .25rem .25rem;
  background: var(--palette-sidebar-bg, var(--site-surface-alt));
}

/* Stacked under the content the panel no longer touches the header, so it is closed on all sides. */
@media (max-width: 991.98px) {
  .has-sidebar-tint :is(.container-sidebar-left, .container-sidebar-right) {
    margin-block-start: 1rem;
    border: 1px solid var(--site-border);
    border-radius: .25rem;
  }
}

/*
 * Titles of uncarded modules: a band in the palette's brand colours, underlined with its accent.
 * Modules may be wrapped by another template's noCard chrome, so the title is also matched by position.
 */
.no-card > :is(.module-title, h1, h2, h3, h4, h5, h6):first-child {
  margin: 0 0 .75rem;
  padding: .625rem 1rem;
  border-block-end: 3px solid var(--palette-accent);
  border-radius: .25rem .25rem 0 0;
  background: linear-gradient(135deg, var(--site-primary) 0%, var(--site-secondary) 100%);
  color: var(--site-header-text);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .025em;
  line-height: 1.3;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

/* The title and a vertical menu below it read as one panel. */
.no-card > :is(.module-title, h1, h2, h3, h4, h5, h6):first-child:has(+ .site-navigation--vertical) {
  margin-block-end: 0;
}

.no-card > :is(.module-title, h1, h2, h3, h4, h5, h6):first-child + .site-navigation--vertical {
  border-block-start: 0;
  border-start-start-radius: 0;
  border-start-end-radius: 0;
}

/* The header and footer are already coloured, so only the underline remains there. */
:is(.container-header, .footer) .no-card > :is(.module-title, h1, h2, h3, h4, h5, h6):first-child {
  padding-inline: 0;
  border-radius: 0;
  background: none;
  color: inherit;
}

::selection {
  color: var(--site-text);
  background-color: var(--palette-accent);
}

:focus-visible {
  outline: 3px solid var(--site-focus);
  outline-offset: 3px;
}

:root[data-theme-mode] {
  scrollbar-color: var(--site-muted) var(--site-bg);
}

.bongovo-theme-switcher {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.bongovo-theme-switcher select,
.bongovo-theme-switcher button {
  min-height: 2.5rem;
  padding: .35rem .7rem;
  color: var(--site-text);
  background-color: var(--site-surface);
  border: 1px solid var(--site-border);
  border-radius: .4rem;
  font: inherit;
}

.bongovo-theme-switcher select {
  width: 10.5rem;
  padding-inline-end: 2rem;
}

.bongovo-theme-switcher select option,
.bongovo-theme-switcher select optgroup {
  color: var(--site-text);
  background-color: var(--site-surface);
}

.bongovo-theme-switcher button {
  flex: 0 0 auto;
  font-weight: 600;
}

.bongovo-theme-switcher button:hover {
  background-color: var(--site-surface-alt);
  border-color: var(--site-primary);
}

.bongovo-theme-switcher [hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: no-preference) {
  body {
    transition: color .18s ease, background-color .18s ease;
  }
}

@media (max-width: 575.98px) {
  .bongovo-theme-switcher select {
    min-width: 0;
    width: min(11rem, calc(100vw - 5rem));
  }
}
