.theme-toggle {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid #a795ad;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .theme-moon,
[data-theme="dark"] .theme-toggle .theme-sun { display: none; }
[data-theme="dark"] .theme-toggle .theme-moon { display: block; }
.theme-toggle:focus-visible { outline: 2px solid #ae735d; outline-offset: 3px; }
@media (max-width: 760px) {
  .theme-toggle { width: 36px; height: 36px; }
}

[data-theme="light"] .site-dropdown > summary:hover {
  background: #f3e7cc;
}
[data-theme="light"] .site-dropdown[open] > summary {
  background: #eddec0;
  border-color: #a38461;
}
[data-theme="light"] .site-menu :is(button, a):hover {
  background: #f3e7cc;
}
[data-theme="light"] .site-menu button[aria-pressed="true"] {
  background: #eddec0;
  color: #2d211b;
}
[data-theme="light"] .site-menu button[aria-pressed="true"]::after {
  color: #824322;
}
[data-theme="light"] :is(.site-dropdown > summary, .site-menu :is(a, button)):focus-visible {
  outline-color: #93603d;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --night-page: #181621;
  --night-panel: #252230;
  --night-panel-raised: #302a3b;
  --night-text: #f5e9d4;
  --night-muted: #c6bacd;
  --night-border: #74677e;
  --night-accent: #ffad83;
  background: var(--night-page);
  color: var(--night-text);
}
[data-theme="dark"] body { background: var(--night-page); color: var(--night-text); }
[data-theme="dark"] :is(main > header, .mast, .site-header, main > footer, #archive) {
  border-color: var(--night-border);
}
[data-theme="dark"] :is(header small, .project-social a, #archive-context, .archive-caption, .calendar-note, #page-status, .muted, .channel span, .site-menu .channel-row small) {
  color: var(--night-muted);
}
[data-theme="dark"] a { color: inherit; }
[data-theme="dark"] :is(.project-x-top, .project-social) [aria-hidden] { color: var(--night-accent); }
[data-theme="dark"] .hero { outline: 1px solid #494151; }
[data-theme="dark"] :is(.site-menu, .lang-menu, #calendar-panel, .community-dialog, .channel, .content, .privacy-copy, .faq, .grid section, body > main > section:not(.hero):not(#archive)) {
  background: var(--night-panel);
  border-color: var(--night-border);
  color: var(--night-text);
}
[data-theme="dark"] :is(.site-dropdown > summary, .archive-choice summary, #archive-pagination button, .theme-toggle, #clear-filters) {
  background: var(--night-panel);
  color: var(--night-text);
  border-color: var(--night-border);
}
[data-theme="dark"] :is(.site-menu button, .site-menu a, .site-menu .channel-row) {
  color: var(--night-text);
}
[data-theme="dark"] :is(.site-menu button, .site-menu a, .theme-toggle):is(:hover,:focus-visible) {
  background: var(--night-panel-raised);
}
[data-theme="dark"] :is(.site-menu button[aria-pressed="true"], .site-menu [aria-selected="true"], .site-menu [aria-current="true"], #status, #browser-reminder-status) {
  background: #40314e;
  color: #f4e2fb;
}
[data-theme="dark"] .site-menu button[aria-pressed="true"]::after { color: #e2bdf3; }
[data-theme="dark"] .site-dropdown:is([open], :hover) > summary { background: var(--night-panel-raised); }
[data-theme="dark"] :is(#archive-pagination button, .controls button):disabled {
  background: var(--night-panel);
  color: var(--night-muted);
  opacity: .75;
}
[data-theme="dark"] :is(.philatelic, .postal-dialog) {
  --post-ink: #f6e8d5;
  --post-ink-soft: #cbbdcc;
  --post-paper: #252230;
  --post-sheet: #252230;
  --post-line: #6f6178;
  --post-mount-paper: #393245;
  --post-tint: #302a3b;
  --post-rule: #a797ae;
  --post-brick: #ffad83;
  --post-blue: var(--post-rule);
}
[data-theme="dark"] :is(.postal-dialog, .community-dialog)::backdrop { background: #0a0815b8; }
[data-theme="dark"] .community-open { color: #352444; }
[data-theme="dark"] .community-dialog figcaption { color: var(--night-muted); }
[data-theme="dark"] :is(input:not([type="checkbox"]), select) {
  background-color: var(--night-panel);
  color: var(--night-text);
  border-color: var(--night-border);
}
[data-theme="dark"] :is(section.letter, .privacy, .lang-menu ul) {
  background: var(--night-panel);
  border-color: var(--night-border);
  color: var(--night-text);
}
[data-theme="dark"] :is(.faq details p, #description) { color: var(--night-muted); }
[data-theme="dark"] :is(.faq summary::after, #reapply) { color: var(--night-accent); }
[data-theme="dark"] .lang-menu button:is(:hover,[aria-pressed="true"]),
[data-theme="dark"] form button:not(.primary):hover { background: var(--night-panel-raised); }
[data-theme="dark"] :is(form button.primary, .controls button#enable:not(:disabled)) { color: #211429; }
[data-theme="dark"] #status[data-error] { background: #512c36; color: #ffddcf; }
