/* Two complete themes. Photos, sample colours and the purple nail retain their actual colours. */
html[data-theme="light"] {
  color-scheme: light;
  --ui-bg: #f3ede3; --ui-ink: #102c40; --ui-muted: #53616e;
  --ui-accent: #6c4a89; --ui-surface: #faf7f2; --ui-soft: #e9e3db;
  --ui-border: #bcb4c0; --ui-on-accent: #ffffff;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --ui-bg: #0d2544; --ui-ink: #f3ede3; --ui-muted: #c3ced4;
  --ui-accent: #c6a6e3; --ui-surface: #163452; --ui-soft: #1c3b57;
  --ui-border: #526577; --ui-on-accent: #102c40;
}
html[data-theme] body[data-theme] {
  --navy: var(--ui-ink); --mustard: var(--ui-accent); --cream: var(--ui-bg);
  --cream-light: var(--ui-surface); --ink: var(--ui-ink); --muted: var(--ui-muted);
  --nav-bg: var(--ui-bg); --nav-text: var(--ui-ink); --nav-hover: var(--ui-accent);
  --hero-title: var(--ui-ink); --link: var(--ui-accent); --link-hover: var(--ui-ink);
  --card-shadow: 5px 5px 0 var(--ui-border);
  --home-background: var(--ui-bg); --home-ink: var(--ui-ink); --home-purple: var(--ui-accent);
  --home-nav-ink: var(--ui-ink); --home-nav-hover: var(--ui-accent);
  background: var(--ui-bg); color: var(--ui-ink);
}
html[data-theme] body[data-theme] :is(.tsinglan-navbar,.site-footer,.bio-canvas,.hero) {
  background: var(--ui-bg) !important; color: var(--ui-ink);
}
html[data-theme] body[data-theme] .tsinglan-navbar {
  --nav-bg: var(--ui-bg); --nav-text: var(--ui-ink); --nav-hover: var(--ui-accent);
  box-shadow: none; border-bottom-color: transparent; backdrop-filter: none;
}
html[data-theme] body[data-theme] :is(.tsinglan-brand,.tsinglan-nav-link,.site-footer h4,.site-footer p,.site-footer li,.site-footer a) { color: var(--ui-ink); text-shadow: none; }
html[data-theme] body[data-theme] .tsinglan-nav-link:is(:hover,:focus,.show),
html[data-theme] body[data-theme] .tsinglan-dropdown .dropdown-item:is(:hover,:focus) { background: var(--ui-soft); color: var(--ui-accent); box-shadow: none; }
html[data-theme] body[data-theme] .tsinglan-dropdown { background: var(--ui-surface); border-color: var(--ui-border); }
html[data-theme] body[data-theme] .tsinglan-dropdown .dropdown-item { color: var(--ui-ink); }
html[data-theme] body[data-theme] .tsinglan-navbar .navbar-collapse { background: var(--ui-bg); border-color: var(--ui-border); }
html[data-theme] body[data-theme] :is(.tsinglan-search-input,.wiki-assistant__input) { background: var(--ui-surface); border-color: var(--ui-border); color: var(--ui-ink); }
html[data-theme] body[data-theme] :is(.tsinglan-search-input,.wiki-assistant__input)::placeholder { color: var(--ui-muted); }
html[data-theme] body[data-theme] :is(.tsinglan-search-btn,.wiki-assistant__btn) { background: var(--ui-accent); border-color: var(--ui-accent); color: var(--ui-on-accent); }
html[data-theme] body[data-theme] :is(.tsinglan-search-status,.wiki-assistant__status) { color: var(--ui-muted); }
html[data-theme] body[data-theme] .tsinglan-toggler { color: var(--ui-ink); border-color: var(--ui-border); }
html[data-theme="light"] body .tsinglan-toggler .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23102c40' stroke-linecap='round' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
html[data-theme="dark"] body .tsinglan-toggler .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23f3ede3' stroke-linecap='round' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
html[data-theme] body[data-theme] :is(a,button,input):focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 4px; }

