:root {
  --bg: #0a0f15;
  --panel: #111922;
  --panel2: #0e151d;
  --line: #1e2a37;
  --line2: #2a3a4b;
  --text: #dbe4ee;
  --muted: #8292a5;
  --accent: #5fe0c4;
  --accent2: #7aa8ff;
  --rest: #6e2630;
  --front: #fff3c0;
  --depol: #e8b23a;
  --repol: #7a86ff;
  --trace: #bff3d3;
  --warn: #ff6b7a;
  --ok: #5fe0a0;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--bg); color: var(--text); }
body { margin: 0; font: 14px/1.5 Inter, system-ui, -apple-system, sans-serif; padding: 0 16px; }
button, select, input { font: inherit; color: inherit; }
h2 { font-size: 22px; line-height: 1.25; margin: 6px 0 14px; letter-spacing: -0.01em; }
h3 { font-size: 13px; margin: 0; font-weight: 600; letter-spacing: .02em; }
h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin: 18px 0 6px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; padding: 18px 0; max-width: 1600px; margin: 0 auto; }
.top-center { display: flex; justify-content: center; min-width: 0; }
.top-actions { justify-self: end; }
@media (max-width: 760px) { .top { grid-template-columns: 1fr auto; } .top-center { grid-column: 1 / -1; grid-row: 2; } }
.brand { display: flex; gap: 12px; align-items: center; color: var(--accent); }
.brand-name { font-weight: 700; font-size: 26px; color: var(--text); letter-spacing: -0.02em; line-height: 1; }
.brand-sub { font-size: 12px; color: var(--muted); }
.top-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.mode-toggle { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg { background: none; border: 0; padding: 6px 14px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 500; }
.seg.on { background: var(--line2); color: var(--text); }
.rhythm-btn { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line2); border-radius: 12px; padding: 9px 14px; cursor: pointer; max-width: 100%; }
.rhythm-btn:hover { border-color: var(--accent); }
.rhythm-btn .lbl { color: var(--muted); font-size: 12px; }
.rhythm-btn .val { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }

