/* 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);

  /* Motion. A spring has no duration: response is how fast it reaches the target, and
     the easings below are sampled springs, so CSS motion settles the way the JS springs
     in /js/motion.js do. --ease-spring is critically damped (no overshoot) and is the
     default for anything the pointer did not throw; --ease-spring-bounce overshoots a
     little and is reserved for motion that follows a flick or a drag release. */
  --resp-press: 100ms;
  --resp-fast: 180ms;
  --resp: 300ms;
  --resp-slow: 400ms;
  --ease-spring: linear(0, 0.0902, 0.2642, 0.4422, 0.594, 0.7127, 0.8009, 0.8641, 0.9084, 0.9389, 0.9596, 0.9734, 0.9826, 0.9887, 0.9927, 0.9953, 1);
  --ease-spring-bounce: linear(0, 0.1182, 0.3674, 0.6317, 0.8475, 0.9921, 1.0689, 1.0942, 1.0873, 1.0651, 1.0397, 1.018, 1.0029, 0.9945, 0.9912, 0.9914, 0.9934, 0.9958, 0.9979, 0.9995, 1.0004, 1.0008, 1);
  --press-scale: 0.975;
  --press-scale-sm: 0.94;

  /* Materials. Translucent chrome floats over the content instead of taking a strip of
     it; the frosted fallback keeps the same geometry when transparency is turned down. */
  --chrome: rgba(255, 255, 255, 0.72);
  --chrome-strong: rgba(255, 255, 255, 0.82);
  --chrome-blur: blur(20px) saturate(180%);
  --chrome-edge: rgba(255, 255, 255, 0.6);
}

*,
*::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: 1340px;
  margin: 0 auto;
  padding-inline: 1.25rem;
}

/* Kept so the viewer pages, which ask for it by name, still line up with everything
   else now that one measure serves the whole site. */
.wrap--wide {
  max-width: 1340px;
}

/* ---------- 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;
  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;
  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 {
  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;
}

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

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

/* ---------- 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 and stats up across the three cards,
     so every card keeps the same inner rhythm. */
  .tiles {
    row-gap: 0;
  }

  .tiles > li {
    display: grid;
    grid-row: span 4;
    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; }

  /* 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;
  }
}

.tiles > li,
.tile {
  min-width: 0;
}

/* 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;
  }
}

/* ---------- 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);
  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%);
  /* Without this the bar is shrink-wrapped into the space from the 50% offset to the right
     edge, so it can never be wider than half the frame and wraps into a tall block that
     covers the image. max-content lets it use the full width up to max-width instead. */
  width: max-content;
  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.
   It also stops being a bar: a label beside a group of chips that wraps onto three rows
   reads as debris. Each group becomes its own block with the label above its buttons. */
@media (max-width: 860px) {
  .dv-controls {
    position: static;
    width: auto;
    transform: none;
    flex-direction: column;
    gap: 0.7rem;
    align-items: stretch;
    justify-content: flex-start;
    max-width: none;
    margin-top: 0.6rem;
    padding: 0;
    border: 0;
    background: none;
    backdrop-filter: none;
  }

  .dv-group {
    flex-direction: column;
    gap: 0.3rem;
    align-items: stretch;
  }

  .dv-controls .dv-chips {
    gap: 0.35rem;
  }

  /* Full-height targets, since a thumb is not a mouse pointer. */
  .dv-controls .dv-chip {
    min-height: 34px;
    padding: 0.35rem 0.75rem;
  }

  .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;
}


/* ----- Viewer and its instructions, side by side -----
   The how-to sits beside the image rather than under it, so it is readable while the
   image is in use rather than after a scroll. Making room for a rail inside the 1080px
   measure would cost the image a third of its width, so the block breaks out of the
   column and runs as wide as the window allows. */
.dv-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18rem;
  gap: 1.25rem;
  align-items: stretch;
}

/* The rail is one column tall: its cards share whatever height the image column takes,
   so the last card ends on the same line as the viewer rather than above or below it. */
.dv-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.dv-side__title {
  margin-top: 0;
}


