/* Shared styles for the home, tools and packages pages.
   The About page keeps its own inline styles. */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #c9d0d9;
  --rule: #e4e8ee;
  --border-strong: #8d98a6;
  --accent: #1d5fb8;
  --accent-dark: #164a90;
  --accent-soft: #e8f0fb;
  --text: #1c2430;
  --muted: #4a5465;
  --faint: #636b79;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(28, 36, 48, 0.04);
  --shadow-hover: 0 4px 14px rgba(28, 36, 48, 0.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--accent);
}

a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  z-index: 10;
}

.skip-link:focus {
  top: 1rem;
}

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding-inline: 1.25rem;
}

/* ---------- Page headings ---------- */

.page-head {
  padding-block: 3rem 1.75rem;
}

.page-head h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.75rem, 1.4rem + 1.4vw, 2.375rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.page-head p {
  margin: 0;
  max-width: 60ch;
  color: var(--muted);
  font-size: 1.0625rem;
}

.page-main {
  padding-bottom: 4rem;
}

/* ---------- Home ---------- */

.home {
  /* Full screen minus the 61px site bar. */
  min-height: calc(100vh - 61px);
  min-height: calc(100svh - 61px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-block: 3.5rem 2.5rem;
}

.intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 3rem;
}

.intro-photo {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  object-fit: cover;
  margin-bottom: 1.25rem;
}

.intro h1 {
  margin: 0;
  font-size: clamp(2rem, 1.5rem + 2vw, 2.75rem);
  line-height: 1.1;
  letter-spacing: -0.025em;
}

.name-line {
  display: block;
  width: 180px;
  height: 12px;
  margin: 0.45rem auto 0.9rem;
  overflow: visible;
}

.name-line path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
}

.tagline {
  margin: 0 0 1.25rem;
  max-width: 40ch;
  color: var(--muted);
  font-size: 1.125rem;
  text-wrap: balance;
}

.social {
  display: flex;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, color 0.15s;
}

.social a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.social svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.5rem 1.5rem 1.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.tile:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-hover);
}

.tile-num {
  color: var(--muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.tile h2 {
  margin: 2.75rem 0 0.4rem;
  font-size: 1.5rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.tile p {
  margin: 0;
  color: var(--muted);
}

.tile {
  align-items: center;
  text-align: center;
}

.tile:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow-hover);
}

.tile-num {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
}

.tile-badge {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-top: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  transition: background 0.2s, color 0.2s;
}

.tile-badge:hover {
  background: var(--accent);
  color: var(--surface);
}

.tile-badge svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

.tile-badge svg.stroke {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tile h2 {
  margin-top: 1.25rem;
}

/* The title link covers the whole card; the badge sits above it. */
.tile-link {
  color: inherit;
  text-decoration: none;
}

.tile-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}

.tile-link:focus-visible {
  outline: none;
}

.tile-link:focus-visible::after {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.intro-scholar {
  display: block;
  width: 220px;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-hover);
}

.intro-scholar img {
  width: 100%;
  height: auto;
}

.tile-arrow {
  position: absolute;
  top: 1.35rem;
  right: 1.35rem;
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.tile-arrow svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}


/* ---------- Tools ---------- */
/* Each tool is a name over a rounded icon box, with a one-line description under the box. */

.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  color: var(--text);
  text-align: center;
  text-decoration: none;
}

.tool-name {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.3rem;
  min-height: 2.5em;
  margin: 0 0 0.6rem;
  font-size: 1.125rem;
  line-height: 1.25;
}

.tool-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 0 0.25rem;
  color: var(--text);
  transition: color 0.2s;
}

.tool-box svg {
  width: 46px;
  height: 46px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

a.tool:hover .tool-box,
a.tool:focus-visible .tool-box {
  color: var(--accent);
}

a.tool:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
  border-radius: 8px;
}

/* Marks a tool that is open to use while still under test. */
.tool-beta {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent-light, #e8f0fb);
  color: var(--accent);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
}

/* ssHelper shows a PubMed wordmark instead of a line icon. */
.tool-box svg.tool-wordmark {
  width: 110px;
  height: 46px;
  stroke: none;
  fill: currentColor;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tool-wordmark__b {
  fill: var(--accent);
}

/* Shaded area under the SD finder curve. */
.tool-shade {
  fill: currentColor;
  fill-opacity: 0.3;
  stroke: none;
}

.tool-desc {
  max-width: 26ch;
  margin: 0.7rem 0 0;
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.45;
}

/* Tools not yet available: muted icon, a tag under it. */
.tool-soon .tool-box {
  color: var(--muted);
}

.tool-soon-tag {
  padding: 0.2rem 0.65rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 650;
  white-space: nowrap;
}

/* ---------- Packages ---------- */

.pkg-list {
  display: grid;
  gap: 1.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-hover);
}

.card-shot {
  margin: 0;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.card-shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top left;
  transition: transform 0.5s var(--ease-out);
}

.card:hover .card-shot img {
  transform: scale(1.03);
}

.card-body {
  display: flex;
  flex-direction: column;
  padding: 2rem;
}

