:root {
  color-scheme: light;
  --ink: #342a2b;
  --muted-ink: #716264;
  --cream: #f6efeb;
  --paper: #fffaf7;
  --sage: #be8d88;
  --sage-dark: #804c52;
  --taupe: #b5a29b;
  --line: rgba(83, 58, 61, 0.15);
  --shadow: 0 20px 60px rgba(83, 56, 58, 0.14);
  --focus: #315f8d;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--cream);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 7%, rgba(226, 137, 126, 0.22), transparent 25rem),
    radial-gradient(circle at 94% 22%, rgba(91, 145, 183, 0.18), transparent 28rem),
    var(--cream);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
canvas:focus-visible,
summary:focus-visible,
.skip-link:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.75rem 1rem;
  color: white;
  background: #713f46;
  border-radius: 0.75rem;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  width: min(1600px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 1.25rem clamp(1rem, 2.5vw, 2.5rem) 1rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.brand-mark {
  position: relative;
  flex: 0 0 auto;
  width: 3.1rem;
  height: 3.1rem;
  border: 1px solid rgba(36, 48, 45, 0.14);
  background: var(--paper);
  border-radius: 1rem;
  box-shadow: 0 8px 24px rgba(74, 68, 57, 0.12);
}

.brand-mark span {
  position: absolute;
  border-radius: 50%;
}

.brand-mark span:nth-child(1) {
  inset: 0.7rem 1.55rem 0.7rem 0.55rem;
  background: #cf626d;
}

.brand-mark span:nth-child(2) {
  inset: 0.55rem 0.55rem 1.35rem 1.45rem;
  background: #5a91b7;
}

.brand-mark span:nth-child(3) {
  inset: 1.45rem 0.75rem 0.55rem 1.25rem;
  background: #efb45d;
}

.eyebrow,
.section-label,
.fact-label {
  margin: 0;
  color: var(--sage-dark);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1.2;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0.08rem 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 3vw, 2.35rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.08;
}

h2,
h3 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.quiet-button,
.view-button,
.control-button,
.icon-button,
.read-button,
.part-button {
  min-height: 2.75rem;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

.quiet-button:hover,
.view-button:hover,
.control-button:hover,
.icon-button:hover,
.read-button:hover,
.part-button:hover {
  transform: translateY(-1px);
}

.quiet-button {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.9rem;
  background: rgba(255, 253, 249, 0.78);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 750;
}

.contrast-icon {
  width: 1.05rem;
  height: 1.05rem;
  background: linear-gradient(90deg, var(--ink) 50%, var(--paper) 50%);
  border: 1px solid var(--ink);
  border-radius: 50%;
}

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

.heart-card,
.info-card {
  overflow: hidden;
  background: rgba(255, 253, 249, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 1.6rem;
  box-shadow: var(--shadow);
}

.heart-card {
  display: flex;
  min-height: 44rem;
  flex-direction: column;
  padding: clamp(1rem, 2vw, 1.4rem);
}

.stage-heading,
.part-heading,
.picker-heading,
.slider-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.stage-heading {
  padding: 0 0.15rem 0.85rem;
}

.stage-heading h2,
.part-heading h2 {
  margin: 0.15rem 0 0;
  font-size: clamp(1.4rem, 2.4vw, 2rem);
  line-height: 1.12;
}

.view-switch {
  display: flex;
  flex: 0 0 auto;
  gap: 0.2rem;
  padding: 0.25rem;
  background: #ebe7df;
  border-radius: 999px;
}

.view-button {
  min-height: 2.4rem;
  padding: 0.45rem 0.9rem;
  background: transparent;
  border-color: transparent;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 760;
}

.view-button.is-active {
  background: var(--paper);
  box-shadow: 0 3px 12px rgba(50, 50, 40, 0.12);
}

.flow-view-button.is-active {
  color: #fff;
  background: linear-gradient(110deg, #397eaa 0 46%, #ca5260 54% 100%);
  box-shadow: 0 4px 15px rgba(67, 71, 98, 0.24);
}

.heart-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 28rem;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 46%, rgba(255, 255, 255, 0.98) 0 15%, rgba(244, 231, 227, 0.66) 60%, rgba(220, 225, 232, 0.42) 100%),
    linear-gradient(#fcf8f6, #f2e9e6);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  isolation: isolate;
  transition: background 320ms ease, border-color 320ms ease, box-shadow 320ms ease;
}

.heart-stage.is-flowing {
  background:
    radial-gradient(circle at 50% 43%, rgba(120, 47, 67, 0.42) 0 16%, rgba(28, 42, 60, 0.92) 56%, #101a28 100%),
    #101a28;
  border-color: rgba(79, 117, 142, 0.56);
  box-shadow: inset 0 0 4rem rgba(5, 12, 22, 0.32);
}

.heart-stage.is-teaching {
  background:
    radial-gradient(circle at 50% 46%, rgba(255, 255, 255, 1) 0 17%, rgba(239, 235, 232, 0.78) 64%, rgba(216, 225, 232, 0.48) 100%),
    linear-gradient(#fffaf7, #eee8e5);
  box-shadow: inset 0 0 3rem rgba(102, 62, 67, 0.045);
}

.heart-stage::before {
  position: absolute;
  z-index: -1;
  right: -8%;
  bottom: -22%;
  left: -8%;
  height: 44%;
  background: linear-gradient(160deg, transparent 34%, rgba(201, 92, 104, 0.08) 35% 53%, transparent 54%);
  content: "";
}

.heart-visual {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 28rem;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.heart-visual.is-dragging {
  cursor: grabbing;
}

.heart-visual.is-hovering-part:not(.is-dragging) {
  cursor: pointer;
}

.heart-visual.has-model-error {
  cursor: default;
  background: url("assets/heart-assembled.png") center 48% / min(82%, 42rem) auto no-repeat;
}

.heart-visual.has-model-error::after {
  opacity: 0.08;
}

.heart-visual::after {
  position: absolute;
  z-index: 0;
  right: 20%;
  bottom: 6%;
  left: 20%;
  height: 7%;
  background: rgba(44, 53, 48, 0.14);
  border-radius: 50%;
  content: "";
  filter: blur(1rem);
  pointer-events: none;
  transform: scaleX(calc(1 + var(--heart-separation, 0) * 0.34));
  transition: opacity 180ms ease, transform 180ms ease;
}

.heart-visual.is-dragging::after {
  opacity: 0.1;
}

.heart-stage.is-flowing .heart-visual::after {
  background: rgba(2, 8, 16, 0.48);
  opacity: 0.58;
}

#heart-canvas {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 320ms ease;
}

#heart-canvas.is-ready {
  opacity: 1;
}

.anatomy-callouts {
  position: absolute;
  z-index: 5;
  inset: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.anatomy-callouts.is-visible {
  opacity: 1;
}

.callout-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.callout-line {
  stroke: color-mix(in srgb, var(--callout-color) 74%, #5b4d50);
  stroke-width: 1.35;
  stroke-linecap: round;
  opacity: 0.74;
  vector-effect: non-scaling-stroke;
}

.callout-dot {
  fill: var(--callout-color);
  stroke: rgba(255, 255, 255, 0.96);
  stroke-width: 2;
  opacity: 0.94;
  vector-effect: non-scaling-stroke;
}

.callout-line.is-selected {
  stroke-width: 2.3;
  opacity: 1;
}

.callout-dot.is-selected {
  stroke-width: 3;
  filter: drop-shadow(0 0 5px var(--callout-color));
}

.anatomy-callout {
  position: absolute;
  top: 0;
  left: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  min-height: 2.1rem;
  max-width: 9.5rem;
  padding: 0.36rem 0.58rem;
  color: #382f31;
  background: rgba(255, 253, 250, 0.94);
  border: 1px solid color-mix(in srgb, var(--callout-color) 38%, rgba(64, 50, 53, 0.18));
  border-radius: 999px;
  box-shadow: 0 0.35rem 1rem rgba(58, 42, 46, 0.13);
  backdrop-filter: blur(8px);
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1.15;
  pointer-events: auto;
  text-align: left;
  white-space: nowrap;
  will-change: transform;
}

.anatomy-callout i {
  flex: 0 0 auto;
  width: 0.54rem;
  height: 0.54rem;
  background: var(--callout-color);
  border: 1px solid rgba(49, 39, 41, 0.18);
  border-radius: 50%;
}

.anatomy-callout:hover,
.anatomy-callout.is-selected {
  background: white;
  border-color: var(--callout-color);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--callout-color) 20%, transparent), 0 0.45rem 1.1rem rgba(58, 42, 46, 0.16);
}

.model-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  display: grid;
  place-items: center;
  gap: 0.8rem;
  width: min(88%, 22rem);
  margin: 0;
  color: var(--sage-dark);
  font-size: 0.84rem;
  font-weight: 780;
  text-align: center;
  transform: translate(-50%, -50%);
}

.model-loading.is-hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.loading-heart {
  position: relative;
  display: block;
  width: 3.9rem;
  height: 3.6rem;
  animation: loading-heartbeat 1.35s ease-in-out infinite;
}

.loading-heart i {
  position: absolute;
  display: block;
  background: linear-gradient(145deg, #e47773, #bd5261);
  box-shadow: inset -0.25rem -0.25rem 0 rgba(99, 43, 49, 0.1);
}

.loading-heart i:nth-child(1) {
  top: 0.28rem;
  left: 0.34rem;
  width: 2.05rem;
  height: 2.05rem;
  border-radius: 50%;
}

.loading-heart i:nth-child(2) {
  top: 0.28rem;
  right: 0.34rem;
  width: 2.05rem;
  height: 2.05rem;
  border-radius: 50%;
}

.loading-heart i:nth-child(3) {
  top: 0.92rem;
  left: 0.82rem;
  width: 2.28rem;
  height: 2.28rem;
  border-radius: 0.34rem 0.48rem 0.34rem 0.48rem;
  transform: rotate(45deg);
}

@keyframes loading-heartbeat {
  0%,
  100% {
    transform: scale(1);
  }

  10% {
    transform: scale(1.08);
  }

  22% {
    transform: scale(1.025);
  }

  31% {
    transform: scale(1.065);
  }

  45% {
    transform: scale(1);
  }
}

.part-tooltip {
  position: absolute;
  z-index: 6;
  max-width: 11rem;
  padding: 0.38rem 0.58rem;
  color: var(--ink);
  background: rgba(255, 253, 249, 0.96);
  border: 1px solid rgba(42, 52, 49, 0.18);
  border-radius: 0.6rem;
  box-shadow: 0 0.4rem 1.1rem rgba(47, 49, 42, 0.16);
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  transform: translate(0.65rem, calc(-100% - 0.65rem));
  transition: opacity 100ms ease;
}

.part-tooltip.is-visible {
  opacity: 1;
}

.stage-badge,
.view-state {
  position: absolute;
  z-index: 7;
  pointer-events: none;
  user-select: none;
}

.stage-badge {
  top: 0.75rem;
  left: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.65rem;
  color: var(--muted-ink);
  background: rgba(255, 253, 249, 0.84);
  border: 1px solid rgba(60, 70, 65, 0.12);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  font-size: 0.79rem;
  font-weight: 740;
}

.drag-symbol {
  color: var(--sage-dark);
  font-size: 1rem;
}

.view-state {
  right: 0.75rem;
  bottom: 0.75rem;
  padding: 0.42rem 0.68rem;
  color: var(--sage-dark);
  background: rgba(255, 253, 249, 0.9);
  border: 1px solid rgba(60, 70, 65, 0.12);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  font-size: 0.78rem;
  font-weight: 800;
}

.flow-hud {
  position: absolute;
  z-index: 7;
  bottom: 0.75rem;
  left: 0.75rem;
  width: min(17.5rem, calc(100% - 7.5rem));
  padding: 0.75rem 0.85rem;
  color: #f7fbff;
  background: rgba(12, 23, 36, 0.78);
  border: 1px solid rgba(173, 210, 232, 0.26);
  border-radius: 0.9rem;
  box-shadow: 0 0.65rem 1.7rem rgba(3, 8, 16, 0.26);
  backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.45rem);
  transition: opacity 220ms ease, transform 220ms ease;
}

.heart-stage.is-flowing .flow-hud {
  opacity: 1;
  transform: translateY(0);
}

.flow-status-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
}

.flow-hud p {
  margin: 0.28rem 0 0.55rem 1rem;
  color: rgba(239, 248, 255, 0.82);
  font-size: 0.76rem;
  line-height: 1.35;
}

.flow-pulse {
  width: 0.5rem;
  height: 0.5rem;
  background: #ff8191;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(255, 129, 145, 0.55);
  animation: flow-pulse 1.32s ease-out infinite;
}

.flow-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.85rem;
  margin-left: 1rem;
  color: rgba(245, 250, 255, 0.88);
  font-size: 0.69rem;
  font-weight: 720;
}

.flow-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
}

.flow-dot {
  width: 0.46rem;
  height: 0.46rem;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  box-shadow: 0 0 0.55rem currentColor;
}

.flow-dot-blue {
  color: #61c9ff;
  background: #61c9ff;
}

.flow-dot-red {
  color: #ff7884;
  background: #ff7884;
}

@keyframes flow-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 129, 145, 0.55);
    transform: scale(0.88);
  }

  55% {
    box-shadow: 0 0 0 0.48rem rgba(255, 129, 145, 0);
    transform: scale(1.12);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(255, 129, 145, 0);
    transform: scale(0.92);
  }
}