/* Shared article surfaces use the same pair of themes. */
html[data-theme] body[data-theme] .hero__lead { color: var(--ui-muted) !important; }
html[data-theme] body[data-theme] :is(.hero__eyebrow,.hero__page-label) { color: var(--ui-muted); border-color: var(--ui-border); }
html[data-theme] body[data-theme] :is(.science-card,.science-note,.science-story details,.science-table-wrap,.science-figure) { background: var(--ui-surface); border-color: var(--ui-border); }
html[data-theme] body[data-theme] :is(.science-tag,.science-number,.science-story code) { color: var(--ui-accent); }
html[data-theme] body[data-theme] :is(.science-figure figcaption,.science-source) { color: var(--ui-muted); border-color: var(--ui-border); }
html[data-theme] body[data-theme] :is(.science-table th,.science-table td,.science-links a) { border-color: var(--ui-border); }
html[data-theme] body[data-theme] .science-table th { background: var(--ui-soft); color: var(--ui-ink); }
html[data-theme] body[data-theme] .science-links a:is(:hover,:focus-visible) { background: var(--ui-soft); color: var(--ui-accent); }
html[data-theme] body[data-theme] :is(.wiki-toc__panel,.wiki-toc__bar) { background: var(--ui-surface); color: var(--ui-ink); }
html[data-theme] body[data-theme] :is(.wiki-toc__title,.wiki-toc__rail-label,.wiki-toc__collapse,.wiki-toc__close) { color: var(--ui-ink); border-color: var(--ui-border); }
html[data-theme] body[data-theme] .wiki-toc__nav a { color: var(--ui-muted); }
html[data-theme] body[data-theme] .wiki-toc__nav a:is(:hover,.is-active,[aria-current]) { color: var(--ui-accent); background: var(--ui-soft); border-color: var(--ui-accent); }

/* The selected colour continues from the opening through all six cycles. */
html[data-theme] body.homepage-simple :is(.flow,.flow-stage,.student-home,.student-home-poster) {
  --flow-navy: var(--ui-bg); --flow-cream: var(--ui-ink); --flow-mustard: var(--ui-accent); --flow-coral: var(--ui-accent);
  background: var(--ui-bg); color: var(--ui-ink);
}
html[data-theme] body.homepage-simple .student-home::after { display: none; }
html:not(.desktop-flow-motion)[data-theme] body.homepage-simple .flow-copy--surface { margin-top: 0; }
html[data-theme] body.homepage-simple .flow-edition { display: none; }
html[data-theme] body.homepage-simple .student-home-poster h1 { color: var(--ui-ink); }
html[data-theme] body.homepage-simple :is(.student-home-caption,.flow-copy__lead,.flow-copy__record,.flow-design-caption,.application-preview figcaption) { color: var(--ui-muted); }
html[data-theme] body.homepage-simple :is(.flow-kicker,.flow-record-link,.student-home-caption .flow-follow,.student-home-caption .flow-follow span) { color: var(--ui-accent); border-color: var(--ui-border); }
html[data-theme] body.homepage-simple :is(.flow-chapters a,.flow-chapters a.is-current,.flow-cycle-nav a,.flow-cycle-nav a span) { color: var(--ui-ink); }
html[data-theme] body.homepage-simple :is(.flow-chapters__number,.flow-chapters a .flow-chapters__number,.flow-cycle-nav__label) { color: var(--ui-accent); }
html[data-theme] body.homepage-simple .flow-chapters__line { background: var(--ui-border); }
html[data-theme] body.homepage-simple .flow-progress { background: var(--ui-soft); }
html[data-theme] body.homepage-simple .flow-progress span { background: var(--ui-accent); }
html[data-theme] body.homepage-simple .flow-cycle-nav a { border-color: var(--ui-border); }