/* One per row in the rail, and no trailing margin: the rail ends where the image does. */
.dv-side .dv-cards {
  flex: 1;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-rows: 1fr;
  gap: 0.5rem;
  margin-bottom: 0;
}

/* Below this the rail would squeeze both itself and the image, so it goes back under. */
@media (max-width: 900px) {
  .dv-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .dv-side__title {
    margin-top: 2rem;
  }

  .dv-side .dv-cards {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    grid-auto-rows: auto;
  }
}

/* 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.1rem 0.55rem;
  /* 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.55rem 0.7rem;
  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.9rem;
  font-weight: 600;
}

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

@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, with the projects stacked inside each one.

   The whole block is a single row grid: title, group note, then four bands per project
   (status, title, description, material). Every level below re-exposes those rows with
   subgrid, so the nth project in one column takes its band heights from the nth project
   in the others and the rules under the descriptions line up across all three. Row gap
   stays zero, because a subgrid inherits the parent gutter between its own bands; the
   rhythm comes from the margins under the material lists instead.

   Row count below is 2 + 4 x the longest column (four projects), so it needs updating
   when a column grows past four. */
.proj-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(18, auto);
  column-gap: 2.5rem;
  row-gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 901px) {
@supports (grid-template-rows: subgrid) {
  .proj-group {
    display: grid;
    grid-row: 1 / -1;
    grid-template-rows: subgrid;
  }

  .proj-group__title {
    grid-row: 1;
  }

  .proj-group__note {
    grid-row: 2;
  }

  .proj-group__list {
    display: grid;
    grid-row: 3 / -1;
    grid-template-rows: subgrid;
  }

  .proj-group__list > .proj {
    display: grid;
    grid-row: span 4;
    grid-template-rows: subgrid;
  }

  .proj-group__list > .proj > * {
    align-self: start;
  }
}
}

.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(--text);
}

.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));
    grid-template-rows: none;
    row-gap: 2.5rem;
  }
}

@media (max-width: 600px) {
  .proj-groups {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    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(--text);
}

.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;
}

/* Every run of prose on this page reads in the body colour rather than the greys the
   rest of the site uses for supporting text. Links keep the accent. */
.imaging-page,
.imaging-page .eyebrow,
.imaging-page .page-head p,
.imaging-page .ground__line,
.imaging-page .proj__status,
.imaging-page .proj__desc,
.imaging-page .proj__why,
.imaging-page .proj__none {
  color: var(--text);
}

/* 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;
  }
}

/* Modality-specific readouts, shown under the date in the top-right corner of the image. */
.dv-overlay__extra {
  display: flex;
  flex-direction: column;
  margin-top: 0.3rem;
  opacity: 0.85;
}

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

/* One line explaining what is peculiar about this modality, under the image. */
.dv-modality-note {
  margin: 0.4rem 0 0;
  max-width: 68ch;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.dv-modality-note:empty {
  display: none;
}

.proj-group__note {
  margin: -0.2rem 0 0.7rem;
  color: var(--text);
  font-size: 0.85rem;
}

/* Identify a structure: box over the image, explanation beside it.
   The masks are published segmentations extracted offline, not drawn by the page. */

.dv-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20rem;
  gap: 1rem;
  align-items: start;
}

/* The highlight of whatever was named. It never takes pointer events: the drag layer above
   it does that, and only while the tool is on. */
.dv-seg-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.dv-seg-layer {
  position: absolute;
  inset: 0;
  cursor: crosshair;
  touch-action: none;
}

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

.dv-seg-box {
  position: absolute;
  border: 1px dashed rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.12);
  pointer-events: none;
}

.dv-chip--on {
  border-color: var(--accent) !important;
  background: var(--accent) !important;
  color: #fff !important;
}

