:root { color-scheme: only light; }
:root[data-theme="dark"] { color-scheme: dark; background: #171918; scrollbar-color:#56605a #171918; }

.site-theme-control {
  --theme-surface: #fdfdfc;
  --theme-text: #232a25;
  --theme-line: #dadfd8;
  --theme-wash: #f2f3ef;
  position: fixed;
  z-index: 15;
  inset: auto auto max(16px,env(safe-area-inset-bottom)) 16px;
  color: var(--theme-text);
  font-size: 13px;
}
.entry-stage > .site-theme-control {
  position: absolute;
  inset: clamp(27px,6.8svh,73px) var(--entry-gutter) auto auto;
}
.site-theme-control summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding-inline: 11px;
  width: max-content;
  border: 1px solid var(--theme-line);
  background: var(--theme-surface);
  border-radius: 9px;
  list-style: none;
  font-weight: 630;
  cursor: pointer;
}
.site-theme-control summary::-webkit-details-marker { display: none; }
.theme-mark {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid currentColor;
  background: linear-gradient(90deg,currentColor 50%,transparent 50%);
}
.site-theme-control fieldset {
  position: absolute;
  inset: auto auto calc(100% + 8px) 0;
  width: 154px;
  padding: 13px 8px 8px;
  margin: 0;
  border: 1px solid var(--theme-line);
  border-radius: 12px;
  background: var(--theme-surface);
  box-shadow: 0 12px 28px #0002;
}
.entry-stage > .site-theme-control fieldset { inset: calc(100% + 6px) 0 auto auto; }
.site-theme-control legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.site-theme-control label { display: flex; gap: 10px; align-items: center; min-height: 43px; padding: 3px 8px; border-radius: 7px; cursor: pointer; }
.site-theme-control label:has(:checked), .site-theme-control label:hover { background: var(--theme-wash); }
.site-theme-control input { margin: 0; accent-color: #ba453e; }
.site-theme-control summary:focus-visible, .site-theme-control label:focus-within { outline: 2px solid var(--red,#ab3b32); outline-offset: 2px; }

html[data-theme="dark"] .sky-theme {
  --site-background: #171918;
  --sky-paper: #202422;
  --sky-layer: #292d2a;
  --sky-border: #3c433e;
  --ink: #f3eee5;
  --muted: #bac2bb;
  --light-ink: #d0d5cf;
  --red: #f08d80;
  --red-dark: #f5a196;
  --ref-ink: #f3eee5;
  --ref-muted: #c2c8c0;
  --ref-yellow: #daaa54;
  color: var(--ink);
}
html[data-theme="dark"] .site-theme-control {
  --theme-surface: #222725;
  --theme-text: #f3eee5;
  --theme-line: #444c46;
  --theme-wash: #303632;
}
html[data-theme="dark"] .sky-theme .brand-image > .brand-logo { content: url("media/brand-logo-reverse.png"); }
html[data-theme="dark"] .sky-theme .company-lockup img { content: url("media/company-sign-night.webp"); }
html[data-theme="dark"] .entry-logo-toggle { opacity: .64; }
html[data-theme="dark"] .entry-logo-toggle:is(:focus-visible,:hover,[aria-pressed="true"]) { opacity: 1; }
html[data-theme="dark"] [data-entry-view], html[data-theme="dark"] .entry-stage {
  --entry-ink: #f7efe6;
  --entry-muted: #c4c5bb;
  --entry-accent: #fd9b8c;
}
html[data-theme="dark"] .entry-page .entry-spot { background: radial-gradient(ellipse at 70% 85%,#40322d,transparent 72%); }
html[data-theme="dark"] .entry-page .entry-login-panel { background: var(--site-background); border-color: var(--line); }
html[data-theme="dark"] .entry-page .entry-login-panel::before { background:none; }
html[data-theme="dark"] .entry-page .entry-back { color: #dfd6cc; }
html[data-theme="dark"] .entry-page .entry-button-primary { background: #a83d34; color: #fff9f1; border-color: #a83d34; }
html[data-theme="dark"] .entry-page .entry-button-secondary { background: var(--sky-paper); color: var(--ink); border-color: var(--line); }
html[data-theme="dark"] .entry-page .entry-button-icon { background: #ffffff16; color: currentColor; }
html[data-theme="dark"] .sky-theme :is(.button.red,.mode-switch [aria-selected="true"]) { color: #fff9f1; background:#a53e36; border-color:#c56355; }
html[data-theme="dark"] .sky-theme :is(.button.ink,.float-site-ai) { background: #e8e3d9; color: #232820; border-color: #e8e3d9; }
html[data-theme="dark"] .sky-theme :is(.button.outline,.button.light,.top-actions .icon-button,.menu) { color:var(--ink); background:var(--sky-paper); border-color:var(--line); }

html[data-theme="dark"] .sky-theme :is(.topnav,.nav-submenu,.dialog,.ask-form,.home-console,.mode-switch,
  .comparison,.support-highlight,.catalog-copy,.reference-course-card,.resource-row,.skill-library,
  .gallery-search,.search-field,.course-section,.route-panel,.route-tools button,.route-directions,.route-deck,
  .site-chat,.site-chat-header,.site-chat-form,.site-chat-close,.site-chat-starters button,.site-chat-links a) {
  background-color: var(--sky-paper);
  color: var(--ink);
  border-color: var(--line);
}
html[data-theme="dark"] .sky-theme.home.refreshed-home :is(.home-hero,.home-console,.ask-form,.facts-bar,.map-callout,.quick-row) {
  background: var(--sky-paper);
  border-color: var(--line);
}
html[data-theme="dark"] .sky-theme.home.refreshed-home .home-hero { background: var(--site-background); }
html[data-theme="dark"] .sky-theme.home.refreshed-home .ref-welcome h1 { color: var(--ink); }
html[data-theme="dark"] .sky-theme.home.refreshed-home .ref-question { color: var(--ink); }
html[data-theme="dark"] .sky-theme :is(input,textarea,select) { color: var(--ink); caret-color: var(--red); }
html[data-theme="dark"] .sky-theme :is(input,textarea)::placeholder { color: #bfc4bc; opacity: 1; }
html[data-theme="dark"] .sky-theme :is(.ask-form input,.site-chat-form textarea) { background: transparent; }
html[data-theme="dark"] .sky-theme :is(.mode-switch button,.ref-question-line > span,.skill-preview-arrow,.welcome-about,
  .ref-card-meta,.reference-course-card .card-bottom,.hero-deck,.course-price,.site-chat-intro,.site-chat-status,
  .knowledge-hero > p,.skill-gallery-byline,.skill-gallery-description,.entry-deck) { color: var(--muted); }
html[data-theme="dark"] .sky-theme :is(.ref-question-library,.notice a,.text-action) { color: #f2a498; }
html[data-theme="dark"] .sky-theme.knowledge-preview :is(.skill-gallery-heading h2,.skill-gallery-card h3,
  .skill-gallery-controls a,.gallery-filters button,.gallery-rank-fields select,.gallery-search input) {
  color:var(--ink);
}
html[data-theme="dark"] .sky-theme.knowledge-preview :is(.skill-gallery-heading p,.skill-gallery-byline span,.skill-session,
  .skill-gallery-meta,.skill-gallery-description) { color:var(--muted); }
html[data-theme="dark"] .sky-theme.knowledge-preview :is(.gallery-search input,.gallery-rank-fields select,.motion-toggle) {
  background:var(--sky-paper);
  border-color:var(--line);
  color:var(--ink);
}
html[data-theme="dark"] .sky-theme.knowledge-preview .gallery-filters button:is([aria-pressed="true"],:hover) {
  background:#33453b;
  color:#f1f5ee;
}
html[data-theme="dark"] .sky-theme.knowledge-preview :is(.skill-media,.skill-library) { border-color:var(--line); }
html[data-theme="dark"] .sky-theme :is(.notice,.gallery-rankbar,.skill-engagement-bar,.skill-author-controls,.route-row,.route-variants,
  .site-chat-message,.site-chat-message.is-user,.site-chat-message.is-assistant,.site-chat-bubble) {
  background-color: var(--sky-layer);
  border-color: var(--line);
  color: var(--ink);
}
html[data-theme="dark"] .sky-theme :is(.ref-section-mast,.ref-lesson-hero,.detail-main > .course-section,.support-focus,.campus-support-pair) {
  background: var(--sky-paper);
  border-color: var(--line);
}
html[data-theme="dark"] .sky-theme :is(.ref-meta-kicker,.ref-band,.ref-poster-foot) { color: #f3a194; }
/* Course artwork stays on its original paper. Only the surrounding UI follows the theme. */
html[data-theme="dark"] .sky-theme .ref-poster-art { --ref-ink: #181714; --ref-yellow:#edbe43; }
html[data-theme="dark"] .sky-theme .ref-poster-art .ref-poster-band { color: #fffaf0; }
html[data-theme="dark"] .sky-theme .site-chat::backdrop { background: #080a099c; }
html[data-theme="dark"] .sky-theme .site-chat :is(p,textarea,button,a) { color: inherit; }
html[data-theme="dark"] .sky-theme .site-chat button[type="submit"] { background:#a53e36; color:#fff9f1; }

html[data-theme="dark"] .sky-theme.ref-map.route-page.atlas-page {
  --map-ink: #f5eee5;
  --map-muted: #b9c4bb;
  --map-label: #202923;
  --map-edge: #404f45;
}
html[data-theme="dark"] .atlas-page .route-field .route-view { background:#202a24; border-color:#404d41; box-shadow:none; }
html[data-theme="dark"] .atlas-page .atlas-landscape { background:radial-gradient(ellipse at 47% 38%,#29372e,#19231e 82%); }
html[data-theme="dark"] .atlas-page .atlas-land { fill:#30392d; }
html[data-theme="dark"] .atlas-page .atlas-wood { fill:#273a30; }
html[data-theme="dark"] .atlas-page .atlas-water-edge { stroke:#31524a; }
html[data-theme="dark"] .atlas-page .atlas-water { stroke:#203b35; }
html[data-theme="dark"] .atlas-page .atlas-contours { stroke:#617769; opacity:.56; }
html[data-theme="dark"] .atlas-page .atlas-current-line { stroke:#85a299; }
html[data-theme="dark"] .atlas-page .atlas-trail { color:color-mix(in srgb,var(--trail) 64%,#f5e7ce); }
html[data-theme="dark"] .atlas-page .atlas-trail-bed { stroke:#426052; }
html[data-theme="dark"] .atlas-page .atlas-trail-line { opacity:1; stroke-width:2.6; }
html[data-theme="dark"] .atlas-page .atlas-sprite { filter:drop-shadow(0 7px 6px #101711a0) brightness(1.13); }
html[data-theme="dark"] .atlas-page .atlas-name { background:#202923;color:#f1eee5;border-color:#5a6b5e; }
html[data-theme="dark"] .atlas-page .atlas-origin .atlas-name { background:#ae4137; border-color:#ec8678; box-shadow:0 0 0 5px #862e2b56,0 7px 15px #100e0cb0; }
html[data-theme="dark"] .atlas-page .atlas-mini { background:#263831;color:#e2eee2;border-color:#4e6b5d; }
html[data-theme="dark"] .atlas-page .atlas-step-dot { background:#263730;border-color:#8ba28e; }
html[data-theme="dark"] .atlas-page .route-field .route-deck { background:#202824;border-color:#465449; }
html[data-theme="dark"] .atlas-page .route-field :is(.route-panel,.route-panel-bar,.route-panel-footer) { background:var(--site-background); border-color:var(--line); }
