@font-face {
  font-family: 'EB Garamond';
  src: url('/css/EBGaramond-400-Normal.woff2') format('woff2');
  font-weight: 400;
}
@font-face {
  font-family: 'Open Sans';
  src: url('/css/OpenSans-300-Normal.woff2') format('woff2');
  font-weight: 300;
}
@font-face {
  font-family: 'DM Mono';
  src: url('/css/JetBrainsMono-400-Normal.woff2') format('woff2');
  font-weight: 400;
}

:root {
  --paper: #fff;
  --paper-deep: #f3f3f2;
  --ink: rgba(0, 0, 0, .9);
  --muted: #828282;
  --line: #dedede;
  --blue: #19407c;
  --blue-soft: #e8edf4;
  --red: #ba3925;
  --red-soft: #ecd8d3;
  --green: #4f765f;
  --shadow: none;
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  height: 100%;
  background: var(--paper);
}
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: 'EB Garamond', serif;
  line-height: 1.7;
}
button,
input {
  font: inherit;
}
button {
  cursor: pointer;
}

.shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px clamp(20px, 4vw, 64px) 30px;
}
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 17px;
}
.brand-lockup,
.lesson-meta,
.signal-footer,
.footer-note,
.anatomy-key,
.rate-control,
.signal-note {
  display: flex;
  align-items: center;
}
.brand-lockup {
  gap: 10px;
  font: 500 13px 'DM Mono', monospace;
  letter-spacing: .08em;
  text-transform: lowercase;
}
.brand-mark {
  display: flex;
  align-items: end;
  gap: 2px;
  width: 20px;
  height: 18px;
}
.brand-mark i {
  display: block;
  width: 4px;
  background: var(--ink);
  border-radius: 99px;
  transform: skew(-22deg);
}
.brand-mark i:nth-child(1) {
  height: 7px;
}
.brand-mark i:nth-child(2) {
  height: 17px;
}
.brand-mark i:nth-child(3) {
  height: 11px;
}
.lesson-meta {
  gap: 9px;
  color: var(--muted);
  font: 400 11px 'DM Mono', monospace;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.eyebrow {
  color: var(--ink);
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(79,118,95,.12);
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 390px);
  gap: 40px;
  align-items: end;
  padding: clamp(40px, 7vw, 90px) 0 clamp(34px, 5vw, 62px);
}
.panel-index,
.data-tile span,
.data-tile small,
.rate-control label {
  font: 400 11px 'DM Mono', monospace;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.kicker {
  color: var(--red);
  margin: 0 0 19px;
}
.kicker span {
  color: var(--muted);
  margin: 0 7px;
}
h1 {
  margin: 0;
  font-size: clamp(47px, 7vw, 92px);
  line-height: .92;
  letter-spacing: -.075em;
  font-weight: 700;
}
h1 em {
  color: var(--red);
  font-family: 'EB Garamond', Georgia, serif;
  font-weight: 400;
  letter-spacing: -.06em;
}
.intro-copy {
  max-width: 325px;
  margin: 0 0 5px;
  color: #656661;
  font-size: 14px;
  line-height: 1.7;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, .86fr) minmax(480px, 1.14fr);
  gap: 18px;
}
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  background: rgba(249,248,245,.62);
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 24px 17px;
  border-bottom: 1px solid var(--line);
}
.panel-index {
  margin: 0 0 8px;
  color: var(--muted);
}
.panel-head h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -.04em;
  font-weight: 700;
}
.micro-label {
  color: var(--red);
  padding-top: 2px;
  font-size: 10px;
}
.heart-stage {
  position: relative;
  height: clamp(450px, 47vw, 610px);
  background: linear-gradient(135deg, rgba(255,255,255,.28), transparent 48%);
  overflow: hidden;
}
.heart-live-stats {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 12px;
  display: grid;
  gap: 5px;
  pointer-events: none;
}
.heart-live-stats > div {
  min-width: 86px;
}
.heart-live-stats span,
.heart-live-stats small {
  display: block;
  color: var(--muted);
  font: 400 8px 'DM Mono', monospace;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.heart-live-stats .state-name {
  margin-bottom: 2px;
  color: var(--red);
  font-weight: 500;
}
.heart-live-stats strong {
  display: inline-block;
  margin: 2px 4px 0 0;
  color: var(--ink);
  font: 500 18px 'DM Mono', monospace;
  letter-spacing: -.08em;
}
.heart-live-stats small {
  display: inline-block;
  font-size: 7px;
  letter-spacing: .02em;
  text-transform: lowercase;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.anatomy-tooltip {
  position: absolute;
  z-index: 2;
  width: min(230px, calc(100% - 24px));
  padding: 9px 12px 10px;
  border: 1px solid rgba(213,210,202,.96);
  border-top: 2px solid var(--tooltip-color, var(--red));
  border-radius: 2px;
  background: rgba(250,249,246,.93);
  box-shadow: 0 12px 28px rgba(37,38,34,.13);
  backdrop-filter: blur(3px);
  pointer-events: none;
}
.anatomy-tooltip[data-side="right"] {
  text-align: left;
}
.anatomy-tooltip[data-side="left"] {
  text-align: right;
}
.anatomy-tooltip-name,
.anatomy-tooltip-fact {
  display: block;
  text-align: inherit;
}
.anatomy-tooltip-name {
  margin-bottom: 6px;
  color: var(--ink);
  font: 600 12px 'DM Mono', monospace;
  letter-spacing: .04em;
  text-transform: lowercase;
}
.anatomy-tooltip-fact {
  color: #656661;
  font-size: 12px;
  line-height: 1.45;
}
.anatomy-tooltip::before {
  display: none;
}
.anatomy-key {
  gap: 18px;
  border-top: 1px solid var(--line);
  padding: 14px 24px;
  color: var(--muted);
  font: 400 10px 'DM Mono', monospace;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.key-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
}
.venous {
  background: var(--blue);
}
.arterial {
  background: var(--red);
}
.muscle {
  background: var(--green);
}
.callout {
  min-height: 67px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-top: 1px solid var(--line);
  padding: 14px 24px 16px;
  opacity: 1;
  text-align: left;
}
.callout-name {
  color: var(--ink);
  font: 600 12px 'DM Mono', monospace;
  text-transform: lowercase;
}
.callout span:last-child {
  color: #656661;
  font-size: 12px;
  line-height: 1.45;
}

.ecg-panel {
  background: rgba(255,255,255,.36);
}
.ecg-head {
  align-items: center;
}
.import-panel {
  padding: 16px 24px 15px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.22);
}
.import-dropzone {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  min-height: 66px;
  border: 1px dashed #bcb8ae;
  padding: 10px 13px;
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
}
.import-dropzone:hover,
.import-dropzone:focus-within,
.import-dropzone.is-dragging {
  border-color: var(--red);
  background: rgba(234,214,208,.28);
  transform: translateY(-1px);
}
.upload-glyph {
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--red-soft);
  border-radius: 50%;
  color: var(--red);
  font: 500 17px 'DM Mono', monospace;
}
.import-label {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}
.import-subcopy {
  color: var(--muted);
  font: 400 9px 'DM Mono', monospace;
  letter-spacing: .02em;
}
.edf-summary {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 13px;
}
.summary-kicker,
.channel-control span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font: 400 9px 'DM Mono', monospace;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.edf-summary strong {
  display: block;
  max-width: 270px;
  overflow: hidden;
  color: var(--ink);
  font: 500 11px 'DM Mono', monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.channel-control {
  min-width: 155px;
}
.channel-control select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  padding: 7px 8px;
  font: 400 10px 'DM Mono', monospace;
}
.import-status {
  margin: 10px 0 0;
  color: var(--muted);
  font: 400 10px 'DM Mono', monospace;
  line-height: 1.5;
}
.import-status[data-state="error"] {
  color: var(--red);
}
.import-status[data-state="loading"] {
  color: var(--ink);
}
.ecg-stage {
  position: relative;
  height: clamp(330px, 33vw, 420px);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  touch-action: none;
}
.ecg-stage canvas {
  touch-action: none;
  cursor: grab;
}
.ecg-stage canvas.is-scrubbing {
  cursor: grabbing;
}
.annotation-bar {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 42px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(234,214,208,.13);
  font: 400 9px 'DM Mono', monospace;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.annotation-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--red);
  white-space: nowrap;
}
.annotation-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}
.annotation-bar strong {
  color: var(--ink);
  font-weight: 500;
}
.annotation-current {
  margin-left: auto;
  max-width: 45%;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: 0;
}
.signal-footer {
  justify-content: space-between;
  gap: 20px;
  padding: 15px 24px;
  border-bottom: 1px solid var(--line);
}
.signal-note {
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}
.live-chip {
  color: var(--red);
  border: 1px solid var(--red-soft);
  padding: 3px 5px;
  font: 500 9px 'DM Mono', monospace;
  letter-spacing: .04em;
}
.playback-controls {
  display: flex;
  align-items: center;
  gap: 17px;
}
.replay-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--red-soft);
  border-radius: 0;
  padding: 6px 9px;
  background: transparent;
  color: var(--red);
  font: 500 9px 'DM Mono', monospace;
  letter-spacing: .06em;
  text-transform: uppercase;
  transition: background .2s, border-color .2s, color .2s;
}
.replay-button:hover:not(:disabled),
.replay-button:focus-visible:not(:disabled) {
  border-color: var(--red);
  background: rgba(234,214,208,.3);
}
.replay-button:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}
.replay-button:disabled {
  cursor: not-allowed;
  opacity: .38;
}
.replay-icon {
  font-size: 15px;
  line-height: .7;
}
.rate-control {
  gap: 9px;
}
.rate-control label {
  color: var(--muted);
  font-size: 9px;
}
.rate-control input {
  accent-color: var(--red);
  width: 80px;
}
.rate-value {
  min-width: 55px;
  color: var(--ink);
  font: 400 10px 'DM Mono', monospace;
}
.data-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}
.data-tile {
  min-height: 123px;
  padding: 18px 20px;
  border-right: 1px solid var(--line);
}
.data-tile:last-child {
  border-right: 0;
}
.data-tile span {
  display: block;
  color: var(--muted);
  font-size: 9px;
}
.data-tile strong {
  display: block;
  margin: 13px 0 4px;
  font: 500 clamp(24px, 3vw, 35px) 'DM Mono', monospace;
  letter-spacing: -.09em;
}
.data-tile small {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .02em;
  text-transform: lowercase;
}

