/* ==========================================================================
   recist.css — RECIST 1.1 Calculator page styles
   Scoped to .recist-* prefix. Uses CSS vars from styles.css for theme support.
   Local fallback tokens for --radius-*, --focus-ring, --space-* not yet in
   global styles.css.
   ========================================================================== */

/* ---------- Local token fallbacks ---------- */
.recist-page {
  --r-radius-sm:   4px;
  --r-radius-md:   8px;
  --r-radius-lg:   12px;
  --r-radius-xl:   16px;
  --r-radius-full: 999px;
  --r-focus-ring:  3px solid var(--color-accent);
  --r-space-xs:    4px;
  --r-space-sm:    8px;
  --r-space-md:    16px;
  --r-space-lg:    24px;
  --r-space-xl:    32px;
  --r-space-2xl:   40px;
  --r-space-3xl:   48px;
}

/* ---------- Page wrapper ---------- */
.recist-page {
  padding-bottom: var(--r-space-3xl);
}

/* Single vertical stack: the container owns ALL vertical spacing between
   top-level blocks via one `gap`. No per-block margins — keeps the rhythm
   uniform and predictable, doesn't collapse, and `display:none`/`[hidden]`
   blocks (conclusion, explain, empty warnings) drop out without leaving a
   double gap. Scoped to `.recist-page > .container` so no other page is
   affected. */
.recist-page > .container {
  display: flex;
  flex-direction: column;
  gap: var(--r-space-lg);
}

/* ---------- Info block ---------- */
.recist-info {
  background: var(--color-surface);
  border-radius: var(--r-radius-lg);
  border: 1px solid var(--color-border);
  padding: var(--r-space-md) var(--r-space-lg);
}

.recist-info__title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 var(--r-space-sm) 0;
  color: var(--color-text);
}

.recist-info p {
  margin: 0 0 var(--r-space-xs) 0;
  font-size: 0.9rem;
  color: var(--color-muted);
  line-height: 1.55;
}

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

/* ---------- Section wrapper ---------- */
.recist-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-radius-lg);
  padding: var(--r-space-md) var(--r-space-lg);
  box-shadow: var(--shadow);
}

.recist-section__title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 var(--r-space-md) 0;
  color: var(--color-accent);
  padding-left: var(--r-space-sm);
  border-left: 3px solid var(--color-accent);
}

/* ---------- Section pairs (desktop: side by side; mobile: stacked) ----------
   Pure layout wrapper — owns NO outer spacing (that's the container stack's
   job). Reduces empty horizontal space on wide screens by placing two related
   sections in a row; stays single-column below the breakpoint with the same
   gap as the rest of the page. No margin-collapse tricks. */
.recist-section-pair {
  display: flex;
  flex-direction: column;
  gap: var(--r-space-lg);
}

@media (min-width: 900px) {
  .recist-section-pair {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--r-space-lg);
    align-items: stretch;
  }

  /* Inside a pair, radio options stack vertically (one under another)
     instead of wrapping in a horizontal flow — matches the narrower
     column width and the requested layout. */
  .recist-section-pair .recist-radio-options {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ---------- Date input (native picker only — see UI guardrails) ---------- */
.recist-date-wrap .form-input {
  width: 100%;
}

/* `color-scheme` tells the browser which palette to render the native
   calendar icon and popup in, so it stays visible/legible in both themes
   instead of defaulting to a light-only indicator on a dark field. */
.recist-page input[type="date"] {
  color-scheme: light;
}

[data-theme='dark'] .recist-page input[type="date"] {
  color-scheme: dark;
}

.recist-page input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.8;
}

.recist-page input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* ---------- Form groups ---------- */
.recist-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--r-space-md);
  margin-bottom: var(--r-space-md);
}

.recist-form-row--3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.recist-form-group {
  display: flex;
  flex-direction: column;
  gap: var(--r-space-xs);
}

.recist-form-group--full {
  grid-column: 1 / -1;
}

.recist-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
}

.recist-label .required-mark {
  color: var(--color-error);
  margin-left: 2px;
}

.recist-label .optional-mark {
  color: var(--color-muted);
  font-weight: 400;
  font-size: 0.8em;
  margin-left: 4px;
}

