/* Light colours stay with their existing component declarations. Dark mode
   supplies shared semantic colours to the same surfaces and controls. */
html[data-theme="dark"] {
  color-scheme: dark;
  --theme-ink: #e5ede6;
  --theme-muted: #b3c2b7;
  --theme-link: #a0d5b8;
  --theme-link-hover: #c9efd8;
  --theme-page: #141c18;
  --theme-paper: #1d2922;
  --theme-wash: #26352c;
  --theme-header: #22352a;
  --theme-line: #47594c;
  --theme-input-border: #718575;
  --theme-selected: #2c4635;
  --theme-button: #346a4e;
  --theme-button-hover: #2c5b43;
  --theme-focus: #edbf76;
  --theme-error: #ffb9ad;
  --theme-error-bg: #432a26;
  --theme-danger-button: #984437;
  --theme-insert-text: #b3e3b4;
  --theme-switch-off: #5c6d60;
}

html[data-theme="light"] { color-scheme: light; }
::selection { background: var(--theme-selected, #dce6d7); color: var(--theme-ink, #25342e); }
.theme-toggle,
body.active_admin #header .theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 42px;
  width: 42px; height: 42px; margin: 0; padding: 9px; border: 0; border-radius: 50%;
  background: transparent; color: var(--theme-link, #275b48);
  box-shadow: none; text-shadow: none; cursor: pointer;
}
.theme-toggle:hover,
body.active_admin #header .theme-toggle:hover { background: var(--theme-selected, #e8eee2); color: var(--theme-link-hover, #204b38); }
.theme-toggle:focus-visible { outline: 3px solid var(--theme-focus, #ac762d); outline-offset: 3px; }
.theme-toggle[hidden] { display: none !important; }
.theme-toggle svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .theme-icon-sun { display: block; }
.site-header nav { align-items: center; }
.site-header nav .theme-toggle { margin-left: auto; }

/* These SVGs share their geometry; only the brand palette changes. */
.archive-logo { display: block; width: 240px; max-width: 100%; }
.archive-logo img { display: block; width: 100%; height: auto; }
.archive-logo .logo-dark { display: none; }
html[data-theme="dark"] .archive-logo .logo-light { display: none; }
html[data-theme="dark"] .archive-logo .logo-dark { display: block; }

@media (max-width: 1100px) {
  body.active_admin #header .theme-toggle { order: 2; }
}

/* ActiveAdmin and Select2 defaults live in vendored stylesheets. These rules
   cover their shared controls; workspace-specific styles use the same tokens. */
html[data-theme="dark"] body.active_admin { background: var(--theme-page); color: var(--theme-ink); }
html[data-theme="dark"] body.active_admin #title_bar { border-color: var(--theme-line); }
html[data-theme="dark"] body.active_admin :is(p, label, legend, table, tbody, td, th, li) { color: inherit; text-shadow: none; }
html[data-theme="dark"] body.active_admin :is(input, textarea, select, dialog) { color: var(--theme-ink); background-color: var(--theme-paper); border-color: var(--theme-input-border); box-shadow: none; }
html[data-theme="dark"] body.active_admin :is(input[type="submit"], button[type="submit"], .button) { color: white; background: var(--theme-button); border-color: var(--theme-button); text-shadow: none; box-shadow: none; }
html[data-theme="dark"] body.active_admin :is(input[type="submit"], button[type="submit"], .button):hover { background: var(--theme-button-hover); }
html[data-theme="dark"] body.active_admin :is(.scopes a, .pagination a, .pagination .current) { background: var(--theme-wash); color: var(--theme-link); border-color: var(--theme-line); text-shadow: none; box-shadow: none; }
html[data-theme="dark"] body.active_admin .scopes .selected a { background: var(--theme-selected); }
html[data-theme="dark"] body.active_admin table.index_table { background: var(--theme-paper); border-color: var(--theme-line); }
html[data-theme="dark"] body.active_admin table.index_table th { background: var(--theme-wash); border-color: var(--theme-line); color: var(--theme-ink); box-shadow: none; text-shadow: none; }
html[data-theme="dark"] body.active_admin table.index_table td { background: var(--theme-paper); border-color: var(--theme-line); color: var(--theme-ink); }
html[data-theme="dark"] body.active_admin table.index_table tr:nth-child(even) td { background: var(--theme-page); }
html[data-theme="dark"] body.active_admin table.index_table tr:hover td { background: var(--theme-selected); }
html[data-theme="dark"] body.active_admin table.index_table th a { color: var(--theme-link); }
html[data-theme="dark"] body.active_admin .scopes .count { color: var(--theme-muted); }
html[data-theme="dark"] body.active_admin :is(.select2-dropdown, .select2-search__field, .select2-selection, .select2-selection__choice) { background: var(--theme-paper); color: var(--theme-ink); border-color: var(--theme-input-border); }
html[data-theme="dark"] body.active_admin :is(.select2-results__option, .select2-selection__rendered, .select2-selection__choice__remove) { color: var(--theme-ink); }
html[data-theme="dark"] body.active_admin .select2-results__option[aria-selected="true"] { background: var(--theme-selected); }
html[data-theme="dark"] body.active_admin .select2-results__option--highlighted[aria-selected] { background: var(--theme-button); color: white; }
html[data-theme="dark"] body.active_admin :is(.select2-selection__placeholder, .select2-results__message) { color: var(--theme-muted); }
html[data-theme="dark"] body.active_admin .select2-selection__choice__remove:hover { color: var(--theme-link-hover); }
html[data-theme="dark"] body.active_admin .select2-results__option[aria-disabled="true"] { color: var(--theme-muted); }

/* Vditor's pre elements also match the administration's generic pre styles. */
html[data-theme] #biography-editor .vditor-reset {
  background: var(--theme-paper, white); color: var(--theme-ink, #25342e);
  font: 17px/1.8 system-ui, sans-serif;
}
html[data-theme="dark"] #biography-editor .vditor-reset a { color: var(--theme-link); }
