:root,
:root[data-theme="light"] {
  color-scheme: light;
  --theme-page: #f3f0e8;
  --theme-surface: #f7f4ed;
  --theme-surface-raised: #ffffff;
  --theme-surface-muted: #eef1f4;
  --theme-control: #e5eaf0;
  --theme-text: #17283a;
  --theme-text-muted: #62758a;
  --theme-border: rgba(19, 45, 70, 0.18);
  --theme-border-strong: rgba(19, 45, 70, 0.34);
  --theme-accent: #1f4e79;
  --theme-accent-strong: #00274c;
  --theme-accent-contrast: #ffffff;
  --theme-focus: #d2ad52;
  --theme-focus-soft: #f2e6bc;
  --theme-danger: #9d3030;
  --theme-danger-surface: #fae7e7;
  --theme-danger-border: #dca5a5;
  --theme-shadow: 0 14px 38px rgba(0, 39, 76, 0.09);
  --theme-shadow-strong: 0 18px 40px rgba(0, 39, 76, 0.16);
  --theme-navy-950: #0b2033;
  --theme-navy-900: #132d46;
  --theme-navy-800: #1d3c59;
  --theme-maize: #d2ad52;
  --theme-maize-bright: #ffcb05;
  --theme-maize-pale: #eee2bd;
  --theme-rail-background: #132d46;
  --theme-rail-text: #ffffff;
  --theme-rail-muted: rgba(255, 255, 255, 0.58);
  --theme-rail-border: rgba(255, 255, 255, 0.12);
  --theme-rail-hover: rgba(255, 255, 255, 0.07);
  --theme-eval-black: #202936;
  --theme-eval-white: #f5f7f8;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --theme-page: #0f1723;
  --theme-surface: #131e2d;
  --theme-surface-raised: #172233;
  --theme-surface-muted: #1c293c;
  --theme-control: #23334a;
  --theme-text: #eef4ff;
  --theme-text-muted: #aab7c8;
  --theme-border: #2d3a4d;
  --theme-border-strong: #46566d;
  --theme-accent: #ffcb05;
  --theme-accent-strong: #ffdb4d;
  --theme-accent-contrast: #0f1723;
  --theme-focus: #ffcb05;
  --theme-focus-soft: #40371d;
  --theme-danger: #ff9f9f;
  --theme-danger-surface: #3a2026;
  --theme-danger-border: #71414a;
  --theme-shadow: 0 18px 44px rgba(0, 0, 0, 0.24);
  --theme-shadow-strong: 0 20px 46px rgba(0, 0, 0, 0.36);
  --theme-navy-950: #08131f;
  --theme-navy-900: #0d2033;
  --theme-navy-800: #17314a;
  --theme-maize: #ffcb05;
  --theme-maize-bright: #ffdb4d;
  --theme-maize-pale: #f4e5a5;
  --theme-rail-background: #0d2033;
  --theme-rail-text: #f7f9fc;
  --theme-rail-muted: rgba(247, 249, 252, 0.62);
  --theme-rail-border: rgba(255, 255, 255, 0.13);
  --theme-rail-hover: rgba(255, 255, 255, 0.08);
  --theme-eval-black: #0b111a;
  --theme-eval-white: #e8edf3;
}

:root[data-mithrandir-theme="active"] {
  --navy-950: var(--theme-navy-950);
  --navy-900: var(--theme-navy-900);
  --navy-800: var(--theme-navy-800);
  --maize: var(--theme-maize);
  --maize-pale: var(--theme-maize-pale);
}

:root[data-mithrandir-theme="active"] .site-rail {
  background: var(--theme-rail-background);
  color: var(--theme-rail-text);
}

:root[data-mithrandir-theme="active"] .site-rail .nav-link {
  border-color: var(--theme-rail-border);
}

:root[data-mithrandir-theme="active"] .site-rail .nav-link:hover,
:root[data-mithrandir-theme="active"] .site-rail .nav-link:focus-visible,
:root[data-mithrandir-theme="active"] .site-rail .nav-link.is-current {
  border-color: var(--theme-rail-border);
  background: var(--theme-rail-hover);
  color: var(--theme-maize-pale);
}

