/* Body-systems block: works on the /research theme and on study pages (site.css). */
.body-systems{
  --bs-bg:var(--surface,#fff);
  --bs-bg2:var(--surface-2,#f3f5f8);
  --bs-text:var(--text,#12141a);
  --bs-muted:var(--muted,#5b6472);
  --bs-line:var(--line,#d5ded9);
  --bs-accent:var(--accent,#d94000);
  color:var(--bs-text);
  background:var(--bs-bg);
  border:1px solid var(--bs-line);
  border-radius:16px;
  padding:16px 16px 12px;
  margin:0 0 18px;
}
html[data-theme="dark"] .body-systems,
html[data-theme="system"] .body-systems{
  --bs-bg:var(--surface,#111726);
  --bs-bg2:var(--surface-2,#161e30);
  --bs-text:var(--text,#f3f5fb);
  --bs-muted:var(--muted,#aeb6cc);
  --bs-line:var(--line,#2a3348);
  --bs-accent:var(--accent,#ff7a33);
}
@media(prefers-color-scheme:dark){
  html:not([data-theme="light"]) .body-systems{
    --bs-bg:var(--surface,#111726);
    --bs-bg2:var(--surface-2,#161e30);
    --bs-text:var(--text,#f3f5fb);
    --bs-muted:var(--muted,#aeb6cc);
    --bs-line:var(--line,#2a3348);
    --bs-accent:var(--accent,#ff7a33);
  }
  html[data-theme="light"] .body-systems{
    --bs-bg:var(--surface,#fff);
    --bs-bg2:var(--surface-2,#f3f5f8);
    --bs-text:var(--text,#12141a);
    --bs-muted:var(--muted,#5b6472);
    --bs-line:var(--line,#d5ded9);
    --bs-accent:var(--accent,#d94000);
  }
}
.body-systems h2{
  margin:0 0 4px;
  font-size:.95rem;
  letter-spacing:.04em;
  text-transform:uppercase;
}
.body-systems-note{
  margin:0 0 12px;
  color:var(--bs-muted);
  font-size:.78rem;
  line-height:1.45;
}
.body-systems-list,
.body-systems-organs{
  list-style:none;
  margin:0;
  padding:0;
}
.body-systems-list>li{
  border-top:1px solid var(--bs-line);
}
.body-systems-row{
  display:flex;
  align-items:stretch;
  gap:0;
}
.body-systems-row>button:first-child{
  flex:1;
  text-align:left;
}
.body-systems button{
  appearance:none;
  border:0;
  background:transparent;
  color:inherit;
  font:inherit;
  cursor:pointer;
  padding:8px 6px;
}
.body-systems-sys{
  display:flex;
  justify-content:space-between;
  gap:8px;
  width:100%;
  font-size:.86rem;
  font-weight:650;
  border-radius:8px;
}
.body-systems-sys:hover,
.body-systems-organ:hover{background:var(--bs-bg2)}
.body-systems-sys.is-active,
.body-systems-organ.is-active{
  background:var(--bs-bg2);
  color:var(--bs-accent);
}
.body-systems-sys.is-current,
.body-systems-organ.is-current{
  box-shadow:inset 3px 0 0 var(--bs-accent);
}
.body-systems-count{
  color:var(--bs-muted);
  font-variant-numeric:tabular-nums;
  font-weight:600;
  font-size:.78rem;
}
.body-systems-sys{min-width:0}
.body-systems-sys>span:first-child{flex:1;min-width:0}
.body-systems-toggle{
  flex:0 0 1.7rem;
  width:1.7rem;
  padding:8px 0;
  color:var(--bs-muted);
  font-size:1.05rem;
  line-height:1.2;
}
.body-systems-toggle[aria-expanded="true"]{color:var(--bs-text)}
.body-systems-organs{
  padding:0 0 8px 10px;
}
.body-systems-organ{
  display:flex;
  justify-content:space-between;
  width:100%;
  font-size:.8rem;
  border-radius:8px;
}
/* /research: show the block in the right rail on desktop; below the list, collapsed, on smaller screens. */
.body-systems-mobile-slot{display:none;margin:20px 0 28px;padding:0 4px}
@media(max-width:1120px){
  .home-right [data-body-systems-desktop]{display:none}
  .body-systems-mobile-slot{display:block}
  .body-systems-mobile-slot .body-systems-list{display:none}
  .body-systems-mobile-slot .body-systems.is-open .body-systems-list{display:block}
  .body-systems-mobile-slot .body-systems-head{cursor:pointer;display:flex;align-items:center;justify-content:space-between;gap:8px}
  .body-systems-mobile-slot .body-systems-head h2{margin:0}
}
@media(min-width:1121px){
  .body-systems-mobile-slot{display:none}
}
/* Study pages: sit in a right column when there is room; stack below the article on small screens. */
@media(min-width:1100px){
  main:has(> .body-systems-rail){
    display:grid;
    grid-template-columns:minmax(0,1fr) 300px;
    gap:28px 32px;
    max-width:1400px;
    margin:0 auto;
    padding:0 22px 40px;
    align-items:start;
  }
  main:has(> .body-systems-rail) > .wrap{
    max-width:none;
    width:auto;
    padding-left:0;
    padding-right:0;
    grid-column:1;
    grid-row:1;
  }
  .body-systems-rail{position:sticky;top:24px;align-self:start;grid-column:2;grid-row:1}
}
@media(max-width:1099px){
  .body-systems-rail{margin:8px auto 32px;max-width:1200px;padding:0 22px}
  .body-systems-rail .body-systems-list{display:none}
  .body-systems-rail .body-systems.is-open .body-systems-list{display:block}
  .body-systems-rail .body-systems-head{cursor:pointer;display:flex;align-items:center;justify-content:space-between;gap:8px}
}

/* Study pages use the dark site.css theme; match it unless the page opts into light. */
.body-systems-rail .body-systems{
  --bs-bg:#16141f;
  --bs-bg2:#201c2c;
  --bs-text:#f3f5fb;
  --bs-muted:#b7b3c7;
  --bs-line:#3a3548;
  --bs-accent:#ff7a33;
}
html[data-theme="light"] .body-systems-rail .body-systems{
  --bs-bg:#fff;
  --bs-bg2:#f3f5f8;
  --bs-text:#12141a;
  --bs-muted:#5b6472;
  --bs-line:#d5ded9;
  --bs-accent:#d94000;
}

/* Filters toggle + summary panel on /research when a body system is selected. */
.research-filters-bar{
  margin:0;
  padding:12px 20px 8px;
}
.research-filters-bar[hidden],
[data-research-top][hidden],
.body-system-summary[hidden]{display:none !important}
.research-filters-toggle{
  display:inline-flex;
  align-items:center;
  gap:6px;
  margin:0;
  padding:0;
  border:0;
  background:none;
  color:var(--link, var(--accent, #6ea8ff));
  font:650 .86rem/1.2 Inter,ui-sans-serif,system-ui,sans-serif;
  letter-spacing:.01em;
  cursor:pointer;
  text-decoration:none;
}
.research-filters-toggle:hover,
.research-filters-toggle:focus-visible{text-decoration:underline}
.research-filters-toggle::after{
  content:"▸";
  font-size:.75em;
  color:var(--muted);
}
.research-filters-toggle[aria-expanded="true"]::after{content:"▾"}
.body-system-summary{
  padding:12px 20px 18px;
  border-bottom:1px solid var(--line);
  background:var(--surface);
}
.body-system-summary .section-kicker{margin:0 0 4px}
.body-system-summary h1{
  margin:0 0 10px;
  font:800 1.35rem/1.2 Inter,ui-sans-serif,system-ui,sans-serif;
  letter-spacing:-.02em;
}
.body-system-summary-organ{
  margin:0 0 10px;
  color:var(--muted);
  font-size:.86rem;
  font-weight:650;
}
.body-system-summary-blurb{
  margin:0 0 16px;
  color:var(--text);
  font-size:.95rem;
  line-height:1.55;
  max-width:40rem;
}
.body-system-summary-counts{
  list-style:none;
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin:0;
  padding:0;
}
.body-system-summary-counts li{
  display:flex;
  flex-direction:column;
  min-width:4.6rem;
  padding:8px 10px;
  border:1px solid var(--line);
  border-radius:12px;
  background:var(--surface-2, var(--bg));
}
.body-system-summary-counts b{font-size:1.05rem;font-variant-numeric:tabular-nums}
.body-system-summary-counts span{color:var(--muted);font-size:.7rem;font-weight:800;letter-spacing:.02em}
.body-system-summary-counts .is-harm b{color:var(--harm)}
.body-system-summary-counts .is-benefit b{color:var(--benefit)}
.body-system-summary-counts .is-mixed b{color:var(--mixed)}
.body-system-summary-counts .is-unclear b{color:var(--unclear)}
@media(max-width:760px){
  .body-system-summary{padding:16px 15px 14px}
  .body-system-summary h1{font-size:1.18rem}
  .body-system-summary-blurb{font-size:.9rem}
}
