/* ===== Theme ===== */
:root {
  --bg: #101418;
  --bg-2: #0c1014;
  --surface: #182028;
  --surface-elevated: #1f2a33;
  --surface-soft: #24323d;
  --surface-muted: #131b22;
  --text: #f8fafc;
  --text-soft: #a7b2bd;
  --text-muted: #7f8c97;
  --border: rgba(167, 178, 189, 0.18);
  --border-strong: rgba(167, 178, 189, 0.28);
  /* Canonical accent palette (purple). theme-overrides.css re-declares these and
     adds the light-mode values + extra tokens — keep the two in sync. */
  --accent: #8b5cf6;
  --accent-strong: #7c3aed;
  --accent-rgb: 139, 92, 246;
  --accent-soft: rgba(var(--accent-rgb), 0.14);
  --shadow: 0 16px 44px rgba(0, 0, 0, 0.28);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --max-width: 1480px;
  --transition: 180ms ease;
}

/* ===== Global ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(var(--accent-rgb), 0.10), transparent 24%),
    radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.08), transparent 18%),
    linear-gradient(180deg, #101418 0%, #0c1014 100%);
  margin: 0;
  padding: 0;
  color: var(--text);
  min-height: 100vh;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

/* ===== Overflow safety net =====
   Two guarantees that keep long content inside its box site-wide, including on
   pages and compounds added in the future:
   1. Any single long, space-less string (IUPAC name, InChI, SMILES, URL) wraps
      onto the next line instead of spilling past its container.
   2. No element may force the page wider than the viewport. overflow-x: clip
      (not hidden) contains stray horizontal overflow — e.g. hover tooltips near
      the right edge — without establishing a scroll container, so the sticky
      header and infobox keep working. */
html {
  overflow-x: clip;
}

body {
  overflow-wrap: break-word;
}

.container {
  width: min(var(--max-width), calc(100% - 48px));
  margin: 0 auto;
}

.skip-link {
  position: absolute;
  top: -48px;
  left: 20px;
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  z-index: 100;
  text-decoration: none;
  transition: top var(--transition);
}
.skip-link:focus {
  top: 18px;
}

:focus {
  outline: none;
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* Give navigational / button-like links a 24px minimum target height
   (WCAG 2.5.8). In-sentence prose links are exempt and left untouched. */
#toc a,
.compound-page table a,
.compound-page .list-reset a,
#targets-container li a,
.view-all-link {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
}

/* ===== Shared surfaces ===== */
/* NOTE: .compound-card and .compound-page .infobox are intentionally excluded.
   backdrop-filter promotes the element to a compositing layer that Chromium
   rasterizes at 1x on HiDPI screens, which blurs the element's own contents —
   most visibly the fine lines of the molecule structure SVGs they contain. */
.site-header,
.hero-panel,
.project-note,
.feature-card,
.panel-card,
.compound-page details,
.toast,
.search-wrapper input,
.search-wrapper button,
.controls select,
.view-toggle button {
  backdrop-filter: blur(10px);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(12, 16, 20, 0.82);
  border-bottom: 1px solid var(--border);
}

.header-shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 18px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  min-width: 0;
}

.logo {
  height: 58px;
  width: auto;
  flex-shrink: 0;
}

/* Theme-aware logo swap. Keyed on [data-theme] (always present on <html>,
   default "dark") rather than prefers-color-scheme, because the header toggle
   can override the OS setting — a media-query swap would show the wrong-colour
   logo whenever the manual theme disagrees with the OS. Exactly one shows. */
.only-dark,
.only-light {
  display: none;
}
[data-theme="dark"] .only-dark {
  display: inline-flex;
}
[data-theme="light"] .only-light {
  display: inline-flex;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.eyebrow {
  color: var(--text-soft);
  font-size: 0.9rem;
  letter-spacing: 0.03em;
}

.brand-title {
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: nowrap;
}

.site-nav {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 28px;
  margin: 0;
  padding: 0;
  white-space: nowrap;
}

.site-nav a {
  position: relative;
  text-decoration: none;
  color: var(--text-soft);
  font-weight: 500;
  padding: 6px 0;
  transition: color var(--transition);
}

.site-nav a:hover,
.site-nav a:focus-visible,
.site-nav a[aria-current="page"] {
  color: var(--text);
}

.site-nav a[aria-current="page"]::after,
.site-nav a:hover::after,
.site-nav a:focus-visible::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 2px;
  border-radius: 999px;
  background: var(--accent);
}