/* Structural experiment artwork follows the UI; coloured samples do not. */
html[data-theme] .assembly-scene text { fill: var(--ui-ink); }
html[data-theme] .assembly-scene .assembly-kicker { fill: var(--ui-accent); }
html[data-theme] .assembly-scene :is(.assembly-small,.assembly-tiny) { fill: var(--ui-muted); }
html[data-theme] .assembly-scene :is(.assembly-line,.assembly-outline,.assembly-tube) { stroke: var(--ui-ink); }
html[data-theme] .assembly-scene .assembly-muted-line { stroke: var(--ui-muted); stroke-opacity: .75; }
html[data-theme] .assembly-scene .assembly-panel { fill: var(--ui-soft); stroke: var(--ui-border); stroke-opacity: 1; }
html[data-theme] .assembly-scene .assembly-tube { fill: var(--ui-ink); }
html[data-theme] .assembly-scene :is(.assembly-cap,.assembly-rack) { fill: var(--ui-muted); stroke: var(--ui-muted); }
html[data-theme] #assembly-dish > :is(path,ellipse),
html[data-theme] #assembly-intro ellipse[stroke="#d8e4d7"],
html[data-theme] .assembly-scene [stroke="#cbd5c1"] { stroke: var(--ui-muted); }
html[data-theme] #assembly-adhesive-domains text,
html[data-theme] #assembly-cycle-4 > text.assembly-label[x="921"] { fill: #faf7f2; }

html[data-theme] .flow-evidence { --evidence-navy: var(--ui-bg); --evidence-cream: var(--ui-ink); --evidence-gold: var(--ui-accent); background: var(--ui-bg); color: var(--ui-ink); }
html[data-theme] .flow-evidence :is(.flow-evidence__eyebrow,.flow-evidence__intro,.flow-evidence__prototype-label p,figcaption span,.flow-evidence__prototype-note,.flow-evidence__records-heading p,.flow-evidence__record-heading small,.flow-evidence__record-body > p) { color: var(--ui-muted); }
html[data-theme] .flow-evidence :is(figcaption,figcaption strong,h3,h4) { color: var(--ui-ink); }
html[data-theme] .flow-evidence :is(.flow-evidence__prototype,.flow-evidence__image-link,.flow-evidence__record-body figure a) { background: var(--ui-surface); }
html[data-theme] .flow-evidence :is(.flow-evidence__prototype,.flow-evidence__prototype-note,.flow-evidence__record,.flow-evidence__index) { border-color: var(--ui-border); }
html[data-theme] .flow-evidence .flow-evidence__enlarge { background: var(--ui-surface); color: var(--ui-ink); border-color: var(--ui-border); }

html[data-theme] .colour-library {
  --library-ink: var(--ui-ink); --library-paper: var(--ui-ink); --library-ocean: var(--ui-bg);
  --library-muted: var(--ui-muted); --library-rule: var(--ui-border);
  border-color: var(--ui-border);
}
html[data-theme] .colour-library :is(.colour-library__eyebrow,.colour-library__eyebrow span,.colour-library__label,.colour-library__footer a) { color: var(--ui-accent); border-color: var(--ui-border); }
html[data-theme] .colour-library .colour-library__range { color: var(--ui-muted); }
html[data-theme] .colour-library .colour-library__photo { background: var(--ui-surface); border-color: var(--ui-border); }
html[data-theme] .colour-library .colour-library__photo:is(:hover,:focus-visible) { border-color: var(--ui-accent); }
html[data-theme] .colour-library :is(.colour-library__dialog,.colour-library__dialog button,.colour-library__dialog figure > img) { background: var(--ui-surface); color: var(--ui-ink); border-color: var(--ui-border); }
html[data-theme] .colour-library :is(.colour-library__dialog figcaption p,.colour-library__dialog-nav p) { color: var(--ui-muted); }
html[data-theme] .colour-library .colour-library__dialog figcaption a { color: var(--ui-accent); }

