/* ==========================================================================
   兽医图谱 · VET ATLAS
   A paper-and-ink study atlas for the Chinese veterinary licensing exam.
   ========================================================================== */

:root {
  --paper: #f3efe5;
  --paper-raised: #fbf8f0;
  --paper-deep: #eae3d3;
  --paper-warm: #f7f2e7;
  --ink: #1e2a25;
  --ink-soft: #46534c;
  --muted: #777d74;
  --faint: #9a9d92;
  --line: #d8d0be;
  --line-strong: #bdb29c;
  --green: #2d5b4e;
  --green-deep: #213f36;
  --green-soft: #e3ebe1;
  --ochre: #ad7e2f;
  --ochre-soft: #f0e3c8;
  --coral: #b1543b;
  --basic: #3e6d8a;
  --prevent: #4f7554;
  --clinic: #b3563d;
  --synthesis: #a47a2e;
  --basic-soft: #e4edf2;
  --prevent-soft: #e5ede3;
  --clinic-soft: #f4e2dc;
  --synthesis-soft: #f1e7cf;
  --serif: "Noto Serif SC Variable", "Songti SC", "STSong", "SimSun", serif;
  --sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --rail: 236px;
  --radius: 3px;
  --shadow: 0 1px 0 rgba(30, 42, 37, .04), 0 18px 46px -34px rgba(30, 42, 37, .5);
  --shadow-lift: 0 2px 0 rgba(30, 42, 37, .05), 0 24px 54px -34px rgba(30, 42, 37, .55);
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: .18;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.18'/%3E%3C/svg%3E");
}

::selection { background: var(--ochre-soft); color: var(--ink); }

button,
input,
textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

a { color: inherit; text-decoration: none; }

svg { display: block; }

h1, h2, h3, h4, p { margin: 0; }

ul, ol { margin: 0; padding: 0; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: -80px;
  z-index: 10000;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--paper);
  transition: top .15s;
}
.skip-link:focus { top: 12px; }

/* --------------------------------------------------------------------------
   Shell & navigation
   -------------------------------------------------------------------------- */

.app-shell {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 28px 22px 22px;
  border-right: 1px solid var(--line);
  background: rgba(243, 239, 229, .82);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  width: fit-content;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--ink);
  color: var(--green);
  background: var(--paper-raised);
}
.brand-mark svg { width: 25px; height: 25px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-family: var(--serif); font-size: 18px; font-weight: 700; letter-spacing: .04em; }
.brand-text small { margin-top: 3px; font-family: var(--mono); font-size: 8px; letter-spacing: .22em; color: var(--muted); }

.rail-rule {
  height: 1px;
  margin: 24px 0 18px;
  background: var(--line);
}

.nav { display: flex; flex-direction: column; gap: 3px; }

.nav a {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 9px 10px 9px 9px;
  border-left: 2px solid transparent;
  color: var(--ink-soft);
  font-size: 14px;
  transition: background .15s, color .15s, border-color .15s;
}
.nav a:hover { background: rgba(251, 248, 240, .72); color: var(--ink); }
.nav a.is-active {
  border-left-color: var(--green);
  background: var(--paper-raised);
  color: var(--ink);
  font-weight: 600;
}
.nav a.is-active .nav-num { color: var(--green); }
.nav-num {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .06em;
  color: var(--faint);
}

.rail-animals { margin-top: 30px; }
.rail-label {
  margin-bottom: 10px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
}
.rail-animal-links { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 4px; }
.rail-animal-links a {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 7px;
  color: var(--muted);
  font-size: 12.5px;
  border-radius: 2px;
  transition: background .15s, color .15s;
}
.rail-animal-links a:hover { background: var(--paper-raised); color: var(--ink); }
.rail-animal-links a.is-active { color: var(--ink); font-weight: 600; }
.rail-animal-links .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--animal, var(--green)); }

.rail-foot {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.save-state {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 10.5px;
}
.save-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--prevent); box-shadow: 0 0 0 3px rgba(79, 117, 84, .12); }
.text-button {
  width: fit-content;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  background: none;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.8;
}
.text-button:hover { color: var(--green); border-color: var(--green); }

.page-shell { min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 72px;
  padding: 0 40px;
  border-bottom: 1px solid var(--line);
  background: rgba(243, 239, 229, .9);
  backdrop-filter: blur(10px);
}
.topbar-left { display: flex; align-items: center; gap: 24px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 16px; }

.mobile-brand { display: none; align-items: center; gap: 8px; }
.mobile-brand .brand-mark { width: 28px; height: 28px; }
.mobile-brand .brand-mark svg { width: 21px; height: 21px; }
.mobile-brand strong { font-family: var(--serif); font-size: 16px; letter-spacing: .03em; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.breadcrumb a:hover { color: var(--green); text-decoration: underline; text-underline-offset: 3px; }
.breadcrumb .sep { color: var(--line-strong); }
.breadcrumb .current { color: var(--ink); overflow: hidden; text-overflow: ellipsis; }

.search-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 310px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(251, 248, 240, .7);
  color: var(--muted);
  text-align: left;
  font-size: 12px;
  transition: border-color .15s, background .15s;
}
.search-trigger:hover { border-color: var(--line-strong); background: var(--paper-raised); }
.search-trigger svg { width: 16px; height: 16px; flex: none; }
.search-trigger span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-trigger kbd {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 2px;
  background: var(--paper);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8.5px;
}

.topbar-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}
.topbar-progress .mini-ring {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: conic-gradient(var(--green) var(--pct, 0%), var(--line) 0);
  position: relative;
}
.topbar-progress .mini-ring::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--paper);
}

#view {
  min-height: calc(100vh - 72px);
  padding: 0 40px;
}
.view-wrap {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 42px 0 88px;
}
.view-wrap.narrow { max-width: 1080px; }