.model-controls {
  display: grid;
  grid-template-columns: auto minmax(12rem, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem 0.1rem 0.25rem;
}

.model-controls.is-flow-mode .action-buttons,
.model-controls.is-flow-mode .separation-control {
  opacity: 0.42;
}

.model-controls button:disabled,
.model-controls input:disabled {
  cursor: not-allowed;
}

.action-buttons {
  display: flex;
  gap: 0.5rem;
}

.control-button,
.icon-button,
.read-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 0.9rem;
  background: #f5f2ec;
  border-radius: 0.8rem;
  font-size: 0.88rem;
  font-weight: 780;
}

.control-button-primary {
  color: white;
  background: #536d61;
  border-color: #536d61;
}

.control-button-primary:hover {
  background: #425a50;
}

.icon-button {
  min-width: 5rem;
}

.separation-control {
  display: block;
  min-width: 0;
  color: var(--muted-ink);
  font-size: 0.78rem;
  font-weight: 730;
}

.slider-label-row output {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  --slider-progress: 0%;
  appearance: none;
  width: 100%;
  height: 2rem;
  margin: 0.1rem 0 0;
  background: transparent;
  cursor: ew-resize;
  touch-action: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 0.55rem;
  background: linear-gradient(90deg, var(--sage-dark) 0 var(--slider-progress), #d9d5cd var(--slider-progress) 100%);
  border: 1px solid rgba(36, 48, 45, 0.16);
  border-radius: 999px;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 1.35rem;
  height: 1.35rem;
  margin-top: -0.45rem;
  background: var(--paper);
  border: 0.23rem solid var(--sage-dark);
  border-radius: 50%;
  box-shadow: 0 0.28rem 0.65rem rgba(36, 48, 45, 0.25);
  cursor: grab;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

input[type="range"]::-moz-range-track {
  height: 0.55rem;
  background: #d9d5cd;
  border: 1px solid rgba(36, 48, 45, 0.16);
  border-radius: 999px;
}

input[type="range"]::-moz-range-progress {
  height: 0.55rem;
  background: var(--sage-dark);
  border-radius: 999px;
}

input[type="range"]::-moz-range-thumb {
  width: 1rem;
  height: 1rem;
  background: var(--paper);
  border: 0.23rem solid var(--sage-dark);
  border-radius: 50%;
  box-shadow: 0 0.28rem 0.65rem rgba(36, 48, 45, 0.25);
  cursor: grab;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.separation-control.is-scrubbing input[type="range"]::-webkit-slider-thumb {
  box-shadow: 0 0 0 0.35rem rgba(83, 109, 97, 0.16), 0 0.38rem 0.8rem rgba(36, 48, 45, 0.28);
  cursor: grabbing;
  transform: scale(1.12);
}

.separation-control.is-scrubbing input[type="range"]::-moz-range-thumb {
  box-shadow: 0 0 0 0.35rem rgba(83, 109, 97, 0.16), 0 0.38rem 0.8rem rgba(36, 48, 45, 0.28);
  cursor: grabbing;
  transform: scale(1.12);
}

.separation-control.is-scrubbing output {
  color: var(--sage-dark);
  font-weight: 850;
}

.interaction-tip {
  margin: 0.65rem 0 0;
  padding: 0.65rem 0.8rem;
  color: #58635f;
  background: rgba(141, 165, 152, 0.11);
  border-radius: 0.75rem;
  font-size: 0.82rem;
  line-height: 1.45;
}

.interaction-tip strong {
  color: var(--sage-dark);
}

.info-card {
  padding: clamp(1rem, 2vw, 1.4rem);
}

.large-swatch {
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  border: 4px solid rgba(255, 255, 255, 0.92);
  border-radius: 0.9rem;
  box-shadow: 0 0 0 1px var(--line), 0 8px 16px rgba(54, 54, 46, 0.12);
}

.part-summary {
  margin: 1rem 0;
  color: #45504c;
  font-size: 1.02rem;
  line-height: 1.65;
}

.fact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.fact-card {
  min-height: 7.7rem;
  padding: 0.85rem;
  background: #f5f2ec;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
}

.fact-card p:last-child {
  margin: 0.48rem 0 0;
  color: #3d4945;
  font-size: 0.88rem;
  line-height: 1.5;
}

.detail-actions {
  display: grid;
  gap: 0.65rem;
  margin: 0.8rem 0 1.1rem;
}

.part-health-connection {
  display: grid;
  gap: 0.55rem;
  margin: 0.85rem 0 1.05rem;
  padding: 0.85rem;
  background: linear-gradient(145deg, rgba(237, 245, 240, 0.82), rgba(249, 242, 235, 0.86));
  border: 1px solid rgba(78, 101, 89, 0.15);
  border-radius: 1rem;
}

.health-connection-heading h3 {
  margin: 0.18rem 0 0;
  font-size: 1.05rem;
}

.connection-card {
  display: flex;
  gap: 0.62rem;
  padding: 0.7rem;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(67, 75, 70, 0.10);
  border-radius: 0.75rem;
}

.connection-card > span {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 1.45rem;
  height: 1.45rem;
  color: white;
  background: #4f8268;
  border-radius: 50%;
  font-size: 0.82rem;
  font-weight: 900;
}

.connection-card-strain > span {
  background: #b86b4f;
}

.connection-card strong {
  color: #34443d;
  font-size: 0.79rem;
}

.connection-card p {
  margin: 0.2rem 0 0;
  color: #53605b;
  font-size: 0.76rem;
  line-height: 1.45;
}

.read-button {
  width: 100%;
  background: #eef2ef;
  border-color: rgba(83, 109, 97, 0.2);
}

.grown-up-detail {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
}

.grown-up-detail summary {
  min-height: 2.75rem;
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 780;
}

.grown-up-detail p {
  margin: 0;
  padding: 0 0.85rem 0.85rem;
  color: #55605c;
  font-size: 0.83rem;
  line-height: 1.55;
}

.part-picker {
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.picker-heading h3 {
  margin: 0;
  font-size: 1.05rem;
}

.picker-heading span {
  color: var(--muted-ink);
  font-size: 0.75rem;
  font-weight: 700;
}

.part-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.health-classroom {
  margin-top: 1rem;
  padding: clamp(1rem, 2.4vw, 1.65rem);
  overflow: hidden;
  background:
    radial-gradient(circle at 4% 5%, rgba(71, 127, 167, 0.13), transparent 21rem),
    radial-gradient(circle at 96% 100%, rgba(218, 80, 91, 0.12), transparent 24rem),
    rgba(255, 253, 249, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 1.6rem;
  box-shadow: var(--shadow);
}

.classroom-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.classroom-heading h2 {
  margin: 0.16rem 0 0;
  font-size: clamp(1.5rem, 2.7vw, 2.15rem);
}

.classroom-heading > p {
  width: min(31rem, 48%);
  margin: 0;
  color: #5b6661;
  font-size: 0.9rem;
  line-height: 1.5;
}

.classroom-grid {
  display: grid;
  grid-template-columns: 1.08fr 0.96fr 0.96fr;
  gap: 0.8rem;
}

.lesson-card {
  position: relative;
  min-width: 0;
  padding: 1rem;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(72, 65, 62, 0.12);
  border-radius: 1rem;
}

.lesson-card::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 0.24rem;
  background: var(--lesson-color, #5d8b73);
  content: "";
}

.lesson-card-move {
  --lesson-color: linear-gradient(90deg, #4e8fb4, #cf5663);
}

.lesson-card-food {
  --lesson-color: #5d8b73;
}

.lesson-card-protect {
  --lesson-color: #d18855;
}

.lesson-number {
  position: absolute;
  top: 0.65rem;
  right: 0.85rem;
  color: rgba(74, 58, 61, 0.12);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.35rem;
  font-weight: 700;
  line-height: 1;
}

.lesson-kicker {
  margin: 0;
  color: var(--sage-dark);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.lesson-card h3 {
  max-width: 85%;
  margin: 0.28rem 0 0.5rem;
  font-size: 1.17rem;
  line-height: 1.2;
}

.lesson-card > p:not(.lesson-kicker):not(.lesson-caution) {
  margin: 0;
  color: #4b5752;
  font-size: 0.86rem;
  line-height: 1.55;
}

.lesson-caution {
  margin: 0.7rem 0 0;
  padding: 0.62rem 0.7rem;
  color: #5c514c;
  background: rgba(247, 235, 220, 0.72);
  border-left: 3px solid #d18855;
  border-radius: 0.35rem 0.65rem 0.65rem 0.35rem;
  font-size: 0.8rem;
  line-height: 1.48;
}

.activity-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
  margin-top: 0.8rem;
  padding: 0.25rem;
  background: #e9ecea;
  border-radius: 0.8rem;
}

.activity-switch button {
  min-height: 2.45rem;
  padding: 0.45rem 0.6rem;
  color: #52605a;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0.62rem;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
}

.activity-switch button.is-active {
  color: white;
  background: linear-gradient(112deg, #3d7ea6, #c84f60);
  box-shadow: 0 0.3rem 0.8rem rgba(70, 65, 80, 0.22);
}

.activity-result {
  margin-top: 0.5rem;
  padding: 0.72rem;
  color: white;
  background: #283b49;
  border-radius: 0.75rem;
}

.activity-result strong {
  font-size: 0.81rem;
}

.activity-result p {
  margin: 0.2rem 0 0;
  color: rgba(245, 250, 252, 0.82);
  font-size: 0.75rem;
  line-height: 1.45;
}

.lesson-link {
  min-height: 2.5rem;
  margin-top: 0.8rem;
  padding: 0.48rem 0.72rem;
  color: #3e5e50;
  background: rgba(232, 242, 236, 0.84);
  border: 1px solid rgba(62, 94, 80, 0.2);
  border-radius: 0.7rem;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
}

.lesson-link:hover {
  background: #e3f0e8;
}

.classroom-note {
  margin: 0.85rem 0 0;
  padding: 0.75rem 0.85rem;
  color: #59635f;
  background: rgba(246, 242, 236, 0.78);
  border: 1px solid rgba(72, 65, 62, 0.10);
  border-radius: 0.8rem;
  font-size: 0.79rem;
  line-height: 1.5;
}

.part-button {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  padding: 0.55rem 0.62rem;
  color: #42504b;
  background: transparent;
  border-radius: 0.7rem;
  font-size: 0.78rem;
  font-weight: 730;
  line-height: 1.25;
  text-align: left;
}

.part-button.is-selected {
  color: var(--ink);
  background: #f1eee8;
  border-color: rgba(67, 85, 78, 0.28);
  box-shadow: inset 3px 0 0 var(--part-color);
}

.part-button-swatch {
  flex: 0 0 auto;
  width: 0.72rem;
  height: 0.72rem;
  background: var(--part-color);
  border: 1px solid rgba(36, 48, 45, 0.22);
  border-radius: 50%;
}

footer {
  margin: 0.85rem 0 0;
  padding: 0 0.25rem;
  color: #69736f;
  font-size: 0.75rem;
  text-align: center;
}

footer p {
  margin: 0;
}

.model-credit {
  margin-top: 0.22rem;
  color: #7a827f;
  font-size: 0.75rem;
}

.health-sources {
  margin-top: 0.28rem;
  color: #7a827f;
  font-size: 0.72rem;
}

.health-sources a {
  color: inherit;
  text-underline-offset: 0.14em;
}

.model-credit a {
  color: inherit;
  text-underline-offset: 0.14em;
}

.model-credit a:hover {
  color: var(--ink);
}

.noscript-message {
  position: fixed;
  inset: 1rem;
  z-index: 20;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 1rem;
  color: white;
  background: #26342f;
  border-radius: 1rem;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

body.high-contrast {
  --ink: #0a0a0a;
  --muted-ink: #222;
  --cream: #fff;
  --paper: #fff;
  --sage-dark: #163f2d;
  --line: rgba(0, 0, 0, 0.42);
  --shadow: 0 0 0 2px #111;
  --focus: #005fcc;
  background: white;
}

body.high-contrast .heart-stage,
body.high-contrast .fact-card,
body.high-contrast .interaction-tip,
body.high-contrast .view-switch,
body.high-contrast .control-button,
body.high-contrast .read-button,
body.high-contrast .health-classroom,
body.high-contrast .lesson-card,
body.high-contrast .part-health-connection,
body.high-contrast .connection-card {
  background: white;
}

body.high-contrast .control-button-primary {
  color: white;
  background: #111;
}

body.high-contrast .part-tooltip {
  color: #000;
  background: #fff;
  border-color: #000;
}

body.high-contrast .anatomy-callout {
  color: #000;
  background: #fff;
  border-color: #000;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: minmax(0, 1.4fr) minmax(18rem, 0.8fr);
  }

  .model-controls {
    grid-template-columns: 1fr auto;
  }

  .action-buttons {
    grid-column: 1 / -1;
  }

  .classroom-grid {
    grid-template-columns: 1fr 1fr;
  }

  .lesson-card-move {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 0.8rem 0.7rem 1rem;
  }

  .topbar {
    align-items: flex-start;
    padding: 0 0.25rem;
  }

  .brand-mark {
    width: 2.7rem;
    height: 2.7rem;
  }

  .quiet-button {
    min-width: 2.75rem;
    padding: 0.65rem;
    font-size: 0;
  }

  .contrast-icon {
    width: 1.15rem;
    height: 1.15rem;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .heart-card {
    min-height: 0;
  }

  .heart-stage,
  .heart-visual {
    min-height: min(58vh, 32rem);
  }

  .info-card {
    overflow: visible;
  }

  .classroom-heading {
    display: block;
  }

  .classroom-heading > p {
    width: auto;
    margin-top: 0.55rem;
  }

  .classroom-grid {
    grid-template-columns: 1fr;
  }

  .lesson-card-move {
    grid-column: auto;
  }
}

@media (max-width: 540px) {
  body {
    font-size: 16px;
  }

  .topbar {
    margin-bottom: 0.7rem;
  }

  .eyebrow {
    font-size: 0.66rem;
  }

  h1 {
    font-size: 1.35rem;
  }

  .heart-card,
  .info-card {
    border-radius: 1.2rem;
  }

  .stage-heading {
    align-items: flex-end;
  }

  .stage-heading h2 {
    font-size: 1.22rem;
  }

  .view-button {
    padding-inline: 0.58rem;
    font-size: 0.76rem;
  }

  .anatomy-callout {
    min-height: 1.9rem;
    max-width: 7.6rem;
    padding: 0.3rem 0.45rem;
    font-size: 0.65rem;
  }

  .anatomy-callout i {
    width: 0.44rem;
    height: 0.44rem;
  }

  .heart-stage,
  .heart-visual {
    min-height: min(52vh, 27rem);
  }

  .stage-badge {
    top: 0.55rem;
    left: 0.55rem;
  }

  .flow-hud {
    bottom: 0.55rem;
    left: 0.55rem;
    width: calc(100% - 6.6rem);
    padding: 0.62rem 0.68rem;
  }

  .flow-hud p,
  .flow-legend {
    margin-left: 0;
  }

  .model-controls {
    grid-template-columns: 1fr;
    gap: 0.7rem;
  }

  .action-buttons,
  .separation-control,
  .icon-button {
    grid-column: 1;
  }

  .action-buttons > * {
    flex: 1 1 0;
  }

  .icon-button {
    width: 100%;
  }

  .fact-grid {
    grid-template-columns: 1fr;
  }

  .fact-card {
    min-height: 0;
  }
}

@media (max-width: 370px) {
  .brand-mark {
    display: none;
  }

  .stage-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .view-switch {
    align-self: flex-start;
  }

  .part-list {
    grid-template-columns: 1fr;
  }
}

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

.host-back-link {
  position: fixed;
  top: 0.65rem;
  left: 0.75rem;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.8rem;
  color: #342a2b;
  background: rgba(255, 250, 247, 0.94);
  border: 1px solid rgba(83, 58, 61, 0.16);
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(83, 56, 58, 0.12);
  backdrop-filter: blur(10px);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
}

.host-back-link:hover {
  background: #fff;
}

.host-back-link:focus-visible {
  outline: 3px solid #315f8d;
  outline-offset: 3px;
}

@media (max-width: 720px) {
  .host-back-link {
    position: relative;
    top: auto;
    left: auto;
    margin: 0.65rem 0.75rem 0;
  }
}