.search-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.search-wrapper input {
  background: rgba(31, 42, 51, 0.94);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.search-wrapper input::placeholder {
  color: var(--text-muted);
}

.search-wrapper input:focus-visible {
  border-color: rgba(var(--accent-rgb), 0.45);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.18);
}

.search-wrapper button,
.hero-search button,
.text-link {
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), color var(--transition), border-color var(--transition);
}

.search-wrapper button {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: var(--bg);
  font-weight: 700;
  padding: 12px 18px;
}

.search-wrapper button:hover,
.search-wrapper button:focus-visible {
  transform: translateY(-1px);
}

#headerSearchInput {
  width: 290px;
}

.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: rgba(24, 32, 40, 0.98);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  width: 100%;
  box-shadow: var(--shadow);
  font-size: 14px;
  display: none;
  z-index: 1000;
  box-sizing: border-box;
  max-height: 280px;
  overflow: auto;
}

.suggestions[role="listbox"] {
  list-style: none;
  padding: 8px 0;
  margin: 0;
}

.suggestions div {
  padding: 12px 16px;
  cursor: pointer;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color var(--transition), color var(--transition);
}

.suggestions div + div {
  border-top: 1px solid rgba(167, 178, 189, 0.08);
}

.suggestions div:hover,
.suggestions div.active {
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--text);
}

/* Why a suggestion matched (synonym / CAS / CID / formula …) shown next to the name. */
.suggestion-meta {
  color: var(--text-muted);
  font-size: 0.82em;
}

/* ===== Homepage ===== */
main {
  padding: 40px 0 0;
}

.hero-layout {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr);
  align-items: start;
}

.hero-panel,
.project-note,
.feature-card,
.panel-card,
.compound-card {
  background: rgba(24, 32, 40, 0.88);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 36px;
  border-radius: 32px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(248, 250, 252, 0.08);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 600;
}

.hero-panel h1 {
  margin: 20px 0 0;
  max-width: 16ch;
  font-size: clamp(2.45rem, 4vw, 4.2rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.hero-copy {
  margin: 18px 0 0;
  max-width: 66ch;
  color: var(--text-soft);
  font-size: 1.06rem;
  line-height: 1.8;
}

.hero-search-panel {
  margin: 30px auto 0;
  max-width: 840px;
  background: rgba(12, 16, 20, 0.42);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 14px;
}

.hero-search {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
}

/* The homepage hero suggestions flow in-line on their own row and push the
   content below down, instead of floating over the cards beneath them. Those
   cards sit in their own stacking contexts (backdrop-filter), so an absolutely
   positioned dropdown would be painted over by them. The header search keeps
   its overlay behaviour (it targets #headerSearchSuggestions, untouched here). */
#searchSuggestions {
  position: static;
  flex: 0 0 100%;
  width: 100%;
  margin-top: 6px;
}

.hero-search input {
  width: 100%;
  min-width: 0;
  font-size: 1rem;
}

.hero-search button {
  white-space: nowrap;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.hero-tag,
.compound-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(var(--accent-rgb), 0.10);
  border: 1px solid rgba(var(--accent-rgb), 0.18);
  color: var(--text);
  font-size: 0.86rem;
  white-space: normal;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.hero-aside {
  display: grid;
  gap: 16px;
}

.quick-card,
.project-note {
  border-radius: 28px;
}

.quick-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px;
  text-decoration: none;
  background: rgba(24, 32, 40, 0.88);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform var(--transition), border-color var(--transition), background var(--transition);
}

.quick-card:hover,
.quick-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(var(--accent-rgb), 0.28);
  background: rgba(31, 42, 51, 0.96);
}

.quick-card-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.quick-card-content strong {
  font-size: 1rem;
  color: var(--text);
}

.quick-card-content span {
  color: var(--text-soft);
  line-height: 1.6;
}