/* ---------- Radio group ---------- */
.recist-radio-group {
  border: none;
  padding: 0;
  margin: 0 0 var(--r-space-md) 0;
}

.recist-radio-group__legend {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--r-space-sm);
  float: none;
  width: 100%;
}

.recist-radio-options {
  display: flex;
  flex-wrap: wrap;
  gap: var(--r-space-sm);
}

.recist-radio-option {
  display: flex;
  align-items: center;
  gap: var(--r-space-xs);
  cursor: pointer;
  font-size: 0.9rem;
}

.recist-radio-option input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-accent);
  cursor: pointer;
  flex-shrink: 0;
}

.recist-radio-option input[type="radio"]:focus-visible {
  outline: var(--r-focus-ring);
  outline-offset: 2px;
  border-radius: 50%;
}

/* ---------- Nadir field visibility ---------- */
.recist-nadir-group {
  transition: opacity 0.2s;
}

.recist-nadir-group[hidden] {
  display: none;
}

/* ---------- Has-target toggle ---------- */
.recist-has-target {
  margin-bottom: var(--r-space-md);
}

/* .recist-radio-group__legend sets width:100%, which beats .visually-hidden's
   width:1px at equal specificity by source order — re-assert it here so the
   hidden legend's absolutely-positioned box doesn't stretch past the viewport. */
.recist-radio-group__legend.visually-hidden {
  width: 1px;
}

/* ---------- Target lesions section ---------- */
.recist-target-section[hidden] {
  display: none;
}

/* Table wrapper — scrollable on mobile */
.recist-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--r-radius-md);
  margin-bottom: var(--r-space-md);
}

.recist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  min-width: 680px;
}

.recist-table th {
  background: color-mix(in srgb, var(--color-accent) 12%, var(--color-surface));
  color: var(--color-text);
  font-weight: 600;
  padding: 10px 8px;
  text-align: left;
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}

.recist-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.recist-table tbody tr:last-child td {
  border-bottom: none;
}

.recist-table tbody tr:hover {
  background: color-mix(in srgb, var(--color-accent) 5%, var(--color-surface));
}

.recist-table input[type="text"],
.recist-table input[type="number"],
.recist-table select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--r-radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 0.85rem;
  font-family: inherit;
  box-sizing: border-box;
  line-height: 1.4;
}

.recist-table input[type="text"]:focus,
.recist-table input[type="number"]:focus,
.recist-table select:focus {
  outline: var(--r-focus-ring);
  outline-offset: 1px;
  border-color: var(--color-accent);
}

.recist-table input:disabled,
.recist-table select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: color-mix(in srgb, var(--color-surface) 80%, var(--color-border));
}

.recist-table input.recist-input--error,
.recist-table select.recist-input--error {
  border-color: var(--color-error);
  background: color-mix(in srgb, var(--color-error) 6%, var(--color-bg));
}

/* iOS zoom prevention */
@media (max-width: 640px) {
  .recist-table input[type="text"],
  .recist-table input[type="number"],
  .recist-table select {
    font-size: max(1rem, 16px);
  }
}

/* Column widths */
.recist-table .col-location { width: 13%; }
.recist-table .col-organ    { width: 13%; }
.recist-table .col-type     { width: 17%; }
.recist-table .col-baseline { width: 12%; }
.recist-table .col-state    { width: 19%; }
.recist-table .col-current  { width: 12%; }
.recist-table .col-del      { width: 7%; text-align: center; }

/* Delete button in table */
.recist-del-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--color-border);
  border-radius: var(--r-radius-sm);
  background: color-mix(in srgb, var(--color-error) 10%, var(--color-surface));
  color: var(--color-error);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  transition: background 0.15s;
}

.recist-del-btn:hover {
  background: color-mix(in srgb, var(--color-error) 20%, var(--color-surface));
}

.recist-del-btn:focus-visible {
  outline: var(--r-focus-ring);
  outline-offset: 2px;
}

/* Add lesion button */
.recist-add-btn {
  margin-top: var(--r-space-xs);
}

/* Inline error under a cell */
.recist-cell-error {
  font-size: 0.78rem;
  color: var(--color-error);
  margin-top: 2px;
  display: block;
}

/* ---------- Non-target / New lesions selects ---------- */
.recist-select-full {
  width: 100%;
  max-width: 480px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--r-radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 0.9rem;
  font-family: inherit;
}

