#app {
  --panel-w: 342px;
  --accent: #a6b8ff;
  --line: #232b3b;
  --muted: #a0acc1;
  color: #ecf0fb;
  color-scheme: dark;
  background: #080b13;
  min-height: 490px;
}
#stage { display: flex; flex-direction: column; background: #05070d; }
.stage-head, .stage-controls, .observation { padding-inline: clamp(18px, 3.5vw, 46px); }
.stage-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-top: 24px; }
.stage-head h1 { font-size: 18px; margin: 0 0 9px; font-weight: 650; }
.stage-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.stage-meta strong { color: #cdd7ff; font-size: 15px; }
.modes { border: 1px solid var(--line); border-radius: 9px; padding: 3px; background: #0e1320; }
.modes button, .modes button:first-child, .modes button:last-child {
  min-height: 36px; white-space: nowrap; padding: 0 12px; border: 0; border-radius: 6px; background: transparent;
}
.modes button.on { color: #eef1ff; background: #2b385a; }

.specimen { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#division { width: 100%; height: 100%; touch-action: pan-y; }
.specimen-legend {
  position: absolute; inset: auto 0 8px; display: flex; justify-content: center; flex-wrap: wrap;
  gap: 8px 19px; color: #b5bfd2; font-size: 11px; pointer-events: none;
}
.specimen-legend span, .chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.specimen-legend span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--swatch); }
.maternal { --swatch: #ffc470; }
.paternal { --swatch: #74d5ff; }
.centromere { --swatch: #f3edff; }

.observation { display: grid; place-content: center; min-height: 63px; text-align: center; }
.observation p { margin: 0; color: #cbd4e6; font-size: 13px; line-height: 1.55; }
#explain, #probe { grid-area: 1 / 1; align-self: center; }
#probe { color: #d6dfff; }
#stage.probing #explain { visibility: hidden; }
.stage-controls { border-top: 1px solid #1c2432; background: #0b0f19; padding-block: 11px 8px; }
.playback { display: flex; align-items: flex-start; gap: 6px; }
#app button { cursor: pointer; }
#app button:disabled { opacity: .35; cursor: default; }
#app :is(button,input,summary,select,a):focus-visible { outline: 2px solid #b2c2ff; outline-offset: 2px; }
.playback button, #panel button, #panel select, #answer, #panelToggle {
  font: inherit; color: inherit; background: #151c2b; border: 1px solid var(--line); border-radius: 7px;
}
.playback button { min-width: 40px; height: 42px; font-size: 22px; }
.playback #play { width: 62px; font-weight: 650; font-size: 13px; background: #c1cdff; color: #151e38; }
.scrubber { flex: 1; min-width: 0; margin-left: 10px; }
#progress { width: 100%; margin: 0; height: 31px; padding: 0; accent-color: #b5c5ff; cursor: ew-resize; }
.timeline-labels, .stage-links { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.stage-links { justify-content: flex-end; align-items: center; min-height: 26px; }
.stage-links a { color: #b9c7e6; text-decoration: none; }
.stage-links a:hover { text-decoration: underline; }

#panel { background: #101520; padding: 19px 17px; font-size: 13px; }
.panel-heading, .section-heading, .setting { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#panel h2 { margin: 0; color: #e0e6f5; font-size: 13px; letter-spacing: 0; }
#panel .panel-heading h2 { font-size: 15px; }
#closePanel { display: none; }
#panel .readout { border: 0; padding-top: 12px; }
.readout dl { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0; }
.readout dl div { background: #171e2d; border-radius: 8px; padding: 8px 10px; }
.readout dt, .note { color: var(--muted); font-size: 11px; line-height: 1.5; }
.readout dd { margin: 3px 0 0; font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 650; }
#chromosomes { color: #ffc470; }
#dna { color: #83e4b5; }
.note { margin: 8px 0 0; }
#panel button, #panel select, #answer { padding: 6px 10px; min-height: 34px; }
#panel .text-button { border: 0; background: transparent; color: var(--muted); padding: 0 3px; font-size: 12px; }
#periods { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 5px; margin-top: 5px; }
#panel #periods button { padding: 4px 2px; font-size: 11px; color: #b9c6dc; }
#panel #periods button.on { border-color: #8495cc; background: #273554; color: #f2f4ff; }
#panel button:hover:not(:disabled), .playback button:hover:not(:disabled) { border-color: #7889bb; }
#panel details { border-top: 1px solid var(--line); padding-bottom: 2px; }
#panel summary { cursor: pointer; padding: 12px 0; color: #dbe3f5; font-weight: 600; }
#chart { display: block; width: 100%; height: 127px; cursor: ew-resize; touch-action: pan-y; }
.chart-legend { display: flex; gap: 15px; padding: 3px 0 11px 22px; font-size: 11px; color: var(--muted); }
.chart-legend span::before { content: ""; width: 16px; border-top: 2px solid #83e4b5; }
.chart-legend span + span::before { border-top: 2px dashed #ffc470; }
.setting { min-height: 42px; }
#orientation { margin: 6px 0; }
.actions { display: flex; gap: 6px; margin: 7px 0; }
#answer { width: 74px; }
#feedback, #shareStatus { color: #bac9ff; overflow-wrap: anywhere; }
#feedback:empty, #shareStatus:empty { display: none; }

@media (max-width: 760px) {
  #app { min-height: 460px; }
  .stage-head { flex-wrap: wrap; padding-top: 13px; row-gap: 5px; }
  .stage-head h1 { font-size: 16px; margin-bottom: 6px; }
  .stage-meta strong { font-size: 13px; }
  .modes button, .modes button:first-child, .modes button:last-child { min-height: 44px; padding: 0 7px; font-size: 11px; }
  .observation { min-height: 56px; }
  .observation p { font-size: 12px; }
  .stage-controls { padding-block: 7px 3px; }
  .playback button { min-width: 44px; height: 44px; }
  .scrubber { margin-left: 5px; }
  #progress { height: 36px; }
  .stage-links { justify-content: space-between; }
  .stage-links a { padding: 10px 0 10px 12px; }
  #panelToggle { position: static; z-index: auto; padding: 0 10px; height: 44px; font-size: 12px; }
  #panel { max-height: 76%; border-radius: 15px 15px 0 0; padding-top: 8px; }
  #panel.collapsed { visibility: hidden; }
  #closePanel { display: block; width: 44px; font-size: 19px; }
  #panel button, #panel select, #panel summary { min-height: 44px; }
}
@media (max-width: 360px) {
  .stage-head, .stage-controls, .observation { padding-inline: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  #panel { transition: none; }
}
@media (max-height: 680px) and (min-width: 761px) {
  #panel { padding-block: 12px; }
  #panel section { padding-block: 8px; }
  .readout dl div { padding-block: 5px; }
  #panel #periods button { min-height: 28px; }
  #chart { height: 108px; }
}
