.header-actions {
  display: flex;
  align-items: center;
  flex: none;
  gap: clamp(.55rem, 1vw, .95rem);
}

.theme-toggle {
  --button-fill: transparent;
  --track: #e7ece3;
  --track-edge: #91a18f;
  --thumb: #fffdf5;
  --active-icon: #294034;
  --idle-icon: #59715e;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 2rem;
  background-color: transparent;
  color: inherit;
  white-space: nowrap;
}
.theme-toggle[hidden] { display: none; }
:root[data-theme] .theme-toggle[hidden] { display: inline-flex; visibility: hidden; }
.theme-label { font-size: .86rem; font-weight: 550; }
.theme-track {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  place-items: center;
  width: 3.75rem;
  height: 2.05rem;
  border: 1px solid var(--track-edge);
  border-radius: 2rem;
  background: var(--track);
}
.theme-track::before {
  content: "";
  position: absolute;
  inset: 3px auto 3px 3px;
  width: calc(50% - 3px);
  border-radius: inherit;
  background: var(--thumb);
  box-shadow: 0 1px 4px rgb(9 24 16 / 15%);
}
.theme-track .icon {
  position: relative;
  width: .99rem;
  height: .99rem;
  stroke-width: 1.8;
}
.theme-sun { color: var(--active-icon); }
.theme-moon { color: var(--idle-icon); }
.theme-toggle:is(:hover, :focus-visible) .theme-track { border-color: currentColor; }
.js .hero-in-view:not(.menu-open) .theme-toggle {
  --track: rgb(18 37 28 / 64%);
  --track-edge: rgb(255 253 247 / 68%);
  --thumb: #fff8e5;
  --idle-icon: #e3ebde;
}

@media (max-width: 1299px) {
  .theme-label { display: none; }
}
@media (min-width: 961px) and (max-width: 1199px) {
  .header-inner { width: calc(100% - 3rem); gap: 1rem; }
  .desktop-nav { gap: clamp(.5rem, 1.15vw, .85rem); }
}
@media (max-width: 960px) {
  .header-actions { margin-inline-start: auto; }
}
@media (max-width: 420px) {
  .header-inner { width: calc(100% - 1.5rem); gap: .5rem; }
  .header-actions { gap: .45rem; }
  .header .clinic-logo { width: clamp(6.7rem, 32vw, 8.5rem); }
  .theme-track { width: 3.4rem; height: 1.95rem; }
}

