:root,
[data-theme="light"] {
  color-scheme: light;
  --background: #ffffff;
  --background-subtle: #f7f8fa;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-muted: #f1f3f5;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-inverse: #ffffff;
  --border: #d1d5db;
  --border-strong: #9ca3af;
  --button-primary: #111827;
  --button-primary-hover: #030712;
  --button-primary-text: #ffffff;
  --focus-ring: #1d4ed8;
  --link: #174ea6;
  --danger: #b42318;
  --danger-surface: #fef3f2;
  --success: #067647;
  --success-surface: #ecfdf3;
  --warning: #92400e;
  --warning-surface: #fffbeb;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.08);
  --shadow-md: 0 14px 36px rgba(17, 24, 39, 0.12);
  --input-background: #ffffff;
  --sidebar-background: #111827;
  --navigation-background: #ffffff;
  --overlay: rgba(17, 24, 39, 0.48);
}

[data-theme="dark"] {
  color-scheme: dark;
  --background: #0b0f17;
  --background-subtle: #111827;
  --surface: #18212f;
  --surface-raised: #202b3a;
  --surface-muted: #253244;
  --text-primary: #f9fafb;
  --text-secondary: #cbd5e1;
  --text-inverse: #111827;
  --border: #475569;
  --border-strong: #64748b;
  --button-primary: #f9fafb;
  --button-primary-hover: #e5e7eb;
  --button-primary-text: #111827;
  --focus-ring: #93c5fd;
  --link: #93c5fd;
  --danger: #fda29b;
  --danger-surface: #4a1d1f;
  --success: #6ce9a6;
  --success-surface: #12372a;
  --warning: #fbd38d;
  --warning-surface: #422006;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 16px 40px rgba(0, 0, 0, 0.4);
  --input-background: #111827;
  --sidebar-background: #080d14;
  --navigation-background: #18212f;
  --overlay: rgba(0, 0, 0, 0.72);
}

html {
  background: var(--background);
  color: var(--text-primary);
}

body {
  background-color: var(--background);
  color: var(--text-primary);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.theme-control {
  position: relative;
  z-index: 1100;
  color: var(--text-primary);
  font-family: inherit;
  text-transform: none;
}

.public-theme-control {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.theme-control__trigger,
.theme-control__option {
  min-height: 48px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
}

.theme-control__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-width: 116px;
  padding: 0.65rem 0.85rem;
  border-radius: 0.75rem;
  cursor: pointer;
  list-style: none;
  box-shadow: var(--shadow-sm);
}

.theme-control__trigger::-webkit-details-marker {
  display: none;
}

.theme-control__chevron {
  margin-left: auto;
  font-size: 0.75em;
  transition: transform 160ms ease;
}

.theme-control[open] .theme-control__chevron {
  transform: rotate(180deg);
}

.theme-control__menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  display: grid;
  gap: 0.25rem;
  width: max-content;
  min-width: 176px;
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 0.875rem;
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
}

/*
 * A public-navigation menu must occupy layout space while it is open.  The
 * earlier absolutely positioned menu rendered over the hero on desktop and
 * could be clipped by the collapsed navigation on small screens.
 */
#mainNav .theme-control[open] .theme-control__menu {
  position: static;
  width: 19rem;
  max-width: calc(100vw - 2rem);
  margin-top: 0.5rem;
}

#mainNav .theme-control[open] {
  display: block;
}

#mainNav .navbar-collapse,
#mainNav .navbar-nav,
#mainNav .nav-item:has(.theme-control) {
  overflow: visible;
}

/*
 * On desktop, reserve a second header row for the open menu. This retains the
 * navigation's original horizontal layout while keeping the menu above (not
 * on top of) the page content. Mobile continues to use the in-flow menu.
 */
@media (min-width: 992px) {
  #mainNav:has(.theme-control[open]) {
    padding-bottom: 12rem;
  }

  #mainNav .theme-control[open] .theme-control__menu {
    position: absolute;
    width: 19rem;
    max-width: calc(100vw - 2rem);
    margin-top: 0;
  }
}

.theme-control__option {
  display: grid;
  grid-template-columns: 1.25rem 1fr;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.65rem 0.8rem;
  border-color: transparent;
  border-radius: 0.625rem;
  text-align: left;
  cursor: pointer;
}

.theme-control__option:hover {
  background: var(--surface-muted);
}

.theme-control__option.is-selected,
.theme-control__option[aria-checked="true"] {
  border-color: var(--border-strong);
  background: var(--surface-muted);
}

.theme-control__option.is-selected::after,
.theme-control__option[aria-checked="true"]::after {
  content: "\2713";
  grid-column: 3;
  color: var(--success);
  font-weight: 800;
}

.theme-control__trigger:focus-visible,
.theme-control__option:focus-visible,
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

@media (max-width: 480px) {
  .theme-control__trigger {
    min-width: 48px;
    padding-inline: 0.75rem;
  }

  .theme-control__menu {
    max-width: calc(100vw - 1.5rem);
  }

  #mainNav .theme-control,
  #mainNav .theme-control__trigger,
  #mainNav .theme-control[open] .theme-control__menu {
    width: 100%;
  }

  #mainNav .theme-control__trigger {
    justify-content: flex-start;
  }
}

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

@media (forced-colors: active) {
  .theme-control__trigger,
  .theme-control__option {
    border: 1px solid ButtonText;
  }

  .theme-control__trigger:focus-visible,
  .theme-control__option:focus-visible {
    outline: 3px solid Highlight;
  }
}