@keyframes view-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.site-foot {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 40px 26px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 10.5px;
}
.site-foot p { max-width: 560px; }
.foot-notes { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.foot-notes .text-button { color: var(--faint); }

/* --------------------------------------------------------------------------
   Shared typography & buttons
   -------------------------------------------------------------------------- */

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 9.5px;
  line-height: 1.6;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--green);
  flex: none;
}
.eyebrow.ochre::before { background: var(--ochre); }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 24px;
}
.section-head h2 {
  margin-top: 7px;
  font-family: var(--serif);
  font-size: clamp(27px, 3.2vw, 40px);
  font-weight: 600;
  line-height: 1.32;
  letter-spacing: -.015em;
}
.section-head p { max-width: 480px; color: var(--muted); font-size: 13px; line-height: 1.8; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 21px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  transition: transform .16s, background .16s, box-shadow .16s;
}
.btn:hover { background: var(--green); border-color: var(--green); transform: translateY(-1px); box-shadow: 3px 3px 0 rgba(45, 91, 78, .14); }
.btn .arrow { font-family: var(--mono); font-size: 15px; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--paper-raised); border-color: var(--ink); box-shadow: none; }
.btn.small { min-height: 36px; padding: 7px 14px; font-size: 12px; }
.btn.accent { background: var(--ochre); border-color: var(--ochre); color: #fffdf6; }
.btn.accent:hover { background: #987022; border-color: #987022; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.wide { width: 100%; }

.icon-button {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--paper-raised);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}
.icon-button:hover { border-color: var(--ink); color: var(--ink); }

.hot-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 3px rgba(177, 84, 59, .12);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--paper);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
  white-space: nowrap;
}
.badge.hot { border-color: rgba(177, 84, 59, .35); background: var(--clinic-soft); color: #8e402d; }
.badge.green { border-color: rgba(79, 117, 84, .3); background: var(--prevent-soft); color: #3c5e41; }
.badge.mastered { border-color: rgba(79, 117, 84, .3); background: var(--green-soft); color: var(--green); }

/* --------------------------------------------------------------------------
   Home — hero
   -------------------------------------------------------------------------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, .92fr);
  gap: clamp(36px, 6vw, 92px);
  align-items: center;
  padding: 46px 0 72px;
}

.hero-copy { position: relative; }

.hero h1 {
  margin: 20px 0 24px;
  font-family: var(--serif);
  font-size: clamp(44px, 4.15vw, 60px);
  font-weight: 560;
  line-height: 1.2;
  letter-spacing: -.03em;
}
.hero h1 .line { display: block; }
.hero h1 .accent {
  position: relative;
  color: var(--green);
  white-space: nowrap;
}
.hero h1 .accent::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: .04em;
  height: .2em;
  z-index: -1;
  background: rgba(173, 126, 47, .23);
  transform: skewX(-6deg);
}
.hero-lead {
  max-width: 540px;
  color: var(--ink-soft);
  font-size: 15.5px;
  line-height: 1.95;
}
.hero-lead strong { color: var(--ink); font-weight: 600; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 30px 0 26px; }
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .04em;
}
.hero-meta span { display: inline-flex; align-items: center; gap: 7px; }
.hero-meta span::before { content: ""; width: 3px; height: 3px; border-radius: 50%; background: var(--line-strong); }
.hero-meta span:first-child::before { background: var(--green); }

.hero-specimen {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1 / 1.04;
  justify-self: end;
  padding: 19px 20px;
  border: 1px solid var(--line-strong);
  background: var(--paper-raised);
  box-shadow: 9px 9px 0 rgba(45, 91, 78, .065);
  transform: rotate(.45deg);
}
.hero-specimen::before,
.hero-specimen::after {
  content: "";
  position: absolute;
  width: 13px;
  height: 13px;
  border-color: var(--line-strong);
  border-style: solid;
}
.hero-specimen::before { top: 8px; left: 8px; border-width: 1px 0 0 1px; }
.hero-specimen::after { right: 8px; bottom: 8px; border-width: 0 1px 1px 0; }

.specimen-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: .12em;
  color: var(--muted);
}
.specimen-head .stamp {
  padding: 2px 6px;
  border: 1px solid rgba(177, 84, 59, .55);
  color: var(--coral);
  transform: rotate(-2deg);
  letter-spacing: .1em;
}

.specimen-lines { position: absolute; inset: 44px 18px 42px; width: calc(100% - 36px); height: calc(100% - 86px); pointer-events: none; }
.specimen-lines path { fill: none; stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }

.specimen-center {
  position: absolute;
  left: 3.5%;
  top: 40%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 25.5%;
  aspect-ratio: 1;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: inset 0 0 0 4px var(--paper-raised), inset 0 0 0 5px var(--line);
}
.specimen-center .mini-seal {
  font-family: var(--serif);
  font-size: clamp(22px, 3.6vw, 34px);
  font-weight: 700;
  line-height: 1.2;
  color: var(--coral);
  letter-spacing: .02em;
}
.specimen-center small {
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: .15em;
  color: var(--muted);
}
.specimen-center .center-rule { width: 18px; height: 1px; margin: 5px 0; background: var(--line-strong); }

.specimen-chain {
  position: absolute;
  right: 4.5%;
  top: 20%;
  bottom: 13%;
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  gap: 8px;
  width: 54%;
  z-index: 2;
}
.specimen-step {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 7px 10px 7px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--subject);
  background: rgba(243, 239, 229, .88);
}
.specimen-step .s-label {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .1em;
  color: var(--subject);
}
.specimen-step p {
  margin-top: 1px;
  font-size: clamp(10px, 1.15vw, 12px);
  line-height: 1.5;
  color: var(--ink-soft);
}
.specimen-step.basic { --subject: var(--basic); }
.specimen-step.prevent { --subject: var(--prevent); }
.specimen-step.clinic { --subject: var(--clinic); }
.specimen-step.synthesis { --subject: var(--synthesis); }

.specimen-foot {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 9.5px;
}
.specimen-foot a { color: var(--green); border-bottom: 1px solid rgba(45, 91, 78, .3); }
.specimen-foot a:hover { border-color: var(--green); }

/* --------------------------------------------------------------------------
   Home — weights & animal cards
   -------------------------------------------------------------------------- */

.weight-panel {
  margin: 0 0 62px;
  padding: 20px 22px 18px;
  border: 1px solid var(--line);
  background: rgba(251, 248, 240, .58);
}
.weight-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 11px;
}
.weight-top strong { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.weight-top span { font-family: var(--mono); font-size: 9.5px; color: var(--muted); letter-spacing: .04em; }
.weight-bar {
  display: flex;
  height: 37px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  overflow: hidden;
}
.weight-seg {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  border-right: 1px solid rgba(251, 248, 240, .5);
  background: var(--animal);
  color: #fffdf7;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .02em;
  transition: filter .15s;
}
.weight-seg:hover { filter: brightness(1.08); }
.weight-seg span { white-space: nowrap; overflow: hidden; padding: 0 5px; }
.weight-seg.rest {
  flex: 5;
  background: repeating-linear-gradient(135deg, var(--paper-deep) 0 6px, var(--paper) 6px 12px);
  color: var(--muted);
  border-right: 0;
}
.weight-note {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 10.5px;
}
.weight-note .official { font-family: var(--mono); font-size: 9px; letter-spacing: .02em; }

.animal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 17px;
}

.animal-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 320px;
  padding: 20px 21px 17px;
  border: 1px solid var(--line);
  background: var(--paper-raised);
  overflow: hidden;
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.animal-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--animal);
}
.animal-card:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-lift);
}
.animal-card .watermark {
  position: absolute;
  right: -10px;
  top: 45px;
  width: 150px;
  height: 150px;
  color: var(--animal);
  opacity: .075;
  pointer-events: none;
  transform: rotate(-5deg);
}

.animal-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.animal-index {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .1em;
  color: var(--faint);
}
.animal-weight { text-align: right; line-height: 1; }
.animal-weight strong {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  color: var(--animal);
}
.animal-weight small {
  display: block;
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .08em;
  color: var(--muted);
}
.animal-icon {
  width: 46px;
  height: 46px;
  margin: 19px 0 10px;
  color: var(--animal);
}
.animal-icon svg { width: 100%; height: 100%; }
.animal-card h3 {
  font-family: var(--serif);
  font-size: 38px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -.02em;
}
.animal-card .latin {
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: .08em;
  color: var(--faint);
  text-transform: uppercase;
}
.animal-card .tagline {
  margin-top: 12px;
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.7;
  max-width: 310px;
}
.animal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 12px;
}
.animal-tags span {
  padding: 2px 6px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.5;
}
.animal-card-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8.5px;
}
.animal-card-foot .bar { flex: 1; height: 3px; background: var(--paper-deep); overflow: hidden; }
.animal-card-foot .bar i { display: block; height: 100%; background: var(--animal); transition: width .4s; }
.animal-card-foot .go { color: var(--animal); font-size: 14px; transition: transform .15s; }
.animal-card:hover .go { transform: translateX(3px); }

/* --------------------------------------------------------------------------
   Home — chain banner & path
   -------------------------------------------------------------------------- */