.recist-select-full:focus {
  outline: var(--r-focus-ring);
  outline-offset: 1px;
  border-color: var(--color-accent);
}

/* iOS zoom prevention */
@media (max-width: 640px) {
  .recist-select-full {
    font-size: max(1rem, 16px);
  }
}

/* ---------- Warnings block ---------- */
.recist-warnings:empty {
  display: none;
}

.recist-warning-item {
  display: flex;
  gap: var(--r-space-sm);
  align-items: flex-start;
  padding: var(--r-space-sm) var(--r-space-md);
  border-radius: var(--r-radius-md);
  margin-bottom: var(--r-space-xs);
  font-size: 0.875rem;
  line-height: 1.45;
}

.recist-warning-item--error {
  background: color-mix(in srgb, var(--color-error) 10%, var(--color-surface));
  border: 1px solid color-mix(in srgb, var(--color-error) 40%, var(--color-border));
  color: var(--color-text);
}

.recist-warning-item--warn {
  background: color-mix(in srgb, #f59e0b 10%, var(--color-surface));
  border: 1px solid color-mix(in srgb, #f59e0b 40%, var(--color-border));
  color: var(--color-text);
}

.recist-warning-item--info {
  background: color-mix(in srgb, var(--color-accent) 10%, var(--color-surface));
  border: 1px solid color-mix(in srgb, var(--color-accent) 40%, var(--color-border));
  color: var(--color-text);
}

.recist-warning-icon {
  flex-shrink: 0;
  font-size: 1rem;
}

/* ---------- Results block ---------- */
.recist-results {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-radius-lg);
  padding: var(--r-space-md) var(--r-space-lg);
  box-shadow: var(--shadow);
}

.recist-results__title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 var(--r-space-md) 0;
  color: var(--color-accent);
  padding-left: var(--r-space-sm);
  border-left: 3px solid var(--color-accent);
}

.recist-results__empty {
  color: var(--color-muted);
  font-size: 0.9rem;
  font-style: italic;
}

/* Metrics grid */
.recist-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--r-space-sm);
  margin-bottom: var(--r-space-md);
}

.recist-metric {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--r-radius-md);
  padding: var(--r-space-sm) var(--r-space-md);
}

.recist-metric__label {
  font-size: 0.78rem;
  color: var(--color-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.recist-metric__value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
}

/* Response badges */
.recist-response-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--r-space-sm);
  margin-top: var(--r-space-md);
}

.recist-response-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 90px;
}

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

.recist-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: var(--r-radius-full);
  font-weight: 700;
  font-size: 0.9375rem;
  border: 2px solid transparent;
}