.picker { position: fixed; inset: 0; background: rgba(4, 8, 12, .6); z-index: 50; display: flex; justify-content: center; align-items: flex-start; padding: 72px 16px 16px; backdrop-filter: blur(3px); }
.picker-panel { width: min(820px, 100%); max-height: calc(100vh - 100px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line2); border-radius: 16px; box-shadow: 0 30px 80px rgba(0,0,0,.5); overflow: hidden; }
#search { margin: 14px; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--accent); background: var(--panel2); outline: none; }
.picker-list { overflow: auto; padding: 0 14px 14px; }
.pg-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; margin: 14px 4px 6px; font-weight: 600; }
.pg-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 2px 8px; }
.pg-item { text-align: left; background: none; border: 0; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.pg-item:hover, .pg-item.kb { background: var(--line); }
.pg-item.cur { background: var(--text); color: var(--bg); }
.pg-item .start { display: block; font-size: 10.5px; color: var(--depol); font-weight: 600; }
.pg-item.cur .start { color: #8a5a00; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; max-width: 1600px; margin: 0 auto; }
/* ECG panel + info panel with a draggable divider */
.top-row { display: grid; grid-template-columns: minmax(0, 1fr) 14px var(--sidew, minmax(0, 1fr)); align-items: start; }
.heart-col { min-width: 0; container-type: inline-size; }
.splitter { align-self: stretch; cursor: col-resize; display: flex; justify-content: center; touch-action: none; outline: none; }
.splitter span { width: 4px; border-radius: 2px; background: var(--line); margin: 40px 0; transition: background .15s; }
.splitter:hover span, .splitter:focus-visible span, .splitter.drag span { background: var(--accent); }
body.resizing { cursor: col-resize; user-select: none; }
@media (max-width: 1000px) { .top-row { grid-template-columns: minmax(0, 1fr); gap: 16px; } .splitter { display: none; } }
.row3 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
.row3 .card + .card { margin-top: 0; }
@media (max-width: 1100px) { .row3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .row3 .axis-card { grid-column: 1 / -1; grid-row: 1; } }
@media (max-width: 700px) { .row3 { grid-template-columns: minmax(0, 1fr); } }
.axis-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.42fr); gap: 12px; align-items: center; }
#axisWheel { width: 100%; aspect-ratio: 1; display: block; max-width: 340px; margin: 0 auto; }
.axis-heart { margin: 0; text-align: center; }
#axisHeart { width: 100%; aspect-ratio: 0.9; display: block; }
.axis-heart figcaption { font-size: 11px; color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; min-width: 0; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.tabs { display: flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.tab { background: none; border: 0; padding: 5px 12px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 500; font-size: 13px; }
.tab.on { background: var(--line2); color: var(--text); }
.tabs.small .tab { font-size: 12px; padding: 4px 10px; }
.toggles { display: flex; gap: 14px; flex-wrap: wrap; }
.chk { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 12.5px; cursor: pointer; user-select: none; }
.chk input { accent-color: var(--accent); }

.ecg-wrap { position: relative; overflow: hidden; border-radius: 10px; background: #0b1218; }
.ecg-wrap canvas { display: block; width: 100%; }
#ecg.calip { cursor: crosshair; }
.controls { display: flex; align-items: center; gap: 14px; margin-top: 12px; flex-wrap: wrap; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line2); background: var(--panel2); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.time { display: flex; flex-direction: column; line-height: 1.15; }
.time b { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 15px; }
.time span { font-size: 11px; color: var(--muted); }
.speed { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.speed select { background: var(--panel2); border: 1px solid var(--line2); border-radius: 8px; padding: 5px 8px; }
#scrub { flex: 1 1 160px; accent-color: var(--accent); min-width: 120px; }
.jumps { display: flex; gap: 4px; border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.jumps button { background: none; border: 0; padding: 4px 9px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.jumps button:hover { background: var(--line2); color: var(--text); }
.caption { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; padding: 10px 12px; background: var(--panel2); border-radius: 10px; border: 1px solid var(--line); min-height: 44px; }
.caption .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; margin-top: 6px; box-shadow: 0 0 10px var(--accent); }

.grid2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.side-stack { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 860px) { .side-stack { grid-template-columns: minmax(0, 1fr); } }
.side-stack .card + .card { margin-top: 0; }
#heart { display: block; width: 100%; margin: 0; border-radius: 10px; }
.heart-stage { position: relative; border-radius: 10px; overflow: hidden; background: radial-gradient(ellipse at 50% 45%, #15212d 0%, #0a0f15 75%); }
#heart.webgl { cursor: grab; }
#heart.webgl.grabbing { cursor: grabbing; }
#heartLabels { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.h3-ctrls { position: absolute; left: 10px; bottom: 10px; display: flex; gap: 12px; align-items: center; background: rgba(10,16,22,.7); border: 1px solid var(--line); border-radius: 10px; padding: 5px 10px; backdrop-filter: blur(4px); }
.h3-ctrls .hint { font-size: 11.5px; color: var(--muted); }
.mini { background: var(--panel2); border: 1px solid var(--line2); border-radius: 7px; padding: 3px 9px; font-size: 12px; cursor: pointer; }
.mini:hover { border-color: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-top: 10px; justify-content: center; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.legend i.line { width: 16px; height: 3px; border-radius: 2px; background: #f2e3a0; }
.legend .ramp { width: 160px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, #ff3b3b, #ffb13b, #f5f04a, #5fe08a, #3bc2ff, #6a5bff, #b04bff); }
.vectors { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vectors figure { margin: 0; text-align: center; }
.vectors canvas { width: 100%; aspect-ratio: 1; display: block; }
.vectors figcaption { font-size: 11px; color: var(--muted); }

.meas { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.m { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.m .k { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.m .v { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 17px; font-weight: 600; }
.m .r { font-size: 10.5px; color: var(--muted); }
.m.bad .v { color: var(--warn); }
.m.ok .v { color: var(--ok); }

.info p { margin: 0; color: #c3cfdb; }
.info ul { margin: 0; padding-left: 18px; color: #c3cfdb; }
.info li { margin: 4px 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: var(--line); color: var(--muted); }
.chip.book { background: rgba(95, 224, 196, .12); color: var(--accent); }
.related { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.related button { background: var(--panel2); border: 1px solid var(--line2); border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; color: var(--muted); }
.related button:hover { color: var(--text); border-color: var(--accent); }
.info.hidden-answer h2, .info.hidden-answer .chips, .info.hidden-answer p, .info.hidden-answer ul, .info.hidden-answer h4, .info.hidden-answer .related { filter: blur(7px); user-select: none; pointer-events: none; }

.quiz-opts { display: grid; gap: 8px; margin-top: 12px; }
.quiz-opts button { text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line2); background: var(--panel2); cursor: pointer; }
.quiz-opts button:hover:not(:disabled) { border-color: var(--accent); }
.quiz-opts button.right { border-color: var(--ok); background: rgba(95, 224, 160, .12); }
.quiz-opts button.wrong { border-color: var(--warn); background: rgba(255, 107, 122, .12); }
.score { font-family: 'JetBrains Mono', monospace; color: var(--accent); }
.primary { margin-top: 12px; width: 100%; padding: 10px; border-radius: 10px; border: 0; background: var(--accent); color: #05221c; font-weight: 700; cursor: pointer; }
.foot { max-width: 1600px; margin: 24px auto; color: var(--muted); font-size: 12px; text-align: center; padding-bottom: env(safe-area-inset-bottom, 0); }

.sources { font-size: 11px; color: var(--muted); text-align: center; margin: 8px auto 0; max-width: 760px; line-height: 1.45; }

.head-left { display: flex; gap: 8px; flex-wrap: wrap; }
#heart2d { display: block; width: 100%; }
#heartLabels { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.heart-stage.hovering { cursor: pointer; }
.h3-ctrls .only3d[hidden] { display: none !important; }
.focus-card { position: absolute; right: 12px; bottom: 12px; width: min(330px, calc(100% - 24px)); background: rgba(12,18,25,.88); border: 1px solid var(--line2); border-radius: 12px; padding: 12px 14px; backdrop-filter: blur(6px); box-shadow: 0 12px 40px rgba(0,0,0,.45); animation: fcIn .25s ease; }
@keyframes fcIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.focus-card h4 { margin: 2px 0 6px; font-size: 15px; color: var(--text); text-transform: none; letter-spacing: 0; }
.focus-card p { margin: 0 0 6px; font-size: 12.5px; color: #c3cfdb; line-height: 1.45; }
.focus-card .fc-note { color: #f0e2a6; margin: 0; }
.focus-card .fc-kind { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.fc-x { position: absolute; right: 8px; top: 6px; background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; }
.fc-x:hover { color: var(--text); }
@media (max-width: 600px) { .focus-card { left: 12px; right: 12px; width: auto; bottom: 56px; } }

.caption .spot { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line2); font-size: 12.5px; color: #f0e2a6; }
.caption .spot b { color: var(--accent); font-weight: 600; }

#valvePlane { position: absolute; top: 10px; right: 10px; width: 200px; pointer-events: none; }
@media (max-width: 600px) { #valvePlane { width: 150px; } }

/* about, credit and references */
.site-info { max-width: 1600px; margin: 8px auto 0; padding: 0 16px; display: grid; gap: 16px; }
.info-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: start; }
.credit-card { max-width: 300px; padding: 12px 16px; }
.credit-card p { margin: 4px 0; }
@media (max-width: 860px) { .info-grid { grid-template-columns: 1fr; } }
.about-card p, .refs-card p { line-height: 1.6; margin: 8px 0; }
.about-card h3, .refs-card h3 { margin: 0 0 6px; }
.howto { margin: 6px 0; padding-left: 20px; line-height: 1.6; }
.byline { font-size: 18px; color: var(--text, #e6edf3); }
.refs { margin: 4px 0 10px; padding-left: 22px; line-height: 1.55; font-size: 13px; }
.refs li { margin: 4px 0; overflow-wrap: anywhere; }
.site-info a, .foot a { color: var(--accent2); text-decoration: none; }
.site-info a:hover, .foot a:hover { text-decoration: underline; }
.info-grid .card + .card { margin-top: 0; }
.further { font-size: 12px; line-height: 1.6; color: var(--muted); margin: 10px 0 6px; }
.further span { color: var(--text); font-weight: 600; }
.zoom { display: inline-flex; gap: 4px; }
.zoom .mini { width: 26px; padding: 3px 0; font-weight: 700; }

/* steady caption: fixed height, text clamped, so changing captions never shift the page */
.caption { height: 138px; overflow: hidden; align-items: flex-start; box-sizing: border-box; }
#captionText { display: block; min-width: 0; }
#captionText .spot { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.capmain { min-height: 4.5em; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
/* memory aid + LITFL link */
.memo { margin: 12px 0 2px; padding: 10px 12px; border-radius: 10px; background: linear-gradient(135deg, rgba(95,224,196,.12), rgba(122,168,255,.08)); border: 1px solid rgba(95,224,196,.3); }
.memo-k { display: inline-block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: var(--accent); margin-bottom: 3px; }
.memo p { margin: 0; color: var(--text) !important; font-weight: 500; }
.litfl { display: inline-block; margin-top: 14px; font-size: 12.5px; color: var(--accent2); text-decoration: none; }
.litfl:hover { text-decoration: underline; }
.info.hidden-answer .memo, .info.hidden-answer .litfl { filter: blur(7px); pointer-events: none; user-select: none; }
.ro-h { margin: 14px 0 6px; }
.readorder { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; counter-reset: ro; }
.readorder li { display: grid; grid-template-columns: 22px 64px minmax(0, 1fr); align-items: baseline; gap: 6px; font-size: 12.5px; padding: 5px 8px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line); counter-increment: ro; }
.readorder li::before { content: counter(ro); color: var(--accent); font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.readorder li span { color: var(--muted); }
.readorder li b { font-weight: 500; color: var(--text); }
.explain { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); font-size: 12.5px; line-height: 1.55; color: #c3cfdb; }
.explain b { color: var(--text); font-weight: 600; }
.cause-why { margin: 0 0 6px !important; }
.causes { margin: 0; padding-left: 18px; color: #c3cfdb; }
.causes li { margin: 3px 0; }
.causes b { color: var(--text); font-weight: 600; }
.info.hidden-answer #infoCauses { filter: blur(7px); pointer-events: none; user-select: none; }

/* rhythm panel beside the heart */
.heart-card { position: relative; }
.heart-info { position: absolute; z-index: 3; top: 64px; left: 26px; width: min(300px, 28%); padding: 14px 16px; border-radius: 12px; background: rgba(12,18,25,.82); border: 1px solid var(--line2); backdrop-filter: blur(4px); pointer-events: none; }
.heart-info .hi-k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); font-weight: 700; }
.heart-info h3 { font-size: clamp(16px, 1.6vw, 21px); margin: 4px 0 10px; line-height: 1.25; }
.heart-info .hi-sub { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.heart-info ul { margin: 0; padding-left: 16px; font-size: 12.5px; line-height: 1.5; color: #c3cfdb; }
.heart-info li { margin: 5px 0; }
.heart-info b { color: var(--text); }
@media (max-width: 1000px) { .heart-info { position: static; width: auto; margin-bottom: 12px; pointer-events: auto; } }

/* ECG and heart side by side; rhythm text in a two-column reading card below */
.info-row { display: grid; gap: 16px; }
.info-row .card + .card { margin-top: 0; }
.info { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 8px 32px; font-size: 14.5px; }
.info h2 { font-size: 24px; }
.info-b > h4:first-child { margin-top: 6px; }
@media (max-width: 900px) { .info { grid-template-columns: minmax(0, 1fr); } }
/* rhythm panel: beside the heart when there is room, otherwise above it */
.heart-info { top: 60px; left: 22px; width: min(270px, 30%); }
@container (max-width: 820px) { .heart-info { position: static; width: auto; margin-bottom: 10px; pointer-events: auto; } }
/* causes slightly smaller than the main description */
#infoCauses .cause-why, #infoCauses .causes { font-size: 0.92em; }

/* heart stage: compact "what to watch" box (top-left) and an optional right-hand rail for axis / vectors */
.heart-info { position: absolute; z-index: 4; top: 10px; left: 10px; width: min(250px, 40%); padding: 10px 12px; border-radius: 10px; background: rgba(12,18,25,.8); pointer-events: auto; }
.heart-info h3 { font-size: 14.5px; margin: 2px 0 6px; padding-right: 18px; }
.heart-info .hi-k { font-size: 9.5px; }
.heart-info .hi-sub { font-size: 9.5px; margin-bottom: 3px; }
.heart-info ul { font-size: 11.5px; line-height: 1.45; padding-left: 14px; }
.heart-info li { margin: 3px 0; }
.heart-info.collapsed .hi-sub, .heart-info.collapsed ul { display: none; }
.heart-info.collapsed h3 { margin-bottom: 0; }
.hi-x { position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 6px; border: 1px solid var(--line2); background: var(--panel2); color: var(--muted); font-size: 13px; line-height: 1; cursor: pointer; padding: 0; }
.hi-x:hover { color: var(--text); border-color: var(--accent); }
@container (max-width: 560px) { .heart-info { position: static; width: auto; margin: 0 0 8px; } }
.heart-stage.with-rail #heart, .heart-stage.with-rail #heart2d { width: calc(100% - var(--rail, 0px)); }
.heart-stage.with-rail #heartLabels { width: calc(100% - var(--rail, 0px)); right: auto; }
.heart-rail { position: absolute; top: 10px; right: 10px; width: calc(var(--rail, 200px) - 20px); display: grid; gap: 10px; z-index: 3; }
.heart-rail figure { margin: 0; padding: 8px; border-radius: 10px; background: rgba(12,18,25,.82); border: 1px solid var(--line2); text-align: center; }
.heart-rail canvas { width: 100%; aspect-ratio: 1; display: block; }
.heart-rail figcaption { font-size: 10.5px; color: var(--muted); margin-top: 4px; }
/* reading card: text flows across two balanced columns with more breathing room */
.info { display: block; column-count: 2; column-gap: 48px; column-fill: balance; font-size: 14.5px; line-height: 1.7; padding: 22px 26px; }
.info-a, .info-b { display: contents; }
.info .chips, .info h2 { column-span: all; }
.info h2 { margin: 8px 0 14px; }
.info h4 { margin: 22px 0 8px; break-after: avoid; }
.info p { margin: 0 0 4px; }
.info ul { margin: 0; break-inside: avoid; }
.info li { margin: 6px 0; }
.info .memo, #infoCauses, .info .related { break-inside: avoid; }
.info .memo { margin: 20px 0 4px; }
.info .related { margin-top: 18px; }
@media (max-width: 900px) { .info { column-count: 1; } }

/* the open "what to watch" box reserves the left of the stage, so the heart sits beside it rather than under it */
.heart-stage.with-left #heart, .heart-stage.with-left #heart2d { margin-left: var(--lrail, 0px); }
.heart-stage.with-left #heartLabels { left: var(--lrail, 0px); right: auto; width: calc(100% - var(--lrail, 0px) - var(--rail, 0px)); }
.heart-stage.with-left:not(.with-rail) #heart, .heart-stage.with-left:not(.with-rail) #heart2d { width: calc(100% - var(--lrail, 0px)); }
.heart-stage.with-left.with-rail #heart, .heart-stage.with-left.with-rail #heart2d { width: calc(100% - var(--lrail, 0px) - var(--rail, 0px)); }
.heart-info { width: min(234px, 30%); }
.heart-info { width: min(210px, 30%); }

/* smaller watch box beside the heart */
.heart-info { width: min(190px, 28%); padding: 9px 11px; }
.heart-info h3 { font-size: 13.5px; }
.heart-info ul { font-size: 11px; }
.watch { margin: 0; padding-left: 18px; color: #c3cfdb; }
.watch li { margin: 6px 0; }
.watch b { color: var(--text); }
#infoWatchBox { break-inside: avoid; }

/* watch box: hazy glass over the heart, sized to its text */
.heart-info { width: auto; max-width: min(200px, 34%); background: rgba(12,18,25,.42); border: 1px solid rgba(255,255,255,.08); backdrop-filter: blur(7px) saturate(1.1); -webkit-backdrop-filter: blur(7px) saturate(1.1); box-shadow: 0 8px 24px rgba(0,0,0,.28); }
.heart-info.collapsed { padding: 8px 34px 8px 12px; }
.heart-info.collapsed h3 { font-size: 16px; margin: 3px 0 0; }
.heart-info.collapsed .hi-k { font-size: 10px; }
.heart-info.collapsed { max-width: min(280px, 60%); }
.heart-rail { gap: 6px; }
.heart-rail figure { padding: 6px; }
.heart-rail figcaption { font-size: 10px; margin-top: 2px; }
/* hazy translucent watch box (no backdrop blur: it bled past the edges over the WebGL canvas) */
.heart-info { backdrop-filter: none; -webkit-backdrop-filter: none; background: linear-gradient(160deg, rgba(22,32,44,.62), rgba(10,15,21,.5)); border: 1px solid rgba(255,255,255,.07); box-shadow: 0 6px 22px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.05); }
.heart-info h3, .heart-info li { text-shadow: 0 1px 3px rgba(0,0,0,.55); }

/* collapsed watch box: same width and type, just shorter */
.heart-info.collapsed { padding: 9px 11px; max-width: none; }
.heart-info.collapsed h3 { font-size: 13.5px; margin: 2px 0 0; }
.heart-info.collapsed .hi-k { font-size: 9.5px; }
/* axis / vector tiles float on the right with the same hazy glass as the watch box, all the same size */
.heart-stage.with-rail #heart, .heart-stage.with-rail #heart2d, .heart-stage.with-rail #heartLabels { width: 100%; }
.heart-rail { width: 132px; gap: 8px; }
.heart-rail figure { padding: 6px 6px 5px; background: linear-gradient(160deg, rgba(22,32,44,.62), rgba(10,15,21,.5)); border: 1px solid rgba(255,255,255,.07); box-shadow: 0 6px 22px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.05); }
.heart-rail canvas { width: 100%; aspect-ratio: 1; }
.heart-rail figcaption { font-size: 9.5px; line-height: 1.25; min-height: 2.5em; display: flex; align-items: center; justify-content: center; text-shadow: 0 1px 3px rgba(0,0,0,.55); }
/* reading card: left column carries most of the text, right column is compact */
.info { display: grid; column-count: auto; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 0 44px; font-size: 15.5px; line-height: 1.7; }
.info-a, .info-b { display: block; }
.info-b { font-size: 14px; border-left: 1px solid var(--line); padding-left: 28px; }
.info-b .related { gap: 5px; }
.info-b .related button { font-size: 11.5px; padding: 3px 9px; }
.info-b .memo p { font-size: 14px; }
@media (max-width: 900px) { .info { grid-template-columns: minmax(0, 1fr); } .info-b { border-left: 0; padding-left: 0; } }
/* measurements: roomier tiles and checklist */
.meas { gap: 10px; }
.m { padding: 12px 14px; }
.m .k { font-size: 11px; }
.m .v { font-size: 20px; }
.m .r { font-size: 11.5px; }
.readorder { gap: 6px; }
.readorder li { font-size: 13.5px; padding: 8px 12px; grid-template-columns: 24px 80px minmax(0, 1fr); }
/* balanced two-column flow (no empty gap under either column); related links compact */
.info { display: block; column-count: 2; column-gap: 52px; column-rule: 1px solid var(--line); font-size: 15px; }
.info-a, .info-b { display: contents; }
.info-b { border-left: 0; padding-left: 0; font-size: inherit; }
.info .chips, .info h2 { column-span: all; }
.info .related button { font-size: 11.5px; padding: 3px 9px; }
@media (max-width: 900px) { .info { column-count: 1; column-rule: none; } }
.info ul, #infoCauses, #infoWatchBox { break-inside: auto; }
.info li, .info .memo, .info p { break-inside: avoid; }
.info h4 { break-after: avoid; }

/* heart and ECG cards line up in height */
.top-row { align-items: stretch; }
.heart-col, .ecg-col { display: flex; flex-direction: column; }
.heart-col > .card, .ecg-col > .card { flex: 1; }
/* reading card: left column wider; right column (footprints, remember, related) narrower */
.info { display: grid; column-count: auto; column-rule: none; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 0 40px; }
.info-a, .info-b { display: block; }
.info-b { border-left: 1px solid var(--line); padding-left: 28px; font-size: 14px; }
.info .chips, .info h2 { column-span: none; }
@media (max-width: 900px) { .info { grid-template-columns: minmax(0, 1fr); } .info-b { border-left: 0; padding-left: 0; } }
/* mobile */
@container (max-width: 560px) {
  .heart-info, .heart-info.collapsed { position: static; width: auto !important; max-width: none; margin: 0 0 8px; padding: 9px 11px; background: rgba(12,18,25,.55); box-shadow: none; }
  .heart-info h3 { font-size: 15px; padding-right: 26px; }
  .heart-info ul { display: grid; gap: 2px; }
  .h3-ctrls .hint { display: none; }
  .heart-rail { width: 96px; }
}
@media (max-width: 600px) {
  body { padding: 0 10px; }
  .credit-card { max-width: none; }
  .info-grid { grid-template-columns: minmax(0, 1fr); }
  .info { padding: 18px 16px; font-size: 15px; }
  .card { padding: 12px; }
  .h3-ctrls { gap: 8px; padding: 4px 8px; }
}
.info.hidden-answer #infoSig { filter: blur(7px); pointer-events: none; user-select: none; }
/* bottom section flush with the cards above */
.site-info { padding: 0; margin-top: 16px; }
/* sticky top bar: rhythm picker always reachable */
.top { position: sticky; top: 0; z-index: 40; margin: 0 -16px; padding: 12px 16px; max-width: none; background: rgba(10,15,21,.78); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); border-bottom: 1px solid rgba(255,255,255,.05); transition: padding .25s ease, box-shadow .25s ease; }
.top.scrolled { padding-top: 8px; padding-bottom: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.top > * { max-width: none; }
.rhythm-btn { padding: 12px 22px; border-radius: 14px; gap: 12px; min-width: min(460px, 100%); justify-content: space-between; box-shadow: 0 0 0 1px rgba(95,224,196,.08), 0 8px 24px rgba(0,0,0,.25); transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
.rhythm-btn .lbl { font-size: 12.5px; text-transform: uppercase; letter-spacing: .08em; }
.rhythm-btn .val { font-size: 17px; max-width: 60vw; }
.rhythm-btn:hover { transform: translateY(-1px); box-shadow: 0 0 0 1px rgba(95,224,196,.35), 0 12px 30px rgba(0,0,0,.35); }
@media (max-width: 760px) { .top { margin: 0 -10px; padding: 10px; } .rhythm-btn { min-width: 0; width: 100%; padding: 10px 14px; } .rhythm-btn .val { font-size: 15px; } }

/* motion: cards lift and glow on hover (pointer devices), and ease in as they scroll into view */
.card { transition: transform .35s cubic-bezier(.2,.7,.2,1), box-shadow .35s ease, border-color .35s ease, opacity .6s ease; }
@media (hover: hover) and (pointer: fine) {
  .card:hover { border-color: rgba(95,224,196,.22); box-shadow: 0 18px 46px rgba(0,0,0,.38), 0 0 0 1px rgba(95,224,196,.06); }
  .row3 .card:hover, .site-info .card:hover, .info:hover { transform: translateY(-4px) scale(1.008); }
  .heart-card:hover, .ecg-card:hover { transform: translateY(-2px); }
  .m, .readorder li, .related button, .chk, .tab { transition: transform .2s ease, background .2s ease, border-color .2s ease; }
  .m:hover { transform: translateY(-2px); border-color: rgba(95,224,196,.3); }
  .readorder li:hover { transform: translateX(3px); border-color: rgba(95,224,196,.25); }
  .related button:hover { transform: translateY(-1px); }
}
.reveal { opacity: 0; transform: translateY(26px); }
.reveal.in { opacity: 1; transform: none; transition: opacity .7s ease, transform .7s cubic-bezier(.2,.7,.2,1); }
@media (prefers-reduced-motion: reduce) { .card, .reveal, .reveal.in, .top { transition: none !important; transform: none !important; opacity: 1 !important; } }

/* quiz: why-not explanations */
.quiz-opts button.other { opacity: .78; }
.quiz-opts button.other:hover, .quiz-opts button.shown { opacity: 1; border-color: var(--warn); }
.quiz-opts button.other::after { content: ' · why not?'; color: var(--muted); font-size: 12px; }
.quiz-why { margin-top: 12px; padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(255, 107, 122, .35); background: rgba(255, 107, 122, .06); font-size: 14px; line-height: 1.5; }
.quiz-why h4 { margin: 0 0 6px; font-size: 14px; color: var(--warn); }
.quiz-why p { margin: 4px 0; }

/* QTc formula picker and measurement note */
.qtc-row { display: flex; align-items: center; gap: 8px; margin: 8px 0 2px; font-size: 12.5px; color: var(--muted, #8fa3b8); }
.qtc-row select { background: #0d151c; color: inherit; border: 1px solid #26364a; border-radius: 6px; padding: 4px 6px; font: inherit; min-height: 32px; }
.meas-note { margin: 6px 0 4px; line-height: 1.45; }

.card-refs { margin: 12px 0 6px; line-height: 1.5; color: var(--muted, #8fa3b8); }
.card-refs a { color: #7fd8c4; }

details.extra { margin: 10px 0; border: 1px solid #22313f; border-radius: 8px; padding: 8px 10px; }
details.extra summary { cursor: pointer; font-weight: 600; min-height: 28px; }
details.extra table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
details.extra td { padding: 4px 6px; border-top: 1px solid #1b2733; vertical-align: top; }
details.extra td.g { color: #8fa3b8; white-space: nowrap; } details.extra td.p { text-align: right; font-family: 'JetBrains Mono', monospace; }

.variant-bar { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; flex-wrap: wrap; }
.variant-bar .vb-k { font-size: 12px; color: #8fa3b8; margin-right: 4px; }
.variant-bar .tab { min-height: 32px; }

/* phones: the ECG keeps a readable grid and pans sideways */
@media (max-width: 759px) { .ecg-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; } .ecg-wrap canvas { width: auto; } }
.close-leads { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 0 0 8px; }
.close-leads .cl-k { font-size: 12px; color: #8fa3b8; margin-right: 4px; }
.close-leads button { min-width: 44px; min-height: 32px; border-radius: 6px; border: 1px solid #26364a; background: #0d151c; color: #c9d5e2; font: 600 12px Inter, sans-serif; cursor: pointer; }
.close-leads button.on { background: #1d3b38; border-color: #5fe0c4; color: #e8fff8; }

/* picker tabs and paths */
.picker-top { display: flex; gap: 10px; align-items: center; padding: 12px 14px 4px; }
.picker-top #search { flex: 1; }
.path-card { display: block; width: 100%; text-align: left; background: none; border: 1px solid var(--line2, #22313f); border-radius: 10px; padding: 10px 12px; margin: 8px 0; cursor: pointer; color: inherit; }
.path-card:hover, .path-card.kb { background: var(--line, #16212c); }
.path-card b { display: block; font-size: 14px; margin-bottom: 2px; }
.path-card span { font-size: 12.5px; color: var(--muted, #8fa3b8); }
.path-bar { margin: 0 0 12px; padding: 12px 14px; border: 1px solid #2a4a46; background: #0e1a1c; border-radius: 14px; }
.pb-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; justify-content: space-between; }
.pb-k { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #5fe0c4; font-weight: 700; }
.pb-step { color: #8fa3b8; font-size: 13px; margin-left: 6px; }
.pb-dots { display: flex; gap: 4px; } .pb-dots i { width: 8px; height: 8px; border-radius: 50%; background: #2a3a4b; display: block; } .pb-dots i.done { background: #3f8f80; } .pb-dots i.cur { background: #5fe0c4; }
.pb-nav { display: flex; gap: 6px; } .pb-nav .mini, #pbCompare { min-height: 36px; padding: 0 12px; }
.pb-note { margin: 8px 0 4px; line-height: 1.5; }
.pb-intro { margin: 6px 0; } .pb-intro summary { cursor: pointer; font-weight: 600; min-height: 28px; } .pb-intro p { line-height: 1.5; margin: 6px 0 0; color: #c9d5e2; }
.compare-bar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin: 0 0 8px; font-size: 12.5px; color: #8fa3b8; }
.compare-bar select { background: #0d151c; color: #e6eef6; border: 1px solid #26364a; border-radius: 6px; padding: 4px 6px; min-height: 36px; font: inherit; max-width: 70vw; }

.real-ex figure { margin: 8px 0; } .real-ex img { max-width: 100%; border-radius: 8px; border: 1px solid #22313f; } .real-ex figcaption { font-size: 12px; color: #8fa3b8; }

h1.brand-name { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* touch devices: tap targets at least 44 px */
@media (pointer: coarse) {
  .tab, .mini, .seg, .icon-btn, .pg-item, .path-card, .rhythm-btn, button.primary, .quiz-opts button, .close-leads button, .related button, select, #pickerTabs .tab { min-height: 44px; }
  .close-leads button { min-width: 44px; }
  label.chk { min-height: 44px; display: inline-flex; align-items: center; padding: 0 4px; }
  label.chk input { width: 20px; height: 20px; }
  #scrub { height: 44px; }
}

.swipe-hint { display: none; margin: 0 0 6px; font-size: 12px; color: #8fa3b8; }
@media (max-width: 759px) { .swipe-hint { display: block; } }

/* welcome card and guided tour */
.help-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line2, #26364a); background: transparent; color: #c9d5e2; font: 700 16px Inter, sans-serif; cursor: pointer; margin-right: 8px; }
@media (pointer: coarse) { .help-btn { width: 44px; height: 44px; } }
.top-actions { display: flex; align-items: center; }
.welcome { position: fixed; inset: 0; z-index: 80; background: rgba(4, 8, 12, .7); display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(3px); }
.welcome-card { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel, #0f171f); border: 1px solid var(--line2, #26364a); border-radius: 16px; padding: 22px 22px 18px; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.welcome-card h2 { margin: 0 0 10px; font-size: 24px; }
.welcome-card p { line-height: 1.55; margin: 0 0 10px; }
.wl-disc { font-size: 13px; color: #8fa3b8; }
.wl-btns, .tour-btns { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.wl-btns button, .tour-btns button { min-height: 44px; padding: 0 16px; }
.tour { position: fixed; inset: 0; z-index: 75; pointer-events: none; }
.tour-ring { position: fixed; border: 2px solid #5fe0c4; border-radius: 12px; box-shadow: 0 0 0 9999px rgba(4, 8, 12, .55); transition: all .25s ease; pointer-events: none; }
.tour-card { position: fixed; width: min(360px, calc(100vw - 32px)); background: var(--panel, #0f171f); border: 1px solid #2f6f66; border-radius: 14px; padding: 14px 16px; box-shadow: 0 20px 60px rgba(0,0,0,.5); pointer-events: auto; }
.tour-card h3 { margin: 2px 0 6px; font-size: 16px; } .tour-card p { margin: 0; line-height: 1.5; }
.tour-k { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #5fe0c4; font-weight: 700; }

.wl-btns button, .tour-btns button { width: auto; flex: 0 0 auto; }
@media (max-width: 440px) { .brand-name { font-size: 20px; } .help-btn { margin-right: 4px; } .brand svg { width: 34px; } }

/* welcome and tour buttons: one height, one type size, no stray margins */
.wl-sig { margin: 4px 0 0; font-size: 13px; font-style: italic; color: #c9d5e2; }
.wl-btns, .tour-btns { align-items: stretch; }
.wl-btns button, .tour-btns button { margin: 0; height: 44px; min-height: 44px; padding: 0 18px; font: 600 14px/1 Inter, sans-serif; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; }
.tour-card { padding-bottom: 14px; } .tour-card p { margin-bottom: 0; } .tour-btns { margin-top: 12px; }
.wl-btns button:focus-visible, .tour-btns button:focus-visible { outline: 2px solid #5fe0c4; outline-offset: 2px; }
#ecg { touch-action: pan-x pan-y; } #ecg.seeking { cursor: ew-resize; }

.focus-card { z-index: 7; }

/* 3D heart: open hand over the heart, closed hand while rotating; a pointing hand only over a clickable structure */
.heart-stage.is3d, .heart-stage.is3d #heart, .heart-stage.is3d #heartLabels { cursor: grab; }
.heart-stage.is3d:has(#heart.grabbing), .heart-stage.is3d:has(#heart.grabbing) * { cursor: grabbing; }
.heart-stage.is3d.hovering:not(:has(#heart.grabbing)), .heart-stage.is3d.hovering:not(:has(#heart.grabbing)) #heart { cursor: pointer; }
.h3-ctrls, .h3-ctrls *, .heart-info, .heart-rail, .focus-card { cursor: auto; }
.h3-ctrls button, .h3-ctrls label, .focus-card button, .heart-info button { cursor: pointer; }

a.brand { text-decoration: none; color: var(--accent); cursor: pointer; } a.brand:focus-visible { outline: 2px solid #5fe0c4; outline-offset: 4px; border-radius: 8px; }