.chain-banner {
  position: relative;
  margin: 76px 0 0;
  padding: 38px 40px 34px;
  background: var(--green-deep);
  color: #f6f1e5;
  overflow: hidden;
}
.chain-banner::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(90deg, rgba(246, 241, 229, .05) 0 1px, transparent 1px 92px);
  opacity: .5;
}
.chain-banner .eyebrow { color: rgba(246, 241, 229, .6); }
.chain-banner .eyebrow::before { background: var(--ochre); }
.chain-banner-head {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  margin: 12px 0 30px;
}
.chain-banner h2 {
  font-family: var(--serif);
  font-size: clamp(28px, 3.5vw, 44px);
  font-weight: 560;
  line-height: 1.3;
  letter-spacing: -.02em;
}
.chain-banner-head p { max-width: 330px; color: rgba(246, 241, 229, .62); font-size: 12px; line-height: 1.8; }
.chain-flow {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid rgba(246, 241, 229, .18);
  border-bottom: 1px solid rgba(246, 241, 229, .18);
}
.chain-flow-step {
  position: relative;
  padding: 21px 22px 20px 0;
}
.chain-flow-step + .chain-flow-step { padding-left: 22px; border-left: 1px solid rgba(246, 241, 229, .16); }
.chain-flow-step .num {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: .12em;
  color: var(--subject);
}
.chain-flow-step h3 {
  margin: 7px 0 5px;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  color: #f6f1e5;
}
.chain-flow-step p { color: rgba(246, 241, 229, .62); font-size: 11.5px; line-height: 1.7; }
.chain-flow-step.basic { --subject: #93bdd3; }
.chain-flow-step.prevent { --subject: #a5c5a2; }
.chain-flow-step.clinic { --subject: #df9d89; }
.chain-flow-step.synthesis { --subject: #d8b971; }
.chain-flow-step .arrow {
  position: absolute;
  right: -8px;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  background: var(--green-deep);
  color: rgba(246, 241, 229, .55);
  font-family: var(--mono);
  font-size: 10px;
}
.chain-banner-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 22px;
}
.chain-banner-foot p { color: rgba(246, 241, 229, .52); font-size: 10.5px; }
.chain-banner .btn.ghost { color: #f6f1e5; border-color: rgba(246, 241, 229, .35); }
.chain-banner .btn.ghost:hover { background: rgba(246, 241, 229, .09); border-color: #f6f1e5; }

.home-path {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin-top: 64px;
  border-top: 1px solid var(--line);
}
.path-step {
  padding: 24px 28px 0 0;
}
.path-step + .path-step { padding-left: 28px; border-left: 1px solid var(--line); }
.path-step .num {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .12em;
  color: var(--ochre);
}
.path-step h3 { margin: 9px 0 7px; font-family: var(--serif); font-size: 20px; font-weight: 600; }
.path-step p { color: var(--muted); font-size: 12px; line-height: 1.8; max-width: 300px; }

/* --------------------------------------------------------------------------
   Atlas page
   -------------------------------------------------------------------------- */

.animal-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  padding: 4px 0 24px;
  border-bottom: 1px solid var(--line);
}
.animal-seal {
  display: grid;
  place-items: center;
  width: 86px;
  height: 86px;
  border: 1px solid var(--animal);
  background: var(--paper-raised);
  color: var(--animal);
  font-family: var(--serif);
  font-size: 47px;
  font-weight: 600;
  line-height: 1;
  box-shadow: inset 0 0 0 4px var(--paper-raised), inset 0 0 0 5px var(--line);
  transform: rotate(-1.5deg);
}
.animal-head-copy h1 {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-family: var(--serif);
  font-size: clamp(34px, 4vw, 48px);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.02em;
}
.animal-head-copy h1 small {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .06em;
  color: var(--muted);
}
.animal-head-copy p {
  max-width: 720px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.8;
}
.animal-head-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.animal-score {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-family: var(--serif);
  color: var(--animal);
}
.animal-score strong { font-size: 42px; font-weight: 600; line-height: 1; }
.animal-score span { font-family: var(--mono); font-size: 9px; color: var(--muted); }
.animal-head-actions .micro {
  font-family: var(--mono);
  font-size: 8.5px;
  color: var(--faint);
  letter-spacing: .04em;
  text-align: right;
}

.focus-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  padding: 13px 0 0;
}
.focus-row .label {
  margin-right: 4px;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: .1em;
  color: var(--faint);
  text-transform: uppercase;
}
.focus-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  background: rgba(251, 248, 240, .55);
  color: var(--ink-soft);
  font-size: 10.5px;
}
.focus-chip::before { content: ""; width: 4px; height: 4px; background: var(--animal); }

.atlas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 18px 0 12px;
}
.toolbar-group { display: flex; align-items: center; gap: 8px; }
.toolbar-hint { color: var(--muted); font-size: 10.5px; }
.toolbar-hint kbd {
  padding: 1px 4px;
  border: 1px solid var(--line);
  background: var(--paper-raised);
  font-family: var(--mono);
  font-size: 8px;
}

.atlas-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  align-items: start;
}

.atlas-map {
  position: relative;
  border: 1px solid var(--line);
  background: var(--paper-raised);
  min-width: 0;
}
.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(243, 239, 229, .76);
}
.map-legend {
  display: flex;
  align-items: center;
  gap: 13px;
  color: var(--muted);
  font-size: 9.5px;
}
.map-legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-mark { width: 6px; height: 6px; border-radius: 50%; background: var(--coral); }
.legend-mark.open { background: transparent; border: 1px solid var(--line-strong); }
.legend-subject { width: 6px; height: 6px; border-radius: 1px; background: var(--prevent); }
.legend-subject.basic { background: var(--basic); }
.legend-subject.clinic { background: var(--clinic); }
.legend-subject.synthesis { background: var(--synthesis); }
.map-tools { display: flex; align-items: center; gap: 4px; }
.map-tools .icon-button { min-width: 27px; height: 27px; font-size: 12px; }
.zoom-value {
  min-width: 38px;
  text-align: center;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted);
}

.map-viewport {
  position: relative;
  height: calc(100vh - 252px);
  min-height: 540px;
  overflow: auto;
  background-color: #f7f3e9;
  background-image: radial-gradient(rgba(45, 91, 78, .12) .7px, transparent .7px);
  background-size: 20px 20px;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}
.map-stage { position: relative; margin: 0 auto; }
.map-canvas {
  position: relative;
  transform-origin: top left;
  will-change: transform;
}
.map-svg { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.map-svg path {
  fill: none;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  transition: opacity .18s;
}
.map-svg path.root-line { stroke: var(--line-strong); stroke-width: 1.4; }
.map-svg path.leaf-line { stroke-width: 1.3; opacity: .65; }
.map-svg path.is-muted { opacity: .18; }

.map-root {
  position: absolute;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 166px;
  height: 108px;
  border: 1px solid var(--ink);
  background: var(--paper);
  box-shadow: 5px 5px 0 var(--tint);
  text-align: center;
}
.map-root .root-kicker {
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: .12em;
  color: var(--muted);
}
.map-root .root-name {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 38px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--animal);
}
.map-root .root-meta {
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: .02em;
  color: var(--muted);
}
.map-root .root-rule { width: 22px; height: 1px; margin: 5px 0 4px; background: var(--line-strong); }

.map-branch {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 158px;
  min-height: 46px;
  padding: 6px 9px 6px 10px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--animal);
  background: rgba(251, 248, 240, .97);
  text-align: left;
  transition: border-color .15s, background .15s;
}
.map-branch:hover { border-color: var(--animal); background: #fffdf7; }
.map-branch .branch-body { flex: 1; min-width: 0; }
.map-branch .branch-name {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-branch .branch-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
  font-family: var(--mono);
  font-size: 7.5px;
  color: var(--muted);
}
.map-branch .lens-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--subject); }
.map-branch .branch-toggle {
  flex: none;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  transition: transform .18s;
}
.map-branch.is-collapsed .branch-toggle { transform: rotate(-90deg); }
.map-branch.is-selected { border-color: var(--ink); }

.map-leaf {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 9px;
  width: 200px;
  min-height: 48px;
  padding: 7px 9px 7px 10px;
  border: 1px solid var(--line);
  background: rgba(251, 248, 240, .97);
  text-align: left;
  transition: border-color .14s, transform .14s, box-shadow .14s, background .14s;
}
.map-leaf:hover {
  border-color: var(--animal);
  background: #fffdf7;
  transform: translateX(2px);
  box-shadow: 3px 3px 0 rgba(30, 42, 37, .05);
}
.map-leaf .leaf-marker {
  flex: none;
  width: 7px;
  height: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}
