.simulator { --sim-gold: var(--accent, #8b6826); --sim-tint: var(--accent-soft, #fbf6e8); --sim-edge: var(--line, #dddddd); font-size: 15px; }
/* --sim-pin-top is where a pinned image sits: under the site header where that is pinned (72px, 60px on phones),
   and at the very top of the screen elsewhere, so nothing scrolling past shows above it.
   --sim-vh is the screen height with the browser's bars showing, so a pinned image does not resize as they hide. */
.simulator { --sim-pin-top: 0px; --sim-vh: 100vh; }
/* A control brought into view stops 4px below what is pinned. The page already keeps --nav-clearance free
   at the top of the screen for every scroll, which is more than the pinned image's own offset, so the
   difference comes off: otherwise a field up to 43px under a pinned picture would shift when clicked. */
.simulator { --sim-clear: calc(var(--sim-pin-top) - var(--nav-clearance, 0px) + 4px); }
@supports (height: 1svh) { .simulator { --sim-vh: 100svh; } }
@media (max-width: 1040px) { .simulator { --sim-pin-top: 72px; } }
@media (max-width: 736px) { .simulator { --sim-pin-top: 60px; } }
.simulator .sim-notice { border: 1px solid #e6d7b1; border-radius: 6px; padding: 8px 12px; background: var(--sim-tint); }
.simulator h2 { font-size: 18px; line-height: 1.3; margin: 0; }
.simulator p { margin: 0 0 10px; }
.simulator .sim-small { font-size: 13px; line-height: 1.45; color: var(--muted); }
.simulator #sim-targets { padding: 0; }
.simulator #sim-completion-status { margin: 8px 0 0; font-weight: 700; }
.simulator #sim-completion-status:empty { margin: 0; }
.simulator #sim-exam-targets { margin: 0 0 10px; padding-inline-start: 22px; }
.simulator #sim-toggle-image { display: none; }
.simulator .sim-row { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.simulator .sim-workspace { display: grid; grid-template-columns: minmax(0,1fr) 304px; gap: 14px; align-items: start; }
.simulator .sim-panel { min-width: 0; background: var(--paper); border: 1px solid var(--sim-edge); border-radius: 10px; box-shadow: 0 1px 3px rgba(21, 21, 21, 0.04); }
.simulator .sim-panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; padding: 10px 14px; background: #fafafa; border-bottom: 1px solid var(--sim-edge); border-radius: 10px 10px 0 0; }
.simulator .sim-panel-content { padding: 13px 14px; }
.simulator .sim-panel-content h2 { margin-bottom: 9px; }
.simulator .sim-badge { padding: 2px 8px; background: var(--light); border: 1px solid var(--sim-edge); border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.simulator .sim-learning { display: grid; gap: 12px; min-width: 0; }
.simulator button { min-height: 44px; padding: 5px 10px; border: 1px solid var(--line-strong, #c2c2c2); border-radius: 6px; background: var(--paper); color: var(--ink, #1d1d1d); font-weight: 600; font-size: 13px; line-height: 1.35; transition: background-color .12s ease, border-color .12s ease; }
/* Only where a pointer can hover: on a touch screen the hover look stays on whatever sits under the last tap. */
@media (hover: hover) { .simulator button:hover:not(:disabled) { border-color: var(--sim-gold); background: #fafafa; } }
/* A chosen button keeps its chosen look under a pointer, and under the hover a touch screen leaves behind after a tap. */
.simulator button[aria-pressed=true], .simulator button[aria-pressed=true]:hover:not(:disabled) { border-color: var(--sim-gold); background: var(--sim-tint); box-shadow: inset 0 0 0 1px var(--sim-gold); color: var(--ink, #1d1d1d); font-weight: 700; }
.simulator button:disabled { color: var(--muted); background: var(--light); border-color: var(--sim-edge); cursor: default; }
.simulator .sim-field { display: block; min-width: 0; font-size: 13px; font-weight: 700; }
.simulator .sim-field input:not([type=range]), .simulator .sim-field select { min-height: 44px; margin: 3px 0 0; padding: 4px 7px; font-size: 14px; border-radius: 6px; }
.simulator .sim-field.sim-mode-picker { display: flex; align-items: center; gap: 8px; }
.simulator .sim-field.sim-mode-picker select { width: auto; margin-top: 0; }
.simulator .sim-field input[type=range] { display: block; width: 100%; accent-color: #866620; }
.simulator .sim-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin: 10px 0; }
.simulator .sim-settings-group { grid-column: 1 / -1; margin: 8px 0 0; padding-bottom: 3px; border-bottom: 1px solid #e2e2e2; font-size: 13px; font-weight: 700; color: #565656; }
.simulator .sim-settings-group:first-child { margin-top: 2px; }
/* A number field. Its − and + buttons show on touch screens only (below); a mouse and keyboard have the field's own steps. */
.simulator .sim-number { position: relative; min-width: 0; }
.simulator .sim-number-step { display: none; }
.simulator .sim-check { position: relative; min-height: 44px; display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border: 1px solid var(--line-strong, #c2c2c2); border-radius: 6px; background: var(--paper); color: var(--ink, #1d1d1d); font-size: 13px; font-weight: 600; line-height: 1.25; cursor: pointer; user-select: none; }
.simulator .sim-check::before { content: ""; width: 7px; height: 7px; border-radius: 999px; border: 1.5px solid #959595; background: transparent; flex: none; }
@media (hover: hover) { .simulator .sim-check:hover:not(:has(input:disabled)):not(:has(input:checked)) { border-color: var(--sim-gold); background: #fafafa; } }
.simulator .sim-check:has(input:checked) { border-color: var(--sim-gold); background: var(--sim-tint); color: var(--ink, #1d1d1d); font-weight: 700; box-shadow: inset 0 0 0 1px var(--sim-gold); }
.simulator .sim-check:has(input:checked)::before { border-color: var(--sim-gold); background: var(--sim-gold); box-shadow: 0 0 0 2px rgba(139, 104, 38, 0.18); }
.simulator .sim-check:has(input:focus-visible) { outline: 3px solid #4c7a9e; outline-offset: 2px; }
.simulator .sim-check:has(input:disabled) { opacity: .55; cursor: default; }
.simulator .sim-check input { position: absolute; inset: -1px; width: calc(100% + 2px); height: calc(100% + 2px); margin: 0; opacity: 0; cursor: pointer; }
.simulator .sim-check input:disabled { cursor: default; }
.simulator .sim-field select { padding-inline-start: var(--select-start-padding); }
.simulator .sim-body select { margin-bottom: 7px; }
.simulator summary { font-size: 13px; font-weight: 700; cursor: pointer; padding: 12px 0; min-height: 44px; box-sizing: border-box; }
.simulator details { border-top: 1px solid var(--line); margin-top: 8px; }
.simulator canvas { display: block; width: 100%; }
.simulator #sim-ultrasound { aspect-ratio: 4 / 3; background: #070707; cursor: crosshair; touch-action: pan-y; }
.simulator #sim-spectrum { aspect-ratio: 320 / 110; background: #101113; }
.simulator .sim-screen-label, .simulator .sim-screen-foot { color: #eaeaea; background: #22211f; font-size: 12px; padding: 4px 10px; margin: 0; }
.simulator .sim-screen-foot { display: flex; flex-wrap: wrap; gap: 3px 10px; }
.simulator .sim-red { color: #ffaca2; }
.simulator .sim-blue { color: #a5cfff; }
.simulator .sim-finding { font-weight: 700; border: 1px solid var(--sim-edge); border-radius: 6px; padding: 7px 10px; background: var(--light, #efefef); }
.simulator .sim-finding:empty, .simulator #sim-scale-note:empty { display: none; }
.simulator .sim-fallback { padding: 20px 12px; background: #efefef; }
.simulator figure { margin: 6px 0 0; }
.simulator .sim-reference { grid-column: 1 / -1; scroll-margin-top: var(--sim-clear); }
.simulator .sim-reference > summary h2 { display: inline; margin-right: 12px; }
.simulator .sim-reference h3 { font-size: 17px; line-height: 1.35; margin: 0 0 8px; }
.simulator .sim-examples-layout { display: grid; grid-template-columns: minmax(0,620px) minmax(240px,1fr); gap: 20px; margin-top: 18px; justify-content: start; }
.simulator .sim-examples-layout figure { min-width: 0; margin: 0; }
.simulator #sim-example-caption { padding-top: 10px; }
.simulator .sim-example-note { margin: 12px 0; }
.simulator .sim-matched-reference { border-top: 1px solid var(--sim-edge); margin-top: 18px; padding-top: 14px; }
.simulator .sim-matched-reference figure { max-width: 960px; }
.simulator #sim-timing { aspect-ratio: 320 / 48; background: #101113; }
.simulator .sim-recorded { position: relative; background: #101113; border-radius: 3px; overflow: hidden; }
.simulator .sim-recorded img, .simulator .sim-recorded video { display: block; width: 100%; height: auto; }
.simulator .sim-recorded svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.simulator .sim-recorded svg text { font-size: 4.5px; fill: #fff6ce; stroke: #251d07; stroke-width: .3; paint-order: stroke; }
.simulator #sim-reference-caption { padding-top: 7px; }
.simulator #sim-ivc-controls { margin-top: 12px; }
.simulator #sim-measurement { margin-top: 8px; }
.simulator #sim-measurement[data-outdated] { font-weight: 400; color: var(--muted); }
.simulator #sim-interpretation { border-top: 1px solid var(--line); padding: 8px 0; margin-top: 8px; }
.simulator #sim-review-answer { margin-top: 6px; }
.simulator #sim-answer-result { margin: 7px 0 0; }
.simulator .sim-exam { margin-top: 9px; }

.simulator .sim-anatomy-plate, .simulator .sim-section-image { position: relative; aspect-ratio: 5 / 4; overflow: hidden; background: #f7f7f7; }
.simulator #sim-body, .simulator #sim-companion-canvas { width: 100%; height: 100%; }
/* The section is drawn 5:4; where a height limit reshapes its box it letterboxes instead of stretching. */
.simulator #sim-companion-canvas { object-fit: contain; }
.simulator #sim-body { touch-action: pan-y; cursor: grab; }
.simulator #sim-body[data-moving-probe=true] { touch-action: none; cursor: crosshair; }
.simulator #sim-body:focus-visible { outline: 3px solid #b49449; outline-offset: -3px; }
.simulator #sim-live-image { aspect-ratio: 5 / 4; object-fit: contain; background: #070707; }
.simulator #sim-anatomy-labels { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.simulator .sim-ct-handoff { margin-bottom: 10px; }
.simulator .sim-anatomy-header { justify-content: space-between; margin-bottom: 8px; }
.simulator .sim-anatomy-selection { font-weight: 700; margin: 0; }
.simulator .sim-anatomy-key { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 10px 0 0; }
.simulator .sim-anatomy-key i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.simulator .sim-vein-key { background: #426c98; }
.simulator .sim-artery-key { background: #b64c45; }
.simulator .sim-marker-key { background: #44cee6; }
.simulator .sim-section-near, .simulator .sim-section-deep { position: absolute; inset-inline-start: 10px; padding: 2px 6px; background: #fafafa; color: #313131; font-size: 12px; font-weight: 700; pointer-events: none; }
.simulator .sim-section-near { top: 10px; }
.simulator .sim-section-deep { bottom: 10px; }
.simulator .sim-section-marker { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -100%); width: 24px; height: 24px; fill: #76581a; stroke: #f9f9f9; stroke-width: 1.3; stroke-linejoin: round; pointer-events: none; }

.simulator .sim-position { display: grid; grid-template-columns: 64px minmax(0,1fr); align-items: start; gap: 4px 10px; }
.simulator .sim-position-controls { display: contents; }
.simulator .sim-position-choice, .simulator #sim-orientation { grid-column: 1 / -1; }
.simulator #sim-probe-contact { align-self: center; margin: 0; }
.simulator .sim-probe-guide { display: block; width: 100%; max-height: 155px; }
.simulator .sim-guide-body { fill: #eeeeee; stroke: #a1a1a1; stroke-width: 1.3; }
.simulator .sim-guide-ribs { fill: none; stroke: #b9b9b9; stroke-width: 1.3; }
.simulator .sim-guide-axis { fill: none; stroke: #a8a8a8; stroke-width: 0.8; stroke-dasharray: 2 3; }
.simulator .sim-probe-guide [hidden] { display: none; }
.simulator .sim-guide-navel { fill: #a7a7a7; }
.simulator .sim-probe-guide text { font: 10px system-ui,sans-serif; fill: #6c6c6c; }
/* The guide is drawn small, so R and L are drawn large in its bottom corners to read at about 12px. */
.simulator .sim-probe-guide .sim-guide-side-letter { font-size: 30px; font-weight: 700; fill: #5d5d5d; }
.simulator #sim-probe-marker rect { fill: #414743; stroke: #f7f7f7; stroke-width: 2; }
.simulator #sim-probe-marker path { fill: #878a7e; }
.simulator #sim-probe-marker circle { fill: #44cee6; }
.simulator .sim-step-label { display: block; color: var(--muted); font-size: 12px; margin: 6px 0; }
.simulator #sim-orientation { margin: 8px 0 0; }
.simulator .sim-interaction { font-size: 13px; line-height: 1.5; }
.simulator #sim-ultrasound[data-editing=true] { touch-action: none; }
.simulator .sim-body { grid-column: 1 / -1; padding: 0 13px; margin-top: 0; scroll-margin-top: var(--sim-clear); }
.simulator .sim-body[open] { padding-bottom: 13px; }
.simulator .sim-anatomy-controls { margin-top: 12px; }
.simulator .sim-anatomy-options { gap: 6px 18px; }
.simulator .sim-probe-maneuvers { gap: 8px 18px; margin: 0 0 12px; font-size: 13px; }
.simulator .sim-probe-maneuvers button { min-width: 44px; }
.simulator .sim-probe-maneuvers .icon { width: 16px; height: 16px; vertical-align: -3px; }
.simulator .sim-anatomy-expanded { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: start; gap: 14px; max-width: 1040px; }
/* Views lead; probe and camera controls sit in a rail beside them, as in Explore anatomy. */
.simulator .sim-anatomy-layout { display: grid; grid-template-columns: 250px minmax(0,1fr); grid-template-areas: "rail views" "rail vessels"; grid-template-rows: auto 1fr; gap: 10px 14px; align-items: start; }
.simulator .sim-anatomy-layout .sim-anatomy-expanded { grid-area: views; }
.simulator .sim-slice-vessels { grid-area: vessels; min-width: 0; max-width: 1040px; }
.simulator .sim-slice-vessels p { margin: 0 0 6px; }
.simulator .sim-anatomy-rail { grid-area: rail; min-width: 0; }
.simulator .sim-anatomy-rail #sim-anatomy-description { margin: 0 0 8px; }
.simulator .sim-anatomy-rail #sim-camera-controls { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; margin-top: 0; }
.simulator .sim-anatomy-rail #sim-move-probe { display: block; width: 100%; margin-bottom: 6px; }
.simulator .sim-anatomy-rail #sim-anatomy-face { grid-column: 1 / -1; }
.simulator .sim-anatomy-rail .sim-fields { grid-template-columns: minmax(0,1fr); }
.simulator .sim-anatomy-rail .sim-probe-maneuvers { margin-bottom: 4px; gap: 8px 12px; }
.simulator .sim-anatomy-rail .sim-anatomy-options { gap: 0 18px; }
@media (min-width: 761px) {
  /* On a short, wide screen the 3D views shrink to stay in sight. An explicit width keeps the limit from narrowing them. */
  .simulator .sim-anatomy-plate, .simulator .sim-section-image, .simulator #sim-live-image { width: 100%; max-height: max(240px, 100vh - 150px); max-height: max(240px, 100dvh - 150px); }
}
@media (pointer: coarse) {
  /* iPhone Safari zooms the whole page when a field with text under 16px takes focus. */
  .simulator .sim-field input:not([type=range]), .simulator .sim-field select { font-size: 16px; }
  /* A slider is grabbed by a full-height target, not only the thin track. */
  .simulator .sim-field input[type=range] { height: 44px; }
  /* The starting-window select and the slide slider line up along their bottoms. */
  .simulator .sim-anatomy-rail .sim-fields { align-items: end; }
}
@media (pointer: coarse), (max-width: 760px) {
  /* On a touch screen a number changes with the − and + at its field's ends, so the keyboard need not open.
     Each field sits at the bottom of its grid row, so the buttons meet it whatever the label's length. */
  .simulator .sim-number { align-self: end; }
  .simulator .sim-number-step { display: block; position: absolute; bottom: 0; left: 0; width: 44px; padding: 0; font-size: 19px; border-radius: 4px 0 0 4px; }
  .simulator .sim-number-step:last-child { left: auto; right: 0; border-radius: 0 4px 4px 0; }
  .simulator .sim-number input[type=number] { padding-inline: 46px; text-align: center; appearance: textfield; -moz-appearance: textfield; }
  .simulator .sim-number input[type=number]::-webkit-inner-spin-button, .simulator .sim-number input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
}
@media (max-width: 350px) {
  /* The narrowest phones have no room for two fields with their buttons side by side: four digits would be cut off. */
  .simulator .sim-fields:has(> .sim-number) { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 900px) {
  .simulator .sim-anatomy-layout { grid-template-columns: minmax(0,1fr); grid-template-areas: "views" "rail" "vessels"; grid-template-rows: auto; }
  .simulator .sim-anatomy-rail .sim-fields { grid-template-columns: repeat(2,minmax(0,1fr)); }
  /* Under the views the camera buttons have room for three across. */
  .simulator .sim-anatomy-rail #sim-camera-controls { grid-template-columns: repeat(6,minmax(0,1fr)); }
  .simulator .sim-anatomy-rail #sim-camera-controls > button { grid-column: span 2; padding-inline: 4px; }
  .simulator .sim-anatomy-rail #sim-camera-controls > [data-adjust] { grid-column: span 3; }
}
.simulator .sim-anatomy-expanded:has(#sim-live-scan:not([hidden])) #sim-companion-figure { grid-column: 1; }
.simulator .sim-anatomy-card { min-width: 0; margin: 0; border: 1px solid var(--sim-edge); }
.simulator .sim-anatomy-card figcaption { padding: 8px 10px; }
.simulator .sim-anatomy-card figcaption span { display: block; }
.simulator .sim-anatomy-card .sim-anatomy-note { margin: 0; padding: 8px 10px; border-top: 1px solid var(--sim-edge); }
.simulator .sim-reference { margin-top: 0; }
.simulator .sim-body > summary, .simulator .sim-reference > summary { min-height: 44px; padding: 12px 0; }
.simulator #sim-ultrasound:focus-visible { outline: 3px solid #b49449; outline-offset: -3px; }
@media (max-width: 760px) {
  .simulator .sim-workspace { grid-template-columns: minmax(0,1fr); }
  .simulator .sim-examples-layout { display: flex; flex-direction: column-reverse; gap: 12px; }
  .simulator .sim-position .sim-row { gap: 5px; }
  .simulator .sim-position button { padding: 5px 8px; }
  .simulator #sim-targets { gap: 5px; }
  .simulator #sim-targets button { flex: 1 1 0; min-width: 44px; padding: 4px; }
  .simulator #sim-camera-controls { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); width: 100%; }
  .simulator #sim-anatomy-face { grid-column: 1 / -1; }
  .simulator .sim-anatomy-expanded:has(#sim-live-scan:not([hidden])) #sim-companion-figure { grid-column: 1 / -1; }

  /* Phone, practice scan: the image, then its trace, then the tools that act on
     them, then where the probe is. The panes dissolve so their parts can order. */
  [role=tabpanel] .simulator #sim-scanner-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .simulator .sim-panel-head { padding: 8px; }
  .simulator #sim-targets { width: 100%; }
  .simulator .sim-notice { font-size: 13px; line-height: 1.4; padding: 6px 10px; }
  /* The whole scanner is one column, so the pinned image stays for all of it. */
  .simulator .sim-scanner { display: flex; flex-direction: column; }
  .simulator .sim-screens, .simulator .sim-image-pane, .simulator .sim-trace-pane { display: contents; }
  .simulator .sim-scanner .sim-trace-tools { border-top: 0; }
  .simulator .sim-scanner > .sim-panel-content:not(.sim-panel) { border-top: 1px solid var(--sim-edge); }
  .simulator .sim-scanner > .sim-panel { border-width: 1px 0 0; border-radius: 0; }
  /* The rail is empty once its panels have joined the scanner. */
  .simulator .sim-learning:not(:has(> *)) { display: none; }
  .simulator .sim-scan-tools { padding: 8px 10px 4px; display: flex; flex-wrap: wrap; gap: 0 12px; }
  .simulator #sim-setup { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); width: 100%; gap: 8px; }
  .simulator #sim-setup label { display: grid; align-content: end; gap: 3px; }
  .simulator #sim-setup select { width: 100%; min-width: 0; }
  .simulator #sim-waveform-controls { display: none; }
  .simulator #sim-core-controls { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); padding: 3px 6px; gap: 4px; background: #fafafa; border-bottom: 1px solid #dadada; }
  .simulator #sim-core-controls button { padding: 3px 2px; line-height: 1.15; border-radius: 5px; }
  .simulator #sim-core-controls .sim-check { padding: 3px 2px; justify-content: center; text-align: center; gap: 3px; font-size: 12px; line-height: 1.15; border-radius: 5px; }
  .simulator #sim-core-controls .sim-check::before { width: 8px; height: 8px; }
  .simulator #sim-toggle-image:not([hidden]) { display: inline-block; margin: 0 0 8px; }
  .simulator .sim-screens[data-image-collapsed] :is(#sim-ultrasound, .sim-image-heading, #sim-color-legend) { display: none; }
  .simulator .sim-scan-feedback { padding: 0 10px 10px; }
  .simulator .sim-scan-feedback .sim-interaction { margin-bottom: 6px; }
  .simulator .sim-position { grid-template-columns: 52px minmax(0,1fr); }
  .simulator .sim-step-label { margin: 4px 0; }
  /* Chips scroll sideways in one row instead of stacking. */
  .simulator #sim-visible-vessels .sim-row, .simulator .sim-slice-vessels .sim-row { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
  .simulator #sim-visible-vessels button, .simulator .sim-slice-vessels button { flex: none; min-width: 44px; }
  .simulator summary { min-height: 44px; padding-block: 12px; }
  /* The fold-out panels read as one set: Real ultrasound's heading takes the size of the others, and closed
     it is as tall as they are, with its title in line with theirs. */
  .simulator .sim-reference > summary h2 { font-size: inherit; }
  .simulator .sim-reference { padding-inline: 10px; }
  .simulator .sim-reference:not([open]) { padding-block: 0; }

  /* Phone, 3D teaching anatomy: both views stay short enough to share the
     screen, and the probe controls come straight after them. */
  .simulator .sim-body { padding: 0 10px; }
  .simulator .sim-body .sim-notice { margin-bottom: 6px; }
  .simulator .sim-body .sim-ct-handoff { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; }
  .simulator .sim-body .sim-ct-handoff p { margin: 0; font-size: 12px; line-height: 1.3; }
  .simulator .sim-body .sim-ct-handoff button { flex: none; padding: 5px 9px; font-size: 12px; }
  .simulator .sim-anatomy-header { margin-bottom: 4px; }
  .simulator #sim-anatomy-landmark { margin-bottom: 6px; font-size: 12px; line-height: 1.35; }
  .simulator .sim-anatomy-expanded { grid-template-columns: minmax(0,1fr); gap: 6px; background: var(--paper); }
  .simulator .sim-anatomy-card figcaption { padding: 2px 10px; font-size: 13px; }
  /* Both views stay short enough to pin together with room for the controls beneath.
     An explicit width stops the height limit from narrowing the box through its aspect ratio. */
  .simulator .sim-anatomy-plate, .simulator .sim-section-image, .simulator #sim-live-image { width: 100%; max-height: calc(var(--sim-vh) * .22); }
  .simulator .sim-anatomy-card .sim-anatomy-note { padding: 4px 10px; font-size: 12px; line-height: 1.35; }
  /* The B-mode's note stays available to screen readers and gives its room to the controls. */
  .simulator #sim-live-note { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
  /* With the perpendicular section on, it shares a row with the B-mode under the 3D view. */
  .simulator .sim-anatomy-expanded:has(#sim-companion-figure:not([hidden])):has(#sim-live-scan:not([hidden])) { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .simulator .sim-anatomy-expanded:has(#sim-companion-figure:not([hidden])):has(#sim-live-scan:not([hidden])) > :first-child { grid-column: 1 / -1; }
  .simulator .sim-anatomy-expanded:has(#sim-companion-figure:not([hidden])):has(#sim-live-scan:not([hidden])) #sim-companion-figure { grid-column: auto; }
  /* Side by side, the two cards share caption, image and note rows, so their images line up whatever the captions' lengths. */
  @supports (grid-template-rows: subgrid) {
    .simulator .sim-anatomy-expanded:has(#sim-companion-figure:not([hidden])):has(#sim-live-scan:not([hidden])) :is(#sim-live-scan, #sim-companion-figure) { display: grid; grid-template-rows: subgrid; grid-row: 2 / span 3; row-gap: 0; }
    .simulator .sim-anatomy-expanded:has(#sim-companion-figure:not([hidden])):has(#sim-live-scan:not([hidden])) #sim-live-note { position: static; width: auto; height: auto; padding: 4px 10px; overflow: visible; clip-path: none; white-space: normal; border-top: 1px solid var(--sim-edge); }
  }
  /* Stretch, so the chip row scrolls inside the column instead of widening the page. */
  .simulator .sim-anatomy-layout { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
  .simulator .sim-anatomy-rail { display: contents; }
  /* Source order: the hint, Move probe, the controls that move it, the camera, the display options, the vessels. */
  .simulator .sim-anatomy-rail :is(#sim-anatomy-description, #sim-move-probe, #sim-probe-positioning, #sim-probe-maneuvers) { margin: 0; }
}

/* Where the scanner is a single column (a phone always; up to the two-pane
   width with PW on) its parts take this order: the image, its trace and the
   ECG, then the tools. Each keeps its source order within a step, so the tab
   order matches. Elsewhere the panes are blocks and the order has no effect. */
.simulator .sim-scanner .sim-scan-tools { order: 1; }
.simulator .sim-scanner .sim-scan-feedback { order: 2; }
.simulator .sim-scanner .sim-measure-tools { order: 3; }
.simulator .sim-scanner :is(.sim-trace-tools, .sim-scanner-settings) { order: 4; }
/* On a phone the script places these in the order they are seen. */
.simulator .sim-scanner > :is(.sim-panel, .sim-panel-content) { order: 5; }
@media (min-width: 761px) and (max-width: 1079px) and (min-height: 600px) {
  /* With PW on there is no room for two panes, and stacked panes would put the
     image's tools between the image and its trace. Only where the screen is tall
     enough to pin both at a readable size: a shorter one (a large phone on its
     side) keeps the panes, which narrow to fit it. */
  .simulator .sim-scanner:has(.sim-screens[data-pw=true]) { display: flex; flex-direction: column; }
  .simulator .sim-screens[data-pw=true], .simulator .sim-screens[data-pw=true] > :is(.sim-image-pane, .sim-trace-pane) { display: contents; }
}

/* Single column: the image, and with PW on its trace, stay pinned under the
   site header while every practice control scrolls beneath them. On a short
   screen their boxes keep the full width and lose height, with the picture
   fitted inside, so 230px stays free for those controls (less only at the
   floors) and nothing shows beside a pinned view. Sizes come from the screen
   alone; the script measures the results (--sim-image-h, --sim-trace-h,
   --sim-views-h) for offsets and scroll margins. */
@media (max-width: 760px) and (min-height: 420px), (min-width: 761px) and (max-width: 1079px) and (min-height: 600px) {
  .simulator { --sim-room: calc(var(--sim-vh) - var(--sim-pin-top) - 230px); --sim-trace-max: max(69px, var(--sim-room) * .314); }
  /* With PW on, the image and the trace share that room in the proportion of their own heights (3/4 to 110/320). */
  .simulator .sim-screens[data-pw=true] #sim-ultrasound { position: sticky; top: var(--sim-pin-top); z-index: 2; max-height: max(150px, var(--sim-room) * .686); object-fit: contain; }
  .simulator .sim-screens[data-pw=true] #sim-spectrum { position: sticky; top: calc(var(--sim-pin-top) + var(--sim-image-h, 0px)); z-index: 2; max-height: var(--sim-trace-max); object-fit: contain; }
  /* Both stop pinning where the scanner ends. The image keeps room under it for the trace, so the two leave the
     screen together instead of the trace sliding up over the image; the next item takes that room back, so
     nothing moves. That item is the colour key when it shows, else the trace's label. */
  .simulator .sim-screens[data-pw=true] #sim-ultrasound { margin-bottom: var(--sim-trace-h, 0px); }
  .simulator .sim-screens[data-pw=true]:not([data-image-collapsed]) #sim-color-legend:not([hidden]),
  .simulator .sim-screens[data-pw=true]:not([data-image-collapsed]):has(#sim-color-legend[hidden]) #sim-spectrum-label { margin-top: calc(-1 * var(--sim-trace-h, 0px)); }
  /* The ECG strip under the trace shares its time axis, so it is fitted to the same picture width:
     both are 320 wide, 110 and 48 tall, so its limit is 48/110 of the trace's. */
  .simulator .sim-screens[data-pw=true] #sim-timing { max-height: calc(var(--sim-trace-max) * 48 / 110); object-fit: contain; }
  /* A control brought into view by focus stops below what is pinned. */
  .simulator .sim-scanner:has(.sim-screens[data-pw=true]) :is(button, input, select, summary) { scroll-margin-top: calc(var(--sim-image-h, 0px) + var(--sim-trace-h, 0px) + var(--sim-clear)); }
}
@media (max-width: 760px) and (min-height: 420px) {
  .simulator {
    --sim-toolbar-h: 50px;
    --sim-scan-top: calc(var(--sim-pin-top) + var(--sim-toolbar-h));
    --sim-room: min(var(--sim-vh) * .4, var(--sim-vh) - var(--sim-scan-top) - 230px);
  }
  .simulator #sim-core-controls { position: sticky; top: var(--sim-pin-top); z-index: 3; }
  .simulator #sim-ultrasound, .simulator .sim-screens[data-pw=true] #sim-ultrasound { top: var(--sim-scan-top); }
  .simulator #sim-ultrasound { position: sticky; z-index: 2; max-height: max(150px, var(--sim-vh) - var(--sim-scan-top) - 230px); object-fit: contain; box-shadow: 0 6px 14px rgba(10, 12, 16, 0.18); }
  .simulator .sim-screens[data-pw=true] #sim-spectrum { top: calc(var(--sim-scan-top) + var(--sim-image-h, 0px)); box-shadow: 0 6px 14px rgba(10, 12, 16, 0.22); }
  .simulator .sim-scanner { scroll-margin-top: var(--sim-clear); }
  .simulator .sim-scanner :is(button, input, select, summary),
  .simulator .sim-scanner:has(.sim-screens[data-pw=true]) :is(button, input, select, summary) { scroll-margin-top: calc(var(--sim-toolbar-h) + var(--sim-image-h, 0px) + var(--sim-trace-h, 0px) + var(--sim-clear)); }
  .simulator .sim-scanner #sim-core-controls :is(button, input) { scroll-margin-top: var(--sim-clear); }
  /* Both 3D teaching views stay pinned while the probe and camera controls scroll beneath them. */
  .simulator .sim-anatomy-expanded { position: sticky; top: var(--sim-pin-top); z-index: 2; }
  .simulator .sim-anatomy-layout :is(button, input, select) { scroll-margin-top: calc(var(--sim-views-h, 0px) + var(--sim-clear)); }
}
@media (min-width: 370px) and (max-width: 760px) {
  .simulator #sim-core-controls .sim-check { white-space: nowrap; }
}
@media (max-width: 480px) and (min-height: 420px) {
  .simulator .sim-screens:not([data-pw=true]) #sim-ultrasound { max-height: max(150px, var(--sim-vh) - 460px); }
}
@media (max-width: 760px) and (max-height: 639px) {
  /* Three views leave too little working room on a short screen, so with the perpendicular section on they scroll. */
  .simulator .sim-anatomy-expanded:has(#sim-companion-figure:not([hidden])) { position: static; }
}
/* Wider screens: with the panes dissolved the image pins inside the whole
   scanner panel, so the tools under it and the rail beside it share the screen
   with it. The two-pane PW layout keeps its panes. */
@media (min-width: 761px) {
  .simulator .sim-screens:not([data-pw=true]), .simulator .sim-screens:not([data-pw=true]) > :is(.sim-image-pane, .sim-trace-pane) { display: contents; }
  .simulator .sim-screens:not([data-pw=true]) > * > * { width: min(100%, 720px, max(300px, (var(--sim-vh) - 250px) * 4 / 3)); margin-inline: auto; }
}
@media (min-width: 761px) and (min-height: 520px) {
  .simulator .sim-screens:not([data-pw=true]) #sim-ultrasound { position: sticky; top: var(--sim-pin-top); z-index: 2; }
  /* A control reached by keyboard under the pinned image scrolls clear of it. */
  .simulator .sim-scanner:has(.sim-screens:not([data-pw=true])) :is(button, input, select, summary) { scroll-margin-top: calc(var(--sim-image-h, 0px) + var(--sim-clear)); }
}

.simulator .sim-scanner { scroll-margin-top: var(--sim-clear); }
/* A control brought back into view keeps a little clear of the bottom edge. */
.simulator .sim-scanner :is(button, input, select, summary) { scroll-margin-bottom: 12px; }
.simulator .sim-scan-feedback { padding: 0 13px 12px; }
.simulator .sim-scan-feedback .sim-row { margin-bottom: 8px; }
.simulator .sim-scan-feedback p:last-child { margin-bottom: 0; }
/* The image stays short enough for its tools to share the screen with it. */
.simulator .sim-image-pane, .simulator .sim-trace-pane { width: min(100%, 720px, max(300px, (var(--sim-vh) - 250px) * 4 / 3)); margin-inline: auto; min-width: 0; }
.simulator .sim-scan-tools { padding-block: 8px; }
.simulator .sim-scan-tools .sim-core-controls { display: contents; }
.simulator .sim-waveform-controls { flex-wrap: nowrap; margin-top: 6px; }
.simulator .sim-case-picker { display: flex; align-items: center; gap: 8px; }
.simulator .sim-case-picker select { width: auto; margin-top: 0; }
/* The labels setting sits above the vessel list (or the actions, when labels are off) with room below it. */
.simulator .sim-scanner > .sim-panel-content > .sim-check { margin-bottom: 10px; }
/* Links in the real-ultrasound panel are full touch targets. */
.simulator .sim-reference .text-link { display: inline-flex; align-items: center; min-height: 44px; }

.simulator .sim-measure-tools:not(:has(> :not([hidden]))) { display: none; }
.simulator .sim-options { margin: 0; padding-block: 0; border-top: 1px solid var(--sim-edge); }
.simulator .sim-options[open] { padding-bottom: 10px; }
.simulator .sim-options summary, .simulator #sim-pw-details > summary, .simulator .sim-scanner-settings > summary { min-height: 44px; padding-block: 12px; }
/* Every scanner setting sits in the scanner, under the pictures it changes, so those stay in sight while it is set. */
.simulator .sim-scanner-settings { margin: 0; padding: 0 10px; border-top: 1px solid var(--sim-edge); background: var(--paper); color: var(--ink); }
.simulator .sim-scanner-settings .sim-fields { margin-top: 0; }
.simulator .sim-secondary-actions { margin-top: 8px; }
.simulator .sim-reference-actions { margin: 4px 0 12px; }
.simulator #sim-preview-note { margin: 10px 0 0; }
@media (min-width: 1080px) {
  .simulator .sim-screens[data-pw=true] { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(0,1fr); align-items: start; }
  .simulator .sim-screens[data-pw=true] .sim-trace-pane { border-left: 1px solid #454542; }
}
@media (min-width: 1080px) and (min-height: 520px) {
  /* Two panes: both run the full height of the row, so the image and the trace
     each stay pinned in their own pane while either pane's tools scroll. */
  .simulator .sim-screens[data-pw=true] { align-items: stretch; }
  .simulator .sim-screens[data-pw=true] :is(#sim-ultrasound, #sim-spectrum) { position: sticky; top: var(--sim-pin-top); z-index: 2; }
  .simulator .sim-screens[data-pw=true] .sim-image-pane :is(button, input, select, summary) { scroll-margin-top: calc(var(--sim-image-h, 0px) + var(--sim-clear)); }
  .simulator .sim-screens[data-pw=true] .sim-trace-pane :is(button, input, select, summary) { scroll-margin-top: calc(var(--sim-trace-h, 0px) + var(--sim-clear)); }
  .simulator .sim-scanner:has(.sim-screens[data-pw=true]) > .sim-panel-content :is(button, input, select, summary) { scroll-margin-top: calc(max(var(--sim-image-h, 0px), var(--sim-trace-h, 0px)) + var(--sim-clear)); }
}

.simulator .sim-image-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.simulator .sim-image-heading .sim-badge { background: #393936; color: #eaeaea; padding: 0 5px; }

.simulator .sim-trace-tools { padding: 10px; background: var(--paper); color: var(--ink); border-top: 1px solid var(--sim-edge); }
.simulator .sim-wave-knobs { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin-bottom: 8px; }
.simulator .sim-knob-label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 5px; }
.simulator .sim-knob-row { display: grid; grid-template-columns: 44px minmax(0,1fr) 44px; align-items: center; }
.simulator .sim-knob-row button { min-width: 44px; min-height: 44px; padding: 4px; font-size: 19px; }
.simulator .sim-knob-row output { text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; }
.simulator .sim-trace-tools p { margin: 0 0 5px; font-size: 12px; }
.simulator .sim-trace-tools p:last-child { margin-bottom: 0; }
@media (min-width: 761px) and (max-width: 1100px) {
  .simulator .sim-wave-knobs { grid-template-columns: minmax(0,1fr); }
}

/* A chip row that scrolls sideways fades out at its right edge until it is scrolled to the end, so a chip cut
   off there reads as "more this way". A row that fits has no scroll timeline, so it keeps no fade. */
@property --sim-row-fade { syntax: '<length>'; inherits: false; initial-value: 0px; }
@keyframes sim-row-fade { from { --sim-row-fade: 36px; } to { --sim-row-fade: 0px; } }
@supports (animation-timeline: scroll()) {
  @media (max-width: 760px) {
    .simulator :is(#sim-visible-vessels, .sim-slice-vessels) .sim-row {
      -webkit-mask-image: linear-gradient(to left, transparent, #000 var(--sim-row-fade));
      mask-image: linear-gradient(to left, transparent, #000 var(--sim-row-fade));
      animation: sim-row-fade linear both; animation-timeline: scroll(self inline);
    }
  }
}