.card-kicker {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.card h2 {
  margin: 0 0 0.6rem;
  font-size: clamp(1.625rem, 1.3rem + 1vw, 2.125rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.card-desc {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 1.0625rem;
}

.card-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  align-self: flex-start;
  margin-top: auto;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}

.card-cta svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.card:hover .card-cta {
  background: var(--accent);
  color: #ffffff;
}

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

@media (max-width: 600px) {
  .tiles {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {

  .tool-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem 1rem;
  }

  .tile {
    min-height: 0;
  }

  .tile h2 {
    margin-top: 1.25rem;
  }

  .card {
    grid-template-columns: minmax(0, 1fr);
  }

  .card-shot {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .card-body {
    padding: 1.5rem;
  }
}

@media (max-width: 480px) {
  .home {
    padding-block: 2.5rem 2rem;
    justify-content: flex-start;
  }

  .intro {
    margin-bottom: 2rem;
  }

  .intro-photo {
    width: 104px;
    height: 104px;
  }

  .page-head {
    padding-block: 2rem 1.25rem;
  }

  .tool-name {
    font-size: 1rem;
  }

  .tool-box svg {
    width: 36px;
    height: 36px;
  }

  .tool-desc {
    font-size: 0.8125rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }

  .card:hover .card-shot img {
    transform: none;
  }
}

/* ---------- Packages: three cards side by side on wide screens ---------- */

@media (min-width: 900px) {
  .pkg-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
  }

  .pkg-list .card {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    height: 100%;
  }

  .pkg-list .card-shot {
    aspect-ratio: 16 / 10;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  /* Zoom into the top-left of the repository page so it stays legible at card width. */
  .pkg-list .card-shot img {
    width: 165%;
    max-width: none;
    height: auto;
  }

  .pkg-list .card-body {
    padding: 1.25rem 1.35rem 1.4rem;
  }

  .pkg-list .card h2 {
    font-size: 1.5rem;
  }

  .pkg-list .card-desc {
    font-size: 1rem;
  }
}

/* ---------- Phones: compact sizes across the site ---------- */

@media (max-width: 600px) {
  body {
    font-size: 0.9375rem;
  }

  .wrap {
    padding-inline: 1rem;
  }

  /* Home */
  .home {
    padding-block: 1.25rem 1.5rem;
  }

  .intro {
    margin-bottom: 1.25rem;
  }

  .intro-scholar {
    width: 150px;
    margin-bottom: 0.75rem;
    border-radius: 10px;
  }

  .intro h1 {
    font-size: 1.625rem;
  }

  .tagline {
    font-size: 0.9375rem;
  }

  .tiles {
    gap: 0.75rem;
  }

  .tile {
    padding: 0.9rem 1rem 1rem;
  }

  .tile-num {
    top: 0.9rem;
    left: 1rem;
    font-size: 0.75rem;
  }

  .tile-arrow {
    top: 0.85rem;
    right: 0.9rem;
    width: 20px;
    height: 20px;
  }

  .tile-badge {
    width: 42px;
    height: 42px;
    margin-top: 0.4rem;
  }

  .tile-badge svg {
    width: 20px;
    height: 20px;
  }

  .tile h2 {
    margin-top: 0.6rem;
    font-size: 1.125rem;
  }

  .tile p {
    font-size: 0.875rem;
  }

  /* Tools and packages */
  .page-head {
    padding-block: 1.25rem 0.9rem;
  }

  .page-head h1 {
    font-size: 1.5rem;
  }

  .page-head p {
    font-size: 0.9375rem;
  }

  .card-shot {
    aspect-ratio: 16 / 9;
  }

  .card-body {
    padding: 0.9rem 1rem 1rem;
  }

  .card-kicker {
    font-size: 0.6875rem;
    margin-bottom: 0.25rem;
  }

  .card h2 {
    font-size: 1.25rem;
    margin-bottom: 0.35rem;
  }

  .card-desc {
    font-size: 0.9375rem;
    margin-bottom: 0.9rem;
  }
}

/* ---------- Home cards: Scholar preview and quick links ---------- */

.tile {
  transform-origin: center;
}

.tile-badge {
  margin-top: 0.25rem;
}

.tile-stats {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin: 1rem 0 0;
}

.tile-stats div {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
}

.tile-stats dd {
  margin: 0;
  color: var(--accent-dark);
  font-size: 1.375rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.tile-stats dt {
  color: var(--muted);
  font-size: 0.75rem;
}

.tile-links {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 0.15rem;
  width: 100%;
  margin: 1rem 0 0;
  padding: 0.85rem 0 0;
  border-top: 1px solid var(--border);
  list-style: none;
  text-align: left;
}

.tile-links a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 32px;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9375rem;
  text-decoration: none;
}

.tile-links a::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.tile-links a:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.tile-soon {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.75rem;
}

@media (max-width: 600px) {
  .tile-stats {
    gap: 1.1rem;
    margin-top: 0.6rem;
  }

  .tile-stats dd {
    font-size: 1.125rem;
  }

  .tile-links {
    margin-top: 0.6rem;
    padding-top: 0.5rem;
  }

  .tile-links a {
    font-size: 0.875rem;
  }
}

/* ---------- Home profile: PubMed and Scholar side by side as the backdrop,
   photo and a bordered text card on top, centred on the seam ---------- */

.profile {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(52rem, 100%);
  height: 22rem;
  margin-bottom: 1.5rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.profile-pubmed,
.profile-scholar {
  display: block;
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
}

.profile-pubmed img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top left;
}

.profile-scholar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.25rem 0.5rem 0.5rem;
  border-left: 1px solid var(--border);
}

.profile-scholar img {
  width: 100%;
  height: auto;
}

/* The overlay lets clicks through to the two panels. */
.profile-card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  pointer-events: none;
}

.profile-photo {
  width: 150px;
  height: 150px;
  border: 4px solid var(--surface);
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 6px 20px rgba(28, 36, 48, 0.18);
}

.profile-text {
  max-width: 21rem;
  padding: 0.75rem 1.1rem 0.85rem;
  border: 1px solid var(--text);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(28, 36, 48, 0.12);
  text-align: center;
}

.profile-text h1 {
  margin: 0 0 0.3rem;
  font-size: 1.6rem;
  line-height: 1.1;
}

.profile-line {
  margin: 0;
  color: var(--text);
  font-size: 0.9375rem;
  line-height: 1.4;
}

.profile-line + .profile-line {
  margin-top: 0.2rem;
}

@media (max-width: 600px) {
  .profile {
    height: 19rem;
    margin-bottom: 1rem;
  }

  .profile-photo {
    width: 104px;
    height: 104px;
    border-width: 3px;
  }

  .profile-text {
    max-width: 16rem;
    padding: 0.55rem 0.8rem 0.65rem;
  }

  .profile-text h1 {
    font-size: 1.3rem;
  }

  .profile-line {
    font-size: 0.8125rem;
  }
}

/* ---------- Home cards: same width as the profile panel; aligned dividers ---------- */

.tiles {
  max-width: 52rem;
  margin-inline: auto;
}

@media (min-width: 861px) {
  /* Subgrid rows line the badge, title, text, stats and links up across the three cards,
     so every divider sits at the same height. */
  .tiles {
    row-gap: 0;
  }

  .tiles > li {
    display: grid;
    grid-row: span 5;
    grid-template-rows: subgrid;
  }

  .tile {
    grid-row: 1 / -1;
    display: grid;
    grid-template-rows: subgrid;
    justify-items: center;
    align-items: start;
    padding-inline: 1.1rem;
  }

  .tile-badge { grid-row: 1; }
  .tile h2 { grid-row: 2; }
  .tile > p { grid-row: 3; }
  .tile-stats { grid-row: 4; }

  .tile-links {
    grid-row: 5;
    align-self: start;
  }

  /* Row gap between the two rows (the subgrid keeps row-gap at 0 for its own tracks). */
  .tiles > li:nth-child(-n + 2) .tile {
    margin-bottom: 1.25rem;
  }
}

.tile-links a {
  white-space: nowrap;
}

.tile-soon {
  font-size: 0.6875rem;
}
.tiles > li,
.tile {
  min-width: 0;
}

/* Sub-items appear when the pointer rests on a card or a link in it has focus. Two-by-two
   grid keeps the row height, so nothing shifts; touch screens show the lists always. */
@media (hover: hover) and (min-width: 601px) {
  .tile {
    overflow: visible;
  }

  .tile-links {
    position: absolute;
    top: 100%;
    right: -1px;
    left: -1px;
    z-index: 5;
    margin: -1px 0 0;
    padding: 0.85rem 1.1rem 1rem;
    border: 1px solid var(--accent);
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-hover);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.2s var(--ease-out), transform 0.2s var(--ease-out), visibility 0s 0.2s;
  }

  .tile:hover,
  .tile:focus-within {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  .tile:hover .tile-links,
  .tile:focus-within .tile-links {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition-delay: 0s;
  }
}

/* The photo and text card stay above both screenshots. */
.profile-card {
  z-index: 2;
}


/* ---------- Calculator pages (static; no motion) ---------- */

.calc-page {
  max-width: 52rem;
  padding-bottom: 3rem;
}

.calc-back {
  margin: 1.25rem 0 0;
  font-size: 0.875rem;
}

.calc-panel {
  margin-top: 1.25rem;
  padding: 1.25rem 1.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.calc-h2 {
  margin: 0 0 0.9rem;
  font-size: 1.125rem;
}

.calc-desc {
  margin: -0.5rem 0 0.9rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.9rem 1rem;
}

.calc-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.calc-label {
  font-size: 0.875rem;
  font-weight: 600;
}

.calc-field input,
.calc-groups input {
  width: 100%;
  min-height: 40px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.calc-field input:focus-visible,
.calc-groups input:focus-visible,
.calc-button:focus-visible,
.calc-remove:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.calc-message {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

.calc-page [data-scenario] .calc-message {
  margin: 1rem 0 0;
}

.calc-message.is-warning {
  padding: 0.55rem 0.75rem;
  border: 1px solid #b45309;
  border-radius: 6px;
  background: #fff7ed;
  color: #7c2d12;
}

.calc-table-wrap {
  overflow-x: auto;
}

.calc-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.calc-table caption {
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: 0.8125rem;
  text-align: left;
}

.calc-table th,
.calc-table td {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  text-align: right;
}

.calc-table thead th {
  background: var(--bg);
  font-size: 0.8125rem;
  font-weight: 600;
}

.calc-table tbody th {
  text-align: left;
  font-weight: 600;
}

.confusion td {
  font-size: 1.125rem;
  font-weight: 600;
}

.confusion .cell-good {
  background: #eef6f0;
}

.confusion .cell-bad {
  background: #fbf0ee;
}

.confusion .calc-total td,
.confusion .calc-total th {
  background: var(--bg);
}

.calc-groups th,
.calc-groups td {
  padding: 0.35rem 0.45rem;
}

.calc-groups tbody th {
  width: 3.5rem;
  text-align: center;
}

.calc-button,
.calc-remove {
  min-height: 36px;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--surface);
  color: var(--accent-dark);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.calc-button {
  margin-top: 0.9rem;
}

.calc-button:hover,
.calc-remove:hover:not(:disabled) {
  background: var(--accent-soft);
}

.calc-remove {
  border-color: var(--border-strong);
  color: var(--text);
  font-weight: 500;
}

.calc-remove:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.calc-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 0;
}

.calc-stats div {
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.calc-stats dt {
  color: var(--muted);
  font-size: 0.8125rem;
}

.calc-stats dd {
  margin: 0.15rem 0 0;
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.calc-stats--big dd {
  color: var(--accent-dark);
  font-size: 1.5rem;
}

.calc-method {
  display: block;
  font-size: 0.75rem;
}

.calc-note {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

@media (max-width: 600px) {
  .calc-panel {
    padding: 0.9rem 0.9rem 1rem;
  }

  .calc-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
  }

  .calc-table th,
  .calc-table td {
    padding: 0.4rem 0.45rem;
  }

  .confusion td {
    font-size: 1rem;
  }

  .calc-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calc-stats--big dd {
    font-size: 1.25rem;
  }
}


.calc-stats + .calc-table-wrap {
  margin-top: 1.25rem;
}

[hidden] {
  display: none !important;
}

/* ---------- Diagnostic tree: total, then diseased / non-diseased, then TP FN TN FP ---------- */

.dt-tree {
  margin-top: 0.25rem;
}

.dt-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dt-row--4 .dt-box {
  margin-inline: 0.4rem;
}

.dt-row--1 .dt-box {
  grid-column: 2 / span 2;
}

.dt-row--2 .dt-box {
  grid-column: span 2;
  margin-inline: 8%;
}

.dt-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-height: 5rem;
  padding: 0.7rem 0.6rem;
  border: 2px solid var(--text);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.dt-label {
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.3;
}

.dt-label abbr {
  font-weight: 700;
  text-decoration: none;
}

.dt-value {
  color: var(--accent-dark);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.dt-box--good {
  background: #eef6f0;
}

.dt-box--bad {
  background: #fbf0ee;
}

.dt-branch {
  display: block;
  overflow: visible;
}

.dt-branch line {
  stroke: var(--text);
  stroke-width: 2;
}

#dt-arrow path {
  fill: var(--text);
}

@media (max-width: 600px) {
  .dt-row--4 .dt-box {
    margin-inline: 0.2rem;
  }

  .dt-row--2 .dt-box {
    margin-inline: 2%;
  }

  .dt-box {
    min-height: 4.25rem;
    padding: 0.5rem 0.3rem;
  }

  .dt-label {
    font-size: 0.75rem;
  }

  .dt-value {
    font-size: 1.125rem;
  }
}

.calc-actions {
  grid-column: 1 / -1;
}

.m2m-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.m2m-toolbar #m2m-copy {
  margin-left: auto;
}

.calc-status {
  min-height: 1.25rem;
  margin: 0.4rem 0 0;
  color: var(--accent-dark);
  font-size: 0.875rem;
  font-weight: 600;
}

@media (max-width: 600px) {
  .m2m-toolbar #m2m-copy {
    margin-left: 0;
  }
}

.calc-button--primary {
  margin-top: 0.25rem;
  background: var(--accent-dark);
  color: var(--surface);
  border-color: var(--accent-dark);
}

.calc-button--primary:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.dt-value.is-empty {
  color: var(--border-strong);
}

/* ---------- Median to mean: one table, intervention and control per study ---------- */

.calc-page--wide {
  max-width: 84rem;
}

.m2m-table {
  min-width: 64rem;
}

.m2m-table th,
.m2m-table td {
  padding: 0.3rem 0.25rem;
  text-align: center;
}

.m2m-table input {
  width: 100%;
  min-width: 3rem;
  min-height: 34px;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.m2m-table input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

.m2m-table .m2m-study {
  min-width: 7rem;
}

.m2m-optional {
  color: var(--muted);
  font-weight: 400;
}

.m2m-arm {
  font-size: 0.875rem !important;
  letter-spacing: 0.02em;
}

.m2m-arm--int {
  background: #e8f0fb !important;
}

.m2m-arm--ctl {
  background: #efeafb !important;
}

.m2m-out-h {
  background: #1c2430 !important;
  color: #ffffff;
}

.m2m-out {
  min-width: 4.4rem;
  background: #eef1f4;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.m2m-out output {
  display: block;
  font-size: 0.9375rem;
}

.m2m-flag {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.m2m-out.is-ok {
  background: #dcf1e2;
  color: #14532d;
}

.m2m-out.is-skewed {
  background: #fbdcd8;
  color: #7f1d1d;
}

.m2m-out.is-error {
  background: #fff4d6;
  color: #7c4a03;
}

.m2m-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.8125rem;
}

.m2m-legend li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.m2m-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
}

.m2m-swatch.is-ok {
  background: #dcf1e2;
  border: 1px solid #14532d;
}

.m2m-swatch.is-skewed {
  background: #fbdcd8;
  border: 1px solid #7f1d1d;
}


/* Keeps absolutely positioned hidden labels inside the scroll area. */
.calc-table-wrap {
  position: relative;
}

/* Sub-navigation jumps land below the pinned bars. */
.pkg-list > li,
[data-top] {
  scroll-margin-top: 112px;
}

/* Scholar counts: third line of the profile card. */
.profile-stats {
  margin-top: 0.45rem !important;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
}

.profile-stats strong {
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
}


@media (max-width: 600px) {
  .profile-stats {
    font-size: 0.75rem;
    white-space: nowrap;
  }
}

/* ---------- X-ray to volume registration (/3d/xvr/) ---------- */

.xvr-views {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 0 0 1rem;
}

.xvr-view {
  margin: 0;
}

.xvr-view canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #000;
}

.xvr-view figcaption {
  display: flex;
  flex-direction: column;
  margin-top: 0.45rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.xvr-view figcaption span {
  color: var(--muted);
  font-weight: 400;
}

.xvr-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.xvr-toolbar .calc-button {
  margin-top: 0;
  min-height: 40px;
}

.calc-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.xvr-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 1.5rem;
}

.xvr-h3 {
  margin: 0 0 0.6rem;
  font-size: 0.9375rem;
  letter-spacing: 0.01em;
}

.xvr-slider {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr) 4.5rem;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}

.xvr-slider label {
  font-size: 0.875rem;
}

.xvr-slider input[type="range"] {
  width: 100%;
  min-height: 24px;
  accent-color: var(--accent);
}

.xvr-slider input[type="range"]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.xvr-slider output {
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.xvr-stats {
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  margin-top: 0;
}

.xvr-plot-label {
  margin: 1rem 0 0.4rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.xvr-plot {
  display: block;
  width: 100%;
  height: 92px;
  border-radius: 6px;
  background: var(--bg);
}

.xvr-credits {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.9375rem;
}

.xvr-credits li + li {
  margin-top: 0.6rem;
}

/* The imaging index holds four cards: two by two, as on the home page. */
.tool-grid--quad {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 620px;
  margin-inline: auto;
}

@media (max-width: 860px) {
  .xvr-columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 600px) {
  .xvr-views {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
  }

  .xvr-slider {
    grid-template-columns: 7rem minmax(0, 1fr) 4rem;
    gap: 0.4rem;
  }
}

/* ---------- /3d/xvr/ step-by-step guide ---------- */

.xvr-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.xvr-step {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.xvr-step__num {
  color: var(--accent-dark);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.xvr-step svg {
  width: 100%;
  max-height: 84px;
  margin: 0.15rem 0 0.35rem;
  color: var(--accent-dark);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.xvr-step h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
}

.xvr-step p {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

/* ---------- /3d/xvr/ flowchart: a step and its sibling detail ---------- */

.xvr-flow-intro {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

.xvr-flow {
  margin: 0;
  padding: 0;
  list-style: none;
}

.xvr-flow__row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
  gap: 0.75rem 1.5rem;
  padding: 0 0 1.5rem 2.25rem;
}

/* The rule joining the steps, and the dot marking each one. Decorative. */
.xvr-flow__row::before {
  content: "";
  position: absolute;
  top: 1.35rem;
  bottom: 0;
  left: 0.42rem;
  width: 2px;
  background: var(--border);
}

.xvr-flow__row:last-child {
  padding-bottom: 0;
}

.xvr-flow__row:last-child::before {
  display: none;
}

.xvr-flow__row::after {
  content: "";
  position: absolute;
  top: 0.3rem;
  left: 0;
  width: 0.875rem;
  height: 0.875rem;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
}

.xvr-flow__num {
  display: block;
  margin-bottom: 0.15rem;
  color: var(--accent-dark);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.xvr-flow__step h3 {
  margin: 0 0 0.3rem;
  font-size: 1rem;
  line-height: 1.3;
}

.xvr-flow__step p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

.xvr-flow__detail {
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.xvr-flow__detail p {
  margin: 0;
  font-size: 0.9375rem;
}

.xvr-eq {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- /3d/xvr/ Colab ---------- */

.xvr-colab-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1.1rem 0 1.25rem;
}

.xvr-colab-cta .calc-button {
  display: inline-flex;
  align-items: center;
  margin-top: 0;
  min-height: 40px;
  text-decoration: none;
}

.xvr-colab-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.9375rem;
}

.xvr-colab-list li + li {
  margin-top: 0.5rem;
}

@media (max-width: 860px) {
  .xvr-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .xvr-flow__row {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.6rem;
  }
}

@media (max-width: 600px) {
  .xvr-steps {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
  }

  .xvr-step svg {
    max-height: 72px;
  }
}

/* The caveat after the flowchart needs air; it is not another step. */
.xvr-flow + .xvr-h3 {
  margin-top: 2rem;
}

/* ---------- /3d/xvr/ keeps every word of prose black ---------- */
/* Scoped to that page's <main>. Links and buttons keep the accent, so they
   still read as things you can act on. */

.xvr-black {
  color: #000;
}

.xvr-black .page-head p,
.xvr-black .calc-note,
.xvr-black .calc-status,
.xvr-black .calc-stats dt,
.xvr-black .xvr-view figcaption span,
.xvr-black .xvr-plot-label,
.xvr-black .xvr-flow-intro,
.xvr-black .xvr-flow__step p,
.xvr-black .xvr-flow__num,
.xvr-black .xvr-step p,
.xvr-black .xvr-step__num {
  color: #000;
}

.xvr-black a {
  color: var(--accent);
}

/* Anchors styled as buttons keep the button's own colours, not the link's. */
.xvr-black a.calc-button {
  color: var(--accent-dark);
}

.xvr-black a.calc-button--primary {
  color: var(--surface);
}

/* ---------- /3d/xvr/ FAQ: native details, so it works without JavaScript ---------- */

.xvr-faq {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.xvr-faq__item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.xvr-faq__item summary {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 44px;
  padding: 0.6rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

/* Hide the default triangle in both marker implementations. */
.xvr-faq__item summary::-webkit-details-marker {
  display: none;
}

.xvr-faq__item summary::marker {
  content: "";
}

/* A chevron that points right when shut and down when open. */
.xvr-faq__item summary::before {
  content: "";
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  margin-left: 0.15rem;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg);
  transition: transform 0.15s var(--ease-out);
}

.xvr-faq__item[open] summary::before {
  transform: rotate(45deg);
}

.xvr-faq__item summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

.xvr-faq__item p {
  margin: 0;
  padding: 0 0.9rem 0.9rem 2.1rem;
  font-size: 0.9375rem;
}

@media (prefers-reduced-motion: reduce) {
  .xvr-faq__item summary::before {
    transition: none;
  }
}

/* ---------- Study track (/study-track/) ---------- */

.st-page {
  max-width: 1240px;
}

.st-layout {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}

/* ----- Topic rail ----- */

.st-rail__inner {
  position: sticky;
  top: 5.25rem;
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
  padding: 0.9rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
}

.st-rail__head {
  margin: 0 0 0.5rem;
  padding-inline: 0.25rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.st-rail__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.st-rail__list a {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.3;
  text-decoration: none;
}

.st-rail__list a:hover {
  background: var(--accent-soft);
}

.st-rail__list a[aria-current] {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 600;
}

.st-rail__count {
  flex: none;
  min-width: 2.25rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.st-rail__list a[aria-current] .st-rail__count {
  background: var(--surface);
  color: var(--accent-dark);
}

.st-rail__note {
  margin: 0.75rem 0 0;
  padding: 0.6rem 0.5rem 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
}

/* ----- Filter bar ----- */

.st-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
  padding: 0 0 1rem;
  border-bottom: 1px solid var(--rule);
}

.st-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 9rem;
}

.st-field--grow {
  flex: 1 1 16rem;
}

.st-field label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.st-field input[type="search"],
.st-field select {
  min-height: 44px;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
}

.st-field input[type="search"]:focus-visible,
.st-field select:focus-visible,
.st-reset:focus-visible,
.st-play:focus-visible,
.st-chip:focus-visible,
.st-linkbtn:focus-visible,
.st-field--check input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.st-field--check {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  min-width: 0;
}

.st-field--check input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
}

.st-field--check label {
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.st-reset {
  min-height: 44px;
  padding: 0.45rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  cursor: pointer;
}

.st-reset:hover {
  background: var(--accent-soft);
}

.st-count {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.st-empty {
  margin: 2rem 0;
  color: var(--muted);
}

.st-linkbtn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* ----- Sections and cards ----- */

.st-section {
  padding-top: 1.75rem;
}

.st-section__head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
  margin: 0 0 0.9rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
  font-size: 1.1875rem;
  letter-spacing: -0.01em;
}

.st-section__count {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 400;
}

.st-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 0.9rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.st-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.9rem 1rem 1rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
}

.st-card--playing {
  grid-column: 1 / -1;
  border-color: var(--accent);
}

.st-card--playing .st-play {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.st-card__name {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
}

.st-card__meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.st-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.15rem 0 0;
}

.st-tag {
  color: var(--faint);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.st-tag--off {
  color: var(--faint);
  font-style: italic;
}

.st-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin: 0.5rem 0 0;
}

.st-play {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  min-height: 36px;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.st-play:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.st-play svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.st-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--accent);
  font-size: 0.8125rem;
  text-decoration: none;
}

.st-link:hover {
  background: var(--accent-soft);
}

.st-link--quiet {
  color: var(--accent-dark);
}

/* ----- In-card player ----- */

.st-player {
  margin-top: 0.75rem;
}

.st-player__frame {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 8px;
  background: #000000;
}

.st-player__frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.st-player__switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.5rem;
}

.st-chip {
  min-height: 32px;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.st-chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 600;
}

.st-player__close {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
}

.st-credit {
  margin: 3rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  max-width: 70ch;
  color: var(--muted);
  font-size: 0.8125rem;
}

/* Tablets and phones: the rail becomes a scrolling strip above the list. */
@media (max-width: 860px) {
  .st-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
  }

  .st-rail__inner {
    position: static;
    max-height: none;
    padding: 0.6rem 0.75rem;
  }

  .st-rail__list {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .st-rail__list li {
    flex: none;
  }

  .st-rail__list a {
    white-space: nowrap;
  }

  .st-rail__note {
    display: none;
  }

  .st-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* ---------------------------------------------------------------------------
   DICOM viewer, /imaging/viewer/
   The page chrome stays Warm Editorial; only the image stage goes dark, because
   that is the surface clinical imaging is read on and a light frame around a CT
   makes mid-grey soft tissue look washed out.
   --------------------------------------------------------------------------- */

/* Status is only present while loading or after a failure; a successful load hides it,
   because the overlay and the provenance line already say what is on screen. */
.dv-status {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.dv-status[hidden] {
  display: none;
}

.dv-status[data-kind='error'] {
  color: #8c1d16;
  font-weight: 600;
}

/* The window and view controls sit over the image, the way a reading workstation puts them
   there, so the eye never leaves the anatomy to change a window. They are a sibling of the
   frame rather than a child, because the frame clips its content and on a narrow screen the
   controls have to drop out and sit underneath instead. */
.dv-viewer {
  position: relative;
}

.dv-controls {
  position: absolute;
  z-index: 2;
  /* Along the bottom rather than the top: the top corners carry the patient and study
     lines, which are long, while the bottom corners hold short readouts, so this is the
     one edge where a centred bar does not cover text. */
  bottom: 0.55rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  align-items: center;
  justify-content: center;
  max-width: calc(100% - 1.5rem);
  padding: 0.4rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(14, 17, 22, 0.72);
  backdrop-filter: blur(6px);
}

.dv-group {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

.dv-group__label {
  color: rgba(233, 238, 245, 0.72);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.dv-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.dv-controls .dv-chip {
  min-height: 26px;
  padding: 0.22rem 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #eef3f9;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background-color 120ms var(--ease-out);
}

.dv-controls .dv-chip:hover {
  background: rgba(255, 255, 255, 0.2);
}

.dv-controls .dv-chip:focus-visible {
  outline: 2px solid #8ab4f8;
  outline-offset: 2px;
}

/* Below this width the bar would cover most of the image, so it returns to the page. */
@media (max-width: 860px) {
  .dv-controls {
    position: static;
    transform: none;
    gap: 0.5rem 1.2rem;
    justify-content: flex-start;
    max-width: none;
    margin-top: 0.6rem;
    padding: 0;
    border: 0;
    background: none;
    backdrop-filter: none;
  }

  .dv-group__label {
    color: var(--muted);
  }

  .dv-controls .dv-chip {
    min-height: 28px;
    border-color: var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
  }

  .dv-controls .dv-chip:hover {
    background: var(--accent-soft);
  }
}

.dv-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: min(72vh, 680px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #000;
}

/* Cornerstone sizes its canvas to this element, so it needs real dimensions before the
   viewport is enabled - a zero-height parent renders a blank black box. */
.dv-stage {
  width: 100%;
  height: 100%;
  background: #000;
  /* The right button zooms, so the browser menu must not open on top of it. */
  touch-action: none;
}

.dv-stage:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.dv-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: #e9eef5;
  font-size: 0.78rem;
  line-height: 1.45;
  /* Readable over both air and bone, without a panel that would hide anatomy. */
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  font-variant-numeric: tabular-nums;
}

.dv-overlay > div {
  position: absolute;
  display: flex;
  flex-direction: column;
  max-width: 42%;
}

.dv-overlay > div > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The bottom corners sit beside the control bar, so they are kept narrow enough to clear it. */
.dv-overlay__bl,
.dv-overlay__br {
  max-width: 24%;
}

@media (max-width: 860px) {
  .dv-overlay__bl,
  .dv-overlay__br {
    max-width: 42%;
  }
}

.dv-overlay b {
  font-weight: 600;
}

.dv-overlay__tl { top: 0.6rem; left: 0.75rem; }
.dv-overlay__tr { top: 0.6rem; right: 0.75rem; align-items: flex-end; text-align: right; }
.dv-overlay__bl { bottom: 0.6rem; left: 0.75rem; }
.dv-overlay__br { bottom: 0.6rem; right: 0.75rem; align-items: flex-end; text-align: right; }

.dv-hint {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.dv-credit {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.dv-credit:empty {
  display: none;
}

.dv-h2 {
  margin: 2rem 0 0.5rem;
  font-size: 1.15rem;
}

@media (max-width: 640px) {
  .dv-frame {
    height: min(58vh, 420px);
  }

  .dv-overlay {
    font-size: 0.72rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dv-chip {
    transition: none;
  }
}

/* ----- Lecture strip and the stage around the player ----- */

.st-strip {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  padding-bottom: 0.4rem;
  overflow-x: auto;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}

.st-lecture {
  position: relative;
  flex: none;
  width: 9.5rem;
  height: 8.6rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  scroll-snap-align: start;
  overflow: hidden;
}

.st-lecture:hover {
  border-color: var(--border-strong);
}

.st-lecture[aria-current] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.st-lecture img {
  width: 100%;
  height: 5.35rem;
  object-fit: cover;
  background: var(--bg);
}

.st-lecture__num {
  position: absolute;
  top: 0.3rem;
  left: 0.3rem;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  background: rgba(28, 36, 48, 0.82);
  color: #ffffff;
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
}

.st-lecture[aria-current] .st-lecture__num {
  background: var(--accent);
}

.st-lecture__name {
  display: block;
  height: 3.25rem;
  overflow: hidden;
  padding: 0.35rem 0.45rem 0.45rem;
  font-size: 0.75rem;
  line-height: 1.3;
}

.st-lecture[aria-current] .st-lecture__name {
  color: var(--accent-dark);
  font-weight: 600;
}

.st-now {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.st-stage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
}

.st-step {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.st-step:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.st-step:disabled {
  opacity: 0.35;
  cursor: default;
}

.st-step:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.st-step svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.st-lecture:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Phones: the step buttons move under the video so it keeps the full width. */
@media (max-width: 600px) {
  .st-stage {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .st-stage .st-player__frame {
    grid-column: 1 / -1;
    order: -1;
  }

  .st-step {
    width: 100%;
    border-radius: 8px;
  }

  .st-lecture {
    width: 8.5rem;
    height: 8.2rem;
  }
}

/* Four cascading pickers above the viewer: imaging type, region, finding, sequence. */

.dv-pickers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.6rem 0.9rem;
  margin-bottom: 0.9rem;
}

.dv-pick {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.dv-pick label {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.dv-pick select {
  width: 100%;
  min-height: 36px;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
}

.dv-pick select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* A level with only one option is shown rather than hidden, so the reader can see the
   choice exists and simply has one answer here. */
.dv-pick select:disabled {
  color: var(--muted);
  background: var(--bg);
  cursor: default;
}

.dv-provenance {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.dv-provenance:empty {
  display: none;
}


/* How-to cards under the viewer. Contents are rebuilt per modality, so the grid has to
   cope with four to six items without leaving a ragged last row. */

.dv-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem;
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
}

.dv-card {
  display: grid;
  grid-template-columns: 26px 1fr;
  grid-template-rows: auto auto;
  gap: 0.15rem 0.6rem;
  /* Cards in a row stretch to the tallest, so the rows are pinned to the top; otherwise a
     short card floats its body down the middle and the grid reads as ragged. */
  align-content: start;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dv-card svg {
  grid-row: 1 / span 2;
  width: 24px;
  height: 24px;
  margin-top: 0.1rem;
  color: var(--accent);
}

.dv-card h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.dv-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

@media (max-width: 640px) {
  .dv-cards {
    grid-template-columns: 1fr;
  }
}

/* ----- Imaging index: the groundwork line and the project rows ----- */

/* A labelled line, not a panel. PRODUCT.md names boxed hero blocks with a call-to-action
   button as an anti-reference, and on a phone the panel filled the screen. */
.ground {
  margin: 0 0 2.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--rule);
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--faint);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ground__line {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  line-height: 1.5;
}

.ground__line a {
  font-weight: 600;
}

.ground__topics {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.ground__topics a {
  color: var(--accent);
  text-decoration-color: var(--border);
}

.ground__topics a:hover {
  color: var(--accent-dark);
  text-decoration-color: currentColor;
}

/* ----- Project rows ----- */

.proj {
  display: flex;
  flex-direction: column;
}

/* ----- Project groups -----
   Three named columns, one per field. Inside a column the projects stack, so the
   subgrid band alignment above does not apply here: each card is a plain flex column
   and the rhythm comes from the margin under its material list. */
.proj-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: 2.5rem;
  row-gap: 2.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.proj-group__title {
  margin: 0 0 1.1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.proj-group__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The last card in a column has nothing under it, so its material list drops the
   separating margin and the three columns end on a level base. */
.proj-group__list > .proj:last-child .proj__needs,
.proj-group__list > .proj:last-child .proj__none {
  margin-bottom: 0;
}

@media (max-width: 900px) {
  .proj-groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .proj-groups {
    grid-template-columns: minmax(0, 1fr);
    column-gap: 0;
    row-gap: 2rem;
  }
}

/* The icon hangs in the margin rather than sitting in the flow, so a title that wraps
   to two lines does not leave it stranded on a line of its own. */
.proj__head {
  position: relative;
  align-self: start;
  margin: 0 0 0.35rem;
  padding-left: 1.9rem;
  font-size: 1.0625rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.proj__head a {
  color: var(--accent);
  text-decoration: none;
}

.proj__head a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Status reads as a word, not a badge: one small capitalised label, no pill, no fill. */
.proj__status {
  align-self: start;
  margin: 0 0 0.3rem;
  color: var(--faint);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.proj__status--live {
  color: var(--accent-dark);
}

.proj__desc {
  align-self: start;
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.proj__needs {
  align-self: start;
  margin: 0 0 2.5rem;
  padding: 0.7rem 0 0;
  border-top: 1px solid var(--rule);
  list-style: none;
}

.proj__needs li {
  margin-bottom: 0.45rem;
  font-size: 0.875rem;
  line-height: 1.45;
}

.proj__needs li:last-child {
  margin-bottom: 0;
}

/* The lecture is the link; the reason sits under it in grey, so neither fights the other. */
.proj__needs a {
  display: block;
  color: var(--accent);
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
}

.proj__needs a:hover {
  color: var(--accent-dark);
  text-decoration-color: currentColor;
}

.proj__why {
  display: block;
  color: var(--muted);
  font-size: 0.8125rem;
}

.proj__none {
  align-self: start;
  margin: 0 0 2.5rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

@media (max-width: 600px) {
  .ground {
    margin-bottom: 1.75rem;
  }
}

/* The imaging intro and groundwork run the full column rather than the 60ch
   measure the other pages use, so the sentence is not broken up early. */
.imaging-page .page-head p {
  max-width: none;
}

/* The project icon, kept from the card layout and set beside the title. */
.proj__icon {
  position: absolute;
  left: 0;
  top: 0.1em;
  width: 22px;
  height: 22px;
  color: var(--faint);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.proj:hover .proj__icon {
  color: var(--accent);
}

/* Loading bar for the slice prefetch. It sits above the image rather than over it: the
   corner readouts and the control bar already occupy the edges inside the frame. */

.dv-progress {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin: 0 0 0.6rem;
}

.dv-progress[hidden] {
  display: none;
}

.dv-progress__track {
  position: relative;
  flex: 1;
  overflow: hidden;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
}

.dv-progress__fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 180ms var(--ease-out);
}

.dv-progress[data-state='complete'] .dv-progress__fill {
  background: #2f7d4f;
}

.dv-progress__text {
  min-width: 15ch;
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .dv-progress__fill {
    transition: none;
  }
}
