:root {
  color-scheme: dark;
  --bg: #0b0c0f;
  --bg-soft: #12141a;
  --bg-card: #16181f;
  --bg-elev: #1c1f28;
  --line: rgba(243, 238, 228, 0.1);
  --line-strong: rgba(243, 238, 228, 0.18);
  --text: #f3eee4;
  --text-soft: #c9c2b6;
  --muted: #9a9388;
  --accent: #d4b08c;
  --accent-deep: #b88962;
  --teal: #8fbfb4;
  --focus: #e8d5b5;
  --danger: #d58b73;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --serif: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  --sans: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --radius: 18px;
  --header-h: 4.25rem;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f4efe6;
  --bg-soft: #ece5d8;
  --bg-card: #fffaf2;
  --bg-elev: #ffffff;
  --line: rgba(28, 24, 18, 0.1);
  --line-strong: rgba(28, 24, 18, 0.18);
  --text: #1c1812;
  --text-soft: #3f3930;
  --muted: #6d665b;
  --accent: #8c5a32;
  --accent-deep: #6e4324;
  --teal: #2f6f66;
  --focus: #8c5a32;
  --danger: #a34532;
  --shadow: 0 20px 50px rgba(60, 44, 24, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html:focus-within { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(212, 176, 140, 0.08), transparent 50%),
    radial-gradient(900px 600px at 110% 0%, rgba(143, 191, 180, 0.07), transparent 46%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.05rem;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--text); }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--bg-elev);
  color: var(--text);
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  z-index: 80;
}
.skip:focus { top: 1rem; }

.wrap {
  width: min(1160px, calc(100% - 2rem));
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(18px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: inherit;
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}
.wordmark svg { width: 1.7rem; height: 1.7rem; color: var(--accent); }
.wordmark span b { font-weight: 400; }
.wordmark em { font-style: italic; color: var(--accent); }

nav { display: flex; align-items: center; gap: 0.35rem 1.1rem; }
nav a {
  color: var(--text-soft);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
}
nav a[aria-current="page"], nav a:hover { color: var(--text); }

.icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--text);
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--line-strong); }
.icon-btn .moon { display: none; }
[data-theme="light"] .icon-btn .sun { display: none; }
[data-theme="light"] .icon-btn .moon { display: block; }

.hero { padding: 4.5rem 0 3.2rem; }
.kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.hero h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.7rem, 7vw, 5.4rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  margin: 0.85rem 0 1.1rem;
  max-width: 14ch;
}
.hero h1 em { font-style: italic; color: var(--accent); }
.lede {
  max-width: 38rem;
  color: var(--text-soft);
  font-size: 1.12rem;
  margin: 0 0 1.8rem;
}

.search-bar {
  display: flex;
  gap: 0.6rem;
  max-width: 38rem;
  padding: 0.4rem;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.search-bar input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  padding: 0.7rem 0.95rem;
  min-width: 0;
}
.search-bar input::placeholder { color: var(--muted); }
.search-bar button, .btn {
  appearance: none;
  border: 0;
  background: var(--text);
  color: var(--bg);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.search-bar button:hover, .btn:hover { opacity: 0.9; color: var(--bg); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line-strong);
}

.section { padding: 3.2rem 0; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1.4rem;
}
.section-head h2, .page-title, .compound-hero h1 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.section-head h2 { font-size: clamp(1.8rem, 3vw, 2.4rem); margin: 0; }
.section-head p, .muted { color: var(--muted); }

.cats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}
@media (min-width: 800px) {
  .cats { grid-template-columns: repeat(3, 1fr); }
}
.cat {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 8.5rem;
  padding: 1.15rem 1.2rem;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  transition: transform 0.4s var(--ease), border-color 0.3s var(--ease);
}
.cat:hover { transform: translateY(-3px); border-color: var(--line-strong); color: inherit; }
.cat strong { font-size: 1.12rem; }
.cat span { color: var(--muted); font-size: 0.88rem; margin-top: 0.6rem; }

.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}
@media (min-width: 700px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1020px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
}
.card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 1.2rem 1.2rem 1.15rem;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  min-height: 13.5rem;
  transition: transform 0.4s var(--ease), border-color 0.3s var(--ease);
}
.card:hover { transform: translateY(-3px); border-color: var(--line-strong); color: inherit; }
.card h3 {
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 400;
  margin: 0;
  letter-spacing: -0.03em;
}
.card p { margin: 0; color: var(--text-soft); flex: 1; }
.card-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.card.is-preview { cursor: default; }
.card.is-preview:hover { transform: none; }