.recist-badge--cr {
  background: color-mix(in srgb, #059669 20%, var(--color-surface));
  border-color: #059669;
  color: #059669;
}

.recist-badge--pr {
  background: color-mix(in srgb, #2563eb 18%, var(--color-surface));
  border-color: #2563eb;
  color: #2563eb;
}

.recist-badge--sd {
  background: color-mix(in srgb, #d97706 18%, var(--color-surface));
  border-color: #d97706;
  color: #8b5a00;
}

.recist-badge--pd {
  background: color-mix(in srgb, var(--color-error) 18%, var(--color-surface));
  border-color: var(--color-error);
  color: var(--color-error);
}

.recist-badge--ne {
  background: color-mix(in srgb, var(--color-muted) 18%, var(--color-surface));
  border-color: var(--color-muted);
  color: var(--color-muted);
}

.recist-badge--needs-review {
  background: color-mix(in srgb, #f59e0b 18%, var(--color-surface));
  border-color: #d97706;
  color: #7c4b00;
}

.recist-badge--non-cr-non-pd {
  background: color-mix(in srgb, #7c3aed 18%, var(--color-surface));
  border-color: #7c3aed;
  color: #7c3aed;
}

/* Dark theme badge adjustments */
[data-theme='dark'] .recist-badge--cr {
  background: color-mix(in srgb, #059669 25%, var(--color-surface));
  color: #34d399;
  border-color: #34d399;
}

[data-theme='dark'] .recist-badge--pr {
  background: color-mix(in srgb, #2563eb 25%, var(--color-surface));
  color: #7aa7ff;
  border-color: #7aa7ff;
}

[data-theme='dark'] .recist-badge--sd {
  background: color-mix(in srgb, #d97706 25%, var(--color-surface));
  color: #fbbf24;
  border-color: #fbbf24;
}

[data-theme='dark'] .recist-badge--pd {
  background: color-mix(in srgb, var(--color-error) 25%, var(--color-surface));
  color: var(--color-error);
  border-color: var(--color-error);
}

[data-theme='dark'] .recist-badge--ne {
  background: color-mix(in srgb, var(--color-muted) 25%, var(--color-surface));
  color: var(--color-muted);
  border-color: var(--color-muted);
}

[data-theme='dark'] .recist-badge--needs-review {
  background: color-mix(in srgb, #f59e0b 25%, var(--color-surface));
  color: #fbbf24;
  border-color: #d97706;
}

[data-theme='dark'] .recist-badge--non-cr-non-pd {
  background: color-mix(in srgb, #7c3aed 25%, var(--color-surface));
  color: #a78bfa;
  border-color: #a78bfa;
}

/* High contrast overrides */
[data-a11y-contrast='high'] .recist-badge--cr  { background: transparent; border-width: 3px; }
[data-a11y-contrast='high'] .recist-badge--pr  { background: transparent; border-width: 3px; }
[data-a11y-contrast='high'] .recist-badge--sd  { background: transparent; border-width: 3px; }
[data-a11y-contrast='high'] .recist-badge--pd  { background: transparent; border-width: 3px; }
[data-a11y-contrast='high'] .recist-badge--ne  { background: transparent; border-width: 3px; }
[data-a11y-contrast='high'] .recist-badge--needs-review { background: transparent; border-width: 3px; }

/* ---------- Conclusion block ---------- */
.recist-conclusion {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-radius-lg);
  padding: var(--r-space-md) var(--r-space-lg);
  box-shadow: var(--shadow);
}

.recist-conclusion__title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 var(--r-space-md) 0;
  color: var(--color-accent);
  padding-left: var(--r-space-sm);
  border-left: 3px solid var(--color-accent);
}

/* ---------- Conclusion header: title + mode switcher ---------- */
.recist-conclusion-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--r-space-sm) var(--r-space-md);
  margin-bottom: var(--r-space-md);
}

/* Title already owns its own bottom margin; inside the flex head the gap
   handles spacing, so drop the duplicate margin. */
.recist-conclusion-head .recist-conclusion__title {
  margin-bottom: 0;
}

/* Segmented control built on real radio inputs (keyboard + a11y for free) */
.recist-conclusion-modes {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--r-radius-full);
}

.recist-conclusion-modes[hidden] {
  display: none;
}

.recist-conclusion-mode {
  position: relative;
  display: inline-flex;
  margin: 0;
}

/* Visually hide the radio but keep it in the layout & accessibility tree */
.recist-conclusion-mode input[type="radio"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.recist-conclusion-mode span {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border-radius: var(--r-radius-full);
  border: 2px solid transparent;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-muted);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

/* Active state distinguished by MORE than colour: filled background,
   accent border and heavier weight. Text uses --color-bg for safe contrast
   on the accent fill (incl. high-contrast theme). */
.recist-conclusion-mode input:checked + span {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-bg);
  font-weight: 700;
}

.recist-conclusion-mode input:not(:checked):hover + span {
  background: color-mix(in srgb, var(--color-accent) 12%, var(--color-bg));
  color: var(--color-text);
}

.recist-conclusion-mode input:focus-visible + span {
  outline: var(--r-focus-ring);
  outline-offset: 2px;
}

@media (max-width: 700px) {
  .recist-conclusion-modes {
    width: 100%;
  }

  .recist-conclusion-mode {
    flex: 1;
  }

  .recist-conclusion-mode span {
    width: 100%;
    justify-content: center;
    padding: 6px 10px;
  }
}

.recist-not-ready-msg {
  color: var(--color-muted);
  font-size: 0.9rem;
  font-style: italic;
  margin: 0 0 var(--r-space-sm) 0;
}

.recist-textarea {
  width: 100%;
  min-height: clamp(360px, 40vh, 480px);
  padding: var(--r-space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--r-radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.6;
  resize: vertical;
  box-sizing: border-box;
}

/* Short conclusion is a single short paragraph — about a third of the tall
   extended height. Stays scrollable if the user resizes/needs more. */
.recist-textarea--short {
  min-height: clamp(120px, 14vh, 160px);
}

.recist-textarea:focus {
  outline: var(--r-focus-ring);
  outline-offset: 1px;
  border-color: var(--color-accent);
}

.recist-textarea::placeholder {
  color: var(--color-muted);
  font-style: italic;
}

.recist-copy-row {
  display: flex;
  align-items: center;
  gap: var(--r-space-md);
  margin-top: var(--r-space-sm);
  flex-wrap: wrap;
}

.recist-copy-status {
  font-size: 0.875rem;
  color: var(--color-muted);
}

.recist-copy-status--success {
  color: #059669;
  font-weight: 600;
}

[data-theme='dark'] .recist-copy-status--success {
  color: #34d399;
}

.recist-copy-status--error {
  color: var(--color-error);
}

/* ---------- Responsive: mobile card layout for table ---------- */
@media (max-width: 700px) {
  .recist-textarea {
    min-height: clamp(280px, 50vh, 360px);
  }

  .recist-textarea--short {
    min-height: clamp(110px, 22vh, 150px);
  }

  .recist-form-row,
  .recist-form-row--3 {
    grid-template-columns: 1fr;
  }

  .recist-table-wrap {
    border: none;
    background: transparent;
    box-shadow: none;
    overflow-x: visible;
  }

  .recist-table,
  .recist-table thead,
  .recist-table tbody,
  .recist-table th,
  .recist-table td,
  .recist-table tr {
    display: block;
    min-width: 0;
  }

  /* Thead hidden visually, available to screen readers */
  .recist-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  /* Each row = card */
  .recist-table tbody tr {
    border: 1px solid var(--color-border);
    border-radius: var(--r-radius-md);
    margin-bottom: 12px;
    background: var(--color-surface);
    box-shadow: var(--shadow);
    padding: 4px 0;
  }

  /* Cell = label:value row */
  .recist-table td {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 7px 12px;
    border: none;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
  }

  .recist-table td:last-child {
    border-bottom: none;
  }

  /* data-label pseudo-element */
  .recist-table td[data-label]::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--color-muted);
    min-width: 110px;
    flex-shrink: 0;
    padding-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  .recist-table td input,
  .recist-table td select {
    flex: 1;
  }

  .recist-table .col-del {
    text-align: left;
  }

  .recist-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .recist-response-row {
    justify-content: center;
  }
}

@media (max-width: 400px) {
  .recist-metrics {
    grid-template-columns: 1fr;
  }
}

/* ---------- NE display (not computable) ---------- */
.recist-metric__ne {
  font-size: 0.85em;
  font-style: italic;
  color: var(--color-muted);
  font-weight: 400;
}

/* ---------- Explain block ---------- */
.recist-explain {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--r-radius-lg);
  padding: var(--r-space-md) var(--r-space-lg);
  box-shadow: var(--shadow);
}

.recist-explain__title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 var(--r-space-md) 0;
  color: var(--color-accent);
  padding-left: var(--r-space-sm);
  border-left: 3px solid var(--color-accent);
}

.recist-explain__empty {
  color: var(--color-muted);
  font-size: 0.9rem;
  font-style: italic;
}

.recist-explain-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.recist-explain-row {
  display: flex;
  gap: var(--r-space-sm);
  font-size: 0.875rem;
  padding: 4px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--color-border) 50%, transparent);
}

.recist-explain-row:last-of-type {
  border-bottom: none;
}

.recist-explain-row__label {
  color: var(--color-muted);
  font-weight: 600;
  min-width: 220px;
  flex-shrink: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.recist-explain-row__value {
  color: var(--color-text);
  font-weight: 500;
}

/* ---------- Compact summary: baseline → current, % change, badge ---------- */
.recist-explain-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--r-space-xs) var(--r-space-md);
  margin-bottom: var(--r-space-md);
}