:root[data-mithrandir-theme="active"] .site-rail .rail-note {
  color: var(--theme-rail-muted);
}

.site-theme-control {
  display: grid;
  gap: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.site-theme-control > span {
  color: var(--theme-maize);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.site-theme-control select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--theme-border-strong);
  border-radius: 6px;
  padding: 0 30px 0 10px;
  background: var(--theme-control);
  color: var(--theme-text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.site-theme-control select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--theme-focus) 32%, transparent);
  outline-offset: 2px;
}

.site-theme-control--card {
  margin: 20px 0 4px;
  padding: 14px;
  border: 1px solid var(--theme-border);
  border-radius: 10px;
  background: var(--theme-surface-muted);
  color: var(--theme-text);
}

.site-theme-control--card > span {
  color: var(--theme-text-muted);
}

.site-settings-shell {
  position: relative;
  flex: 0 0 auto;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--theme-rail-border);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.site-settings-button {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid rgba(210, 173, 82, 0.42);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--theme-rail-text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  text-align: left;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.site-settings-button:hover,
.site-settings-button:focus-visible,
.site-settings-button[aria-expanded="true"] {
  border-color: rgba(210, 173, 82, 0.72);
  background: var(--theme-rail-hover);
  color: var(--theme-maize-pale);
}

.site-settings-button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--theme-focus) 38%, transparent);
  outline-offset: 2px;
}

.site-settings-button-icon,
.site-appearance-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.site-settings-button-icon {
  width: 23px;
  height: 23px;
  color: var(--theme-maize-bright);
}

.site-settings-button-icon svg,
.site-appearance-icon svg {
  width: 100%;
  height: 100%;
}

.site-settings-popover {
  position: fixed;
  z-index: 90000;
  box-sizing: border-box;
  padding: 16px;
  border: 1px solid var(--theme-border-strong);
  border-radius: 12px;
  background: var(--theme-surface-raised);
  color: var(--theme-text);
  box-shadow: var(--theme-shadow-strong);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.site-settings-popover[hidden] {
  display: none !important;
}

.site-settings-popover::after {
  content: "";
  position: absolute;
  left: 24px;
  width: 12px;
  height: 12px;
  border-right: 1px solid var(--theme-border-strong);
  border-bottom: 1px solid var(--theme-border-strong);
  background: var(--theme-surface-raised);
  transform: rotate(45deg);
}

.site-settings-popover[data-placement="top"]::after {
  bottom: -7px;
}

.site-settings-popover[data-placement="bottom"]::after {
  top: -7px;
  transform: rotate(225deg);
}

.site-settings-heading {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.site-settings-heading strong {
  font-size: 16px;
  line-height: 1.2;
}

.site-settings-heading span {
  color: var(--theme-text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.site-appearance-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--theme-border-strong);
  border-radius: 9px;
  background: var(--theme-surface-muted);
}

.site-appearance-option {
  min-width: 0;
  min-height: 78px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  padding: 10px 6px;
  border: 0;
  border-right: 1px solid var(--theme-border-strong);
  background: transparent;
  color: var(--theme-text-muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.site-appearance-option:last-child {
  border-right: 0;
}

.site-appearance-option:hover,
.site-appearance-option:focus-visible {
  background: color-mix(in srgb, var(--theme-accent) 9%, transparent);
  color: var(--theme-text);
  outline: none;
}

.site-appearance-option.is-selected {
  background: color-mix(in srgb, var(--theme-accent) 14%, var(--theme-surface-raised));
  color: var(--theme-accent);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--theme-accent) 64%, transparent);
}

.site-appearance-option:focus-visible {
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--theme-focus) 65%, transparent);
}

.site-appearance-icon {
  width: 24px;
  height: 24px;
}

@media (min-width: 1001px) {
  .site-rail.has-site-settings .session-nav-link {
    margin-top: 20px;
  }
}

@media (max-width: 1000px) {
  .site-settings-shell {
    display: none;
    margin-top: 14px;
    padding-top: 14px;
  }

  .site-rail.is-open .site-settings-shell {
    display: block;
  }

  .site-settings-button {
    max-width: 240px;
  }

  .site-theme-control--card {
    display: grid;
  }
}