.map-leaf.is-high .leaf-marker { border-color: var(--coral); background: var(--coral); box-shadow: 0 0 0 3px rgba(177, 84, 59, .09); }
.map-leaf .leaf-copy { flex: 1; min-width: 0; }
.map-leaf .leaf-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-leaf .leaf-alias {
  display: block;
  margin-top: 1px;
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: .01em;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-leaf .leaf-state {
  flex: none;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  color: var(--green);
  font-size: 12px;
}
.map-leaf.is-selected {
  border-color: var(--animal);
  background: #fffdf7;
  box-shadow: inset 0 0 0 1px var(--animal);
}
.map-leaf.is-selected .leaf-name { color: var(--animal); }
.map-leaf.is-muted { opacity: .27; }
.map-leaf .leaf-hot {
  position: absolute;
  top: -4px;
  right: 10px;
  padding: 0 4px;
  background: var(--paper-raised);
  color: var(--coral);
  font-family: var(--mono);
  font-size: 6.5px;
  letter-spacing: .05em;
  border: 1px solid rgba(177, 84, 59, .24);
}

.map-empty {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 500px;
  padding: 40px;
  text-align: center;
  color: var(--muted);
}

/* Touch tree: the map gets a readable, vertical fallback on narrow screens. */
.mobile-tree { display: none; padding: 12px; }
.mobile-tree-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 10px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: .03em;
}
.mt-branch {
  border: 1px solid var(--line);
  background: var(--paper-raised);
  margin-bottom: 7px;
}
.mt-branch:last-child { margin-bottom: 0; }
.mt-branch-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-left: 3px solid var(--animal, var(--green));
  background: transparent;
  text-align: left;
}
.mt-lens {
  flex: none;
  padding: 1px 4px;
  border: 1px solid var(--subject);
  color: var(--subject);
  font-family: var(--mono);
  font-size: 7px;
}
.mt-name { flex: 1; font-size: 12px; font-weight: 600; }
.mt-count { color: var(--faint); font-family: var(--mono); font-size: 8px; }
.mt-toggle { color: var(--faint); font-size: 11px; transition: transform .15s; }
.mt-branch.is-collapsed .mt-toggle { transform: rotate(-90deg); }
.mt-leaves { border-top: 1px solid var(--line); }
.mt-leaves[hidden] { display: none; }
.mt-leaf {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 9px 10px 9px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
}
.mt-leaf:last-child { border-bottom: 0; }
.mt-leaf:hover { background: var(--paper-warm); }
.mt-leaf-dot { flex: none; width: 6px; height: 6px; border: 1px solid var(--line-strong); border-radius: 50%; }
.mt-leaf-dot.is-high { border-color: var(--coral); background: var(--coral); }
.mt-leaf-name { flex: none; max-width: 54%; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-leaf-alias { flex: 1; min-width: 0; color: var(--faint); font-family: var(--mono); font-size: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-leaf-hot { flex: none; padding: 0 3px; border: 1px solid rgba(177, 84, 59, .3); color: var(--coral); font-family: var(--mono); font-size: 6.5px; }
.mt-leaf-check { flex: none; color: var(--prevent); font-size: 10px; }
.mt-leaf.is-selected { background: var(--paper-warm); box-shadow: inset 2px 0 0 var(--animal); }
.mt-leaf.is-selected .mt-leaf-name { color: var(--animal); }

/* --------------------------------------------------------------------------
   Inspector / detail drawer
   -------------------------------------------------------------------------- */

.inspector {
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 116px);
  overflow-y: auto;
  border: 1px solid var(--line);
  background: var(--paper-raised);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.inspector.is-empty { background: rgba(251, 248, 240, .55); }

.inspector-inner { padding: 20px 20px 22px; }

.inspector-head { padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.inspector-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.inspector-kicker .close-detail { margin: -5px -6px -5px 0; }
.inspector h2 {
  margin: 8px 0 2px;
  font-family: var(--serif);
  font-size: 31px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -.02em;
}
.inspector-alias {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .02em;
  color: var(--faint);
}
.inspector-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }

.hook {
  position: relative;
  margin: 14px 0;
  padding: 10px 12px 10px 14px;
  border-left: 2px solid var(--ochre);
  background: var(--paper-warm);
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.75;
}
.hook::before {
  content: "“";
  position: absolute;
  left: 2px;
  top: -8px;
  font-family: var(--serif);
  font-size: 26px;
  color: var(--ochre);
  opacity: .5;
}

.chain-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 15px 0 11px;
}
.chain-label h3 {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
}
.chain-label span { font-family: var(--mono); font-size: 7.5px; color: var(--faint); letter-spacing: .04em; }

.subject-chain { position: relative; }
.chain-step {
  position: relative;
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr);
  gap: 9px;
  padding-bottom: 12px;
}
.chain-step:last-child { padding-bottom: 0; }
.chain-step::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 28px;
  bottom: -1px;
  width: 1px;
  background: var(--line);
}
.chain-step:last-child::before { display: none; }
.chain-num {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border: 1px solid var(--subject);
  border-radius: 50%;
  background: var(--paper-raised);
  color: var(--subject);
  font-family: var(--mono);
  font-size: 7.5px;
}
.chain-content {
  padding: 2px 0 0;
}
.chain-content h4 {
  display: flex;
  align-items: baseline;
  gap: 6px;
  color: var(--subject);
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1.5;
}
.chain-content h4 small {
  font-family: var(--mono);
  font-size: 7px;
  font-weight: 400;
  letter-spacing: .04em;
  color: var(--faint);
}
.chain-content p {
  margin-top: 1px;
  color: var(--ink-soft);
  font-size: 11.5px;
  line-height: 1.78;
}
.chain-step.basic { --subject: var(--basic); }
.chain-step.prevent { --subject: var(--prevent); }
.chain-step.clinic { --subject: var(--clinic); }
.chain-step.synthesis { --subject: var(--synthesis); }

.note-pair { margin-top: 14px; display: grid; gap: 9px; }
.note-pair .note-item {
  padding: 9px 11px;
  border: 1px dashed var(--line-strong);
  background: rgba(243, 239, 229, .5);
}
.note-pair .note-item h4 {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 2px;
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: .08em;
  color: var(--faint);
  text-transform: uppercase;
}
.note-pair .note-item.pitfall h4 { color: var(--coral); }
.note-pair .note-item p { color: var(--ink-soft); font-size: 11px; line-height: 1.7; }

.my-note { margin-top: 14px; }
.my-note label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.my-note textarea {
  width: 100%;
  min-height: 62px;
  resize: vertical;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 1px;
  background: var(--paper);
  font-size: 11px;
  line-height: 1.65;
}
.my-note textarea::placeholder { color: var(--faint); }
.my-note textarea:focus { background: #fffdf7; border-color: var(--green); }

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 14px;
}
.detail-actions .btn { min-height: 37px; padding: 7px 10px; font-size: 10.5px; }
.detail-actions .btn.is-done { background: var(--green-soft); border-color: rgba(79, 117, 84, .4); color: var(--green); }
.detail-actions .btn.is-queued { background: var(--synthesis-soft); border-color: rgba(164, 122, 46, .35); color: #7f5b1c; }
.detail-pager {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 13px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.detail-pager button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 10px;
}
.detail-pager button:hover { color: var(--green); }
.detail-pager button:disabled { opacity: .35; cursor: default; }

.inspector-empty { padding: 24px 22px; }
.inspector-empty h2 {
  margin: 10px 0 7px;
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 600;
  line-height: 1.38;
}
.inspector-empty > p { color: var(--muted); font-size: 11.5px; line-height: 1.8; }
.read-steps { display: grid; gap: 10px; margin: 18px 0; }
.read-step {
  display: grid;
  grid-template-columns: 19px 1fr;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.7;
}
.read-step .n {
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7px;
}
.subject-legend { display: grid; gap: 6px; padding: 13px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.subject-legend-row { display: flex; align-items: center; gap: 7px; font-size: 10px; color: var(--muted); }
.subject-legend-row i { width: 16px; height: 2px; background: var(--subject); }
.subject-legend-row b { color: var(--subject); font-weight: 600; }
.subject-legend-row.basic { --subject: var(--basic); }
.subject-legend-row.prevent { --subject: var(--prevent); }
.subject-legend-row.clinic { --subject: var(--clinic); }
.subject-legend-row.synthesis { --subject: var(--synthesis); }
.empty-tip {
  margin-top: 15px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  background: var(--paper-warm);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.7;
}
.empty-tip strong { color: var(--ink); }

.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(30, 42, 37, .34);
  backdrop-filter: blur(2px);
}

/* --------------------------------------------------------------------------
   Chain page
   -------------------------------------------------------------------------- */

.page-head { padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.page-head h1 {
  margin: 11px 0 10px;
  font-family: var(--serif);
  font-size: clamp(38px, 5vw, 64px);
  font-weight: 560;
  line-height: 1.18;
  letter-spacing: -.03em;
}
.page-head h1 em { font-style: normal; color: var(--green); }
.page-head .lead { max-width: 760px; color: var(--ink-soft); font-size: 14px; line-height: 1.9; }

.formula {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin: 30px 0 36px;
  border: 1px solid var(--line);
  background: var(--paper-raised);
}
.formula-step {
  position: relative;
  padding: 18px 19px 17px;
  border-right: 1px solid var(--line);
}
.formula-step:last-child { border-right: 0; }
.formula-step .n {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .1em;
  color: var(--subject);
}
.formula-step h3 {
  margin: 5px 0 3px;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
}
.formula-step p { color: var(--muted); font-size: 10.5px; line-height: 1.7; }
.formula-step.basic { --subject: var(--basic); }
.formula-step.prevent { --subject: var(--prevent); }
.formula-step.clinic { --subject: var(--clinic); }
.formula-step.synthesis { --subject: var(--synthesis); }
.formula-step::after {
  content: "→";
  position: absolute;
  right: -7px;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  background: var(--paper-raised);
  color: var(--line-strong);
  font-family: var(--mono);
  font-size: 9px;
}
.formula-step:last-child::after { display: none; }

.workup-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 14px;
}
.workup-head h2 { font-family: var(--serif); font-size: 27px; font-weight: 600; }
.workup-head p { color: var(--muted); font-size: 11px; }

.animal-tabs { display: flex; flex-wrap: wrap; gap: 5px; }
.animal-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  transition: background .15s, border-color .15s, color .15s;
}
.animal-tab .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--animal); }
.animal-tab:hover { background: var(--paper-raised); color: var(--ink); }
.animal-tab.is-active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.animal-tab.is-active .dot { background: var(--paper); }

