.site-theme-toggle {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, .82);
  color: var(--dim);
  cursor: pointer;
  font: 800 17px/1 inherit;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.site-theme-toggle:hover {
  color: var(--ink);
  border-color: rgba(173, 92, 255, .45);
}
.site-theme-toggle .theme-sun { display: none; }
.site-theme-floating {
  position: fixed;
  top: 26px;
  right: 7vw;
  z-index: 190;
}

html[data-site-theme="midnight"] {
  color-scheme: dark;
  --paper: #0d1117;
  --surface: #1b232f;
  --ink: #f2f7fc;
  --dim: #9aabc0;
  --line: rgba(169, 196, 226, .14);
  --blue: #57c8ff;
  --purple: #c17cff;
  --green: #5bea97;
  --pink: #ff7199;
  --orange: #ff825c;
  --yellow: #f5d85d;
}
html[data-site-theme="midnight"] body {
  background: #0d1117;
  color: var(--ink);
}
html[data-site-theme="midnight"] .site-theme-toggle {
  background: rgba(27, 35, 47, .92);
  border-color: var(--line);
  color: var(--dim);
}
html[data-site-theme="midnight"] .site-theme-toggle .theme-moon {
  display: none;
}
html[data-site-theme="midnight"] .site-theme-toggle .theme-sun {
  display: inline;
}

/* Shared informational/library pages. */
html[data-site-theme="midnight"] body:is(
  [data-site-page="themes"],
  [data-site-page="guide"]
) {
  background: #0d1117;
}
html[data-site-theme="midnight"] :is(
  body[data-site-page="themes"],
  body[data-site-page="guide"]
) :is(.back, .card, .role-card, .option-compare .opt, nav.toc a) {
  background: #1b232f;
  border-color: var(--line);
  color: var(--ink);
}
html[data-site-theme="midnight"] body[data-site-page="guide"] :is(code, kbd) {
  background: rgba(169, 196, 226, .10);
  border-color: var(--line);
}
html[data-site-theme="midnight"] body[data-site-page="guide"] pre {
  background: #080b10;
  border: 1px solid var(--line);
}
html[data-site-theme="midnight"] body[data-site-page="guide"] .support-box {
  background: linear-gradient(
    135deg,
    rgba(193, 124, 255, .12),
    rgba(87, 200, 255, .08)
  );
  border-color: rgba(193, 124, 255, .28);
}

/* Theme library. Live preview iframes retain their requested display mode. */
html[data-site-theme="midnight"] body[data-site-page="themes"] :is(
  .theme-card,
  .modal,
  .bulk-scope-btn,
  .bulk-deck-list
) {
  background: #1b232f;
  border-color: var(--line);
  color: var(--ink);
}
html[data-site-theme="midnight"] body[data-site-page="themes"] :is(
  .field input,
  .field select,
  .field textarea,
  .share-form input,
  .share-form select,
  .bulk-deck-search
) {
  background: #111823;
  border-color: var(--line);
  color: var(--ink);
}
html[data-site-theme="midnight"] body[data-site-page="themes"] :is(
  .modal-actions .btn-cancel,
  .version-chip
) {
  background: rgba(169, 196, 226, .10);
  color: var(--ink);
}
html[data-site-theme="midnight"] body[data-site-page="themes"] .modal-veil {
  background: rgba(3, 6, 10, .68);
}
html[data-site-theme="midnight"] body[data-site-page="themes"] .theme-card.retired {
  background: #241b1a;
  border-color: rgba(255, 130, 92, .34);
}
html[data-site-theme="midnight"] body[data-site-page="themes"] .retired-banner {
  background: rgba(255, 130, 92, .13);
  color: #ffb099;
}
html[data-site-theme="midnight"] body[data-site-page="themes"] :is(
  .pptx-warnings,
  .bulk-preview
) {
  color: var(--ink);
}
html[data-site-theme="midnight"] body[data-site-page="themes"] :is(
  .pptx-error,
  .bulk-error
) {
  color: #ff9ab7;
}
html[data-site-theme="midnight"] body[data-site-page="themes"] .mini {
  background: #222d3b;
  border-color: var(--line);
}
body[data-site-page="themes"] .theme-load-error {
  margin: 8px 0 14px;
  color: var(--pink);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
}

/* Operational analytics surface. */
html[data-site-theme="midnight"] body[data-site-page="analytics"] {
  --paper: #0d1117;
  --surface: #1b232f;
  --ink: #f2f7fc;
  --dim: #9aabc0;
  --line: #303c4b;
  --purple: #c17cff;
  --blue: #57c8ff;
  --green: #5bea97;
  --pink: #ff7199;
  --orange: #ff825c;
  --yellow: #f5d85d;
}
html[data-site-theme="midnight"] body[data-site-page="analytics"] :is(
  .insight-band,
  .health-summary
) {
  background: #17202a;
}
html[data-site-theme="midnight"] body[data-site-page="analytics"] :is(
  .period,
  .table-tools input
) {
  background: #111823;
  border-color: var(--line);
  color: var(--ink);
}
html[data-site-theme="midnight"] body[data-site-page="analytics"] .grid-line {
  stroke: #303c4b;
}
html[data-site-theme="midnight"] body[data-site-page="analytics"] .axis-label {
  fill: var(--dim);
}
html[data-site-theme="midnight"] body[data-site-page="analytics"] .heat-cell {
  background: #222d3b;
}
html[data-site-theme="midnight"] body[data-site-page="analytics"] .refresh:hover {
  border-color: var(--blue);
}
