:where(.seh-demos) .theme-switch {
  display: inline-flex;
  grid-area: theme;
  justify-self: end;
  align-self: start;
  gap: 3px;
  margin-top: 6px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

:where(.seh-demos) .theme-switch[hidden] { display: none; }

@media (max-width: 680px) {
  :where(.seh-demos) .theme-switch { margin-bottom: 14px; }
}

:where(.seh-demos) .theme-switch button {
  min-height: 34px;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: .875rem;
  font-weight: 650;
  cursor: pointer;
}

:where(.seh-demos) .theme-switch button[aria-pressed="true"] {
  border-color: var(--theme-hover-border, #bbd9e4);
  color: var(--accent);
  background: var(--accent-light, #e4f1f5);
}

@media (hover: hover) and (pointer: fine) {
  :where(.seh-demos) .theme-switch button:hover { border-color: var(--theme-hover-border, #bbd9e4); }
}

@media (prefers-reduced-motion: no-preference) {
  :where(.seh-demos) .theme-switch button {
    transition: background-color var(--control-speed), color var(--control-speed),
      border-color var(--control-speed);
  }
}

:where(.seh-demos) .theme-picker {
  --theme-preview-light: #fff;
  --theme-preview-dark: #343943;
  --theme-preview-sand: #d4a64e;
  --theme-preview-slate: #738aaa;
  position: relative;
  z-index: 1;
  flex: none;
  align-self: flex-start;
}

:where(.seh-demos) .theme-picker[hidden] { display: none; }

:where(.seh-demos) .theme-picker-trigger {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--demo-control-radius);
  background: var(--theme-control);
  cursor: pointer;
  list-style: none;
}

:where(.seh-demos) .theme-picker-trigger::marker { content: ""; }
:where(.seh-demos) .theme-picker-trigger::-webkit-details-marker { display: none; }
:where(.seh-demos) .theme-picker-trigger:hover,
:where(.seh-demos) .theme-picker[open] > .theme-picker-trigger { border-color: var(--theme-hover-border); }

:where(.seh-demos) .theme-palette {
  width: 25px;
  height: 25px;
  border: 1px solid var(--muted);
  border-radius: 50%;
  background: conic-gradient(
    var(--theme-preview-light) 0 25%,
    var(--theme-preview-sand) 25% 50%,
    var(--theme-preview-slate) 50% 75%,
    var(--theme-preview-dark) 75%
  );
}

.seh-demos .theme-picker > .theme-picker-options {
  position: absolute;
  inset-block-start: calc(100% + 6px);
  inset-inline-end: 0;
  display: grid;
  width: min(14rem, calc(100vw - 3rem));
  max-width: none;
  max-block-size: var(--theme-options-space, calc(100dvh - 70px));
  margin: 0;
  padding: 5px;
  overflow: auto;
  overscroll-behavior-y: contain;
  box-shadow: var(--control-shadow);
}

:where(.seh-demos) .theme-picker-options button {
  display: flex;
  align-items: center;
  min-height: 40px;
  gap: 10px;
  text-align: start;
}

:where(.seh-demos) .theme-swatch {
  width: 18px;
  height: 18px;
  flex: none;
  border: 1px solid var(--muted);
  border-radius: 50%;
}

:where(.seh-demos) [data-theme-choice="light"] .theme-swatch { background: var(--theme-preview-light); }
:where(.seh-demos) [data-theme-choice="dark"] .theme-swatch { background: var(--theme-preview-dark); }
:where(.seh-demos) [data-theme-choice="sand"] .theme-swatch { background: var(--theme-preview-sand); }
:where(.seh-demos) [data-theme-choice="slate"] .theme-swatch { background: var(--theme-preview-slate); }

.seh-demos[data-theme="dark"] {
  color-scheme: dark;
  color: var(--theme-text);
  background-color: #121c27;
  background-image:
    radial-gradient(ellipse 54rem 32rem at 14% 0, #202f40, transparent),
    radial-gradient(ellipse 38rem 25rem at 93% 4%, #1b2a3b, transparent);
  --surface: #1b2938;
  --border: #405367;
  --muted: #b5c5d5;
  --accent: #8bd0e5;
  --accent-light: #294658;
  --track: #405367;
  --theme-inset: #131f2b;
  --theme-control: #253649;
  --theme-text: #eef4fa;
  --theme-strong: #dce9f4;
  --theme-hover-border: #6b9fb5;
  --theme-focus: #a3ddf0;
  --theme-amber-surface: #4b3518;
  --theme-amber-border: #86663b;
  --theme-amber-text: #ffdf9a;
  --control-shadow: 0 4px 10px rgb(0 0 0 / .23);
}

.seh-demos[data-theme="dark"] :is(a, button, select, input):focus-visible {
  outline-color: var(--theme-focus);
}

.seh-demos[data-theme="dark"] :is(.back, .back-link) { color: var(--accent); }

.seh-demos[data-theme="dark"] :is(.scene-card, .info-layout > .demo, .info-panel, .eye-layout > .card, .station-panel) {
  box-shadow: 0 20px 42px -19px rgb(0 0 0 / .48), 0 3px 12px rgb(0 0 0 / .12);
}

.seh-demos[data-theme="dark"] :is(.info-panel, .station, .station-panel) {
  background-image: linear-gradient(#213243, transparent 145px);
}

.seh-demos[data-theme="dark"] :is(.info-panel p, .info-panel dt, .limit strong) {
  color: var(--theme-strong);
}

.seh-demos[data-theme="dark"] :is(.model-controls, .controls, .limit) { background: var(--theme-inset); }

.seh-demos[data-theme="dark"] .demo-header button {
  border-color: var(--border);
  color: var(--theme-text);
  background: var(--theme-control);
}

.seh-demos[data-theme="dark"] .demo-header .light[aria-pressed="true"] {
  border-color: var(--theme-amber-border);
  color: var(--theme-amber-text);
  background: var(--theme-amber-surface);
}

.seh-demos[data-theme="dark"] .demo-header .correction[aria-pressed="true"] {
  border-color: var(--theme-hover-border);
  color: var(--accent);
  background: var(--accent-light);
}

.seh-demos[data-theme="dark"] .demo-header .correction[aria-pressed="true"] .switch { background: #397b91; }

@media (hover: hover) and (pointer: fine) {
  .seh-demos[data-theme="dark"] .demo-header button:hover { border-color: var(--theme-hover-border); }
}