.project-note {
  padding: 22px;
}

.section-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-soft);
  font-size: 0.95rem;
  font-weight: 600;
}

.project-note p {
  margin: 16px 0 0;
  color: var(--text-soft);
  line-height: 1.75;
}

.icon-shell {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--accent-rgb), 0.10);
  border: 1px solid rgba(var(--accent-rgb), 0.18);
  color: var(--accent);
  flex-shrink: 0;
}

.icon-shell--small {
  width: 28px;
  height: 28px;
  border-radius: 999px;
}

.icon-shell svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin-top: 26px;
}

.feature-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 210px;
  padding: 24px;
  border-radius: 28px;
}

.feature-card h2 {
  margin: 0;
  font-size: 1.08rem;
  letter-spacing: -0.02em;
}

.feature-card p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.7;
}

.featured {
  padding: 54px 0 0;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.section-head--stacked {
  align-items: start;
}

.section-head h2 {
  margin: 0;
  font-size: clamp(1.65rem, 2vw, 2rem);
  letter-spacing: -0.03em;
}

.section-head p {
  margin: 6px 0 0;
  color: var(--text-soft);
  line-height: 1.7;
}

.text-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  background: rgba(248, 250, 252, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}
.text-link:hover,
.text-link:focus-visible {
  background: rgba(var(--accent-rgb), 0.12);
  border-color: rgba(var(--accent-rgb), 0.24);
}

.compound-featured-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.compound-card {
  width: 100%;
  overflow: hidden;
  border-radius: 28px;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.compound-card:hover,
.compound-card:focus-within {
  transform: translateY(-3px);
  border-color: rgba(var(--accent-rgb), 0.24);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.34);
}

.compound-card-link {
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
}

.compound-thumb-wrap {
  aspect-ratio: 1.5 / 1;
  background:
    radial-gradient(circle at top left, rgba(var(--accent-rgb), 0.16), transparent 30%),
    linear-gradient(180deg, rgba(31, 42, 51, 0.94), rgba(20, 27, 34, 0.94));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  border-bottom: 1px solid rgba(167, 178, 189, 0.10);
}

.compound-thumb {
  max-height: 100%;
  object-fit: contain;
}

/* Inline structure SVG (rendered crisp by the vector engine at any size/DPI). */
.compound-structure-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 100%;
}

.compound-card-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  height: 100%;
}

.compound-card-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.compound-card-name-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.compound-card-title {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.25;
  word-break: break-word;
  min-width: 0;
}

.compound-card-subtitle {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 0.94rem;
}

.compound-card-copy {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.65;
  font-size: 0.94rem;
}

.compound-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compound-card-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(167, 178, 189, 0.10);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-soft);
  font-size: 0.94rem;
}

.inline-link {
  color: var(--text);
  font-weight: 600;
}

.featured-badge {
  background: rgba(248, 250, 252, 0.08);
  border-color: rgba(248, 250, 252, 0.12);
  color: var(--text);
}

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.78rem;
  white-space: normal;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.legal-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  /* Legal values are data-driven and occasionally hold a full sentence
     (e.g. "BtMG Anlage III (narcotic prescription form required)"). Let the
     badge wrap and stay within its container instead of forcing page overflow. */
  white-space: normal;
  overflow-wrap: anywhere;
  max-width: 100%;
  border: 1px solid transparent;
}
/* Pills that carry full legal wording in a tooltip get a subtle "more info"
   affordance (dotted underline + help cursor) without adding visual bulk. */
.legal-status--has-detail {
  cursor: help;
  text-decoration: underline dotted currentColor 1px;
  text-underline-offset: 3px;
}
.legal-status.legal {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.30);
  color: #6ee7b7;
}
.legal-status.restricted {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.28);
  color: #ffd487;
}
.legal-status.illegal {
  background: rgba(244, 63, 94, 0.16);
  border-color: rgba(244, 63, 94, 0.26);
  color: #ffb1bf;
}

/* Single full-width panel since the "About this project" card moved to about.html. */
.browse-grid {
  padding: 54px 0 0;
}

.panel-card {
  padding: 28px;
  border-radius: 32px;
}