/* Both controls remain available at the lower right, including on the opening. */
html[data-theme] body[data-theme] #theme-switcher,
html[data-theme] body[data-theme] #wiki-assistant { display: block !important; position: fixed; top: auto; left: auto; visibility: visible !important; pointer-events: auto !important; opacity: 1; margin: 0; z-index: 1080; }
html[data-theme] body[data-theme] #theme-switcher { right: 18px; bottom: max(15px,env(safe-area-inset-bottom)); width: 56px; height: 88px; }
html[data-theme] body[data-theme] #theme-toggle { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; width: 56px; height: 88px; min-height: 44px; padding: 3px; color: var(--ui-ink); border: 0; border-radius: 12px; background: transparent; box-shadow: none; filter: none; }
html[data-theme] body[data-theme] #theme-toggle:hover { background: var(--ui-soft); transform: translateY(-2px); }
html[data-theme] body[data-theme] #theme-toggle .theme-toggle__icon { display: block; width: 36px; height: 64px; filter: none; }
html[data-theme] body[data-theme] .theme-toggle__detail { stroke: var(--ui-bg); opacity: .55; }
html[data-theme] body[data-theme] .theme-toggle__bottle-name { fill: var(--ui-bg); font: 600 57px Georgia,serif; letter-spacing: 2px; }
html[data-theme] body[data-theme] .theme-toggle__label { font: 500 10px/1.4 Arial,sans-serif; letter-spacing: .08em; }
html[data-theme] body[data-theme] #wiki-assistant { right: 88px; bottom: max(20px,env(safe-area-inset-bottom)); width: 48px; height: 48px; }
html[data-theme] body[data-theme] #wiki-assistant-toggle { display: grid; place-items: center; width: 48px; height: 48px; min-width: 48px; min-height: 48px; padding: 11px; border: 1px solid var(--ui-border); border-radius: 50%; background: var(--ui-bg); color: var(--ui-ink); box-shadow: none; transform: none; }
html[data-theme] body[data-theme] #wiki-assistant-toggle:hover { color: var(--ui-accent); border-color: var(--ui-accent); transform: scale(1.06); }
html[data-theme] body[data-theme] .wiki-assistant__icon { display: block; width: 24px; height: 24px; }
html[data-theme] body[data-theme] #wiki-assistant-panel { position: absolute; top: auto; bottom: 64px; right: -70px; left: auto; width: min(320px,calc(100vw - 36px)); max-width: none; padding: 18px; background: var(--ui-surface); color: var(--ui-ink); border: 1px solid var(--ui-border); box-shadow: 0 12px 36px #0002; }
html[data-theme] body[data-theme] .wiki-assistant__title { color: var(--ui-ink); }
html[data-theme] body[data-theme] .back-to-top { right: 24px; bottom: 116px; background: var(--ui-surface); color: var(--ui-ink); border-color: var(--ui-border); }
html[data-theme] body[data-theme] .wiki-toc-fab { color: var(--ui-ink); background: var(--ui-surface); border-color: var(--ui-border); }
@media (max-width:599px) {
  html[data-theme] body.homepage-simple .student-home-poster { height: calc(100svh - 274px); min-height: 320px; }
}
@media (max-height:500px) and (min-width:600px) {
  html[data-theme] body.homepage-simple .student-home-caption { margin-left: 6.5%; margin-right: 180px; width: calc(93.5% - 180px); }
}
@media (max-width:991.98px) {
  html[data-theme] body.mobile-menu-open #scroll-logo { opacity: 0; visibility: hidden !important; pointer-events: none; }
}
html[data-theme="dark"] body.homepage-simple .tsinglan-toggler .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23f3ede3' stroke-linecap='round' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
@media (prefers-reduced-motion:reduce) {
  html[data-theme] body[data-theme] #theme-toggle:hover, html[data-theme] body[data-theme] #wiki-assistant-toggle:hover { transform: none; }
}
