:root {
  color-scheme: light dark;
  --page: #eef2e8;
  --surface: #fffdf7;
  --surface-2: #f6f0e3;
  --ink: #183129;
  --muted: #66766f;
  --line: #ced9cf;
  --leaf: #267457;
  --leaf-dark: #15583f;
  --sun: #e8ab3d;
  --animal: #d27143;
  --plant: #398b61;
  --fungus: #8b61a8;
  --microbe: #397da0;
  --shadow: 0 18px 45px rgba(26, 53, 41, .13);
}
@media (prefers-color-scheme: dark) {
  :root { --page:#122019; --surface:#1b2b23; --surface-2:#24362c; --ink:#f2f3e9; --muted:#aab9b0; --line:#3e5348; --leaf:#75c9a0; --leaf-dark:#a5e5c5; --sun:#f2c66d; --animal:#efa078; --plant:#74c897; --fungus:#c39add; --microbe:#79bdda; --shadow:0 18px 45px rgba(0,0,0,.28); }
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: radial-gradient(circle at 8% 2%, color-mix(in srgb, var(--sun) 17%, transparent), transparent 27rem), var(--page); font: 16px/1.55 ui-rounded, -apple-system, BlinkMacSystemFont, "SF Pro Rounded", system-ui, sans-serif; }
a { color: var(--leaf-dark); text-underline-offset: .18em; }
button, input, select { font: inherit; }
button, .button { min-height: 44px; }
.skip-link { position: fixed; left: 12px; top: -80px; z-index: 99; padding: 10px 14px; background: var(--surface); border-radius: 12px; }
.skip-link:focus { top: 12px; }
.site-header { height: 58px; padding: 8px clamp(14px, 3vw, 34px); display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(14px); position: relative; z-index: 20; }
.brand, .life-home { color: var(--ink); font-weight: 800; text-decoration: none; }
.life-home { color: var(--leaf-dark); }
.development-banner { margin: 0; padding: 8px 16px; text-align: center; background: #7d3a91; color: white; font-weight: 850; letter-spacing: .015em; position: relative; z-index: 18; }
.loading { padding: 36px; font-weight: 750; }
.explorer { min-height: calc(100vh - 58px); display: grid; grid-template-rows: auto minmax(440px, 1fr); }
.explorer-head { padding: 16px clamp(14px, 3vw, 34px) 14px; display: grid; grid-template-columns: minmax(230px, 1fr) auto; gap: 12px 22px; align-items: end; }
.title-group h1 { margin: 0; font-size: clamp(25px, 4vw, 42px); line-height: 1.05; }
.title-group p { margin: 6px 0 0; color: var(--muted); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: end; }
.search { position: relative; width: min(430px, 100%); }
.search label { display: block; font-size: 13px; font-weight: 750; margin: 0 0 4px 4px; }
.search input { width: 100%; min-height: 48px; padding: 9px 44px 9px 16px; border: 1px solid var(--line); border-radius: 15px; color: var(--ink); background: var(--surface); box-shadow: 0 4px 18px rgba(26,53,41,.07); }
.search input:focus, button:focus-visible, a:focus-visible, select:focus-visible { outline: 3px solid color-mix(in srgb, var(--sun) 78%, white); outline-offset: 2px; }
.search-results { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); max-height: 50vh; overflow: auto; }
.search-results:empty, .search-results[hidden] { display: none; }
.search-results button { width: 100%; padding: 9px 11px; border: 0; border-radius: 10px; color: var(--ink); background: transparent; text-align: left; cursor: pointer; }
.search-results button:hover, .search-results button[aria-selected="true"] { background: var(--surface-2); }
.search-results small { display: block; color: var(--muted); }
.tool-button, .button { border: 1px solid var(--line); border-radius: 13px; padding: 9px 14px; background: var(--surface); color: var(--ink); font-weight: 750; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.tool-button[aria-pressed="true"], .button { color: white; background: var(--leaf-dark); border-color: transparent; }
.button.ghost { color: var(--leaf-dark); background: transparent; border-color: var(--line); }
.workspace { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 390px); border-top: 1px solid var(--line); }
.tree-panel { position: relative; min-width: 0; overflow: auto; padding: 14px clamp(10px, 2vw, 24px) 50px; background-image: radial-gradient(circle, color-mix(in srgb, var(--line) 65%, transparent) 1px, transparent 1px); background-size: 18px 18px; }
.diagram-note { width: fit-content; max-width: 100%; margin: 0 auto 9px; padding: 6px 11px; border-radius: 999px; color: var(--muted); background: color-mix(in srgb, var(--surface) 90%, transparent); font-size: 13px; }
.diagram-shell { height: min(66vh, 690px); min-height: 470px; position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 24px; background: color-mix(in srgb, var(--surface) 72%, transparent); box-shadow: inset 0 0 55px rgba(42, 91, 68, .05); }
.branch-map { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; user-select: none; }
.branch-map.dragging { cursor: grabbing; }
.branch-map:focus-visible { outline: 4px solid var(--sun); outline-offset: -5px; border-radius: 24px; }
.map-controls { position: absolute; z-index: 4; right: 10px; top: 10px; display: flex; gap: 5px; padding: 5px; border: 1px solid var(--line); border-radius: 15px; background: color-mix(in srgb, var(--surface) 94%, transparent); box-shadow: 0 4px 16px rgba(26,53,41,.12); }
.map-controls button { min-width: 42px; min-height: 40px; padding: 4px 9px; border: 0; border-radius: 10px; color: var(--ink); background: var(--surface-2); font-weight: 850; cursor: pointer; }
.map-edges path { fill: none; stroke: color-mix(in srgb, var(--leaf) 63%, var(--line)); stroke-width: 5; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.map-edges path.selected-edge { stroke: var(--sun); stroke-width: 8; }
.map-node { cursor: pointer; outline: none; }
.map-node:focus .branch-dot, .map-node:focus .portrait-ring { stroke: var(--sun); stroke-width: 5; }
.branch-dot { fill: var(--surface); stroke: var(--leaf); stroke-width: 5; vector-effect: non-scaling-stroke; }
.portrait-ring { fill: var(--surface); stroke: var(--leaf); stroke-width: 5; vector-effect: non-scaling-stroke; }
.portrait-ring.selected { stroke: var(--sun); stroke-width: 8; }
.branch-label, .tip-label { fill: var(--ink); font: 800 21px ui-rounded, system-ui, sans-serif; paint-order: stroke; stroke: var(--surface); stroke-width: 5px; stroke-linejoin: round; }
.tip-label { font-size: 22px; }
.branch-secondary, .tip-secondary, .tip-count { fill: var(--muted); font: 550 italic 14px ui-rounded, system-ui, sans-serif; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.tip-count { font-style: normal; font-weight: 750; fill: var(--leaf-dark); }
.about-tree { max-width: 760px; margin: 10px auto 0; padding: 8px 12px; border-radius: 13px; background: color-mix(in srgb, var(--surface) 86%, transparent); color: var(--muted); font-size: 14px; }
.about-tree summary { color: var(--ink); font-weight: 780; cursor: pointer; }
.about-tree p { margin: 7px 0 2px; }
.tree-note { margin: 0 auto 18px; max-width: 760px; padding: 9px 14px; border: 1px solid var(--line); border-radius: 13px; color: var(--muted); background: color-mix(in srgb, var(--surface) 90%, transparent); font-size: 14px; }
.tree-list, .tree-list ul { margin: 0; padding: 0; list-style: none; }
.tree-list { max-width: 780px; margin: 0 auto; }
.tree-list ul { position: relative; margin-left: 21px; padding-left: 24px; border-left: 2px solid var(--line); }
.tree-list li { position: relative; padding: 5px 0; }
.tree-list ul > li::before { content: ""; position: absolute; top: 27px; left: -24px; width: 20px; border-top: 2px solid var(--line); }
.node-row { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.node-button { max-width: min(100%, 560px); min-height: 40px; border: 1px solid var(--line); border-radius: 14px; padding: 7px 12px; color: var(--ink); background: var(--surface); font-weight: 700; text-align: left; cursor: pointer; box-shadow: 0 3px 0 rgba(25,60,45,.08); }
.node-button:hover { border-color: var(--leaf); transform: translateY(-1px); }
.node-button.selected { border: 3px solid var(--sun); padding: 5px 10px; }
.node-button.path { border-color: var(--leaf); background: color-mix(in srgb, var(--plant) 12%, var(--surface)); }
.node-button.mrca { border: 3px double var(--animal); padding: 5px 10px; }
.node-button small { display: block; color: var(--muted); font-weight: 550; }
.branch-toggle { width: 36px; min-height: 36px; padding: 0; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--ink); cursor: pointer; font-weight: 900; }
.leaf-mark { width: 36px; text-align: center; color: var(--leaf); }
.side-card { min-width: 0; min-height: 0; overflow: auto; border-left: 1px solid var(--line); background: var(--surface); padding: 20px; }
.empty-card { min-height: 100%; display: grid; place-content: center; color: var(--muted); text-align: center; }
.empty-card h2, .empty-card p { margin: 5px auto; max-width: 260px; }
.welcome-leaf { font-size: 54px; }
.organism-card, .organism-card figure, .detail-card figure, .hero-grid > * { margin: 0; min-width: 0; max-width: 100%; }
.organism-card img { width: 100%; max-height: 280px; object-fit: cover; border-radius: 20px; background: var(--surface-2); }
figcaption { margin-top: 7px; color: var(--muted); font-size: 13px; }
.organism-card h2 { margin: 13px 0 3px; font-size: 28px; line-height: 1.1; }
.card-close { display: none; width: 100%; min-height: 44px; margin: 0 0 12px; border: 1px solid var(--line); border-radius: 13px; color: var(--leaf-dark); background: var(--surface-2); font-weight: 800; cursor: pointer; }
.eyebrow { margin: 12px 0 4px; color: var(--leaf-dark); font-size: 13px; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; }
.scientific { margin: 0 0 12px; color: var(--muted); font-style: italic; }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 17px 0 5px; }
.collection-note { padding: 11px 13px; border-left: 4px solid var(--sun); border-radius: 8px; background: var(--surface-2); }
.list-browser { max-width: 760px; margin: 0 auto; }
.list-browser h2 { margin: 0 0 8px; }
.list-browser ul { padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.list-browser a { display: block; min-height: 48px; padding: 11px 14px; border-radius: 13px; background: var(--surface); border: 1px solid var(--line); font-weight: 720; text-decoration: none; }
.detail-card, .tool-page { width: min(1080px, calc(100% - 28px)); max-width: calc(100% - 28px); min-width: 0; margin: clamp(18px, 4vw, 44px) auto; padding: clamp(18px, 4vw, 42px); border: 1px solid var(--line); border-radius: 28px; background: var(--surface); box-shadow: var(--shadow); overflow-wrap: anywhere; }
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--muted); margin-bottom: 20px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, .95fr); gap: clamp(22px, 4vw, 48px); align-items: center; }
.hero-grid img { display: block; width: 100%; max-width: 100%; height: auto; max-height: 570px; object-fit: cover; border-radius: 24px; background: var(--surface-2); }
.hero-grid h1, .tool-page h1 { margin: 0; font-size: clamp(34px, 6vw, 64px); line-height: 1; }
.quick-facts { margin: 34px 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.quick-facts li { padding: 15px; border-radius: 16px; background: var(--surface-2); }
.quick-facts b, .quick-facts span { display: block; }
.quick-facts b { color: var(--muted); font-size: 13px; }
.story { max-width: 760px; margin: 28px auto; }
.story h2, .sources h2 { margin-bottom: 7px; }
.media-gallery { max-width: 940px; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 16px; }
.media-gallery h2 { grid-column: 1 / -1; }
.media-gallery img { display: block; width: 100%; max-width: 100%; height: auto; max-height: 480px; object-fit: cover; border-radius: 20px; }
.sources { min-width: 0; max-width: 100%; margin-top: 38px; padding-top: 22px; border-top: 1px solid var(--line); font-size: 14px; overflow-wrap: anywhere; word-break: break-word; }
.sources li { margin: 9px 0; }
.sources li span { display: block; color: var(--muted); }
.tool-page { min-height: 60vh; }
.chooser { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 24px 0; }
.chooser label { font-weight: 750; }
.chooser select { width: 100%; min-height: 48px; margin-top: 4px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); background: var(--surface-2); }
.choice-stack { display: grid; gap: 9px; align-content: start; }
.member-choice[hidden] { display: none; }
.connection { margin: 24px 0; padding: 20px; border-radius: 20px; background: var(--surface-2); }
.compare-diagram { width: 100%; overflow: hidden; border-radius: 20px; background: var(--surface); }
.compare-portraits { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; padding-top: 18px; }
.compare-portrait { display: flex; align-items: center; flex-direction: column; gap: 5px; padding: 0 5px; min-width: 0; text-align: center; text-decoration: none; line-height: 1.2; }
.compare-portrait img { width: clamp(60px, 12vw, 96px); height: clamp(60px, 12vw, 96px); object-fit: cover; border-radius: 50%; border: 5px solid var(--animal); }
.compare-portrait.second img { border-color: var(--microbe); }
.compare-portrait strong { font-size: clamp(15px, 2vw, 22px); }
.compare-portrait em { color: var(--muted); font-size: 12px; }
.compare-shared-label { display: flex; flex-direction: column; text-align: center; gap: 3px; padding: 0 12px 18px; }
.compare-shared-label span { color: var(--muted); font-size: 13px; }
.compare-map { display: block; width: 100%; height: auto; max-height: 420px; }
.milestone-card { margin: 20px 0; padding: 16px 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.milestone-card h2 { margin: 3px 0 7px; }
.milestone-age { color: var(--leaf-dark); font-weight: 800; }
.compare-branch { fill: none; stroke-width: 12; stroke-linecap: round; }
.compare-branch.first { stroke: var(--animal); }
.compare-branch.second { stroke: var(--microbe); }
.compare-tip circle { fill: var(--surface); stroke-width: 7; }
.compare-tip.first circle { stroke: var(--animal); }
.compare-tip.second circle { stroke: var(--microbe); }
.compare-tip-label, .compare-ancestor-label { fill: var(--ink); text-anchor: middle; font: 850 20px ui-rounded, system-ui, sans-serif; paint-order: stroke; stroke: var(--surface); stroke-width: 5px; }
.compare-tip-secondary { fill: var(--muted); text-anchor: middle; font: italic 13px ui-rounded, system-ui, sans-serif; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.compare-ancestor circle { fill: var(--sun); stroke: var(--surface); stroke-width: 7; }
.compare-ancestor-label { font-size: 22px; }
.exact-paths { margin-top: 16px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 14px; }
.exact-paths summary { cursor: pointer; font-weight: 780; }
.source-path { max-height: 270px; overflow: auto; }
.source-path li { margin: 5px 0; }
.source-path code { display: block; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.path-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 12px 0; }
.path-strip span { padding: 6px 9px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.path-strip span + span::before { content: "←"; margin-right: 7px; color: var(--muted); }
.journey-list { list-style: none; padding: 0 0 0 20px; border-left: 3px solid var(--leaf); }
.journey-list li { position: relative; margin: 0 0 18px; padding: 10px 15px; border-radius: 15px; background: var(--surface-2); }
.journey-list li::before { content:""; position:absolute; width:12px; height:12px; left:-27px; top:18px; border-radius:50%; background:var(--sun); border:2px solid var(--surface); }
.muted { color: var(--muted); }
.error { padding: 16px; border-radius: 14px; background: #8c2f3917; color: #8c2f39; font-weight: 700; }
@media (max-width: 820px) {
  .explorer-head { grid-template-columns: 1fr; }
  .toolbar { justify-content: start; }
  .workspace { display: block; }
  .tree-panel { min-height: calc(100vh - 190px); padding: 8px 8px 62px; }
  .diagram-shell { height: 56vh; min-height: 410px; border-radius: 18px; }
  .side-card { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; max-height: 62vh; border: 1px solid var(--line); border-radius: 24px 24px 0 0; box-shadow: 0 -12px 40px rgba(0,0,0,.2); transform: translateY(calc(100% - 70px)); transition: transform .24s ease; padding-top: 16px; }
  .side-card.open { transform: none; }
  .side-card:not(.open) { display: none; }
  .side-card::before { content:""; display:block; width:46px; height:5px; margin:-5px auto 13px; border-radius:4px; background:var(--line); }
  .card-close { display: block; }
  .empty-card { min-height: 38px; }
  .hero-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .brand { font-size: 0; }
  .brand::first-letter { font-size: 24px; }
  .explorer-head { padding-top: 11px; }
  .chooser { grid-template-columns: 1fr; }
  .detail-card, .tool-page { width: calc(100% - 20px); max-width: calc(100% - 20px); margin: 8px auto; padding: 16px; border-radius: 20px; }
  .hero-grid h1, .tool-page h1 { font-size: 34px; }
  .branch-secondary, .tip-secondary { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; }
}
@media print { .site-header, .development-banner, .action-row, .toolbar { display:none; } body{background:white;color:black}.detail-card{box-shadow:none;border:0} }

/* Continuous explorer: the camera moves across one stable page-only tree. */
.explorer { height: calc(100dvh - 58px); min-height: 640px; grid-template-rows: auto minmax(0, 1fr); }
.explorer-head { align-items: center; padding-top: 12px; padding-bottom: 12px; gap: 10px 22px; }
.title-group h1 { font-size: clamp(25px, 3vw, 34px); }
.title-group p { font-size: 14px; }
.toolbar { align-items: end; }
.toolbar .search { width: min(310px, 100%); }
.toolbar .tool-button { font-size: 14px; }
.group-shortcuts { grid-column: 1 / -1; display: flex; gap: 7px; flex-wrap: wrap; }
.group-shortcuts button { min-height: 40px; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 750; font-size: 14px; cursor: pointer; }
.group-shortcuts button:hover, .group-shortcuts button[aria-pressed="true"] { border-color: var(--leaf); background: var(--leaf-dark); color: var(--surface); }
.random-organism { border-color: var(--leaf); }
.workspace { grid-template-columns: minmax(0, 1fr) 320px; }
.tree-panel { display: flex; flex-direction: column; padding: 10px 12px; overflow: hidden; }
.diagram-shell { flex: 1; height: auto; min-height: 280px; border-radius: 20px; }
.diagram-shell[hidden], .list-browser[hidden] { display: none; }
.diagram-note { flex: none; border-radius: 12px; font-size: 12px; margin-bottom: 7px; }
.about-tree { flex: none; margin-top: 7px; padding: 5px 11px; width: 100%; max-height: 28%; overflow: auto; font-size: 12px; }
.side-card { padding: 16px; }
.organism-card img { max-height: 230px; object-fit: contain; }
.organism-card h2 { font-size: 25px; }
.organism-card p { font-size: 14px; }
.map-status { position: absolute; bottom: 7px; left: 9px; margin: 0; padding: 4px 8px; background: var(--surface); border-radius: 8px; color: var(--muted); pointer-events: none; font-size: 11px; }
.map-accessible { position: absolute; left: 0; top: 0; z-index: 5; }
.map-accessible button { position: absolute; width: 1px; height: 1px; min-height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.map-accessible button:focus-visible { position: relative; width: auto; height: auto; min-height: 44px; padding: 8px 14px; margin: 12px; clip-path: none; border: 2px solid var(--sun); border-radius: 12px; background: var(--surface); color: var(--ink); font-weight: 800; }
.list-browser { width: 100%; overflow: auto; }
.extinction-note { margin: 14px 0; padding: 10px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.extinction-note strong { display: inline-block; font-size: 13px; letter-spacing: .02em; }
.extinction-note p { margin: 3px 0 0; font-size: 14px; }
@media (max-width: 1100px) { .explorer-head { grid-template-columns: 1fr; } .toolbar { justify-content: start; } }
@media (max-width: 820px) {
  .explorer { min-height: 570px; }
  .explorer-head { padding: 8px 10px; gap: 8px; }
  .title-group { display: none; }
  .toolbar { gap: 5px; }
  .toolbar .search { flex: 1 1 100%; width: 100%; }
  .search label { display: none; }
  .search input { min-height: 42px; }
  .toolbar .tool-button { min-height: 36px; padding: 5px 10px; font-size: 12px; }
  .group-shortcuts { gap: 5px; flex-wrap: nowrap; overflow-x: auto; padding: 1px 1px 4px; }
  .group-shortcuts button { flex: 0 0 auto; min-height: 36px; padding: 4px 10px; font-size: 12px; }
  .workspace { display: flex; min-height: 0; }
  .tree-panel { flex: 1; min-height: 0; padding: 5px 6px 8px; }
  .diagram-shell { height: auto; min-height: 240px; }
  .diagram-note { font-size: 10px; margin-bottom: 4px; padding: 4px 7px; }
  .about-tree { font-size: 11px; }
  .side-card { padding: 14px; max-height: 65dvh; }
  .side-card img { max-height: 160px; }
}