.workup-card {
  position: relative;
  border: 1px solid var(--line-strong);
  background: var(--paper-raised);
  padding: 24px 25px 21px;
  box-shadow: 6px 6px 0 rgba(45, 91, 78, .045);
}
.workup-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}
.workup-top .case-kicker {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .12em;
  color: var(--faint);
}
.workup-top h3 {
  margin-top: 4px;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.4;
}
.case-animal {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
  padding: 6px 9px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}
.case-animal .seal-small {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--animal);
  color: var(--animal);
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
}
.case-quote {
  position: relative;
  margin-bottom: 18px;
  padding: 13px 16px 13px 18px;
  border-left: 2px solid var(--animal);
  background: var(--paper-warm);
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.8;
}
.case-quote b { color: var(--ink); font-weight: 600; }

.workup-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.workup-step { position: relative; padding: 15px 16px 16px 0; }
.workup-step + .workup-step { padding-left: 16px; border-left: 1px solid var(--line); }
.workup-step .step-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: .05em;
  color: var(--subject);
}
.workup-step h4 {
  margin: 4px 0 4px;
  color: var(--subject);
  font-size: 11.5px;
  font-weight: 650;
}
.workup-step p { color: var(--ink-soft); font-size: 10.5px; line-height: 1.75; }
.workup-step.basic { --subject: var(--basic); }
.workup-step.prevent { --subject: var(--prevent); }
.workup-step.clinic { --subject: var(--clinic); }
.workup-step.synthesis { --subject: var(--synthesis); }
.workup-takeaway {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin-top: 15px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.75;
}
.workup-takeaway strong {
  flex: none;
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: .1em;
  color: var(--ochre);
}

.chain-index { margin-top: 54px; }
.chain-index-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 12px;
}
.chain-index-head h2 { font-family: var(--serif); font-size: 28px; font-weight: 600; }
.chain-index-head p { color: var(--muted); font-size: 11px; }
.index-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.index-search {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 210px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  background: var(--paper-raised);
}
.index-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 10.5px; }
.index-search svg { width: 13px; height: 13px; color: var(--faint); }
.index-count { font-family: var(--mono); font-size: 8.5px; color: var(--faint); }

.chain-table { border: 1px solid var(--line); background: var(--paper-raised); }
.chain-row {
  display: grid;
  grid-template-columns: 158px repeat(4, minmax(0, 1fr));
  gap: 0;
  width: 100%;
  border-bottom: 1px solid var(--line);
  transition: background .13s;
}
.chain-row:last-child { border-bottom: 0; }
.chain-row:hover { background: var(--paper-warm); }
.chain-row.table-head {
  background: var(--paper-deep);
  border-bottom-color: var(--line-strong);
  position: sticky;
  top: 72px;
  z-index: 2;
}
.chain-row.table-head span {
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: .06em;
  color: var(--subject, var(--muted));
  border-right: 1px solid var(--line);
}
.chain-row.table-head span:last-child { border-right: 0; }
.chain-row.table-head .head-disease { color: var(--muted); }
.chain-cell {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-width: 0;
  padding: 10px 11px;
  border-right: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 9.5px;
  line-height: 1.65;
}
.chain-cell:last-child { border-right: 0; }
.chain-cell.disease { background: rgba(243, 239, 229, .36); }
.chain-cell .d-name { color: var(--ink); font-size: 11.5px; font-weight: 650; line-height: 1.4; }
.chain-cell .d-meta { margin-top: 2px; color: var(--faint); font-family: var(--mono); font-size: 7px; }
.chain-cell.basic { box-shadow: inset 2px 0 0 rgba(62, 109, 138, .14); }
.chain-cell.prevent { box-shadow: inset 2px 0 0 rgba(79, 117, 84, .14); }
.chain-cell.clinic { box-shadow: inset 2px 0 0 rgba(179, 86, 61, .14); }
.chain-cell.synthesis { box-shadow: inset 2px 0 0 rgba(164, 122, 46, .14); }
.chain-cell .locked { color: var(--faint); }

.load-more { display: flex; justify-content: center; margin-top: 16px; }

/* --------------------------------------------------------------------------
   Quiz
   -------------------------------------------------------------------------- */

.quiz-shell { max-width: 920px; margin: 0 auto; }
.quiz-intro {
  display: grid;
  grid-template-columns: 1.08fr .92fr;
  border: 1px solid var(--line-strong);
  background: var(--paper-raised);
  box-shadow: 7px 7px 0 rgba(45, 91, 78, .045);
}
.quiz-intro-main { padding: 36px 38px 32px; }
.quiz-intro-main .big-num {
  margin: 14px 0 4px;
  font-family: var(--serif);
  font-size: 82px;
  font-weight: 560;
  line-height: .95;
  letter-spacing: -.05em;
  color: var(--green);
}
.quiz-intro-main .big-num small { font-size: 17px; letter-spacing: 0; color: var(--muted); font-family: var(--mono); }
.quiz-intro-main h1 {
  font-family: var(--serif);
  font-size: 38px;
  font-weight: 600;
  line-height: 1.3;
}
.quiz-intro-main > p { max-width: 480px; margin-top: 11px; color: var(--muted); font-size: 12.5px; line-height: 1.85; }
.quiz-intro-side {
  padding: 30px 30px;
  border-left: 1px solid var(--line);
  background: var(--paper-warm);
}
.quiz-intro-side h3 {
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 400;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--faint);
}
.quiz-facts { display: grid; gap: 11px; margin: 16px 0 24px; }
.quiz-fact { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.quiz-fact span { color: var(--muted); font-size: 10.5px; }
.quiz-fact b { font-family: var(--serif); font-size: 19px; font-weight: 600; color: var(--ink); }
.quiz-fact b small { font-family: var(--mono); font-size: 8px; color: var(--faint); font-weight: 400; }
.quiz-start-actions { display: grid; gap: 7px; }

.quiz-coverage {
  margin-top: 15px;
  padding: 17px 19px 16px;
  border: 1px solid var(--line);
  background: rgba(251, 248, 240, .55);
}
.quiz-coverage-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 12px;
}
.quiz-coverage-head h3 {
  margin-top: 4px;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
}
.quiz-coverage-head > p { max-width: 300px; color: var(--muted); font-size: 10px; line-height: 1.6; text-align: right; }
.coverage-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: var(--paper-raised);
}
.coverage-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-right: 1px solid var(--line);
  transition: background .13s;
}
.coverage-cell:last-child { border-right: 0; }
.coverage-cell:hover { background: var(--paper-warm); }
.coverage-seal {
  flex: none;
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border: 1px solid var(--animal);
  color: var(--animal);
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
}
.coverage-copy { min-width: 0; }
.coverage-copy strong { display: block; font-family: var(--serif); font-size: 14px; font-weight: 600; line-height: 1.2; }
.coverage-copy small { display: block; margin-top: 1px; color: var(--faint); font-family: var(--mono); font-size: 6.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.coverage-note { margin-top: 9px; color: var(--muted); font-size: 9.5px; line-height: 1.65; }

.quiz-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}.quiz-progress .q-count { flex: none; font-family: var(--mono); font-size: 8.5px; color: var(--muted); }
.quiz-progress .bar { flex: 1; height: 3px; background: var(--paper-deep); overflow: hidden; }
.quiz-progress .bar i { display: block; height: 100%; background: var(--green); transition: width .3s; }
.quiz-progress .q-score { flex: none; font-family: var(--mono); font-size: 8.5px; color: var(--green); }