@media screen {
  :root[data-theme="light"] { color-scheme: light; }
  :root[data-theme="dark"] {
    color-scheme: dark;
    --paper: #101c17;
    --ink: #edf2e8;
    --muted: #b8c8ba;
    --line: #405448;
    --gold: #dfc692;
    --surface: #17271f;
    --panel: #1e3228;
    --hover: #304b3b;
    --accent: #c4d8b7;
    background-color: var(--paper);
  }
  [data-theme="dark"] .theme-toggle {
    --track: #233a2d;
    --track-edge: #819681;
    --thumb: #dbe6c7;
    --idle-icon: #bfcebe;
  }
  [data-theme="dark"] .theme-track::before { transform: translateX(100%); }
  [data-theme="dark"] .theme-sun { color: var(--idle-icon); }
  [data-theme="dark"] .theme-moon { color: var(--active-icon); }

  /* Add an independent scrim so the existing scroll reveal and photo colours are preserved. */
  .scene-photo::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: #071910;
    opacity: 0;
  }
  [data-theme="dark"] .scene-photo::before { opacity: .39; }

  [data-theme="dark"] .header {
    color: var(--ink);
    background-color: rgb(17 31 24 / 96%);
    border-bottom-color: var(--line);
  }
  [data-theme="dark"] .header .clinic-logo {
    filter: grayscale(1) contrast(1.45) invert(1) brightness(1.15);
  }
  .js[data-theme="dark"] .hero-in-view:not(.menu-open) .header-visit:is(:hover,:focus-visible) {
    color: #17281e;
  }
  [data-theme="dark"] .intro-ribbon,
  [data-theme="dark"] :is(.hours, .equipment) { background-color: var(--surface); }
  [data-theme="dark"] :is(.visit, .tour) { background-color: var(--paper); }
  [data-theme="dark"] .director-story {
    --director-ink-rgb: 23 39 31;
    --director-type: var(--ink);
    --director-muted: var(--muted);
    --director-gold: var(--gold);
  }
  [data-theme="dark"] .care { background-color: #122d23; }
  [data-theme="dark"] .footer { background-color: #0b1912; }
  [data-theme="dark"] :is(.director-profile, .visit-tip, .hours-card, .visit-map-card,
                          .address-dialog, .contact-dialog, .quick-top) {
    background-color: var(--panel);
  }
  [data-theme="dark"] :is(.hours, .director, .director-profile dl > div, .promise-list li,
                          .faq-list, .address-block, .hours-contact, .hours-contact-icon, .hours-card,
                          .hours-card-heading, .hours-schedule > div, .visit-map-card, .visit-map-address,
                          .contact-dialog, .address-dialog, .quick-top, .mobile-quick) {
    border-color: var(--line);
  }
  [data-theme="dark"] :is(.section-heading .section-description, .principles-caption,
                          .staff-portrait figcaption, .staff-layout .director-greeting > p,
                          .promise-list li p, .process-row-description, .process-row .step-en,
                          .equipment-caption, .hours-contact small, .detail-label, .visit-map-address) {
    color: var(--muted);
  }
  [data-theme="dark"] :is(.staff-layout .director-greeting .director-hello,
                          .staff-layout .director-profile dt, .quick-top) { color: var(--ink); }
  [data-theme="dark"] :is(.promise-sign span, .process-row .icon, .hours-clock,
                          .hours-contact-arrow, .copy-address, .map-fallback) { color: var(--accent); }
  [data-theme="dark"] :is(.promise-list li > span, .process-row .step-no) { color: var(--gold); }
  [data-theme="dark"] .bonmaek-watermark { color: var(--accent); }

  [data-theme="dark"] .practice-band:first-child {
    --band-bg: #2b382a;
    --band-title: #f2f3e6;
    --band-copy: #ced6c3;
    --band-accent: #d7c69a;
  }
  [data-theme="dark"] .practice-band:nth-child(2) { --band-bg: #304b39; }
  [data-theme="dark"] .practice-band:nth-child(3) { --band-bg: #17372b; }
  [data-theme="dark"] .promise-label { background-image: linear-gradient(var(--hover), var(--hover)); }
  [data-theme="dark"] .process-step.is-active :is(.process-row-description, .step-en, .icon) {
    color: #edf2e5;
  }
  [data-theme="dark"] .tour-wordmark {
    background-color: var(--surface);
    border-color: var(--line);
    color: #93a997;
  }
  [data-theme="dark"] .equipment-controls button {
    --button-fill: var(--hover);
    border-color: #708b79;
    color: var(--ink);
  }
  [data-theme="dark"] :is(.equipment-controls button, .equipment-stage):focus-visible {
    outline-color: var(--gold);
  }
  [data-theme="dark"] .equipment-progress { background-color: var(--line); }
  [data-theme="dark"] .equipment-progress i,
  [data-theme="dark"] .plus::before, [data-theme="dark"] .plus::after { background-color: var(--accent); }
  [data-theme="dark"] :is(.faq-list summary, .text-link, .hours-contact, .copy-address,
                          .button-outline, .menu-toggle, .dialog-close, .quick-top, .mobile-quick a) {
    --button-fill: var(--hover);
  }
  [data-theme="dark"] :is(.text-link, .button-outline) { border-color: #839c88; }
  [data-theme="dark"] :is(.button-dark, .skip-link) {
    --button-fill: #d8e6cb;
    background-color: var(--accent);
    color: #14251b;
  }
  [data-theme="dark"] .address-fallback { background-color: var(--paper); }
  [data-theme="dark"] .mobile-quick { background-color: rgb(23 39 31 / 97%); color: var(--ink); }
  [data-theme="dark"] .mobile-quick a:is(:active, :focus-visible) { color: var(--accent); }
  [data-theme="dark"] .visit-map-card .root_daum_roughmap { color-scheme: light; color: #2b392e; }
  [data-theme="dark"] .tmap-dialog img { background-color: white; }
}

@media screen and (prefers-reduced-motion: no-preference) {
  .theme-track, .theme-track::before, .theme-track .icon {
    transition: transform .28s ease, background-color .25s ease, color .25s ease, border-color .25s ease;
  }
  .scene-photo::before { transition: opacity .32s ease; }
  body, .intro-ribbon, .equipment, .tour, .tour-wordmark, .hours, .visit, .director-profile, .visit-tip {
    transition: background-color .25s ease, color .25s ease, border-color .25s ease;
  }
}
@media print {
  .header-actions { display: none; }
}