.recist-explain-summary__sums,
.recist-explain-summary__pct {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
}

.recist-explain-summary__label {
  font-size: 0.78rem;
  color: var(--color-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Criteria checklist (CR / PR / PD / SD) ---------- */
.recist-explain-criteria {
  display: flex;
  flex-wrap: wrap;
  gap: var(--r-space-sm);
  list-style: none;
  margin: 0 0 var(--r-space-md) 0;
  padding: 0;
}

.recist-explain-criteria__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  border-radius: var(--r-radius-full);
  border: 2px solid var(--color-border);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--color-muted);
}

/* "Met" criterion is distinguished by more than colour: thicker border,
   bolder weight, filled background and the ✓ glyph + visually-hidden text. */
.recist-explain-criteria__item.is-met {
  border-width: 3px;
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 12%, var(--color-surface));
  font-weight: 800;
}

.recist-explain-criteria__item.is-not-met {
  opacity: 0.65;
}

.recist-explain-criteria__mark {
  font-size: 1rem;
  line-height: 1;
}

/* ---------- Dynamic reasons (PR / PD / CR / SD) ---------- */
.recist-explain-reasons {
  display: flex;
  flex-direction: column;
  gap: 4px;
  list-style: none;
  margin: 0 0 var(--r-space-md) 0;
  padding: 0;
  font-size: 0.875rem;
  color: var(--color-text);
  line-height: 1.5;
}