.target-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.target-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 94px;
  padding: 18px;
  border-radius: 22px;
  text-decoration: none;
  color: var(--text);
  background: rgba(12, 16, 20, 0.42);
  border: 1px solid var(--border);
  transition: transform var(--transition), border-color var(--transition), background var(--transition);
}

.target-card:hover,
.target-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(var(--accent-rgb), 0.24);
  background: rgba(31, 42, 51, 0.96);
}

.target-card-content {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.target-card-content strong {
  font-size: 1rem;
}

.target-count {
  color: var(--text-soft);
  line-height: 1.55;
}

.target-arrow {
  margin-left: auto;
  color: var(--text-soft);
  font-size: 1.15rem;
}

.site-footer {
  margin-top: 56px;
  padding: 26px 0 36px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  text-align: center;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 24px;
  margin-bottom: 18px;
}

.footer-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  color: var(--text-soft);
  text-decoration: none;
  font-size: 0.92rem;
  transition: color var(--transition);
}

.footer-nav a:hover,
.footer-nav a:focus-visible {
  color: var(--text);
}

.footer-copy {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.footer-wordmark {
  line-height: 0;
}

.footer-wordmark img {
  height: 18px;
  width: auto;
  display: block;
}

.footer-disclaimer {
  max-width: 82ch;
  margin: 16px auto 0;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text-muted);
}

/* ===== Controls / compounds listing ===== */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  margin-bottom: 20px;
  color: var(--text-soft);
}
.controls select {
  margin-left: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(24, 32, 40, 0.94);
  color: var(--text);
}

.view-toggle {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
  gap: 10px;
  margin-left: auto; /* push the Grid/List toggle to the right of the controls row */
}
.view-toggle button {
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: rgba(24, 32, 40, 0.94);
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.9rem;
}
.view-toggle button.active {
  background: rgba(var(--accent-rgb), 0.12);
  border-color: rgba(var(--accent-rgb), 0.24);
  color: #d4fff0;
}

/* Compound sections & cards */
.compound-subclass {
  margin-bottom: 60px;
}
.compound-subclass h2 {
  font-size: 1.6rem;
  margin-bottom: 20px;
  color: var(--text);
  border-left: 4px solid var(--accent);
  padding-left: 12px;
}
.compound-list {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}
.compound-list.list-view {
  flex-direction: column;
  align-items: stretch;
}

.compound-list .compound-card {
  width: 220px;
  padding: 0;
}

.compound-list.list-view .compound-card {
  display: block;
  width: 100%;
  max-width: 100%;
}

.compound-list.list-view .compound-card-link {
  display: grid;
  grid-template-columns: 160px 1fr;
  min-height: 100%;
}
.compound-list.list-view .compound-thumb-wrap {
  aspect-ratio: auto;
  min-height: 100%;
}

.view-all-link {
  display: inline-block;
  margin: 0.5em 0;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.view-all-link:hover {
  text-decoration: underline;
}

/* About / legacy blocks */
.about {
  background: rgba(24, 32, 40, 0.88);
  border: 1px solid var(--border);
  padding: 30px;
  border-left: 4px solid var(--accent);
  margin-bottom: 60px;
  font-size: 1.05rem;
  border-radius: 18px;
  color: var(--text-soft);
}

h1, h2, h3 {
  color: var(--text);
}

/* Toast */
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 2000;
  background: rgba(24, 32, 40, 0.98);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

/* ===== Compound page ===== */
.compound-page .compound-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
}

.compound-page .infobox {
  background: rgba(24, 32, 40, 0.92);
  border: 1px solid var(--border);
  border-radius: 18px;
  font-size: 0.92rem;
  padding: 16px;
  position: sticky;
  /* --infobox-sticky-top is set by JS: 96px when the box fits the viewport,
     or a negative offset so a tall box scrolls up naturally and then pins with
     its bottom in view, releasing again at the end of the content column. */
  top: var(--infobox-sticky-top, 96px);
  color: var(--text-soft);
}
.compound-page .infobox img {
  max-width: 100%;
  height: auto;
  margin-bottom: 12px;
}
.compound-page .infobox-smiles-btn {
  display: block;
  width: 100%;
  margin: 0 0 14px;
  padding: 8px 12px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.compound-page .infobox-smiles-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent, #8b5cf6);
}
.compound-page .prop-unavailable {
  color: var(--text-soft);
  font-style: italic;
  font-size: 0.92em;
}
.compound-page .infobox table {
  width: 100%;
  border-collapse: collapse;
}
.compound-page .infobox th {
  text-align: left;
  padding-right: 10px;
  font-weight: 700;
  color: var(--text);
}
.compound-page .infobox td {
  text-align: right;
}