.dv-seg-panel {
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.dv-seg-panel__title {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.dv-seg-panel h3 {
  margin: 0 0 0.3rem;
  font-size: 1.05rem;
}

.dv-seg-panel p {
  margin: 0 0 0.6rem;
  font-size: 0.86rem;
  line-height: 1.5;
}

/* Lesion and normal are the first thing to read, so they are a badge rather than a sentence. */
.dv-seg-kind {
  display: inline-block;
  margin-bottom: 0.6rem !important;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.dv-seg-kind[data-kind='lesion'] {
  background: #fdecea;
  color: #8c1d16;
}

.dv-seg-kind[data-kind='normal'] {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.dv-seg-also,
.dv-seg-source,
.dv-seg-none {
  color: var(--muted);
  font-size: 0.78rem !important;
}

.dv-seg-source {
  margin-bottom: 0 !important;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

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

.dv-seg-hint:empty {
  display: none;
}

/* Below this width the panel goes under the image rather than beside it. */
@media (max-width: 1000px) {
  .dv-workspace {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* The control bar floats over the image, so its own box must not intercept drags meant for
   the picture underneath. Only the controls themselves take pointer events; the gaps between
   them, and the padding around them, stay transparent to the image. */
.dv-controls {
  pointer-events: none;
}

.dv-controls > * {
  pointer-events: auto;
}

.dv-seg-list {
  margin: 0.4rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.3rem;
}

.dv-seg-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: space-between;
}

/* ---------- Study track: the screen, and the topic level ---------- */

/* The screen holds the only player on the page. Sticky rather than scrolling away, because
   the whole point of the level-by-level catalogue underneath is that picking the next thing
   leaves the thing being watched exactly where it was. */
.st-screen {
  position: sticky;
  top: 0;
  z-index: 3;
  margin-bottom: 1.25rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.st-screen__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.3rem 0.75rem;
  margin-bottom: 0.6rem;
}

.st-screen__name {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.3;
}

.st-screen__meta {
  grid-column: 1;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.st-screen__close {
  grid-column: 2;
  grid-row: 1;
}

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

.st-topic {
  width: 100%;
  min-height: 3.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms var(--ease-out), transform 120ms var(--ease-out);
}

.st-topic:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

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

.st-topic__name {
  font-weight: 600;
  line-height: 1.3;
}

.st-topic__count {
  color: var(--muted);
  font-size: 0.82rem;
}

.st-level {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.9rem;
  margin-bottom: 0.9rem;
}

.st-level__title {
  margin: 0;
  font-size: 1.15rem;
}

.st-level__title:focus {
  outline: none;
}

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

.st-back {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 24px;
  padding: 0.2rem 0.5rem 0.2rem 0.25rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.st-back svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.st-back:hover {
  border-color: var(--accent);
}

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

@media (max-width: 860px) {
  /* On a phone a sticky screen would eat the catalogue it is meant to serve. */
  .st-screen {
    position: static;
  }

  .st-topics {
    grid-template-columns: 1fr;
  }
}

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

  .st-topic:hover {
    transform: none;
  }
}

/* ---------- Questions block, used on every project and tool page ----------
   An explainer written as paragraphs is read by nobody: it is a wall under the thing the
   reader came for. The same material as questions lets them take the one they have. Each
   row runs the full width of the page, and js/faq.js keeps one open at a time. */

.faq {
  margin: 2rem 0 0;
  border-top: 1px solid var(--border);
}

.faq > h2 {
  margin-top: 1.5rem;
}

.faq__lead {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.faq__item {
  border-bottom: 1px solid var(--border);
}

.faq__item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 44px;
  padding: 0.7rem 0.2rem;
  color: var(--text);
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.faq__item summary::-webkit-details-marker {
  display: none;
}

/* A plus that becomes a minus, so the state is readable without relying on the arrow
   the browser would otherwise draw at a different place on every platform. */
.faq__item summary::after {
  content: "+";
  flex: none;
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 400;
  line-height: 1;
}

.faq__item[open] summary::after {
  content: "−";
}

.faq__item summary:hover {
  color: var(--accent-dark);
}

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

.faq__body {
  padding: 0 0.2rem 1rem;
}

.faq__body p {
  margin: 0 0 0.75rem;
}

.faq__body p:last-child {
  margin-bottom: 0;
}

/* ---------- The viewers hub ---------- */

/* Not a card grid. Five rows, read top to bottom like an index: what the viewer is, what
   it does differently, and how much is actually in it. The counts come from the same
   index the viewers read, so the page cannot promise a series that is not there. */

.pick {
  margin: 0 0 2.5rem;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--border);
}

.pick li {
  border-bottom: 1px solid var(--border);
}

.pick__row {
  display: grid;
  grid-template-columns: 2rem minmax(7rem, 10rem) minmax(0, 1fr) auto 1.5rem;
  align-items: center;
  gap: 0 1.25rem;
  padding: 1.1rem 0.4rem;
  color: inherit;
  text-decoration: none;
  transition: background-color 120ms var(--ease-out), padding-left 120ms var(--ease-out);
}

.pick__row:hover {
  background: var(--accent-soft);
  padding-left: 0.9rem;
}

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

.pick__icon {
  width: 1.75rem;
  height: 1.75rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--accent);
}

.pick__name {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.pick__what {
  color: var(--muted);
  font-size: 0.95rem;
}

.pick__facts {
  color: var(--faint);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pick__facts b {
  color: var(--text);
  font-weight: 600;
}

/* A dot between the count and the regions, so the two facts do not run together. */
.pick__sep::before {
  content: "·";
  padding: 0 0.45rem;
}

.pick__go {
  justify-self: end;
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--faint);
  transition: transform 120ms var(--ease-out), color 120ms var(--ease-out);
}

.pick__row:hover .pick__go {
  color: var(--accent);
  transform: translateX(3px);
}

/* The combined viewer is the floor of the list, not a fifth sibling: it holds everything
   the four above it split up, so it carries the accent and sits apart. */
.pick__row--all {
  background: var(--surface);
}

.pick__row--all .pick__name {
  color: var(--accent-dark);
}

/* Phones: the row folds into a block, with the icon and the name on one line. */
@media (max-width: 760px) {
  .pick__row {
    grid-template-columns: 2rem minmax(0, 1fr) 1.25rem;
    gap: 0.3rem 0.9rem;
    padding: 0.95rem 0.4rem;
  }

  .pick__name {
    font-size: 1.1rem;
  }

  .pick__what,
  .pick__facts {
    grid-column: 2 / -1;
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pick__row,
  .pick__go {
    transition: none;
  }

  .pick__row:hover {
    padding-left: 0.4rem;
  }

  .pick__row:hover .pick__go {
    transform: none;
  }
}

/* ===========================================================================
   Apple-design pass
   Response, materials, type metrics and the three preference signals. The rules
   live at the end of the file so they settle the question wherever an older rule
   said something softer. Ordered the way the skill is: response first, then
   materials, then type, then preferences.
   =========================================================================== */

/* ----- 1. Response: feedback belongs on the press, not the release -----
   Every surface that can be pressed answers on pointer-down, in 100ms, with a
   transform only, so the compositor carries it. */

.tile,
.card,
a.tool,
.tile-badge,
.card-cta,
.social a,
.pkg-cta,
.btn,
button,
summary {
  touch-action: manipulation;
}

.tile:active,
.card:active,
a.tool:active {
  transform: scale(var(--press-scale));
  transition: transform var(--resp-press) var(--ease-spring);
}

.tile-badge:active,
.card-cta:active,
.social a:active,
.site-bar__social a:active,
.site-bar__links a:active {
  transform: scale(var(--press-scale-sm));
  transition: transform var(--resp-press) var(--ease-spring);
}

/* The press has to beat the hover growth the tile is already running, so the
   hover scale from /js/home.js is overridden by a transform of equal weight. */
.tile[data-tile]:active {
  transform: scale(0.99);
}

/* Hovers and state changes settle on a spring rather than a flat curve. */
.tile,
.card,
.social a,
.card-cta,
.tile-badge,
.tool-box {
  transition-timing-function: var(--ease-spring);
  transition-duration: var(--resp-fast);
}

/* The screenshot zoom is a slow reveal, not a response: it keeps its own pace. */
.card-shot img {
  transition: transform var(--resp-slow) var(--ease-spring);
}

/* ----- 9. Boundaries rubber-band instead of stopping hard -----
   The horizontal strips (bar links, sub-bar, topic rails) are native scrollers,
   so the browser's own overscroll is the rubber band; it is kept inside the
   strip rather than handed to the page. */

.site-bar__links,
.site-subnav__links,
.scroll-strip {
  overscroll-behavior-inline: contain;
}

/* ----- 12. Scroll edge effect, not a hard divider -----
   Where a strip scrolls out of view the content fades instead of being cut by an
   edge, and the fade only exists on the side that still has content. */

.site-bar__links[data-overflow],
.site-subnav__links[data-overflow],
.st-rail__list[data-overflow],
.st-strip[data-overflow] {
  /* The fade exists per side, and only on a side that is still hiding something:
     at the left end of a strip there is nothing to the left to suggest. */
  --edge-start: 0px;
  --edge-end: 0px;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--edge-start),
    #000 calc(100% - var(--edge-end)), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 var(--edge-start),
    #000 calc(100% - var(--edge-end)), transparent 100%);
}

[data-overflow][data-fade-start] {
  --edge-start: 1.25rem;
}

[data-overflow][data-fade-end] {
  --edge-end: 1.25rem;
}

/* ----- 15. Typography: tracking and leading are size-specific -----
   Large text reads too loose as it grows, so it is tightened; small text needs a
   little more room. Nothing here is one value for all sizes. */

html {
  font-optical-sizing: auto;
}

body {
  letter-spacing: 0;
}

h1 {
  letter-spacing: -0.025em;
}

h2 {
  letter-spacing: -0.015em;
}

h3 {
  letter-spacing: -0.01em;
}

.tool-desc,
.tile p,
.pkg-note,
.card-kicker {
  letter-spacing: 0.005em;
}

/* Spacing in em so a larger text setting moves the layout with the text. */
.tile h2 {
  line-height: 1.18;
}

.page-head h1 {
  line-height: 1.1;
}

/* ----- 14. Reduced motion: a gentler equivalent, not silence -----
   Transforms and overshoot go; the colour and border feedback stays, so a press
   still answers. */

@media (prefers-reduced-motion: reduce) {
  .tile:active,
  .card:active,
  a.tool:active,
  .tile[data-tile]:active,
  .tile-badge:active,
  .card-cta:active,
  .social a:active,
  .site-bar__social a:active,
  .site-bar__links a:active {
    transform: none;
  }

  .tile:active,
  .card:active,
  a.tool:active {
    border-color: var(--accent);
    background: var(--accent-soft);
  }
}

/* ----- Reduced transparency: frostier, not blurrier ----- */

@media (prefers-reduced-transparency: reduce) {
  :root {
    --chrome: var(--surface);
    --chrome-strong: var(--surface);
    --chrome-blur: none;
    --chrome-edge: var(--border);
  }
}

/* ----- More contrast: near-solid surfaces with a defined border ----- */

@media (prefers-contrast: more) {
  :root {
    --chrome: var(--surface);
    --chrome-strong: var(--surface);
    --chrome-blur: none;
    --border: #5c6675;
    --muted: #333c4a;
    --faint: #3c4452;
  }

  .tile,
  .card,
  .tool-soon-tag {
    border-width: 2px;
  }
}

/* ===========================================================================
   Apple-design pass, page level
   The surfaces that are not shared: the viewer's controls, the two FAQ
   disclosures, the study-track rails and the calculator buttons.
   =========================================================================== */

/* ----- Response on every page's own controls ----- */

.dv-chip,
.dv-pick select,
.st-linkbtn,
.st-reset,
.calc-button,
.faq__item summary {
  touch-action: manipulation;
}

.dv-chip:active,
.st-linkbtn:active,
.st-reset:active,
.calc-button:active {
  transform: scale(0.96);
  transition: transform var(--resp-press) var(--ease-spring);
}

/* A disclosure row is wide, so it answers with the row's own tint rather than a
   scale that would read as the whole page moving. */
.faq__item summary:active {
  background: var(--accent-soft);
}

/* ----- The disclosures open as a height, not as a jump -----
   Only where the browser can interpolate to a keyword height; elsewhere the
   native open/close stands, which is the correct degradation for a detail that
   is pure craft. */

@supports (interpolate-size: allow-keywords) and selector(::details-content) {
  .faq__item {
    interpolate-size: allow-keywords;
  }

  .faq__item::details-content {
    overflow: clip;
    block-size: 0;
    opacity: 0;
    transition: block-size 260ms var(--ease-spring), opacity 160ms var(--ease-spring),
      content-visibility 260ms allow-discrete;
  }

  .faq__item[open]::details-content {
    block-size: auto;
    opacity: 1;
  }

  @media (prefers-reduced-motion: reduce) {
    .faq__item::details-content {
      transition: opacity 140ms linear;
      block-size: auto;
    }
  }
}

/* ----- Rails: the overscroll stays in the rail, and the ends fade where there
   is more to reach. /js/chrome.js stamps data-overflow only when a strip really
   overflows, so a short rail has no fade to explain. ----- */

.st-rail__list,
.st-strip {
  overscroll-behavior-inline: contain;
}

/* The rails use the same per-side fade as the bars; see the shared rule above. */

/* ----- The viewer's control bar is chrome over an image, so it is a material
   too: it floats on the image instead of taking a strip of it. ----- */

.dv-overlay__tl,
.dv-overlay__tr,
.dv-overlay__bl,
.dv-overlay__br {
  letter-spacing: 0.01em;
}

@media (prefers-reduced-transparency: reduce) {
  .dv-controls {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* ---------- Congenital heart: two studies read against each other ---------- */

.chd-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
  align-items: start;
}

/* Each modality is a section of its own, so the two pairs do not read as four viewers. */
.chd-modality {
  margin: 2.5rem 0 0.2rem;
  font-size: 1.45rem;
  letter-spacing: -0.015em;
}

.chd-modality:first-of-type {
  margin-top: 0;
}

.chd-modality__note {
  margin: 0 0 1.1rem;
  max-width: 78ch;
  color: var(--muted);
  font-size: 0.9rem;
}

.chd-side__title {
  font-size: 1.1rem;
}

.chd-side__title {
  margin: 0 0 0.6rem;
}

/* The case number is part of the title rather than a line under it: it identifies the study,
   it is not a second thought about it. */
.chd-side__id {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 400;
}

/* Side by side each frame has half the width, so the tall single-viewer height would leave
   the image floating in black. */
.chd-side .dv-frame {
  height: min(52vh, 460px);
}

/* ----- The named structure, over the top of its own image ----- */

.chd-readout {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 3;
  padding: 0.7rem 0.9rem 0.75rem;
  /* A flat scrim behind the text rather than a gradient through it: a gradient had already
     faded by the last line, which then sat on bright lung and could not be read. The fade
     is moved below the block, where there is no text to lose. */
  background: rgb(0 0 0 / 0.8);
  color: #fff;
  /* The identify layer underneath has to keep receiving drags. */
  pointer-events: none;
}

.chd-readout::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  height: 1.75rem;
  background: linear-gradient(to bottom, rgb(0 0 0 / 0.8), rgb(0 0 0 / 0));
}

.chd-readout__name {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.chd-readout__what {
  margin: 0;
  max-width: 52ch;
  font-size: 0.8rem;
  line-height: 1.45;
  color: rgb(255 255 255 / 0.88);
}

.chd-readout__note {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: rgb(255 255 255 / 0.7);
}

/* The corner caption and the readout occupy the same corner, so the caption steps aside
   while something is named. */
.chd-frame--named .dv-overlay__tl {
  opacity: 0;
}

/* The single-viewer page floats its controls over the image. Here they sit under it, so that
   the half width left to each study goes on anatomy rather than on chips. */
.dv-controls--static {
  position: static;
  transform: none;
  width: auto;
  max-width: none;
  margin-top: 0.5rem;
  border-color: var(--border);
  background: var(--surface);
  backdrop-filter: none;
}

.dv-controls--static .dv-group__label,
.dv-controls--static .dv-chip {
  color: inherit;
}

.dv-controls--static .dv-chip {
  border-color: var(--border);
  background: transparent;
}

.dv-controls--static .dv-chip:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* ----- One toolbar above the pair ----- */

/* The toolbar above the pair is a bar, not a floating pill: it runs the full measure, its
   groups read from the left, and the 999px radius that suits a one-line pill is dropped so
   that a wrapped bar does not bulge into an oval. */
.dv-controls--shared {
  width: 100%;
  max-width: none;
  margin: 1rem 0 0;
  justify-content: flex-start;
  gap: 0.5rem 1.6rem;
  padding: 0.6rem 0.9rem;
  border-radius: 14px;
}

.chd-hint {
  margin: 0.65rem 0 0;
  max-width: 72ch;
  color: var(--muted);
  font-size: 0.85rem;
}


@media (max-width: 1000px) {
  /* Two half-width viewers are unreadable on a phone, so they stack and each takes the full
     width instead. */
  .chd-pair {
    grid-template-columns: minmax(0, 1fr);
  }

  .chd-side .dv-frame {
    height: min(58vh, 420px);
  }
}


/* ---------------------------------------------------------------------------
   Risk of bias visualiser (/tools/robvis/). A four-step wizard, a matrix of
   studies against signalling questions, and the traffic light figure.
   --------------------------------------------------------------------------- */

.rv-stepper-wrap {
  margin-top: 1.25rem;
}

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

.rv-step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--resp-fast) var(--ease-spring), color var(--resp-fast) var(--ease-spring);
}

.rv-step__n {
  display: grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  background: var(--bg);
  font-size: 0.75rem;
  font-weight: 600;
}

.rv-step.is-current {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.rv-step.is-current .rv-step__n {
  background: var(--accent);
  color: #fff;
}

.rv-step.is-locked {
  opacity: 0.55;
  cursor: not-allowed;
}

.rv-resume {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.rv-resume p {
  margin: 0;
  font-size: 0.9rem;
}

.rv-resume__actions {
  display: flex;
  gap: 0.5rem;
}

.rv-resume__actions .calc-button {
  margin-top: 0;
}

/* Step 1: the instrument cards. */

.rv-instruments {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0.85rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.rv-pick {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
  height: 100%;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: border-color var(--resp-fast) var(--ease-spring), box-shadow var(--resp-fast) var(--ease-spring);
}

.rv-pick:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-hover);
}

.rv-pick.is-chosen {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.rv-pick__name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.rv-pick__alias {
  margin-left: 0.5rem;
  color: var(--faint);
  font-size: 0.75rem;
  font-weight: 400;
}

.rv-pick__designs {
  color: var(--accent-dark);
  font-size: 0.8125rem;
  font-weight: 600;
}

.rv-pick__blurb {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.rv-pick__meta {
  margin-top: auto;
  padding-top: 0.5rem;
  color: var(--faint);
  font-size: 0.75rem;
}

/* Step 2: the study list. */

.rv-studies {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 1.25rem;
  margin-top: 1rem;
  align-items: start;
}

.rv-studies__table th,
.rv-studies__table td {
  text-align: left;
}

.rv-study-n {
  width: 2.5rem;
  color: var(--faint);
  font-weight: 400;
}

.rv-study-remove {
  width: 3rem;
  text-align: center;
}

.rv-input,
.rv-textarea {
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

.rv-textarea {
  resize: vertical;
  line-height: 1.5;
}

.rv-input:focus-visible,
.rv-textarea:focus-visible,
.rv-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.rv-paste .calc-button {
  margin-top: 0.6rem;
}

.rv-count {
  color: var(--faint);
  font-size: 0.8125rem;
}

.rv-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.rv-actions .calc-button {
  margin-top: 0;
}

/* Step 3: domain tabs and the question matrix. */

.rv-mode {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.75rem 0 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--bg);
}

.rv-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.rv-switch input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
}

.rv-domain-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1rem;
}

.rv-domain-tab {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  font: inherit;
  font-size: 0.8125rem;
  color: var(--muted);
  cursor: pointer;
}

.rv-domain-tab__id {
  font-weight: 700;
  color: var(--text);
}

.rv-domain-tab__count {
  color: var(--faint);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.rv-domain-tab__count.is-done {
  color: #2e7d32;
  font-weight: 600;
}

.rv-domain-tab.is-open {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.rv-domain {
  margin-top: 1rem;
}

.rv-domain__title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.rv-questions th,
.rv-questions td {
  text-align: left;
  vertical-align: top;
}

.rv-questions__q {
  min-width: 20rem;
  max-width: 34rem;
  font-weight: 400;
}

.rv-questions__study {
  min-width: 9rem;
  white-space: nowrap;
}

.rv-q-id {
  display: inline-block;
  min-width: 2.4rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.rv-q-text {
  font-size: 0.875rem;
  line-height: 1.45;
}

.rv-select {
  width: 100%;
  min-width: 7.5rem;
  padding: 0.35rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.8125rem;
}

.rv-select:disabled {
  background: var(--bg);
  color: var(--faint);
}

.rv-questions td.is-inactive {
  background: repeating-linear-gradient(135deg, var(--bg), var(--bg) 6px, var(--surface) 6px, var(--surface) 12px);
}

.rv-questions__applicability {
  background: var(--bg);
}

.rv-questions__judgement th,
.rv-questions__judgement td {
  border-top: 2px solid var(--border-strong);
  background: var(--bg);
}

.rv-questions__judgement .rv-q-text {
  font-weight: 600;
}

.rv-judge-cell .rv-select {
  margin-top: 0.4rem;
}

.rv-judge-cell__partial {
  display: block;
  margin-top: 0.25rem;
  color: var(--faint);
  font-size: 0.75rem;
}

.rv-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.5rem 0.2rem 0.25rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.75rem;
  line-height: 1.3;
}

.rv-pill__mark {
  display: grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
}

.rv-pill__tag {
  color: var(--faint);
  font-size: 0.6875rem;
  font-style: italic;
}

.rv-pill.is-empty {
  padding-left: 0.5rem;
  color: var(--faint);
}

.rv-pill.is-low .rv-pill__mark { background: #2e7d32; color: #fff; }
.rv-pill.is-some .rv-pill__mark,
.rv-pill.is-moderate .rv-pill__mark { background: #efc000; color: #1c2430; }
.rv-pill.is-high .rv-pill__mark,
.rv-pill.is-serious .rv-pill__mark { background: #c62828; color: #fff; }
.rv-pill.is-critical .rv-pill__mark { background: #7f1d1d; color: #fff; }
.rv-pill.is-unclear .rv-pill__mark,
.rv-pill.is-ni .rv-pill__mark { background: #2b6cb0; color: #fff; }

.rv-domain-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.rv-domain-nav .calc-button {
  margin-top: 0;
}

/* The domain-only grid and the data table. */

.rv-grid th,
.rv-grid td,
.rv-data th,
.rv-data td {
  text-align: left;
}

.rv-grid__study {
  min-width: 10rem;
  font-weight: 400;
}

.rv-data__cell {
  font-size: 0.8125rem;
  white-space: nowrap;
}

.rv-data__cell.is-low { background: rgba(46, 125, 50, 0.14); }
.rv-data__cell.is-some,
.rv-data__cell.is-moderate { background: rgba(239, 192, 0, 0.22); }
.rv-data__cell.is-high,
.rv-data__cell.is-serious { background: rgba(198, 40, 40, 0.14); }
.rv-data__cell.is-critical { background: rgba(127, 29, 29, 0.18); }
.rv-data__cell.is-unclear,
.rv-data__cell.is-ni { background: rgba(43, 108, 176, 0.14); }

/* Step 4: options and the figure. */

.rv-options {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 1rem 1.5rem;
  margin: 0.75rem 0 1.25rem;
}

.rv-options .calc-field {
  flex: 1 1 18rem;
  min-width: 18rem;
}

.rv-h3 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1rem;
}

.rv-figure {
  overflow-x: auto;
  padding: 0.75rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: #fff;
}

.rv-figure svg {
  display: block;
  max-width: 100%;
  height: auto;
}

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

  .rv-step__label {
    display: none;
  }

  .rv-step {
    padding: 0.4rem 0.55rem;
  }

  .rv-questions__q {
    min-width: 14rem;
  }
}

.calc-formula {
  display: grid;
  gap: 0.6rem;
  justify-items: start;
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.05rem;
  overflow-x: auto;
}

.calc-formula math {
  margin: 0;
}

@media (max-width: 600px) {
  .calc-formula {
    font-size: 0.9rem;
    padding: 0.75rem 0.8rem;
  }
}