.recist-explain-reasons li strong {
  color: var(--color-accent);
}

/* Highlight the reason line for the criterion that is actually met (met: true).
   Distinguished by more than colour: background tint, left border stripe,
   bolder weight and a ✓ glyph (decorative — the "так"/"ні" wording stays the
   primary accessible signal). */
.recist-explain-reasons__item--met {
  position: relative;
  margin-left: calc(-1 * var(--r-space-sm));
  padding: 4px var(--r-space-sm) 4px calc(var(--r-space-sm) + 8px);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--r-radius-sm);
  background: color-mix(in srgb, var(--color-accent) 10%, transparent);
  font-weight: 600;
}

.recist-explain-reasons__mark {
  display: inline-block;
  color: var(--color-accent);
  font-weight: 700;
}

.recist-explain-note {
  margin: 0 0 var(--r-space-md) 0;
  padding: var(--r-space-sm) var(--r-space-md);
  background: color-mix(in srgb, var(--color-accent) 8%, var(--color-surface));
  border-left: 3px solid var(--color-accent);
  border-radius: var(--r-radius-sm);
  font-size: 0.875rem;
  color: var(--color-text);
  line-height: 1.5;
}

/* ---------- New / non-target lesion status ---------- */
.recist-explain-extra {
  display: flex;
  flex-direction: column;
  gap: 4px;
  list-style: none;
  margin: 0 0 var(--r-space-md) 0;
  padding: 0;
  font-size: 0.875rem;
  color: var(--color-text);
}

.recist-explain-extra li strong {
  color: var(--color-muted);
  font-weight: 600;
}

.recist-explain-extra:last-child {
  margin-bottom: 0;
}

/* ---------- Formulas disclosure ---------- */
.recist-explain-details {
  margin-top: var(--r-space-sm);
}

.recist-explain-details summary {
  cursor: pointer;
  display: inline-block;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--color-accent);
  padding: 4px 0;
  border-radius: var(--r-radius-sm);
}

.recist-explain-details summary:focus-visible {
  outline: var(--r-focus-ring);
  outline-offset: 2px;
}

/* Toggle the summary label via the native open/closed state — no JS.
   Only one label is in the DOM/flow at a time (display:none also removes the
   inactive one from the accessibility tree), so the screen reader announces
   exactly the current action. */
.recist-explain-details .recist-explain-details__hide { display: none; }
.recist-explain-details[open] .recist-explain-details__show { display: none; }
.recist-explain-details[open] .recist-explain-details__hide { display: inline; }

.recist-explain-details[open] summary {
  margin-bottom: var(--r-space-sm);
}

@media (max-width: 700px) {
  .recist-explain-row {
    flex-direction: column;
    gap: 2px;
    padding: 6px 0;
  }

  .recist-explain-row__label {
    min-width: 0;
  }

  .recist-explain-summary {
    gap: var(--r-space-xs) var(--r-space-sm);
  }

  .recist-explain-summary__sums,
  .recist-explain-summary__pct {
    font-size: 0.95rem;
  }
}
