/* Theme toggle button (top right of the masthead) */
.masthead__inner-wrap { padding-right: 3.5em; }
.theme-toggle {
  position: absolute; top: 50%; right: 1em; transform: translateY(-50%);
  width: 2.2em; height: 2.2em; padding: 0; z-index: 30;
  border: 1px solid #ccc; border-radius: 50%; background: transparent;
  color: #7a8288; font-size: 1em; line-height: 1; cursor: pointer;
}
.theme-toggle:hover { color: #333; border-color: #333; }
.theme-toggle svg { display: block; margin: auto; }
.theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Dark theme: headings/titles are light violet, everything else is white */
html[data-theme="dark"] {
  color-scheme: dark;
  --violet: #c4b0ff;
  --violet-hover: #ddd0ff;
  --text: #f2f2f5;
  --line: #3a3f45;
  --panel: #1f2225;
}
html[data-theme="dark"] body { background: #16181a; color: var(--text); }

/* Text: white */
html[data-theme="dark"] p, html[data-theme="dark"] li, html[data-theme="dark"] td, html[data-theme="dark"] th,
html[data-theme="dark"] strong, html[data-theme="dark"] em, html[data-theme="dark"] figcaption,
html[data-theme="dark"] .author__bio, html[data-theme="dark"] .author__pronouns,
html[data-theme="dark"] .author__urls li, html[data-theme="dark"] .author__desktop, html[data-theme="dark"] .author__urls i,
html[data-theme="dark"] .page__meta, html[data-theme="dark"] .archive__item-excerpt,
html[data-theme="dark"] .pub-citation, html[data-theme="dark"] .talk-meta, html[data-theme="dark"] .mentor-meta,
html[data-theme="dark"] .mentor-role, html[data-theme="dark"] .fund-meta, html[data-theme="dark"] .fund-role,
html[data-theme="dark"] .fund-desc, html[data-theme="dark"] .fund-amount, html[data-theme="dark"] .teach-meta,
html[data-theme="dark"] .teach-role, html[data-theme="dark"] .teach-desc,
html[data-theme="dark"] .page__footer, html[data-theme="dark"] .page__footer a,
html[data-theme="dark"] .code-grid figcaption, html[data-theme="dark"] .gif-row figcaption,
html[data-theme="dark"] .video-grid figcaption, html[data-theme="dark"] .sim-grid figcaption { color: var(--text); }

/* Headings and item titles: light violet (titles' links included) */
html[data-theme="dark"] h1, html[data-theme="dark"] h2, html[data-theme="dark"] h3,
html[data-theme="dark"] h4, html[data-theme="dark"] h5, html[data-theme="dark"] h6,
html[data-theme="dark"] .page__title, html[data-theme="dark"] .archive__item-title, html[data-theme="dark"] .archive__item-title a,
html[data-theme="dark"] .author__name, html[data-theme="dark"] .masthead__menu-item--lg a,
html[data-theme="dark"] .pub-title, html[data-theme="dark"] .pub-title a,
html[data-theme="dark"] .talk-title, html[data-theme="dark"] .talk-title a,
html[data-theme="dark"] .teach-title, html[data-theme="dark"] .teach-title a,
html[data-theme="dark"] .fund-title, html[data-theme="dark"] .fund-title a,
html[data-theme="dark"] .mentor-title, html[data-theme="dark"] .mentor-title a { color: var(--violet); }
html[data-theme="dark"] .pub-title a:hover, html[data-theme="dark"] .teach-title a:hover,
html[data-theme="dark"] .talk-title a:hover, html[data-theme="dark"] .fund-title a:hover { color: var(--violet-hover); }

/* Other links: white */
html[data-theme="dark"] a, html[data-theme="dark"] a:visited { color: var(--text); }
html[data-theme="dark"] a:hover { color: var(--violet-hover); }
html[data-theme="dark"] .masthead a, html[data-theme="dark"] .greedy-nav a { color: var(--text); }
html[data-theme="dark"] .masthead a:hover, html[data-theme="dark"] .greedy-nav a:hover { color: var(--violet-hover); }
html[data-theme="dark"] .masthead__menu-item--lg a { color: var(--violet); }

/* Surfaces and borders */
html[data-theme="dark"] .masthead, html[data-theme="dark"] .greedy-nav,
html[data-theme="dark"] .greedy-nav .hidden-links { background: #1c1f22; border-color: var(--line); }
html[data-theme="dark"] .masthead { border-bottom: 1px solid var(--line); }
html[data-theme="dark"] .greedy-nav button { background: var(--line); }
html[data-theme="dark"] .page__footer { background: #1c1f22; }
html[data-theme="dark"] hr, html[data-theme="dark"] .showcase-hr,
html[data-theme="dark"] table, html[data-theme="dark"] th, html[data-theme="dark"] td { border-color: var(--line); }
html[data-theme="dark"] .showcase-hr { border-top: 1px solid var(--line); }
html[data-theme="dark"] thead, html[data-theme="dark"] tr:nth-child(even) { background: var(--panel); }
html[data-theme="dark"] code, html[data-theme="dark"] pre, html[data-theme="dark"] .highlight { background: var(--panel); color: var(--text); }
html[data-theme="dark"] .author__urls { background: var(--panel); border-color: var(--line); }
html[data-theme="dark"] .author__urls:before, html[data-theme="dark"] .author__urls:after { border-color: var(--panel) transparent; }
html[data-theme="dark"] .pub-item, html[data-theme="dark"] .talk-item, html[data-theme="dark"] .mentor-item,
html[data-theme="dark"] .fund-item, html[data-theme="dark"] .teach-item { border-bottom-color: var(--line); }
html[data-theme="dark"] .code-grid img, html[data-theme="dark"] .gif-row img { border-color: var(--line); }

/* Buttons: same neutral style everywhere */
html[data-theme="dark"] .pub-links a, html[data-theme="dark"] .pub-bibtex-btn,
html[data-theme="dark"] .talk-links a, html[data-theme="dark"] .mentor-links a, html[data-theme="dark"] .code-link {
  color: var(--text); background: var(--panel); border-color: #6b6f76;
}
html[data-theme="dark"] .pub-links a:hover, html[data-theme="dark"] .pub-bibtex-btn:hover,
html[data-theme="dark"] .talk-links a:hover, html[data-theme="dark"] .mentor-links a:hover,
html[data-theme="dark"] .code-link:hover { background: var(--line); color: var(--violet-hover); }
html[data-theme="dark"] .mentor-name { color: var(--violet); }
html[data-theme="dark"] .mentor-name span { color: var(--text); }
html[data-theme="dark"] .mentor-thesis { color: var(--violet); }
/* Title links stay violet once visited (they'd otherwise fall back to the white link colour) */
html[data-theme="dark"] .pub-title a:visited, html[data-theme="dark"] .talk-title a:visited,
html[data-theme="dark"] .teach-title a:visited, html[data-theme="dark"] .fund-title a:visited,
html[data-theme="dark"] .archive__item-title a:visited { color: var(--violet); }
html[data-theme="dark"] .pub-title a:visited:hover, html[data-theme="dark"] .talk-title a:visited:hover,
html[data-theme="dark"] .teach-title a:visited:hover, html[data-theme="dark"] .fund-title a:visited:hover { color: var(--violet-hover); }