.footer-note {
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  padding-top: 22px;
  font-size: 9px;
}
.footer-rule {
  width: 38px;
  height: 1px;
  background: var(--red);
}
.footer-id {
  margin-left: auto;
  color: var(--ink);
}

@media (max-width: 850px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .heart-stage {
    height: min(620px, 88vw);
  }
  .ecg-stage {
    height: min(410px, 66vw);
  }
  .intro {
    grid-template-columns: 1fr;
    gap: 25px;
  }
  .intro-copy {
    max-width: 440px;
  }
}
@media (max-width: 540px) {
  .shell {
    padding: 20px 14px 22px;
  }
  .lesson-meta .eyebrow {
    display: none;
  }
  .intro {
    padding-top: 52px;
  }
  .intro-copy {
    font-size: 13px;
  }
  .panel-head {
    padding: 18px 16px 15px;
  }
  .micro-label {
    display: none;
  }
  .import-panel {
    padding-left: 16px;
    padding-right: 16px;
  }
  .edf-summary {
    align-items: stretch;
    flex-direction: column;
    gap: 13px;
  }
  .channel-control {
    min-width: 0;
  }
  .anatomy-key,
  .callout,
  .signal-footer {
    padding-left: 16px;
    padding-right: 16px;
  }
  .signal-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 13px;
  }
  .annotation-bar {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 7px 11px;
    padding-left: 16px;
    padding-right: 16px;
  }
  .annotation-current {
    width: 100%;
    max-width: none;
    margin-left: 17px;
  }
  .data-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .data-tile {
    padding: 15px 12px;
    min-height: 108px;
  }
  .data-tile:nth-child(2n) {
    border-right: 0;
  }
  .data-tile strong {
    font-size: 22px;
  }
  .footer-note {
    align-items: flex-start;
  }
  .footer-note span:nth-child(2) {
    line-height: 1.5;
  }
  .footer-id {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* Three concise, synchronized state views. */
.comparison-page {
  min-height: 100%;
  overflow-y: auto;
}
.comparison-shell {
  display: grid;
  grid-template-rows: 38px auto;
  gap: 10px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 10px clamp(12px, 3vw, 42px) 28px;
}
.comparison-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  min-width: 0;
  border-bottom: 1px solid var(--line);
}
.start-button {
  border: 1px solid var(--red);
  padding: 7px 11px;
  background: var(--red);
  color: #fff;
  font: 600 9px 'DM Mono', monospace;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.start-button:hover:not(:disabled),
.start-button:focus-visible:not(:disabled) {
  background: #843d37;
}
.start-button:disabled {
  cursor: wait;
  opacity: .78;
}
.comparison-controls .rate-control {
  border-left: 1px solid var(--line);
  padding-left: 14px;
}
.comparison-controls strong {
  min-width: 38px;
  font: 500 11px 'DM Mono', monospace;
}
.comparison-states {
  display: grid;
  gap: 12px;
}
.state-panel {
  height: 310px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper-deep);
  box-shadow: var(--shadow);
}
.state-panel iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: var(--paper);
}

