/* 由表及里 · 人体 — the page around the figure. Dark like the rest of Tipo Lab, with the app's rose tone for actions
   and a warm gold for whatever is selected. html[data-lang] picks Chinese, English or both. */
:root {
  color-scheme: dark;
  --bg: #07090b;
  --bg2: #0b1013;
  --panel: #0d1317;
  --raise: #121a1f;
  --line: #1c272e;
  --line2: #263540;
  --text: #e9eef0;
  --muted: #a2b0b5;
  --quiet: #73848b;
  --rose: #efbcc3;
  --rose-rgb: 239 188 195;
  --gold: #ffd98a;
  --gold-rgb: 255 217 138;
  --sans: "DM Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --serif: "Instrument Serif", "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", serif;
  --head: 60px;
  --rail: 248px;
  --side: 424px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(130% 80% at 50% -10%, #142028 0%, #0b1115 45%, var(--bg) 100%) fixed;
  color: var(--text);
  font: 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--quiet); }

/* ── Languages ─────────────────────────────────────────────────────────────────────────────────────────────── */
.bi .en { margin-left: .42em; font-size: .86em; color: var(--quiet); font-weight: 400; letter-spacing: 0; }
.bp.en { color: var(--muted); font-size: .94em; margin-top: -.35em; }
.bp.zh + .bp.en { margin-top: .15em; }
html[data-lang="zh"] .bi .en, html[data-lang="zh"] .bp.en, html[data-lang="zh"] .stage-tip .en { display: none; }
html[data-lang="en"] .bi .zh, html[data-lang="en"] .bp.zh, html[data-lang="en"] .stage-tip .zh { display: none; }
html[data-lang="en"] .bi .en { margin-left: 0; font-size: inherit; color: inherit; font-weight: inherit; }
html[data-lang="en"] .bp.en { color: inherit; font-size: inherit; margin-top: 0; }

/* ── Header: the site's <tipo-bar> (/tipo/tipo.css) with the atlas's views, search and body on it ──────────────── */
tipo-bar {
  --tipo-fg: var(--text);
  --tipo-muted: var(--quiet);
  --tipo-line: var(--line2);
  --tipo-accent: var(--gold);
  --tipo-accent-bg: rgb(var(--gold-rgb) / .14);
  position: relative; z-index: 20;
  max-width: none;
  height: var(--head);
  gap: 18px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgb(7 9 11 / .72);
  backdrop-filter: blur(14px);
}
/* The views follow the app's name; the search pushes the rest to the right. */
tipo-bar .tipo-crumb { margin-right: 0; }
.modes { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg2); }
.modes button { border: 0; background: none; padding: 6px 13px; border-radius: 999px; color: var(--muted); white-space: nowrap; transition: background .2s, color .2s; }
.modes button:hover { color: var(--text); }
.modes button.is-on { background: rgb(var(--rose-rgb) / .16); color: var(--text); box-shadow: inset 0 0 0 1px rgb(var(--rose-rgb) / .35); }
.modes .bi .en { font-size: .78em; }
/* The search keeps room to type in (at least 120px): on a full bar the app's name gives way first. */
.search { position: relative; flex: 1 1 160px; min-width: 120px; max-width: 300px; margin-left: auto; }
.search input { width: 100%; height: 34px; padding: 0 12px 0 34px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg2); outline: none; transition: border-color .2s; }
.search input:focus { border-color: rgb(var(--gold-rgb) / .55); }
.search input::-webkit-search-cancel-button { filter: invert(.7); }
.search-icon { position: absolute; left: 11px; top: 9px; width: 16px; height: 16px; fill: none; stroke: var(--quiet); stroke-width: 2; stroke-linecap: round; }
.search-results { position: absolute; top: 40px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none; background: var(--raise); border: 1px solid var(--line2); border-radius: 14px; box-shadow: 0 18px 40px rgb(0 0 0 / .5); max-height: 60vh; overflow: auto; }
.search-results li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.search-results li small { color: var(--quiet); white-space: nowrap; }
.search-results li.is-on, .search-results li:hover { background: rgb(var(--gold-rgb) / .1); }
.toggles { display: flex; align-items: center; gap: 8px; }
.seg { display: flex; padding: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg2); }
.seg button { border: 0; background: none; padding: 5px 10px; border-radius: 999px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--raise); color: var(--text); box-shadow: inset 0 0 0 1px var(--line2); }
.seg .bi .en { display: none; }
html[data-lang="en"] .seg .bi .en { display: inline; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: var(--bg2); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }

/* ── Layout ────────────────────────────────────────────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr) var(--side); height: calc(100dvh - var(--head)); }
.rail { overflow-y: auto; padding: 14px 14px 30px; border-right: 1px solid var(--line); }
.stage-wrap { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.panel { overflow-y: auto; padding: 18px 20px 40px; border-left: 1px solid var(--line); background: linear-gradient(180deg, rgb(13 19 23 / .85), rgb(10 14 17 / .6)); scroll-behavior: smooth; }

/* ── Rail ──────────────────────────────────────────────────────────────────────────────────────────────────── */
.rail-sec + .rail-sec { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.rail-title { margin: 0 0 10px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--quiet); }
.rail-title .en { text-transform: none; letter-spacing: 0; }
.rail-hint { margin: 10px 2px 0; color: var(--muted); font-size: 12.5px; }
.layers { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.layer-btn { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; border: 1px solid transparent; background: none; text-align: left; color: var(--muted); transition: background .2s, color .2s, border-color .2s; }
.layer-btn:hover { background: var(--raise); color: var(--text); }
.layer-btn.is-on { background: rgb(var(--gold-rgb) / .09); border-color: rgb(var(--gold-rgb) / .3); color: var(--text); }
.layer-btn.is-near { border-color: var(--line2); color: var(--text); }
.layer-n { flex: none; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--raise); font-size: 11px; color: var(--quiet); }
.layer-btn.is-on .layer-n { background: var(--gold); color: #1a1408; }
.layer-btn .bi { display: flex; flex-direction: column; line-height: 1.25; }
.layer-btn .bi .en { margin: 0; font-size: 11.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line2); background: rgb(255 255 255 / .02); color: var(--text); font-size: 13px; line-height: 1.3; text-align: left; transition: background .2s, border-color .2s; }
.chip:hover { background: rgb(255 255 255 / .06); border-color: #35505d; }
.chip.is-on { background: rgb(var(--gold-rgb) / .14); border-color: rgb(var(--gold-rgb) / .6); }
.chip-small { padding: 3px 9px; font-size: 12px; }
.chip-primary { background: rgb(var(--rose-rgb) / .14); border-color: rgb(var(--rose-rgb) / .45); }
.chip-primary:hover { background: rgb(var(--rose-rgb) / .22); }
.chip-view { border-color: rgb(var(--gold-rgb) / .38); }
.chip-view:hover { background: rgb(var(--gold-rgb) / .08); border-color: rgb(var(--gold-rgb) / .6); }
.chip-sign { border-style: dashed; }
.view-mark { color: var(--gold); margin-right: 3px; font-size: .9em; }
.play-mark { font-size: .8em; color: var(--rose); margin-right: 2px; }
.chip-risk { border-color: rgb(255 140 110 / .4); }
.chip-disease { border-style: dashed; }
.chip-static { cursor: default; color: var(--muted); }
.chip-toggle.is-on { background: rgb(255 120 90 / .16); border-color: rgb(255 140 110 / .65); }
.chip .bi .en { font-size: .82em; }
.rail-chips .chip { max-width: 100%; }
.tones { display: flex; gap: 10px; }
.tone { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; background: var(--c); box-shadow: inset 0 -4px 8px rgb(0 0 0 / .25); }
.tone.is-on { border-color: var(--gold); }
.jlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.jbtn { width: 100%; display: flex; justify-content: space-between; gap: 8px; padding: 9px 10px; border-radius: 10px; border: 1px solid transparent; background: none; text-align: left; color: var(--muted); }
.jbtn:hover { background: var(--raise); color: var(--text); }
.jbtn.is-on { background: rgb(var(--rose-rgb) / .1); border-color: rgb(var(--rose-rgb) / .35); color: var(--text); }
.jbtn small { color: var(--quiet); }
.jbtn .bi { display: flex; flex-direction: column; }
.jbtn .bi .en { margin: 0; font-size: 11.5px; }
.agepick { display: grid; gap: 12px; }
.age-out { font: 400 58px/1 var(--serif); color: var(--text); }
.age-out small { margin-left: 6px; font: 13px var(--sans); color: var(--muted); }
input[type="range"] { width: 100%; accent-color: var(--rose); }
.stages { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.stage-btn { width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 9px; border: 1px solid transparent; background: none; text-align: left; color: var(--muted); }
.stage-btn:hover { background: var(--raise); color: var(--text); }
.stage-btn.is-on { background: rgb(var(--gold-rgb) / .09); border-color: rgb(var(--gold-rgb) / .3); color: var(--text); }
.stage-range { flex: none; width: 52px; font-size: 11.5px; color: var(--quiet); font-variant-numeric: tabular-nums; }
.filter-q { width: 100%; height: 34px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line2); background: var(--bg2); outline: none; }
.filter-q:focus { border-color: rgb(var(--gold-rgb) / .55); }

/* ── Stage ─────────────────────────────────────────────────────────────────────────────────────────────────── */
.stage-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 16px 0; min-height: 46px; }
.stagebar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); }
.crumb { border: 0; background: none; padding: 2px 4px; border-radius: 6px; color: var(--muted); }
button.crumb:hover { color: var(--text); background: var(--raise); }
.crumb.is-here { color: var(--text); font-weight: 500; }
.crumb-sep { color: var(--line2); }
.stepcount { margin-left: 8px; padding: 2px 9px; border-radius: 999px; background: var(--raise); color: var(--muted); font-size: 12px; }
.states { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); }
.state-btn { border: 0; background: none; padding: 5px 10px; border-radius: 9px; color: var(--muted); font-size: 12.5px; }
.state-btn:hover { color: var(--text); }
.state-btn.is-on { background: rgb(var(--gold-rgb) / .14); color: var(--text); box-shadow: inset 0 0 0 1px rgb(var(--gold-rgb) / .45); }
.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; }
.stage[hidden] { display: none; }
.stage-glow { position: absolute; inset: 6% 18%; border-radius: 50%; background: radial-gradient(closest-side, rgb(120 170 200 / .09), transparent); pointer-events: none; }
.stage-viewport { position: absolute; inset: 0; padding: 10px 16px 18px; cursor: default; }
.stage.is-zoomed .stage-viewport { cursor: grab; }
.stage-viewport > svg { width: 100%; height: 100%; will-change: transform; }
.stage-loading { position: absolute; inset: 0; display: grid; place-content: center; margin: 0; color: var(--quiet); font-size: 13px; animation: breathe 1.8s ease-in-out infinite; }
.stage-loading .en { margin-left: .4em; }
@keyframes breathe { 50% { opacity: .45; } }
.stage.is-entering .stage-viewport > svg { animation: enter .45s cubic-bezier(.2, .7, .2, 1); }
@keyframes enter { from { opacity: 0; transform: scale(.975); } }
.stage-tip { position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none; padding: 5px 10px; border-radius: 9px; background: rgb(13 19 23 / .92); border: 1px solid var(--line2); box-shadow: 0 8px 24px rgb(0 0 0 / .45); font-size: 13px; white-space: nowrap; }
.stage-tip .en { margin-left: .45em; color: var(--quiet); font-size: .9em; }
html[data-lang="en"] .stage-tip .en { margin: 0; color: inherit; font-size: inherit; }
.stage-ctrl { position: absolute; right: 14px; bottom: 14px; display: flex; gap: 6px; z-index: 2; }
.ctrl { min-width: 34px; height: 34px; padding: 0 9px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line2); background: rgb(13 19 23 / .8); color: var(--muted); font-size: 17px; backdrop-filter: blur(8px); }
.ctrl:hover { color: var(--text); }
.ctrl svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.ctrl-wide { font-size: 12.5px; }
.ctrl[aria-pressed="true"] { color: var(--gold); border-color: rgb(var(--gold-rgb) / .45); }
.ctrl .bi .en { display: none; }
html[data-lang="en"] .ctrl .bi .en { display: inline; }
.peek { display: none; }
.sheet-scrim { display: none; }
.mode-hint { position: absolute; left: 18px; bottom: 12px; margin: 0; max-width: 46%; color: var(--quiet); font-size: 12px; pointer-events: none; }
.stagelist { flex: 1; overflow-y: auto; padding: 8px 16px 30px; }
.list-count { margin: 4px 2px 12px; color: var(--muted); }
.list-count strong { font: 400 28px/1 var(--serif); color: var(--text); margin-right: 4px; }
.dgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }

/* Markers of the ages and risks views. */
.atlas-svg .marker { cursor: pointer; }
.atlas-svg .marker .m-glow { fill: rgb(255 110 80 / .16); transform-box: fill-box; transform-origin: center; animation: glow 2.6s ease-in-out infinite; }
.atlas-svg .marker .m-dot { stroke: #fff; stroke-width: 1.4; stroke-opacity: .85; }
.atlas-svg .marker.lvl-3 .m-dot { fill: #ff5747; }
.atlas-svg .marker.lvl-2 .m-dot { fill: #ff9a55; }
.atlas-svg .marker.lvl-1 .m-dot { fill: #ffd27a; }
.atlas-svg .marker.lvl-1 .m-glow { fill: rgb(255 210 120 / .12); }
.atlas-svg .m-label { font-size: 14px; font-weight: 600; fill: #fff; paint-order: stroke; stroke: #0b0e11; stroke-width: 4px; stroke-linejoin: round; }
.atlas-svg .m-lead { fill: none; stroke: #ffffff; stroke-opacity: .32; stroke-width: 1; }
.atlas-svg .marker:hover .m-lead { stroke: var(--gold); stroke-opacity: .9; }
.atlas-svg .m-label .en { font-size: 11.5px; font-weight: 400; fill: #b7c4c9; }
.atlas-svg .marker:hover .m-dot { stroke: var(--gold); stroke-width: 2.4; }
@keyframes glow { 50% { transform: scale(1.18); opacity: .55; } }

/* ── Panel cards ───────────────────────────────────────────────────────────────────────────────────────────── */
.card { animation: rise .35s ease; }
.card + .card { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.eyebrow { margin: 0 0 6px; font-size: 12px; color: var(--quiet); letter-spacing: .04em; }
.crumb-link { border: 0; background: none; padding: 0; color: var(--rose); }
.crumb-link:hover { text-decoration: underline; }
.card-title { margin: 0 0 12px; font: 400 32px/1.12 var(--serif); letter-spacing: -.005em; }
.card-title .title-bi { display: inline; }
.card-title .bi .en { display: block; margin: 4px 0 0; font: italic 400 18px/1.2 "Instrument Serif", serif; color: var(--muted); }
html[data-lang="en"] .card-title .bi .en { display: inline; font: inherit; color: inherit; margin: 0; }
.big-age { font-size: 1.4em; }
.bp { margin: 0 0 .7em; }
.lead.zh { font-size: 15px; color: #dfe7e9; }
.small { font-size: 12.5px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 16px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 6px 0 18px; }
.stat { padding: 10px 12px; border-radius: 12px; background: var(--raise); border: 1px solid var(--line); }
.stat dt { font-size: 11.5px; color: var(--quiet); }
.stat dd { margin: 3px 0 0; font-weight: 600; line-height: 1.3; }
.stat .bi { display: flex; flex-direction: column; }
.stat .bi .en { margin: 1px 0 0; }
.card-sec { margin-top: 18px; }
.card-sec h3, .fact h3, .age-block h3 { margin: 0 0 9px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--rose); }
.card-sec h3 .en, .fact h3 .en, .age-block h3 .en { text-transform: none; letter-spacing: 0; color: var(--quiet); }
.bullets { margin: 0; padding: 0 0 0 18px; }
.bullets li { margin-bottom: 6px; }
.bullets li::marker { color: var(--rose); }
.cellcard { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgb(255 255 255 / .015); }
.cellcard + .cellcard { margin-top: 8px; }
.cellcard h4 { margin: 0 0 4px; font-size: 14px; }
.cellcard .bp { margin-bottom: .3em; font-size: 13px; }
.partner { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.partner .chip { margin-bottom: 6px; }
.partner .bp { font-size: 13px; margin-bottom: .2em; }
.fact { margin: 20px 0 0; padding: 14px 16px; border-radius: 14px; background: linear-gradient(135deg, rgb(var(--gold-rgb) / .1), rgb(var(--rose-rgb) / .05)); border: 1px solid rgb(var(--gold-rgb) / .22); }
.fact .bp:last-child { margin-bottom: 0; }
.disclaimer { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--quiet); font-size: 12px; }
.disclaimer .bi { display: block; }
.disclaimer .bi .en { display: block; margin: 4px 0 0; font-size: 1em; }
.drows { display: grid; gap: 6px; }
.drow { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgb(255 255 255 / .02); text-align: left; transition: border-color .2s, background .2s; }
.drow:hover, .drow.is-on { border-color: rgb(var(--gold-rgb) / .45); background: rgb(var(--gold-rgb) / .05); }
.drow-top { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.drow-name { font-weight: 600; }
.drow-where { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.drow .agebar { grid-column: 1; align-self: center; }
.drow-age { grid-column: 2; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.drow-age small { margin-left: 2px; }
.drow-age .bi .en { display: none; }
.kind { flex: none; padding: 1px 8px; border-radius: 999px; font-size: 11px; background: var(--raise); color: var(--muted); white-space: nowrap; }
.kind .bi .en { display: none; }
html[data-lang="en"] .kind .bi .en, html[data-lang="en"] .drow-age .bi .en { display: inline; }
.kind-cancer { background: rgb(214 92 140 / .18); color: #f2a7c6; }
.kind-vascular { background: rgb(224 68 61 / .18); color: #ff9c94; }
.kind-infection { background: rgb(120 200 120 / .15); color: #a8e0a2; }
.kind-degenerative { background: rgb(200 170 120 / .16); color: #e6cc9c; }
.kind-metabolic { background: rgb(240 190 90 / .16); color: #f4d08a; }
.kind-immune { background: rgb(150 140 240 / .17); color: #c6bff7; }
.kind-injury { background: rgb(255 150 90 / .16); color: #ffc296; }
.kind-genetic { background: rgb(110 190 230 / .16); color: #a7dcf3; }
.kind-functional { background: rgb(160 180 190 / .14); color: #c4d2d8; }
.kind-mental { background: rgb(190 140 230 / .16); color: #dcbcf3; }
.kind-life { background: rgb(var(--rose-rgb) / .16); color: var(--rose); }
.agebar { position: relative; }
.agebar-track { position: relative; height: 6px; border-radius: 99px; background: rgb(255 255 255 / .07); }
.agebar-band { position: absolute; top: 0; bottom: 0; border-radius: 99px; background: linear-gradient(90deg, rgb(255 160 110 / .55), rgb(255 90 80 / .85)); }
.agebar-peak { position: absolute; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgb(255 90 80 / .5); }
.agebar-ticks { position: relative; height: 16px; margin-top: 4px; font-size: 10.5px; color: var(--quiet); }
.agebar-ticks span { position: absolute; transform: translateX(-50%); }
.agebar-ticks span:first-child { transform: none; }
.agebar-ticks span:last-child { transform: translateX(-100%); }
.agebar.compact .agebar-track { height: 4px; }
.agebar.compact .agebar-peak { width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; }
.age-block { margin: 6px 0 16px; padding: 12px 14px; border-radius: 14px; background: var(--raise); border: 1px solid var(--line); }
.age-num { margin-left: 6px; color: var(--text); font: 400 20px/1 var(--serif); letter-spacing: 0; }
.age-block .bp { margin: 8px 0 0; }
.welcome .layer-note { margin: 16px 0; padding: 12px 14px; border-radius: 14px; background: var(--raise); border: 1px solid var(--line); }
.welcome .layer-note .bp { margin: 6px 0 0; font-size: 13px; }
.welcome-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.tile { display: grid; gap: 4px; justify-items: center; padding: 14px 6px 12px; border-radius: 14px; border: 1px solid var(--line); background: rgb(255 255 255 / .02); text-align: center; transition: border-color .2s, background .2s, transform .2s; }
.tile:hover { border-color: rgb(var(--rose-rgb) / .5); background: rgb(var(--rose-rgb) / .06); transform: translateY(-1px); }
.tile .bi { display: flex; flex-direction: column; }
.tile .bi .en { margin: 0; }
.tile-icon { font-size: 20px; color: var(--rose); }
.welcome-links { display: flex; flex-wrap: wrap; gap: 8px; }
.jcard { width: 100%; display: grid; gap: 4px; margin-top: 8px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: rgb(255 255 255 / .02); text-align: left; color: var(--muted); font-size: 13px; }
.jcard strong { color: var(--text); font-size: 15px; font-weight: 600; }
.jcard:hover { border-color: rgb(var(--rose-rgb) / .5); }
.jnav { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 6px 0 16px; }
.jcount { min-width: 46px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line2); background: var(--raise); color: var(--text); }
.btn:hover:not(:disabled) { border-color: #3c5866; }
.btn:disabled { opacity: .4; cursor: default; }
.btn-primary { background: rgb(var(--rose-rgb) / .18); border-color: rgb(var(--rose-rgb) / .55); }
.btn-ghost { background: none; }
.btn[aria-pressed="true"] { border-color: rgb(var(--gold-rgb) / .6); color: var(--gold); }
.jsteps { list-style: none; margin: 0; padding: 0; position: relative; }
.jsteps::before { content: ""; position: absolute; left: 13px; top: 8px; bottom: 8px; width: 1px; background: var(--line2); }
.jstep { position: relative; padding-left: 36px; }
.jstep + .jstep { margin-top: 2px; }
.jstep-head { width: 100%; display: flex; align-items: center; gap: 10px; margin-left: -36px; padding: 7px 8px 7px 0; border: 0; background: none; text-align: left; color: var(--muted); }
.jstep-head:hover { color: var(--text); }
.jstep-n { position: relative; z-index: 1; flex: none; width: 27px; height: 27px; display: grid; place-items: center; border-radius: 50%; background: var(--bg2); border: 1px solid var(--line2); font-size: 12px; font-variant-numeric: tabular-nums; }
.jstep.is-done .jstep-n { background: rgb(var(--rose-rgb) / .2); border-color: rgb(var(--rose-rgb) / .4); color: var(--text); }
.jstep.is-on .jstep-n { background: var(--gold); border-color: var(--gold); color: #1a1408; font-weight: 600; }
.jstep.is-on .jstep-head { color: var(--text); font-weight: 600; font-size: 15px; }
.jstep-body { padding: 2px 0 12px; }
.jstep-body .chips { margin-top: 8px; }
.milestones, .checks, .effects, .timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.milestones li, .checks li { display: grid; grid-template-columns: 54px 1fr; gap: 10px; }
.ms-age { padding-top: 3px; font: 400 18px/1.1 var(--serif); color: var(--rose); font-variant-numeric: tabular-nums; }
.milestones .chip, .checks .chip, .effects .chip { margin: 0 6px 6px 0; }
.effect { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgb(255 255 255 / .015); }
.effect .bp { font-size: 13.5px; margin-bottom: .4em; }
.timeline { position: relative; padding-left: 16px; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(180deg, var(--gold), rgb(120 220 160 / .6)); border-radius: 2px; }
.timeline li { position: relative; }
.timeline li::before { content: ""; position: absolute; left: -16px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--bg); border: 2px solid var(--gold); }
.tl-when { display: block; font-weight: 600; margin-bottom: 2px; }
.timeline .bp { font-size: 13.5px; }

/* ── About ─────────────────────────────────────────────────────────────────────────────────────────────────── */
.about { max-width: 620px; width: calc(100% - 32px); padding: 0; border: 1px solid var(--line2); border-radius: 20px; background: var(--panel); color: var(--text); box-shadow: 0 30px 80px rgb(0 0 0 / .6); }
.about::backdrop { background: rgb(0 0 0 / .6); backdrop-filter: blur(4px); }
.about-card { padding: 26px 28px 24px; max-height: 84vh; overflow: auto; }
.about h2 { margin: 0 0 14px; font: 400 30px/1.15 var(--serif); }
.about h2 .bi .en { display: block; margin: 4px 0 0; font: italic 18px/1.2 "Instrument Serif", serif; }
html[data-lang="en"] .about h2 .bi .en { display: inline; font: inherit; margin: 0; }
.about-note { color: var(--quiet); font-size: 12.5px; }
.noscript { padding: 30px; text-align: center; }

/* ── Small screens: everything stacks and the page scrolls ──────────────────────────────────────────────────── */
/* A laptop's bar is full, and fuller in English: tighter, and 留言 as its icon (the word stays for screen readers). */
@media (min-width: 961px) and (max-width: 1280px) {
  tipo-bar { gap: 12px; padding: 0 14px; }
  .modes button { padding: 6px 10px; }
  tipo-bar .tipo-feedback { justify-content: center; width: 40px; padding: 0; }
  tipo-bar .tipo-feedback-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
@media (max-width: 1180px) {
  :root { --rail: 220px; --side: 360px; }
  tipo-bar .tipo-crumb { display: none; }
}
/* Narrower still, the bodies are ♂ and ♀ alone in English, whose names are long (screen readers still hear them). */
@media (min-width: 961px) and (max-width: 1180px) {
  html[data-lang="en"] .seg .bi { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
/* 中EN on the busiest bars, a phone's and a small laptop's: the views in Chinese alone. */
@media (max-width: 520px), (min-width: 961px) and (max-width: 1100px) {
  html[data-lang="both"] .modes .bi .en { display: none; }
}
@media (max-width: 960px) {
  body { overflow: auto; }
  tipo-bar { height: auto; flex-wrap: wrap; gap: 10px; padding: max(10px, env(safe-area-inset-top)) 12px 10px; position: sticky; top: 0; }
  .tipo-word { display: none; }
  /* The views take a row of their own, under the language switch. */
  .modes { order: 100; width: 100%; overflow-x: auto; justify-content: space-between; scrollbar-width: none; }
  .modes button { padding: 6px 10px; }
  .search { order: 2; max-width: none; flex: 1; min-width: 0; margin: 0; }
  .toggles { order: 2; }
  .seg button { padding: 5px 8px; }
  .app { display: flex; flex-direction: column; height: auto; }
  .rail { order: 1; border: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; overflow: visible; }
  .rail-sec + .rail-sec { margin-top: 10px; padding-top: 10px; }
  .layers { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .layer-btn { padding: 6px 10px; }
  .layer-btn .bi .en { display: none; }
  html[data-lang="en"] .layer-btn .bi .en { display: inline; }
  .rail-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .rail-chips .chip { flex: none; }
  .rail-hint { display: none; }
  .stages { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; }
  .jlist { grid-auto-flow: column; grid-auto-columns: 70%; overflow-x: auto; }
  .agepick { grid-template-columns: auto 1fr; align-items: center; }
  .agepick .btn { grid-column: 1 / -1; justify-self: start; }
  .age-out { font-size: 40px; }
  .stage-wrap { order: 2; }
  .stagelist { overflow: visible; }
  .panel { order: 3; border: 0; border-top: 1px solid var(--line); overflow: visible; padding: 18px 16px 60px; }
  .mode-hint { display: none; }
  .peek:not([hidden]) { display: flex; position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 3; align-items: center; gap: 10px; max-width: calc(100% - 140px); padding: 8px 14px; border-radius: 999px; border: 1px solid rgb(var(--gold-rgb) / .5); background: rgb(13 19 23 / .9); backdrop-filter: blur(10px); white-space: nowrap; overflow: hidden; }
  /* A long name gives way, never "Details ↓". */
  .peek > .bi { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .peek-go { flex: none; color: var(--gold); font-size: 12px; }
  /* In 中EN the pill says it in Chinese alone; in English the English shows (tipo.css hides the Chinese). */
  html[data-lang="both"] .peek .bi .en { display: none; }
  .stage-ctrl { right: 8px; bottom: auto; top: 4px; gap: 4px; }
  .ctrl { min-width: 30px; height: 30px; padding: 0 7px; font-size: 15px; background: rgb(13 19 23 / .9); }
  .stage-viewport { padding-top: 40px; }
  /* The stage on a phone is as tall as the drawing needs, so a close-up isn't letterboxed in a tall box. */
  .stage-wrap { height: auto; min-height: 0; }
  .stage { flex: none; height: min(74vh, 640px); }
  /* Most of the screen is the stage, so an up or down swipe on it scrolls the page; taps still pick parts, and two
     fingers still zoom. Once zoomed in, one finger moves the drawing instead. */
  .stage:not(.is-zoomed) { touch-action: pan-y; }
  body[data-view="diagram"] .stage { height: auto; aspect-ratio: var(--stage-ratio, 1000 / 760); max-height: 74vh; }
  .states { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  .state-btn { flex: none; }
  .stage-head { padding: 8px 12px 0; }
  .card-title { font-size: 28px; }
  .dgrid { grid-template-columns: 1fr; }
  /* The diseases view: the list is long and the panel comes after it, so a disease's card opens as a sheet over the
     list (main.mjs sets has-sheet), and closing it (← Back, a tap above it, Esc or the browser's Back) finds the list
     where it was. */
  body.has-sheet { overflow: hidden; }
  body.has-sheet .panel { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; max-height: 86vh; max-height: 86dvh; overflow-y: auto; overscroll-behavior: contain; padding: 0 16px calc(32px + env(safe-area-inset-bottom)); border: 1px solid var(--line2); border-bottom: 0; border-radius: 20px 20px 0 0; background: var(--panel); box-shadow: 0 -24px 64px rgb(0 0 0 / .6); animation: sheet .32s cubic-bezier(.2, .7, .2, 1); }
  body.has-sheet .panel .card > .eyebrow:first-child { position: sticky; top: 0; z-index: 1; margin: 0 -16px 10px; padding: 16px 16px 10px; background: var(--panel); border-bottom: 1px solid var(--line); font-size: 13px; }
  body.has-sheet .panel .crumb-link { padding: 4px 8px 4px 0; font-size: 14px; }
  body.has-sheet .sheet-scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgb(0 0 0 / .55); touch-action: none; }
}
@keyframes sheet { from { transform: translateY(48px); opacity: .4; } }
/* A phone: the bar's first row is the site's (Tipo Lab, the search, 留言, 中 | EN | 中EN) and the views have the
   second to themselves. The bodies' toggles and About sit at the head of the stage instead (main.mjs moves them
   there; until it has, they are not drawn in the bar). Search results are as wide as the screen. */
@media (max-width: 520px) {
  tipo-bar .toggles { display: none; }
  .stage-head .toggles { order: 1; margin-left: auto; }
  .stagetools { order: 2; flex-basis: 100%; }
  .stagetools:empty { display: none; }
  .search-results { left: -40px; right: auto; width: calc(100vw - 24px); }
}
@media (max-width: 400px) {
  .modes button { padding: 6px 8px; }
}
@media (max-width: 340px) {
  .modes button { padding: 6px 5px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