.question-card {
  border: 1px solid var(--line-strong);
  background: var(--paper-raised);
  padding: 27px 30px 24px;
  box-shadow: 7px 7px 0 rgba(45, 91, 78, .045);
}
.q-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.q-animal {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border: 1px solid var(--animal);
  color: var(--animal);
  font-size: 9.5px;
}
.q-animal .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--animal); }
.q-type { font-family: var(--mono); font-size: 8px; color: var(--faint); letter-spacing: .08em; }
.q-stem {
  margin: 17px 0 19px;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
  line-height: 1.8;
  color: var(--ink);
}
.q-options { display: grid; gap: 7px; }
.q-option {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  background: var(--paper);
  text-align: left;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.6;
  transition: border-color .13s, background .13s;
}
.q-option:hover:not(:disabled) { border-color: var(--green); background: #fffdf7; }
.q-option .letter {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 8px;
  color: var(--muted);
}
.q-option.is-correct { border-color: var(--prevent); background: var(--prevent-soft); color: #294f30; }
.q-option.is-correct .letter { border-color: var(--prevent); background: var(--prevent); color: #fff; }
.q-option.is-wrong { border-color: var(--coral); background: var(--clinic-soft); color: #7c3626; }
.q-option.is-wrong .letter { border-color: var(--coral); background: var(--coral); color: #fff; }
.q-option.is-dim { opacity: .45; }
.q-option:disabled { cursor: default; }

.q-feedback {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
  animation: view-in .25s both;
}
.q-result-line { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.q-result-line strong { font-family: var(--serif); font-size: 16px; font-weight: 600; }
.q-result-line.good strong { color: var(--prevent); }
.q-result-line.bad strong { color: var(--coral); }
.q-result-line span { font-family: var(--mono); font-size: 8px; color: var(--faint); }
.q-explain { color: var(--ink-soft); font-size: 11.5px; line-height: 1.8; }
.q-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.q-tag {
  padding: 2px 6px;
  border-left: 2px solid var(--subject);
  background: var(--paper-warm);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 7.5px;
}
.q-tag.basic { --subject: var(--basic); }
.q-tag.prevent { --subject: var(--prevent); }
.q-tag.clinic { --subject: var(--clinic); }
.q-tag.synthesis { --subject: var(--synthesis); }
.q-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 16px; }
.q-actions .back-link { border: 0; background: none; padding: 0; color: var(--muted); font-size: 10.5px; border-bottom: 1px solid var(--line); }
.q-actions .back-link:hover { color: var(--ink); }

.quiz-result {
  border: 1px solid var(--line-strong);
  background: var(--paper-raised);
  padding: 34px 38px 31px;
  box-shadow: 7px 7px 0 rgba(45, 91, 78, .045);
}
.result-top { display: flex; align-items: center; justify-content: space-between; gap: 30px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.result-score { display: flex; align-items: baseline; gap: 8px; }
.result-score strong { font-family: var(--serif); font-size: 78px; font-weight: 560; line-height: 1; color: var(--green); letter-spacing: -.05em; }
.result-score span { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.result-top h2 { margin: 5px 0 5px; font-family: var(--serif); font-size: 30px; font-weight: 600; }
.result-top p { color: var(--muted); font-size: 11.5px; line-height: 1.7; max-width: 420px; }
.result-breakdown { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0; }
.result-cell { padding: 11px 12px; border: 1px solid var(--line); background: var(--paper-warm); }
.result-cell .k { font-family: var(--mono); font-size: 7.5px; letter-spacing: .06em; color: var(--faint); }
.result-cell .v { margin-top: 2px; font-family: var(--serif); font-size: 19px; font-weight: 600; }
.result-cell .v small { font-family: var(--mono); font-size: 13px; color: var(--ink-soft); }
.result-animal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 0 0 20px;
}
.result-by-label {
  margin: 0 0 6px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: .08em;
}
.result-animal {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  background: var(--paper);
}
.result-animal:hover { background: var(--paper-warm); }
.ra-seal {
  flex: none;
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border: 1px solid var(--animal);
  color: var(--animal);
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
}
.ra-body { flex: 1; min-width: 0; }
.ra-name { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; font-size: 10.5px; font-weight: 600; }
.ra-name small { color: var(--faint); font-family: var(--mono); font-size: 7px; font-weight: 400; }
.ra-bar { display: block; height: 3px; margin-top: 4px; background: var(--paper-deep); overflow: hidden; }
.ra-bar i { display: block; height: 100%; background: var(--animal); }
.ra-pct { flex: none; color: var(--animal); font-family: var(--serif); font-size: 14px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.result-wrong {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin: 0 0 20px;
  padding: 10px 12px;
  border: 1px dashed var(--line-strong);
  background: var(--paper-warm);
  font-size: 10.5px;
}
.result-wrong > span {
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: .1em;
  color: var(--coral);
}
.result-wrong a {
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line-strong);
}
.result-wrong a:hover { color: var(--green); border-color: var(--green); }

body.search-open,
body.drawer-open,
body.modal-open { overflow: hidden; }

.quiz-empty { padding: 60px 0; text-align: center; }

/* --------------------------------------------------------------------------
   Review page
   -------------------------------------------------------------------------- */

.review-stats {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1fr;
  gap: 12px;
  margin: 26px 0 34px;
}
.stat-card {
  position: relative;
  padding: 19px 20px;
  border: 1px solid var(--line);
  background: var(--paper-raised);
  overflow: hidden;
}
.stat-card.primary { background: var(--green-deep); color: #f6f1e5; border-color: var(--green-deep); }
.stat-card .k { font-family: var(--mono); font-size: 7.5px; letter-spacing: .1em; color: var(--muted); }
.stat-card.primary .k { color: rgba(246, 241, 229, .55); }
.stat-card .v { display: flex; align-items: baseline; gap: 5px; margin-top: 7px; }
.stat-card .v strong { font-family: var(--serif); font-size: 46px; font-weight: 560; line-height: 1; letter-spacing: -.04em; }
.stat-card.primary .v strong { color: #f6f1e5; }
.stat-card .v span { font-family: var(--mono); font-size: 9px; color: var(--muted); }
.stat-card.primary .v span { color: rgba(246, 241, 229, .55); }
.stat-card p { margin-top: 6px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.stat-card.primary p { color: rgba(246, 241, 229, .55); }
.stat-card .corner {
  position: absolute;
  right: 16px;
  bottom: 15px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: conic-gradient(var(--ochre) var(--pct, 0%), rgba(246, 241, 229, .16) 0);
}
.stat-card .corner::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--green-deep); }

.review-section { margin-top: 34px; }
.review-section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 12px; }
.review-section-head h2 { font-family: var(--serif); font-size: 25px; font-weight: 600; }
.review-section-head p { color: var(--muted); font-size: 10.5px; }

.animal-progress-list { border: 1px solid var(--line); background: var(--paper-raised); }
.animal-progress-row {
  display: grid;
  grid-template-columns: 34px 92px minmax(100px, 1fr) 76px 86px 24px;
  gap: 13px;
  align-items: center;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
}
.animal-progress-row:last-child { border-bottom: 0; }
.animal-progress-row:hover { background: var(--paper-warm); }
.ap-seal {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border: 1px solid var(--animal);
  color: var(--animal);
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
}
.ap-name { font-size: 12px; font-weight: 600; }
.ap-name small { display: block; margin-top: 1px; font-family: var(--mono); font-size: 7px; color: var(--faint); font-weight: 400; }
.ap-bar { height: 4px; background: var(--paper-deep); overflow: hidden; }
.ap-bar i { display: block; height: 100%; background: var(--animal); }
.ap-count { font-family: var(--mono); font-size: 8.5px; color: var(--muted); text-align: right; }
.ap-pct { font-family: var(--serif); font-size: 16px; text-align: right; color: var(--animal); }
.ap-go { color: var(--faint); text-align: right; }
.animal-progress-row:hover .ap-go { color: var(--animal); }

.review-columns { display: grid; grid-template-columns: 1.2fr .8fr; gap: 20px; align-items: start; }
.review-list { border: 1px solid var(--line); background: var(--paper-raised); }
.review-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border-bottom: 1px solid var(--line);
  transition: background .13s;
}
.review-item:last-child { border-bottom: 0; }
.review-item:hover { background: var(--paper-warm); }
.review-item .ri-seal {
  flex: none;
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border: 1px solid var(--animal);
  color: var(--animal);
  font-family: var(--serif);
  font-size: 15px;
}
.review-item .ri-copy { flex: 1; min-width: 0; }
.review-item .ri-name { display: block; font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.review-item .ri-meta { display: block; margin-top: 1px; color: var(--faint); font-family: var(--mono); font-size: 7px; }
.review-item .ri-flag { font-family: var(--mono); font-size: 7px; color: var(--ochre); border: 1px solid rgba(164, 122, 46, .3); padding: 1px 4px; }
.review-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 10.5px; }

.history-list { border: 1px solid var(--line); background: var(--paper-raised); }
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; border-bottom: 1px solid var(--line); font-size: 10.5px; }
.history-item:last-child { border-bottom: 0; }
.history-item .date { color: var(--faint); font-family: var(--mono); font-size: 7.5px; }
.history-item .score { font-family: var(--serif); font-size: 16px; color: var(--green); }

.data-tools { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.data-tools .btn { min-height: 34px; padding: 6px 12px; font-size: 10px; }
.danger-link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--coral);
  font-size: 10px;
  border-bottom: 1px solid rgba(177, 84, 59, .35);
}
.danger-link:hover { border-color: var(--coral); }

/* --------------------------------------------------------------------------
   Search overlay, about modal, toast
   -------------------------------------------------------------------------- */

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 10vh 20px 20px;
  background: rgba(30, 42, 37, .42);
  backdrop-filter: blur(4px);
}
.search-overlay[hidden] { display: none; }
.search-panel {
  width: min(680px, 100%);
  max-height: 72vh;
  border: 1px solid var(--line-strong);
  background: var(--paper-raised);
  box-shadow: 0 30px 80px -30px rgba(30, 42, 37, .6);
  animation: view-in .2s both;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.search-field svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.search-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
}
.search-field input::placeholder { color: var(--faint); }
.search-body { padding: 12px 14px 16px; overflow-y: auto; }
.search-hint { margin-bottom: 9px; font-family: var(--mono); font-size: 8px; letter-spacing: .04em; color: var(--faint); }
.search-results { display: grid; gap: 2px; }
.search-result {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 8px 9px;
  border: 0;
  background: transparent;
  text-align: left;
}
.search-result:hover, .search-result.is-active { background: var(--paper-warm); }
.search-result .sr-seal {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--animal);
  color: var(--animal);
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
}
.search-result .sr-name { display: block; font-size: 12px; font-weight: 600; }
.search-result .sr-name mark { background: var(--ochre-soft); color: var(--ink); padding: 0 1px; }
.search-result .sr-meta { display: block; margin-top: 1px; color: var(--faint); font-size: 8.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result .sr-subject { font-family: var(--mono); font-size: 7px; color: var(--muted); border: 1px solid var(--line); padding: 1px 5px; }
.search-none { padding: 24px 6px; color: var(--muted); font-size: 11px; text-align: center; }
.search-more { margin-top: 8px; padding: 6px; border-top: 1px solid var(--line); color: var(--faint); font-size: 8.5px; text-align: center; }

.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(30, 42, 37, .48);
  backdrop-filter: blur(4px);
}
.modal-scrim[hidden] { display: none; }
.about-modal {
  position: relative;
  width: min(760px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  padding: 32px 34px 27px;
  border: 1px solid var(--line-strong);
  background: var(--paper-raised);
  box-shadow: 0 30px 90px -30px rgba(30, 42, 37, .65);
  animation: view-in .22s both;
}
.about-modal h2 { margin: 9px 0 17px; font-family: var(--serif); font-size: 33px; font-weight: 600; }
.modal-close { position: absolute; right: 16px; top: 15px; font-size: 17px; }
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 28px; }
.about-grid h3 { margin-bottom: 4px; font-size: 12px; font-weight: 650; color: var(--green); }
.about-grid p { color: var(--ink-soft); font-size: 11px; line-height: 1.85; }
.about-source { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--faint); font-size: 9px; line-height: 1.7; }
.about-source a { color: var(--green); text-decoration: underline; text-underline-offset: 2px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 200;
  padding: 9px 16px;
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.noscript { padding: 20px; background: #fff3cd; color: #5c4500; text-align: center; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

/* Laptops: the map gets the full width and the inspector becomes a drawer. */
@media (max-width: 1400px) and (min-width: 901px) {
  .atlas-layout { grid-template-columns: 1fr; }
  .inspector {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    width: min(430px, 94vw);
    max-height: none;
    height: 100%;
    border: 0;
    border-left: 1px solid var(--line-strong);
    transform: translateX(102%);
    transition: transform .25s cubic-bezier(.2, .7, .3, 1);
    box-shadow: -20px 0 60px -30px rgba(30, 42, 37, .5);
  }
  .inspector.is-open { transform: translateX(0); }
  .inspector.is-empty { display: none; }
  .map-viewport { height: calc(100vh - 252px); }
}

@media (max-width: 1240px) {
  :root { --rail: 210px; }
  .rail { padding-left: 17px; padding-right: 17px; }
  .animal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { padding: 0 28px; }
  #view { padding: 0 28px; }
  .site-foot { padding-left: 28px; padding-right: 28px; }
  .search-trigger { width: 250px; }
}

@media (max-width: 1040px) {
  .hero { grid-template-columns: minmax(0, 1fr) minmax(330px, .8fr); gap: 40px; }
  .hero h1 { font-size: clamp(38px, 4.2vw, 46px); }
  .workup-grid { grid-template-columns: repeat(2, 1fr); }
  .workup-step:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .workup-step:nth-child(4) { border-top: 1px solid var(--line); }
  .chain-row { grid-template-columns: 138px repeat(4, minmax(0, 1fr)); }
  .review-columns { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .app-shell { display: block; }
  .rail {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 60;
    display: block;
    height: auto;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--line);
    background: rgba(251, 248, 240, .96);
    backdrop-filter: blur(12px);
  }
  .brand, .rail-rule, .rail-animals, .rail-foot { display: none; }
  .nav { flex-direction: row; justify-content: space-around; gap: 0; }
  .nav a {
    flex-direction: column;
    align-items: center;
    gap: 1px;
    flex: 1;
    padding: 5px 2px 3px;
    border-left: 0;
    border-top: 2px solid transparent;
    font-size: 10px;
  }
  .nav a.is-active { border-top-color: var(--green); border-left-color: transparent; background: transparent; }
  .nav-num { font-size: 7px; }
  .topbar { padding: 0 20px; height: 62px; }
  .mobile-brand { display: flex; }
  .breadcrumb { display: none; }
  .search-trigger { width: 200px; }
  .topbar-progress { display: none; }
  #view { padding: 0 20px; }
  .view-wrap { padding: 28px 0 90px; }
  .site-foot { padding: 18px 20px 86px; margin-bottom: 0; flex-direction: column; gap: 4px; }
  .foot-notes { align-items: flex-start; text-align: left; }
  .hero { grid-template-columns: 1fr; gap: 44px; padding-top: 26px; }
  .hero h1 { font-size: clamp(44px, 8vw, 70px); }
  .hero-specimen { justify-self: center; max-width: 470px; }
  .animal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .atlas-layout { grid-template-columns: 1fr; }
  .inspector {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    width: min(430px, 94vw);
    max-height: none;
    height: 100%;
    border: 0;
    border-left: 1px solid var(--line-strong);
    transform: translateX(102%);
    transition: transform .25s cubic-bezier(.2, .7, .3, 1);
    box-shadow: -20px 0 60px -30px rgba(30, 42, 37, .5);
  }
  .inspector.is-open { transform: translateX(0); }
  .inspector.is-empty { display: none; }
  .map-viewport { height: 66vh; min-height: 440px; }
  .map-toolbar { flex-wrap: wrap; }
  .workup-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .chain-banner { padding: 30px 24px 28px; }
  .chain-flow { grid-template-columns: 1fr 1fr; }
  .chain-flow-step:nth-child(3) { padding-left: 0; border-left: 0; border-top: 1px solid rgba(246, 241, 229, .16); }
  .chain-flow-step:nth-child(4) { border-top: 1px solid rgba(246, 241, 229, .16); }
  .chain-flow-step:nth-child(2) .arrow, .chain-flow-step:nth-child(4) .arrow { display: none; }
  .chain-flow-step:nth-child(3) .arrow { display: block; }
  .chain-row { grid-template-columns: 120px repeat(4, minmax(0, 1fr)); }
  .chain-cell { padding: 8px 8px; font-size: 8.5px; }
  .chain-row.table-head { top: 62px; }
  .quiz-intro { grid-template-columns: 1fr; }
  .quiz-intro-side { border-left: 0; border-top: 1px solid var(--line); }
  .coverage-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .coverage-cell:nth-child(3n) { border-right: 0; }
  .coverage-cell:nth-child(-n + 3) { border-bottom: 1px solid var(--line); }
  .quiz-coverage-head { flex-direction: column; align-items: flex-start; gap: 4px; }
  .quiz-coverage-head > p { text-align: left; }
  .review-stats { grid-template-columns: 1fr 1fr; }
  .stat-card.primary { grid-column: 1 / -1; }
  .chain-banner-head { flex-direction: column; align-items: flex-start; gap: 10px; }
}

@media (max-width: 780px) {
  .atlas-toolbar { display: none; }
  .atlas-map .map-toolbar,
  .atlas-map .map-viewport { display: none; }
  .mobile-tree { display: block; }
  .atlas-map { background: var(--paper-raised); }
}

@media (max-width: 680px) {
  .topbar { padding: 0 14px; }
  #view { padding: 0 14px; }
  .view-wrap { padding-top: 22px; }
  .mobile-brand strong { display: none; }
  .search-trigger { width: 38px; padding: 8px; justify-content: center; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .hero h1 { font-size: clamp(36px, 9.8vw, 46px); }
  .hero-lead { font-size: 14px; }
  .hero-actions .btn { flex: 1; min-width: 140px; }
  .hero-specimen { max-width: 100%; aspect-ratio: 1 / 1.06; }
  .specimen-step p { font-size: 9.5px; }
  .weight-panel { padding: 15px 14px 13px; }
  .weight-top { align-items: flex-start; flex-direction: column; gap: 2px; }
  .weight-bar { height: 32px; }
  .weight-seg { font-size: 7px; }
  .weight-seg span { padding: 0 2px; }
  .weight-note { flex-direction: column; gap: 2px; }
  .animal-grid { grid-template-columns: 1fr; }
  .animal-card { min-height: 300px; }
  .animal-card h3 { font-size: 34px; }
  .chain-banner { margin-top: 48px; padding: 26px 18px 24px; }
  .chain-flow { grid-template-columns: 1fr; }
  .chain-flow-step, .chain-flow-step + .chain-flow-step { padding: 14px 0; border-left: 0; border-top: 1px solid rgba(246, 241, 229, .14); }
  .chain-flow-step:first-child { border-top: 0; }
  .chain-flow-step .arrow { display: none !important; }
  .chain-banner-foot { flex-direction: column; align-items: flex-start; gap: 14px; }
  .home-path { grid-template-columns: 1fr; margin-top: 44px; }
  .path-step, .path-step + .path-step { padding: 18px 0; border-left: 0; border-top: 1px solid var(--line); }
  .path-step:first-child { border-top: 0; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 7px; }
  .animal-head { grid-template-columns: auto 1fr; gap: 15px; }
  .animal-seal { width: 62px; height: 62px; font-size: 34px; }
  .animal-head-copy h1 { font-size: 31px; }
  .animal-head-copy p { font-size: 11px; }
  .animal-head-actions { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; }
  .animal-score strong { font-size: 32px; }
  .animal-head-actions .micro { text-align: left; }
  .atlas-toolbar { align-items: flex-start; flex-direction: column; gap: 7px; }
  .map-legend { flex-wrap: wrap; gap: 8px; }
  .map-viewport { height: 62vh; min-height: 400px; }
  .inspector h2 { font-size: 27px; }
  .page-head h1 { font-size: clamp(34px, 9vw, 46px); }
  .formula { grid-template-columns: 1fr 1fr; }
  .formula-step:nth-child(2) { border-right: 0; }
  .formula-step:nth-child(3), .formula-step:nth-child(4) { border-top: 1px solid var(--line); }
  .formula-step:nth-child(3)::after { display: none; }
  .formula-step:nth-child(2)::after { content: "↓"; right: 8px; top: auto; bottom: -7px; }
  .workup-card { padding: 18px 16px 17px; }
  .workup-top { flex-direction: column; gap: 9px; }
  .workup-grid { grid-template-columns: 1fr; }
  .workup-step, .workup-step + .workup-step { padding: 12px 0; border-left: 0; border-top: 1px solid var(--line); }
  .workup-step:first-child { border-top: 0; }
  .workup-head h2 { font-size: 23px; }
  .chain-index-head { flex-direction: column; align-items: flex-start; gap: 3px; }
  .index-tools { align-items: flex-start; flex-direction: column; }
  .index-search { width: 100%; }
  .chain-table { border: 0; background: transparent; display: grid; gap: 9px; }
  .chain-row.table-head { display: none; }
  .chain-row {
    display: block;
    border: 1px solid var(--line);
    background: var(--paper-raised);
    padding: 10px 11px;
  }
  .chain-cell { display: block; padding: 4px 0; border-right: 0; box-shadow: none; font-size: 10px; }
  .chain-cell.disease { background: transparent; padding-bottom: 7px; margin-bottom: 3px; border-bottom: 1px solid var(--line); }
  .chain-cell:not(.disease)::before {
    content: attr(data-label);
    display: inline-block;
    width: 30px;
    margin-right: 5px;
    font-family: var(--mono);
    font-size: 7px;
    color: var(--subject);
  }
  .chain-cell.basic { --subject: var(--basic); }
  .chain-cell.prevent { --subject: var(--prevent); }
  .chain-cell.clinic { --subject: var(--clinic); }
  .chain-cell.synthesis { --subject: var(--synthesis); }
  .quiz-intro-main { padding: 26px 21px; }
  .quiz-intro-main .big-num { font-size: 64px; }
  .quiz-intro-main h1 { font-size: 30px; }
  .quiz-intro-side { padding: 22px 21px; }
  .question-card { padding: 20px 16px 18px; }
  .q-stem { font-size: 16.5px; }
  .q-option { font-size: 11.5px; padding: 8px 9px; }
  .result-top { flex-direction: column; align-items: flex-start; gap: 14px; }
  .result-score strong { font-size: 62px; }
  .result-breakdown { grid-template-columns: 1fr; }
  .result-animal-grid { grid-template-columns: 1fr; }
  .quiz-result { padding: 24px 19px; }
  .review-stats { grid-template-columns: 1fr; }
  .stat-card.primary { grid-column: auto; }
  .animal-progress-row { grid-template-columns: 32px 70px minmax(60px, 1fr) 60px 22px; gap: 8px; }
  .animal-progress-row .ap-count { display: none; }
  .page-head h1 { font-size: 36px; }
  .about-modal { padding: 26px 20px 22px; }
  .about-grid { grid-template-columns: 1fr; gap: 14px; }
  .about-modal h2 { font-size: 27px; }
  .search-overlay { padding: 5vh 10px 10px; }
  .search-panel { max-height: 84vh; }
  .site-foot { padding-bottom: 82px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
  }
}
