/* Shared theme controls; the same header appears on every generated page. */
:root { color-scheme: light; }
.header-controls { display:flex; align-items:center; gap:10px; order:3; margin-left:24px; }
.header nav { margin-left:auto; gap:26px; }
.theme-toggle { display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:44px; padding:9px 12px; border:1px solid var(--line); border-radius:6px; background:transparent; color:var(--ink); font-size:14px; font-weight:600; }
.theme-toggle:hover { background:var(--pale); border-color:var(--blue); }
.theme-toggle svg { width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.theme-toggle .theme-sun { display:none; }
[data-theme="dark"] .theme-toggle .theme-sun { display:block; }
[data-theme="dark"] .theme-toggle .theme-moon { display:none; }

:root[data-theme="dark"] {
  color-scheme:dark;
  --ink:#e5edf9;
  --muted:#aabbd0;
  --blue:#8fb4ff;
  --pale:#172b45;
  --line:#30435c;
  --paper:#0b1423;
  --surface:#101f33;
}
[data-theme="dark"] .header { background:rgba(11,20,35,.97); }
[data-theme="dark"] ::selection { background:#385c92; color:#fff; }
[data-theme="dark"] :is(.skip,form,.firmware-excerpt,.experience-block.job-section,.model-detail,.model-parts button,.model-controls button) { background:var(--surface); border-color:var(--line); }
[data-theme="dark"] :is(.sensor-demo,.signal-cover,.gallery .mechanism-video,.model-layout,.result-note) { background:var(--pale); border-color:var(--line); }
[data-theme="dark"] :is(.sensor-demo,.signal-cover) { border-top-color:var(--blue); }
[data-theme="dark"] :is(.sensor-demo video,.mechanism-video video) { background:var(--surface); border-color:var(--line); }
[data-theme="dark"] :is(.motion-steps li,.project-results dl>div+div,.model-detail,.model-controls button) { border-color:var(--line); }
[data-theme="dark"] .hero-visual { box-shadow:12px 14px 0 #213854; }
[data-theme="dark"] :is(.primary,.model-parts button[aria-pressed="true"]) { background:var(--blue); color:#0b1c35; }
[data-theme="dark"] .primary:hover { background:#b6ceff; }
[data-theme="dark"] .model-parts button[aria-pressed="true"] span { color:#233e63; }
[data-theme="dark"] .filter-bar button.active { background:var(--blue); border-color:var(--blue); color:#0b1c35; }
[data-theme="dark"] .dialog-close { background:#dce8fa; color:#102a4c; }
[data-theme="dark"] :is(.image-label,.project-arrow,.zoom-image span) { background:#172b45; color:#e5edf9; }
[data-theme="dark"] :is(input,textarea) { border-color:#5e7694; }
[data-theme="dark"] .model-stage { background:radial-gradient(ellipse at center,#294666 0%,#142a44 72%); }
[data-theme="dark"] .model-loading { background:#142a44ee; }
/* Transparent monochrome wordmarks sit directly on dark surfaces. */
[data-theme="dark"] :is(.employer-logo,.role-logo,.education-logo) { background:transparent; border-radius:0; padding:0; filter:brightness(0) invert(1); opacity:.92; }
[data-theme="dark"] .technical-gallery .zoom-image { border-color:#526982; }
[data-theme="dark"] :is(.signal-cover .zoom-image,.model-detail .zoom-image) { border-color:#526982; }

/* Theme the display of paper figures; keep photographs and PCB colors intact. */
[data-theme="dark"] :is(.zoom-image,.technical-gallery .zoom-image,.signal-cover .zoom-image,.model-detail .zoom-image,.project-image.analysis) { background:var(--surface); border-color:var(--line); }
[data-theme="dark"] :is(.chapter-content>figure .zoom-image img,.project-image.analysis img) { background:var(--surface); }
[data-theme="dark"] img[data-theme-media="paper"] { background:#fff!important; filter:invert(1) hue-rotate(180deg) brightness(1.4) contrast(.9); }
[data-theme="dark"] .firmware-diagram .zoom-image { background:var(--surface); }
[data-theme="dark"] dialog { background:var(--surface); border:1px solid var(--line); }

@media(max-width:1050px) and (min-width:761px) {
  .header { padding-inline:28px; }
  .header nav { gap:18px; }
  .header-controls { margin-left:18px; }
}
@media(max-width:760px) {
  .header-controls { margin-left:auto; gap:8px; }
  .header nav { margin-left:0; }
  .theme-toggle { min-width:76px; padding:9px 10px; }
  .header-controls .menu-toggle { min-height:44px; }
}
@media(max-width:380px) {
  .header { padding-inline:16px; }
  .brand { gap:8px; font-size:8px; }
  .brand-mark { font-size:36px; }
  .header-controls { gap:6px; }
  .header-controls .menu-toggle { gap:6px; padding:9px; }
  .theme-toggle { min-width:68px; gap:5px; padding:9px 8px; }
}