.compound-page details {
  margin-bottom: 1rem;
  background: rgba(24, 32, 40, 0.92);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0.75rem 1rem;
  color: var(--text-soft);
}
.compound-page details summary {
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
}

.compound-page #toc {
  margin: 12px 0 20px;
  font-size: 0.95rem;
}
.compound-page #toc a {
  text-decoration: none;
  color: var(--accent);
  margin-right: 12px;
}
.compound-page #toc a:hover {
  text-decoration: underline;
}

.compound-page .util-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 10px 0 16px;
}
.compound-page .util-row button {
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: rgba(24, 32, 40, 0.94);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
}
.compound-page .util-row button:hover {
  background: rgba(var(--accent-rgb), 0.10);
}

.enantiomer-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
.enantiomer-grid figure {
  flex: 1 1 45%;
  text-align: center;
}

.enantiomers {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 20px 0;
  background-color: rgba(24, 32, 40, 0.92);
  border: 1px solid var(--border);
  padding: 15px;
  border-radius: 18px;
  box-shadow: var(--shadow);
  /* Stack the two structures onto separate rows when they can't fit side by
     side, instead of overflowing the container on narrow screens. */
  flex-wrap: wrap;
}

.enantiomers figure {
  margin: 0;
  text-align: center;
  /* Cap each structure+caption to the structure width so a long caption wraps
     instead of widening the figure (and the whole box) past the column. */
  min-width: 0;
  max-width: 200px;
}

.enantiomers figcaption {
  margin-top: 8px;
  font-size: 0.95rem;
  color: var(--text-soft);
  overflow-wrap: anywhere;
}

.enantiomers img,
.enantiomers .compound-structure-svg {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Marks the configuration the substance's name normally refers to
   (e.g. (S)-methamphetamine) when both mirror forms are shown. */
.enantiomer-badge {
  /* Always sit on its own line, directly under the enantiomer name, rather
     than flowing beside it when the name is short. Block + fit-content keeps
     the pill sized to its text; auto side-margins centre it under the caption. */
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 6px auto 0;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(var(--accent-rgb), 0.14);
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  color: var(--text);
  white-space: normal;
  overflow-wrap: anywhere;
}

/* ===== Responsive ===== */
@media (max-width: 1180px) {
  .hero-layout {
    grid-template-columns: 1fr;
  }

  .compound-featured-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .header-shell,
  .header-tools {
    flex-direction: column;
    align-items: stretch;
  }

  .header-tools {
    gap: 14px;
  }

  .site-nav {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 18px;
  }

  #headerSearchInput {
    width: min(100%, 480px);
  }
}

@media (max-width: 900px) {
  .feature-grid,
  .target-grid,
  .compound-featured-row {
    grid-template-columns: 1fr;
  }

  .hero-panel,
  .panel-card,
  .feature-card {
    padding: 24px;
  }

  .hero-search {
    flex-direction: column;
    align-items: stretch;
  }

  /* The hero search stacks into a column here, so its button should fill the
     width. The header search stays a horizontal row, so a full-width button
     would crowd the input and crop its placeholder — exclude it. */
  .hero-search button,
  .search-wrapper:not(.header-search) button {
    width: 100%;
  }

  .compound-page .compound-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .container {
    width: min(var(--max-width), calc(100% - 28px));
  }

  .header-shell {
    padding: 14px 0;
  }

  .brand {
    align-items: center;
  }

  .logo {
    height: 50px;
  }

  .site-nav {
    gap: 14px;
  }

  .hero-panel h1 {
    font-size: 2.3rem;
  }

  .section-head {
    align-items: start;
    flex-direction: column;
  }

  .compound-list.list-view .compound-card-link {
    grid-template-columns: 1fr;
  }

  .enantiomers {
    flex-wrap: wrap;
  }
}

