:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --surface: #fcfcfb;
  --ink: #16161a;
  --ink2: #52514e;
  --muted: #8a8880;
  --line: #e3e1da;
  --p1: #2a78d6;
  --p2: #e34948;
  --p1-tint: #d6e6fa;
  --p2-tint: #fbdad9;
  --het: #b9b6ad;
  --accent: #4a3aa7;
  --accent-tint: #ecebf7;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.top { background: var(--accent); color: #fff; padding: 22px 0 26px; margin-bottom: 16px; }
.top h1 { margin: 2px 0 6px; font-size: clamp(1.5rem, 6vw, 2.1rem); line-height: 1.15; letter-spacing: -0.01em; }
.eyebrow { margin: 0; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }
.lede { margin: 0; opacity: .92; max-width: 56ch; }
h2 { font-size: 1.08rem; margin: 0 0 8px; }
h3 { font-size: .95rem; margin: 0 0 6px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.note { color: var(--ink2); font-size: .9rem; margin: 6px 0 10px; }
.count { color: var(--muted); font-weight: 500; font-size: .9rem; margin-left: 4px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.sw { display: inline-block; width: .8em; height: .8em; border-radius: 3px; vertical-align: -1px; }
.sw.p1 { background: var(--p1); } .sw.p2 { background: var(--p2); } .sw.het { background: var(--het); }
.foot { color: var(--muted); font-size: .8rem; padding-bottom: 40px; }

/* buttons */
.btn { font: inherit; font-weight: 600; border-radius: 10px; border: 1px solid transparent; padding: 11px 16px; min-height: 44px; cursor: pointer; touch-action: manipulation; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:active { filter: brightness(.9); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: .85rem; }
.btn:disabled { opacity: .45; cursor: default; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 14px; }
.combo { display: flex; }
.combo .btn { border-radius: 10px 0 0 10px; }
.combo select { font: inherit; font-weight: 600; border: 0; border-left: 1px solid rgba(255,255,255,.35); background: #3b2e8a; color: #fff; border-radius: 0 10px 10px 0; padding: 0 8px; min-height: 44px; }
.seg { display: inline-flex; background: #e7e5de; border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: transparent; font: inherit; font-size: .82rem; font-weight: 600; padding: 6px 10px; border-radius: 7px; color: var(--ink2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: .8rem; color: var(--ink2); }
.viewrow { margin-bottom: 10px; }

/* chromosomes */
.karyo { display: flex; gap: 14px; align-items: flex-start; }
.chrom { min-width: 0; }
.chrom .lab, .mbiv .lab { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; white-space: nowrap; }
.mk-head { position: relative; height: 16px; font-size: .72rem; font-weight: 700; color: var(--ink2); }
.mk-head span { position: absolute; transform: translateX(-50%); }
.bars { position: relative; display: grid; gap: 3px; }
.bar { height: 12px; border-radius: 6px; position: relative; }
.bars .tick { position: absolute; top: -2px; bottom: -2px; width: 0; border-left: 1.5px solid rgba(255,255,255,.9); pointer-events: none; }
.bars .cen { position: absolute; width: 8px; height: 8px; margin: 2px 0 0 -4px; border-radius: 50%; background: rgba(255,255,255,.85); box-shadow: 0 0 0 1px rgba(0,0,0,.25); pointer-events: none; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.chip { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.chip .site { font-size: .62rem; font-weight: 700; color: var(--muted); line-height: 1; }
.chip .call { display: inline-flex; align-items: center; font: 600 .78rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink); }
.chip .call b { padding: 4px 3.5px; border-radius: 4px; font-weight: 600; }
.chip .call b.a0 { background: var(--p1-tint); box-shadow: inset 0 -2px 0 var(--p1); }
.chip .call b.a1 { background: var(--p2-tint); box-shadow: inset 0 -2px 0 var(--p2); }
.chip .call i { font-style: normal; color: var(--muted); width: 6px; text-align: center; font-size: .7rem; }
.chips .sep { width: 6px; }
.calls { position: relative; height: 46px; margin-top: 5px; }
.callcol { position: absolute; top: 0; transform: translateX(-50%); display: grid; gap: 2px; font: 600 .74rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.callcol b { padding: 4px 2.5px; border-radius: 4px; font-weight: 600; text-align: center; }
.callcol b.a0 { background: var(--p1-tint); box-shadow: inset 0 -2px 0 var(--p1); }
.callcol b.a1 { background: var(--p2-tint); box-shadow: inset 0 -2px 0 var(--p2); }
.calls::before { content: ""; }
.cross .chrom .lab, .mbiv .lab { font-size: .6rem; }

/* the cross diagram */
.cross { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.cross .who { font-size: .8rem; font-weight: 600; margin-bottom: 4px; }
.cross .x { font-size: 1.2rem; color: var(--muted); }
.cross .f1 { grid-column: 1 / -1; max-width: 340px; margin: 0 auto; width: 100%; }
.cross .arrow { grid-column: 1 / -1; text-align: center; color: var(--muted); line-height: 1; font-size: .85rem; font-weight: 600; }
.cross .tester { max-width: 170px; }

/* animated meiosis */
.stage { position: relative; }
.meio { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mcol h3 { font-size: .8rem; color: var(--ink2); margin: 0 0 2px; }
.mbiv { margin-bottom: 8px; }
.mbiv .mk-head { font-size: .62rem; height: 13px; }
.strands { position: relative; height: 48px; margin-top: 4px; }
.strand { position: absolute; left: 0; right: 0; height: 9px; border-radius: 4.5px; transition: opacity .5s; }
.strands .mline { position: absolute; top: -2px; bottom: -2px; border-left: 1px dashed rgba(22,22,26,.4); pointer-events: none; }
.xo { position: absolute; width: 0; border-left: 2px solid var(--ink); opacity: 0; transition: opacity .4s; }
.xo b { position: absolute; left: -8px; top: 50%; margin-top: -7px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 8px; line-height: 1; box-shadow: 0 0 0 1.5px var(--surface); transform: scale(.2); transition: transform .4s cubic-bezier(.3,1.6,.6,1); }
.stage:not([data-phase="0"]) .xo { opacity: 1; }
.stage:not([data-phase="0"]) .xo b { transform: none; }
.stage:is([data-phase="2"],[data-phase="3"],[data-phase="4"]) .strand:not(.picked) { opacity: .16; }
.stage:is([data-phase="2"],[data-phase="3"],[data-phase="4"]) .xo { opacity: .12; }
.stage[data-phase="3"] .strand.picked { opacity: .16; }
.strand.picked { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--ink); z-index: 1; }
.fly { position: absolute; z-index: 3; border-radius: 5px; transform-origin: 0 0; transition: transform 1s cubic-bezier(.5,0,.2,1); box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.hint { font-size: .85rem; color: var(--ink2); background: var(--accent-tint); border-radius: 10px; padding: 9px 12px; margin: 6px 0 10px; min-height: 4.2em; }
.kid { border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.kid .id { font-size: .75rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.kid .bar, .kid .tick, .kid .calls { transition: opacity .5s; }
.stage:not([data-phase="4"]) .kid :is(.bar, .tick, .calls) { opacity: 0; transition: none; }
.stage[data-phase="4"] .kid { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.empty { color: var(--muted); font-size: .9rem; text-align: center; padding: 18px 0; margin: 0; }

/* population canvas */
.pophead { display: flex; gap: 14px; }
.pophead .mk-head { min-width: 0; }
.popscroll { max-height: 380px; overflow-y: auto; border-radius: 8px; -webkit-overflow-scrolling: touch; }
.popscroll canvas { display: block; width: 100%; }

/* heatmap + charts */
.heat { width: 100%; max-width: 440px; display: block; margin: 0 auto; touch-action: manipulation; }
.heat text { font-family: inherit; }
.heat .cell { cursor: pointer; }
.detail { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; font-size: .9rem; }
.detail .big { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
.detail table { border-collapse: collapse; margin-top: 8px; font-size: .85rem; font-variant-numeric: tabular-nums; }
.detail td.rec { background: var(--accent-tint); font-weight: 700; }
.detail td, .detail th { border: 1px solid var(--line); padding: 4px 10px; text-align: center; }
.detail td.rec { background: var(--accent-tint); font-weight: 700; }
.detail th { color: var(--ink2); font-weight: 600; background: #f6f5f1; }
.scale { display: flex; align-items: center; gap: 8px; justify-content: center; font-size: .75rem; color: var(--ink2); margin-top: 8px; }
.scale i { display: block; width: 140px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, #f1f0fa, #4a3aa7); }
.scatter { width: 100%; display: block; }
.scatter text { font-family: inherit; fill: var(--ink2); }
.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--ink); color: #fff; font-size: .8rem; padding: 6px 9px; border-radius: 7px; max-width: 220px; line-height: 1.35; }
@media (max-width: 370px) { .callcol { font-size: .66rem; } .callcol b { padding: 4px 2px; } .chip .call { font-size: .68rem; } .chip .call b { padding: 4px 2.5px; } .chips { gap: 3px; } }