.pill, .grade {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: color-mix(in srgb, var(--bg-soft) 70%, transparent);
}
.grade-robust { color: var(--teal); border-color: color-mix(in srgb, var(--teal) 45%, var(--line)); }
.grade-moderate { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.grade-limited { color: var(--accent-deep); border-color: color-mix(in srgb, var(--accent-deep) 50%, var(--line)); }
.grade-preclinical { color: var(--muted); }

.grades {
  display: grid;
  gap: 0.75rem;
}
@media (min-width: 800px) { .grades { grid-template-columns: repeat(4, 1fr); } }
.grade-card {
  padding: 1.15rem 1.15rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-card);
}
.grade-card h3 { margin: 0.55rem 0 0.4rem; font-size: 1.15rem; }
.grade-card p { margin: 0; color: var(--muted); font-size: 0.95rem; }

.disclaimer, .callout {
  padding: 1.4rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--bg-soft);
}
.disclaimer h2, .callout h2 { margin: 0 0 0.5rem; font-size: 1.2rem; }
.disclaimer p, .callout p { margin: 0; color: var(--text-soft); }
.disclaimer a { color: inherit; }

.site-footer {
  margin-top: 3rem;
  padding: 2.4rem 0 3rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
}
.footer-grid {
  display: grid;
  gap: 1.5rem;
}
@media (min-width: 800px) {
  .footer-grid { grid-template-columns: 1.4fr 1fr 1fr; }
}
.site-footer a { color: var(--text-soft); text-decoration: none; }
.site-footer a:hover { color: var(--text); }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.site-footer h2 { font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 0 0 0.6rem; font-weight: 600; }

/* Compound page */
.compound-hero { padding: 2.6rem 0 1.4rem; }
.compound-hero h1 { font-size: clamp(2.6rem, 6vw, 4.6rem); margin: 0.35rem 0 0.4rem; }
.aka { color: var(--muted); margin: 0 0 1rem; }
.toc {
  position: sticky;
  top: var(--header-h);
  z-index: 20;
  display: flex;
  gap: 0.2rem;
  overflow-x: auto;
  padding: 0.65rem 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.toc a {
  white-space: nowrap;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
}
.toc a:hover, .toc a[aria-current="true"] { color: var(--text); background: var(--bg-card); }

.prose { max-width: 46rem; padding: 2rem 0 3rem; }
.prose h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 2rem;
  letter-spacing: -0.03em;
  margin: 2.4rem 0 0.7rem;
}
.prose h2:first-child { margin-top: 0; }
.prose p { color: var(--text-soft); }
.prose ul, .prose ol { color: var(--text-soft); padding-left: 1.15rem; }
.prose li { margin: 0.35rem 0; }
.prose figure, .evidence-box {
  margin: 1.3rem 0;
  padding: 1.1rem 1.15rem;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.cite-list { list-style: none; padding: 0; }
.cite-list li {
  padding: 0.85rem 0;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
}
.cite-list li:first-child { border-top: 0; }
.cite-list a { font-family: var(--mono); font-size: 0.84rem; }

.split {
  display: grid;
  gap: 0.8rem;
}
@media (min-width: 760px) { .split { grid-template-columns: 1fr 1fr; } }
.split article h3 { margin: 0 0 0.4rem; font-size: 1.05rem; }

/* Index */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 1.1rem 0 1.4rem;
  align-items: center;
}
.filters label { color: var(--muted); font-size: 0.85rem; }
.filters select, .filters input[type="search"] {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  font: inherit;
  font-size: 0.92rem;
  padding: 0.55rem 0.85rem;
}
.count { margin: 0 0 1rem; color: var(--muted); font-size: 0.92rem; }
.empty { padding: 2rem; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }

.page-title { font-size: clamp(2.2rem, 5vw, 3.6rem); margin: 2.2rem 0 0.5rem; }

@media (max-width: 720px) {
  nav .hide-sm { display: none; }
  .hero { padding-top: 2.8rem; }
  .search-bar { flex-direction: column; border-radius: 18px; }
  .search-bar button { width: 100%; }
}