/* Each iframe has a complete, height-aware two-pane layout. */
body.comparison-embed,
.comparison-embed .shell,
.comparison-embed .workspace,
.comparison-embed .panel {
  height: 100%;
  min-height: 0;
}
.comparison-embed .shell {
  max-width: none;
  padding: 0;
}
.comparison-embed .workspace {
  grid-template-columns: minmax(130px, .3fr) minmax(0, .7fr);
  gap: 0;
}
.comparison-embed .panel {
  border: 0;
  box-shadow: none;
}
.comparison-embed .heart-panel {
  border-right: 1px solid var(--line);
}
.comparison-embed .panel-head,
.comparison-embed .anatomy-key,
.comparison-embed .annotation-bar,
.comparison-embed .signal-footer,
.comparison-embed .data-grid {
  display: none;
}
.comparison-embed .heart-stage {
  height: 100%;
  min-height: 0;
}
.comparison-embed .heart-live-stats {
  top: 5px;
  left: 5px;
  gap: 3px;
}
.comparison-embed .heart-live-stats > div {
  min-width: 64px;
}
.comparison-embed .heart-live-stats span {
  font-size: 7px;
}
.comparison-embed .heart-live-stats small {
  margin-top: 1px;
  color: var(--ink);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: .04em;
}
.comparison-embed .heart-live-stats .state-name {
  margin-bottom: 4px;
  font-size: 12px;
  letter-spacing: .08em;
}
.comparison-embed .heart-live-stats strong {
  margin-top: 0;
  font-size: 15px;
}
.comparison-embed .ecg-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
}
.comparison-embed .import-panel {
  display: none;
}
.comparison-embed .ecg-stage {
  grid-row: 1;
}
/* Bundled comparison recordings start together; per-panel upload controls stay out of this view. */
.comparison-embed .import-panel {
  min-height: 0;
  padding: 5px 10px;
  overflow: hidden;
}
.comparison-embed .import-dropzone {
  min-height: 38px;
  padding: 5px 8px;
}
.comparison-embed .upload-glyph {
  width: 24px;
  height: 24px;
  font-size: 14px;
}
.comparison-embed .import-subcopy,
.comparison-embed .import-status {
  display: none;
}
.comparison-embed .import-panel:has(.edf-summary:not([hidden])) .import-dropzone {
  display: none;
}
.comparison-embed .edf-summary {
  align-items: center;
  margin-top: 4px;
}
.comparison-embed .summary-kicker,
.comparison-embed .channel-control span {
  display: none;
}
.comparison-embed .edf-summary strong {
  max-width: 180px;
  font-size: 9px;
}
.comparison-embed .channel-control {
  min-width: 115px;
}
.comparison-embed .channel-control select {
  padding: 4px;
  font-size: 9px;
}
.comparison-embed .ecg-stage {
  height: auto;
  min-height: 0;
}
@media (max-width: 850px) {
  .comparison-shell {
    display: block;
  }
  .comparison-controls {
    height: 38px;
  }
  .comparison-states {
    gap: 10px;
  }
  .state-panel {
    height: 260px;
  }
}
@media (max-width: 540px) {
  .comparison-shell {
    padding: 8px;
  }
  .comparison-embed .workspace {
    grid-template-columns: minmax(105px, .3fr) minmax(0, .7fr);
  }
}