/* ===== Harm reduction: single homepage callout + dedicated page ===== */
.hr-callout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin: 28px 0;
  padding: 18px 22px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--accent-soft, rgba(139, 92, 246, 0.12));
}
.hr-callout__icon {
  flex: 0 0 auto;
  display: inline-flex;
  color: var(--accent, #8b5cf6);
}
.hr-callout__icon svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.hr-callout__text {
  flex: 1 1 300px;
  margin: 0;
  color: var(--text-soft);
  line-height: 1.6;
}
.hr-callout__text strong { color: var(--text); }
.hr-callout__cta { flex: 0 0 auto; white-space: nowrap; }

.hr-page .hr-lead {
  color: var(--text-soft);
  max-width: 72ch;
  line-height: 1.7;
  margin: 0 0 28px;
}
.hr-page .panel-card { margin-bottom: 18px; }
.hr-page .panel-card > h2 { margin-top: 0; }
.hr-page .panel-card ul { line-height: 1.7; margin: 0; padding-left: 1.2rem; }
.hr-page .hr-emergency { border-color: var(--accent, #8b5cf6); }
.hr-page .hr-disclaimer {
  color: var(--text-soft);
  font-size: 0.92rem;
  line-height: 1.7;
  border-top: 1px solid var(--border);
  margin-top: 28px;
  padding-top: 18px;
}

/* ===== About page =====
   Editorial layout: a full-width hero statement followed by section rows that
   place a short heading in a narrow left column and the prose in a wider right
   column, separated by thin top rules. All colours come from the shared theme
   tokens, so the page tracks light/dark automatically. */
.about-page {
  /* Narrower measure than the site-wide container for comfortable reading. */
  width: min(1080px, calc(100% - 48px));
  padding-bottom: 8px;
}

.about-eyebrow {
  display: inline-block;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.about-hero {
  padding: 28px 0 8px;
}

.about-hero h1 {
  margin: 16px 0 0;
  max-width: 20ch;
  font-size: clamp(2.35rem, 4.4vw, 3.7rem);
  line-height: 1.04;
  letter-spacing: -0.03em;
}

.about-hero__lead {
  margin: 26px 0 0;
  max-width: 58ch;
  color: var(--text-soft);
  font-size: clamp(1.08rem, 1.6vw, 1.3rem);
  line-height: 1.7;
}

.about-section {
  display: grid;
  grid-template-columns: minmax(0, 0.34fr) minmax(0, 0.66fr);
  gap: 20px 56px;
  padding: 46px 0;
  border-top: 1px solid var(--border);
}

.about-section:first-of-type {
  margin-top: 40px;
}

.about-section__label {
  align-self: start;
}

.about-section__label h2 {
  margin: 0;
  font-size: clamp(1.4rem, 2vw, 1.85rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.about-section__body {
  max-width: 68ch;
}

.about-section__body > p {
  margin: 0 0 18px;
  color: var(--text-soft);
  font-size: 1.05rem;
  line-height: 1.8;
}

.about-section__body > p:last-child {
  margin-bottom: 0;
}

.about-section__body strong {
  color: var(--text);
  font-weight: 700;
}

.contact-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}

.contact-list__row {
  display: grid;
  grid-template-columns: 96px 1fr;
  align-items: center;
  gap: 6px 18px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.contact-list__row:last-child {
  border-bottom: 0;
}

.contact-list__label {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.contact-list__value {
  color: var(--text);
  text-decoration: none;
  font-size: 1.02rem;
  overflow-wrap: anywhere;
}

a.contact-list__value:hover,
a.contact-list__value:focus-visible {
  color: var(--accent);
  text-decoration: underline;
}

.contact-list__value--placeholder {
  color: var(--text-muted);
  font-style: italic;
}

@media (max-width: 760px) {
  .about-section {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 36px 0;
  }

  .about-section:first-of-type {
    margin-top: 28px;
  }
}
