.cases-page {
  --case-gold: var(--accent);
  --case-gold-accent: var(--accent);
  --case-gold-soft: var(--accent-soft);
  --case-gold-border: #d9bb62;
}

.cases-page .page-heading { margin-bottom: 14px; }
.cases-note { max-width: 72ch; margin: 0 0 22px; }

.case-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0 8px;
  margin: 0 0 24px;
  border-bottom: 1px solid var(--line);
}
.case-tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 14px;
  border-bottom: 3px solid transparent;
  color: var(--ink);
  font-size: 15px;
  text-decoration: none;
}
.case-tabs a:hover { background: #f1f1f1; color: #222; }
.case-tabs a[aria-selected="true"],
.case-tabs a[aria-current="true"] {
  border-color: var(--case-gold-accent);
  color: #222;
  font-weight: 700;
}

.case-panel { scroll-margin-top: 72px; }
.case-panel:not([role="tabpanel"]) + .case-panel:not([role="tabpanel"]) {
  margin-top: 48px;
  padding-top: 36px;
  border-top: 2px solid var(--line);
}

.case-header { margin-bottom: 22px; max-width: 72ch; }
.case-header h2 { margin-bottom: 6px; }
.case-setting { margin: 0; font-size: 14px; color: var(--muted); }

/* Each case step is a plain section; the IVC box and scan cards inside it carry the framing. */
.case-section {
  padding: 22px 0 0;
  margin-bottom: 22px;
  border-top: 1px solid var(--line);
}
.case-section h3 {
  font-size: 20px;
  margin: 0 0 14px;
}

.case-presentation > p:not(.case-prompt) { font-size: 15px; max-width: 72ch; margin-bottom: 16px; }
.case-snapshot {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  padding: 12px 0;
  margin: 0 0 16px;
  border-block: 1px solid var(--line);
}
.case-snapshot > div {
  padding: 2px 14px;
}
.case-snapshot > div:first-child {
  padding-left: 0;
}
.case-snapshot > div + div {
  border-left: 1px solid var(--line);
}
@media (max-width: 760px) {
  .case-snapshot {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
  }
  .case-snapshot > div { padding: 2px 0; }
  .case-snapshot > div + div { border-left: 0; }
}
.case-snapshot dt {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 3px;
}
.case-snapshot dd { margin: 0; font-size: 14px; line-height: 1.45; color: #262323; }
.case-prompt {
  margin: 0;
  padding: 11px 14px;
  border: 1px solid #e6d7b1;
  background: var(--case-gold-soft);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--ink);
}

.case-exam-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 14px;
}
.case-exam-head h3 { margin: 0; }
.case-toggle-reads { min-height: 44px; padding: 8px 2px; font-weight: 700; color: var(--case-gold); }
.case-toggle-reads:hover { color: #262323; }

.case-ivc {
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--light);
  margin-bottom: 18px;
}
.case-ivc-dilated { border-color: #e2d1a3; background: var(--accent-soft); }
.case-ivc-normal { border-color: #c2decb; background: #f4f9f6; }
.case-ivc-measure {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 6px;
}
.case-ivc-label { font-size: 13px; font-weight: 700; color: var(--muted); }
.case-ivc-measure strong { font-size: 20px; color: #262323; }
.case-ivc p { margin: 0; font-size: 14px; color: #444; max-width: 72ch; }

.case-scans {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.case-scan-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  background: var(--paper);
}
.case-scan-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--light);
}
.case-scan-head :is(h3, h4) { margin: 0; font-size: 15px; color: #262323; }

.case-scan-link {
  display: block;
  text-decoration: none;
  color: #f4f4f4;
  background: #141715;
  cursor: zoom-in;
}
.case-scan-frame {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  background: #0b0d0c;
  overflow: hidden;
}
.case-scan-frame img {
  display: block;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform .25s ease;
}
@media (hover: hover) {
  .case-scan-link:hover .case-scan-frame img { transform: scale(1.025); }
  .case-scan-link:hover .case-scan-expand { text-decoration: underline; color: #fff; }
}
.case-scan-expand {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  border-top: 1px solid #2b302d;
  font-size: 13px;
  font-weight: 700;
  color: #e8ebe8;
}
.case-scan-expand .icon { width: 16px; height: 16px; }
.case-scan-link:focus-visible { outline-offset: -3px; }

.case-scan-body { padding: 12px; font-size: 13.5px; line-height: 1.55; flex: 1; }
.case-scan-body p { margin: 0; }
.case-scan-body p + p {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.case-scan-cue { color: var(--muted); }
.case-scan-read { color: #262323; }

.case-question fieldset { min-inline-size: 0; margin: 0; padding: 0; border: 0; }
.case-question legend { padding: 0; margin-bottom: 10px; font-size: 16px; font-weight: 700; color: #262323; }
.case-question label {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid #e1e1e1;
  border-radius: 4px;
  background: var(--paper);
  font-weight: 400;
  cursor: pointer;
  transition: border-color .14s ease, background-color .14s ease;
}
.case-question label:hover { border-color: #999; }
.case-question label:has(input:checked) {
  border-color: #555;
  background: #f5f5f5;
  box-shadow: inset 0 0 0 1px #555;
}
.case-question input { flex: none; margin: 0; width: 16px; height: 16px; accent-color: var(--case-gold); }
.case-question-actions { margin-top: 12px; }
.case-question-actions .button { min-height: 44px; padding: 9px 18px; }
.case-answer { margin: 0; font-size: 14.5px; line-height: 1.6; }
.case-answer:not(:empty) {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid #e5d6aa;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  color: var(--ink);
}
.case-answer[data-correct="true"] { border-color: #bddbc7; background: #eff7f1; }

.case-walkthrough {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 0;
  margin-bottom: 22px;
}
.case-walkthrough > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  list-style: none;
  min-height: 54px;
  padding: 12px clamp(16px, 2.5vw, 26px);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}
.case-walkthrough > summary::-webkit-details-marker { display: none; }
.case-walkthrough > summary .icon { margin-left: auto; width: 18px; height: 18px; transition: transform .16s ease; }
.case-walkthrough[open] > summary .icon { transform: rotate(180deg); }
.case-walkthrough-body {
  border-top: 1px solid var(--line);
  padding: clamp(16px, 2.5vw, 26px);
}

.case-score-banner {
  padding: 15px 18px;
  border: 1px solid #e5d6aa;
  border-radius: var(--radius-sm);
  background: var(--case-gold-soft);
  margin-bottom: 20px;
}
.case-score-grade { display: flex; align-items: flex-start; gap: 12px; }
.case-score-grade .grade-pill {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  line-height: 34px;
  margin: 0;
  font-weight: 700;
  background: #262323;
  color: #fff;
}
.case-score-grade strong { display: block; font-size: 17px; color: #262323; margin-bottom: 2px; }
.case-score-grade p { margin: 0; font-size: 14px; color: #444; }
.case-decision {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid #e5d6aa;
  font-size: 15px;
  color: #262323;
}

.case-walkthrough-body h4 {
  font-size: 16px;
  margin: 20px 0 8px;
  color: #262323;
}
.case-vein-summary ul,
.case-pearls ul {
  margin: 0;
  padding-left: 20px;
  font-size: 14.5px;
  max-width: 78ch;
}
.case-vein-summary li + li,
.case-pearls li + li { margin-top: 8px; }
.case-synthesis p { font-size: 15px; max-width: 72ch; margin-bottom: 12px; }
.case-synthesis p:last-child { margin-bottom: 0; }
.case-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin: 20px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.case-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 14px;
}

.case-pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 28px;
}
.case-pager .button { min-height: 44px; padding: 9px 16px; gap: 8px; }
.case-pager .icon { width: 16px; height: 16px; }

.cases-footer-note { margin-top: 12px; }
.cases-footer-note p, .case-prompt, .drill-prompt { max-width: 72ch; }


/* Serial Decongestion Trajectory */
.serial-case,
.scan-drill {
  margin: 44px 0 36px;
  padding-top: 32px;
  border-top: 2px solid var(--line);
  scroll-margin-top: 72px;
}
.serial-intro {
  max-width: 72ch;
  font-size: 15px;
  color: #323232;
  margin: 8px 0 0;
}
.serial-day-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.serial-day-tabs button {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid #b8b8b8;
  background: #fff;
  color: #272727;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.serial-day-tabs button[aria-selected="true"] {
  background: #fff0c6;
  border-color: #8b6826;
  box-shadow: inset 0 0 0 1px #8b6826;
}
.serial-case .grade-pill {
  width: auto;
  height: auto;
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--case-gold-soft);
  border: 1px solid #d9c389;
  color: var(--case-gold);
}
.serial-case .grade-pill.grade-3 {
  background: #fdeee9;
  border-color: #df9c8a;
  color: #8b2d19;
}
.serial-case .grade-pill.grade-1 {
  background: #ebf6ee;
  border-color: #8ac297;
  color: #1f5c2e;
}
@media (hover: hover) {
  .serial-day-tabs button:hover:not([aria-selected="true"]) {
    background: #fcf6e8;
    border-color: #89651f;
  }
}

/* 10-Scan Real Atlas Bedside Challenge */
.drill-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: clamp(18px, 2.5vw, 26px);
}
.drill-topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 14px;
}
.drill-progress-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.drill-pill {
  min-width: 44px;
  min-height: 44px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #bebebe;
  background: #fff;
  color: #2a2a2a;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.drill-pill[aria-selected="true"] {
  border-color: #8b6826;
  box-shadow: inset 0 0 0 2px #8b6826;
  background: #fff5d9;
}
.drill-pill[data-result="correct"] {
  background: #e9f6ec;
  border-color: #4f9460;
  color: #1c542b;
}
.drill-pill[data-result="wrong"] {
  background: #fdf0ed;
  border-color: #c96f5d;
  color: #7c2718;
}
.drill-score-badge {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--case-gold-soft);
  border: 1px solid #dec993;
  color: var(--case-gold);
  font-size: 13px;
  font-weight: 700;
}
.drill-meta-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 16px;
  margin-bottom: 6px;
}
.drill-counter { font-size: 14px; font-weight: 700; color: var(--muted); }
.drill-meta-row h3 {
  margin: 2px 0 0;
  font-size: 21px;
}
.drill-expert-btn {
  min-height: 44px;
  font-weight: 700;
  color: var(--case-gold);
}
.drill-prompt {
  margin: 0 0 12px;
  font-size: 14px;
  color: #393939;
}
.drill-stage {
  position: relative;
  background: #0a0c0e;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #2b3036;
  margin-bottom: 12px;
  user-select: none;
  touch-action: none;
  cursor: crosshair;
}
.drill-stage img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 480px;
  object-fit: contain;
  pointer-events: none;
}
.drill-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.drill-overlay [hidden] {
  display: none;
}
.drill-overlay text {
  font: 700 13px/1 system-ui, sans-serif;
  paint-order: stroke;
  stroke: rgba(10, 12, 15, 0.92);
  stroke-width: 5px;
  stroke-linejoin: round;
}
.drill-qrs-group line {
  stroke: #5ce68a;
  stroke-width: 2;
  stroke-dasharray: 6 4;
}
.drill-qrs-group text {
  fill: #7cf5a4;
}
.drill-caliper-vmax line {
  stroke: #ffd269;
  stroke-width: 2;
}
.drill-caliper-vmax text {
  fill: #ffd269;
}
.drill-caliper-vmin line {
  stroke: #ff8e72;
  stroke-width: 2;
}
.drill-caliper-vmin text {
  fill: #ff9c84;
}
.drill-caliper-zero line {
  stroke: #6ad7f0;
  stroke-width: 2;
  stroke-dasharray: 6 4;
}
.drill-caliper-zero text {
  fill: #6ad7f0;
}
.drill-tool-controls {
  padding: 10px 12px;
  background: #f8f8f8;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  margin-bottom: 14px;
  font-size: 13px;
}
.drill-tool-controls label {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.drill-tool-controls input[type="range"] {
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 36px;
  margin: 0;
  accent-color: #89651f;
}
[data-drill-qrs-controls] {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}
[data-drill-qrs-controls] input[type="range"] {
  flex: 1 1 200px;
}
.drill-pf-readout {
  margin-bottom: 8px;
  font-size: 13.5px;
  color: #222222;
}
.drill-caliper-sliders {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 14px;
}
.drill-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.drill-choice {
  min-height: 46px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #b1b1b1;
  background: #fff;
  color: #232323;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.drill-choice[data-state="expected"] {
  background: #e9f6ec;
  border-color: #3e8350;
  box-shadow: inset 0 0 0 1px #3e8350;
  color: #164723;
}
.drill-choice[data-state="wrong"] {
  background: #fdf0ed;
  border-color: #bf5c4a;
  color: #7c2314;
}
@media (hover: hover) {
  .drill-choice:hover:not([data-state]) {
    border-color: #89651f;
    background: #fcf6e8;
  }
}
.drill-feedback {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 14px;
  line-height: 1.5;
  background: #eff7f1;
  border: 1px solid #bddbc7;
  color: var(--ink);
}
.drill-feedback[data-correct="false"] {
  background: #fdf5f2;
  border-color: #e6bfb6;
}
.drill-nav-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.drill-nav-row .button {
  min-height: 44px;
  gap: 6px;
}
@media (max-width: 680px) {
  .drill-caliper-sliders,
  .drill-choices {
    grid-template-columns: 1fr;
  }
  .serial-day-tabs button {
    width: 100%;
    text-align: left;
  }
}
@media (pointer: coarse) {
  .drill-tool-controls input[type="range"] {
    height: 44px;
  }
}

@media (max-width: 980px) {
  .case-snapshot { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .case-scans { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .case-tabs {
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--paper);
    overflow: hidden;
  }
  .case-tabs a {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border-bottom: 1px solid var(--line);
    border-left: 3px solid transparent;
  }
  .case-tabs a:last-child { border-bottom: 0; }
  .case-tabs a[aria-selected="true"],
  .case-tabs a[aria-current="true"] {
    background: var(--case-gold-soft);
    border-bottom-color: var(--line);
    border-left-color: var(--case-gold-accent);
  }
  .case-tabs a:last-child[aria-selected="true"],
  .case-tabs a:last-child[aria-current="true"] { border-bottom-color: transparent; }
  .case-snapshot { grid-template-columns: 1fr; }
  .case-scans { grid-template-columns: 1fr; }
  .case-walkthrough > summary { font-size: 16px; }
  .case-pager { flex-direction: column; }
  .case-pager > span:empty { display: none; }
  .case-pager .button { width: 100%; }
}
