@font-face {
  font-family: 'Inter';
  src: url('fonts/inter.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Fraunces';
  src: url('fonts/fraunces.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #0e0e10;
  --bg-top: #141416;
  --surface: #19191c;
  --surface-2: #232327;
  --border: #2f2f34;
  --text: #ececee;
  --muted: #9b9ba3;
  --accent: #eea3b4;
  --accent-strong: #f7bfce;
  --accent-ink: #2a1018;
  --leaf: #6c9e95;
  --link: #f2a8ba;
  --code-bg: #0a0a0b;
  --topbar-h: 60px;
  --stem: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 48'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 0C3 12 11 12 7 24S3 36 7 48'/%3E%3Cpath d='M8.6 12 12.5 8.8M5.4 36 1.5 32.8'/%3E%3C/g%3E%3C/svg%3E");
  --bud: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Ccircle cx='6' cy='6' r='4.4' fill='none' stroke='%23000' stroke-width='1.5'/%3E%3Ccircle cx='6' cy='6' r='1.7'/%3E%3C/svg%3E");
  --radius: 6px;
  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

:root[data-theme='light'] {
  --bg: #f6f1ec;
  --bg-top: #fbf8f4;
  --surface: #fffdfa;
  --surface-2: #efe8e0;
  --border: #ded3c7;
  --text: #1b2a2b;
  --muted: #5d6e6d;
  --accent: #dd7f95;
  --accent-strong: #ad3c59;
  --accent-ink: #2a1018;
  --leaf: #3f7168;
  --link: #a73756;
  --code-bg: #efe8e0;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 16px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.7 var(--sans);
  font-feature-settings: 'cv11', 'ss03';
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent); color: var(--accent-ink); }
a { color: var(--link); text-underline-offset: 3px; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
kbd {
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
}

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h);
  padding: 0 clamp(14px, 3vw, 32px);
  background: var(--bg-top);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-family: var(--display); font-weight: 600; font-size: 21px; letter-spacing: -0.01em; }
.brand img { border-radius: 50%; }
.spacer { flex: 1; }
.toplinks { display: flex; gap: 8px; }
.pill {
  padding: 8px 18px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  font-weight: 600; font-size: 14px;
  transition: background 0.15s;
}
.pill:hover { background: var(--accent-strong); }
.searchbtn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font: inherit; font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.searchbtn { min-width: 220px; }
.searchbtn:hover { border-color: var(--accent); color: var(--text); }
.searchbtn-label { flex: 1; text-align: left; }
.icon-btn {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border: 0; border-radius: var(--radius);
  background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.navtoggle { display: none; }

.shell {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 230px;
  gap: 8px;
  max-width: 1500px;
  margin: 0 auto;
}

.booknav {
  position: sticky; top: var(--topbar-h);
  align-self: start;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 28px 18px 40px 28px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.booknav-title { margin: 0 0 16px; font-family: var(--display); font-size: 20px; font-weight: 500; font-style: italic; color: var(--muted); }
.group { position: relative; margin-bottom: 4px; padding-left: 22px; }
.group::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 14px;
  background: var(--border);
  -webkit-mask: var(--stem) repeat-y top left / 14px 48px;
  mask: var(--stem) repeat-y top left / 14px 48px;
  transition: background-color 0.15s;
}
.group.open::before { background: var(--accent); }
.group-head { display: flex; align-items: center; gap: 2px; padding: 5px 6px 5px 4px; }
.group-head > a { flex: 1; color: var(--text); text-decoration: none; font-weight: 600; font-size: 15px; padding: 3px 4px; border-radius: var(--radius); }
.group-head > a:hover, .group-head > a[aria-current='page'] { color: var(--accent-strong); }
.group-toggle { display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: var(--radius); background: none; color: var(--muted); cursor: pointer; }
.group-toggle svg { transition: transform 0.15s; }
.group.open .group-toggle svg { transform: rotate(90deg); }
.group-toggle:hover { background: var(--surface-2); }
.count { font-size: 12px; color: var(--muted); padding-right: 4px; font-variant-numeric: tabular-nums; }
.group ul { display: none; list-style: none; margin: 0 0 8px; padding: 0 0 0 8px; }
.group.open ul { display: block; }
.group li a {
  position: relative;
  display: block; padding: 4px 10px; margin: 1px 0;
  color: var(--muted); text-decoration: none; font-size: 14px;
  border-radius: var(--radius);
}
.group li a:hover { color: var(--text); background: var(--surface-2); }
.group li a[aria-current='page'] { color: var(--accent-strong); background: var(--surface-2); font-weight: 600; }
.group li a[aria-current='page']::before {
  content: ''; position: absolute; left: -28px; top: 50%; width: 12px; height: 12px; margin-top: -6px;
  background: var(--accent);
  -webkit-mask: var(--bud) no-repeat center / contain;
  mask: var(--bud) no-repeat center / contain;
}
.tag {
  margin-left: 8px; padding: 1px 7px;
  border: 1px solid var(--leaf); border-radius: 999px;
  font-size: 11px; font-weight: 600;
  color: var(--leaf); vertical-align: middle;
}

.content { min-width: 0; padding: 36px clamp(16px, 3vw, 40px) 80px; }
.content article { max-width: 760px; margin: 0 auto; }
.content > .pager { max-width: 760px; margin: 56px auto 0; }
.crumbs { margin-bottom: 8px; font-size: 14px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent-strong); }
.content h1 { margin: 0 0 10px; font-family: var(--display); font-size: clamp(34px, 4.4vw, 48px); font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; }
.vine { display: block; height: auto; color: var(--accent); stroke-width: 1.8; }
.vine-small { width: 170px; margin: 0 0 22px; }
.prose h2 { margin: 44px 0 12px; font-family: var(--display); font-size: 27px; font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; }
.prose h3 { margin: 28px 0 8px; font-size: 18px; font-weight: 650; }
.prose p, .prose ul, .prose ol { margin: 0 0 16px; }
.prose li { margin: 4px 0; }
.prose li::marker { color: var(--accent); }
.prose .anchor { margin-left: 8px; color: var(--muted); text-decoration: none; opacity: 0; font-weight: 400; }
.prose :is(h2, h3):hover .anchor { opacity: 1; }
.prose code { padding: 2px 6px; border-radius: 4px; background: var(--code-bg); font: 0.88em ui-monospace, 'Cascadia Code', Consolas, monospace; }
.prose pre { overflow-x: auto; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--code-bg); }
.prose pre code { padding: 0; background: none; }
.prose blockquote, .draft-note {
  position: relative; margin: 0 0 20px; padding: 14px 18px 14px 50px;
  border: 1px solid color-mix(in srgb, var(--leaf) 40%, transparent); border-radius: var(--radius);
  background: color-mix(in srgb, var(--leaf) 12%, var(--surface));
  color: var(--text);
}
.prose blockquote::before, .draft-note::before {
  content: ''; position: absolute; left: 18px; top: 19px; width: 16px; height: 16px;
  background: var(--leaf);
  -webkit-mask: var(--bud) no-repeat center / contain;
  mask: var(--bud) no-repeat center / contain;
}
.prose blockquote p:last-child { margin: 0; }
.prose table { width: 100%; margin: 0 0 20px; border-collapse: collapse; font-size: 15px; display: block; overflow-x: auto; }
.prose th, .prose td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.prose th { font-size: 14px; font-weight: 600; color: var(--muted); border-bottom-color: var(--accent); }
.prose img { border-radius: var(--radius); }
.gene { display: inline-block; line-height: 1.25; white-space: nowrap; border: 1px solid var(--border); border-radius: 4px; }
.genes { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.al {
  display: inline-block; min-width: 1.5em; padding: 0.12em 0.3em;
  font-size: 0.86em; font-weight: 600; line-height: 1.25; text-align: center; color: var(--muted);
}
.al:first-child { border-radius: 3px 0 0 3px; }
.al:last-child { border-radius: 0 3px 3px 0; }
.al + .al { border-left: 1px solid var(--border); }
.al.dom { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-strong); }
.al.neutral { font-style: italic; font-weight: 500; }
.coat {
  display: inline-block; width: 20px; height: 20px; margin-right: 10px; vertical-align: -5px;
  border: 3px solid var(--points); border-radius: 50%; background: var(--body);
}
.prose figure.punnett { margin: 24px 0; }
.prose .punnett table { display: table; width: auto; margin: 0 0 14px; font-size: 16px; }
.punnett figcaption { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.punnett th, .punnett td { min-width: 76px; padding: 10px 14px; border: 1px solid var(--border); text-align: center; vertical-align: middle; }
.punnett thead th, .punnett tbody th { background: var(--surface); }
.punnett thead td { border: 0; }
.punnett .gene { font-size: 17px; }
.odds { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 0; padding: 0; list-style: none; }
.odds li { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 15px; }
.odds li span { color: var(--muted); }
.draft-note { font-size: 15px; }

.entries { margin-top: 30px; border-top: 1px solid var(--border); }
.entry {
  display: block; padding: 14px 4px 16px;
  border-bottom: 1px solid var(--border);
  color: inherit; text-decoration: none;
}
.entry h3 { margin: 0; font-family: var(--display); font-size: 21px; font-weight: 600; color: var(--text); transition: color 0.15s; }
.entry:hover h3 { color: var(--accent-strong); }
.entry p { margin: 4px 0 0; color: var(--muted); font-size: 15px; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pager a { display: block; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; font-weight: 600; transition: border-color 0.15s; }
.pager a:hover { border-color: var(--accent); }
.pager span { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.pager .next { text-align: right; }

.toc { position: sticky; top: var(--topbar-h); align-self: start; max-height: calc(100vh - var(--topbar-h)); overflow-y: auto; padding: 36px 20px 40px 8px; font-size: 13.5px; }
.toc p { margin: 0 0 8px; font-family: var(--display); font-style: italic; font-size: 15px; color: var(--muted); }
.toc ul { margin: 0; padding: 0; list-style: none; border-left: 1px solid var(--border); }
.toc li a { display: block; padding: 3px 12px; color: var(--muted); text-decoration: none; }
.toc li.l3 a { padding-left: 24px; }
.toc li a:hover, .toc li a.active { color: var(--accent-strong); }

.home { max-width: 1040px; margin: 0 auto; padding: 64px clamp(16px, 3vw, 32px) 90px; }
.hero { display: flex; align-items: center; justify-content: space-between; gap: 40px; }
.hero-text { max-width: 540px; }
.hero h1 { margin: 0 0 14px; font-family: var(--display); font-size: clamp(46px, 8vw, 78px); font-weight: 600; line-height: 1; letter-spacing: -0.03em; }
.lede { margin: 0; color: var(--muted); font-size: 18px; line-height: 1.6; }
.rift-title { position: relative; display: grid; }
.rift-title span { grid-area: 1 / 1; }
.rift-top { clip-path: polygon(0 0, 59% 0, 61% 18%, 58% 36%, 61% 54%, 58% 74%, 60% 100%, 0 100%); }
.rift-bottom { clip-path: polygon(59% 0, 100% 0, 100% 100%, 60% 100%, 58% 74%, 61% 54%, 58% 36%, 61% 18%); transform: translate(10px, 14px); }
.rift-line { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linejoin: round; pointer-events: none; }
.hero-text .pill { display: inline-block; margin-top: 26px; }
.hero-logo { flex: none; width: clamp(130px, 22vw, 220px); height: auto; }
.home .vine { width: 300px; margin: 44px auto 40px; }
.join { margin-top: 44px; padding: 0 30px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.join-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 24px 0 12px; }
.join-head h2 { margin: 0; font-family: var(--display); font-size: 24px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.join-head a { font-size: 14px; }
.join-rows { margin: 0; padding: 0 0 24px; }
.join-rows > div { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: center; gap: 0 16px; padding: 2px 0; }
.join-rows dt { font-size: 14px; font-weight: 600; color: var(--muted); }
.join-rows dd { display: flex; flex-wrap: wrap; align-items: center; gap: 0 22px; margin: 0; }
.join-port { display: inline-flex; align-items: center; gap: 10px; }
.join-label { font-size: 14px; color: var(--muted); }
.copy {
  display: inline-flex; align-items: baseline; gap: 12px;
  padding: 5px 0 7px; border: 0;
  background: transparent; color: var(--text); font: inherit; cursor: pointer;
}
.copy-value { font-family: var(--display); font-size: 24px; font-weight: 600; letter-spacing: -0.01em; transition: color 0.15s; }
.copy:hover .copy-value, .copy:focus-visible .copy-value { color: var(--accent-strong); }
.copy-hint { min-width: 3.4em; font-size: 12.5px; color: var(--muted); text-align: right; opacity: 0; transition: opacity 0.15s; }
.copy:hover .copy-hint, .copy:focus-visible .copy-hint, .copy.copied .copy-hint { opacity: 1; }
.copy.copied .copy-hint { color: var(--leaf); font-weight: 600; }
@media (hover: none) { .copy-hint { opacity: 1; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.home-heading { margin: 0 0 18px; font-family: var(--display); font-size: 28px; font-weight: 600; letter-spacing: -0.01em; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.card {
  display: flex; flex-direction: column; padding: 20px 22px 18px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: inherit; text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.card .emblem { margin-bottom: 14px; color: var(--accent); }
.card:hover { border-color: var(--accent); background: var(--surface-2); }
.card h3 { margin: 0 0 4px; font-family: var(--display); font-size: 21px; font-weight: 600; }
.card p { margin: 0 0 12px; color: var(--muted); font-size: 15px; flex: 1; }
.card-count { font-size: 13px; color: var(--leaf); font-weight: 600; }

.footer { padding: 28px clamp(16px, 3vw, 32px) 36px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; text-align: center; }
.footer p { margin: 0; }

.search-modal { position: fixed; inset: 0; z-index: 100; }
.search-modal[hidden] { display: none; }
.search-backdrop { position: absolute; inset: 0; background: rgba(5, 11, 12, 0.7); }
.search-panel { position: relative; width: min(640px, calc(100vw - 24px)); margin: 10vh auto 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.search-field { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--muted); }
.search-field input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 17px; }
.search-results { list-style: none; margin: 0; padding: 8px; max-height: min(60vh, 460px); overflow-y: auto; }
.search-results:empty { display: none; }
.search-results li a { display: block; padding: 10px 12px; border-radius: var(--radius); color: var(--text); text-decoration: none; }
.search-results li a:hover, .search-results li a.selected { background: var(--surface-2); }
.search-results .r-title { font-family: var(--display); font-size: 17px; font-weight: 600; }
.search-results .r-chapter { margin-left: 8px; font-size: 12px; color: var(--leaf); font-weight: 600; }
.search-results .r-snippet { margin-top: 2px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.search-results mark { background: transparent; color: var(--accent-strong); font-weight: 600; }
.search-empty { padding: 18px 14px; color: var(--muted); text-align: center; }

.nav-scrim { display: none; }

@media (max-width: 1180px) {
  .shell { grid-template-columns: 270px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .navtoggle { display: grid; }
  .booknav {
    position: fixed; z-index: 60; top: var(--topbar-h); left: 0; bottom: 0;
    width: min(320px, 86vw); height: auto;
    background: var(--bg-top); border-right: 1px solid var(--border);
    transform: translateX(-100%); transition: transform 0.2s;
  }
  body.nav-open .booknav { transform: none; }
  body.nav-open .nav-scrim { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 50; background: rgba(5, 11, 12, 0.6); }
  .searchbtn { min-width: 0; padding: 8px 10px; }
  .searchbtn-label, .searchbtn kbd { display: none; }
  .brand span { display: none; }
  .hero { flex-direction: column-reverse; align-items: flex-start; }
  .hero-logo { width: 120px; }
  .join { grid-template-columns: minmax(0, 1fr); }
  .join-rows > div { grid-template-columns: minmax(0, 1fr); padding: 6px 0; }
  .copy-value { font-size: 22px; }
}
@media (max-width: 520px) {
  .pill { padding: 7px 12px; }
  .pager { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
