:root {
  --bg: #0e1116;
  --panel: #161b22;
  --ink: #e6edf3;
  --muted: #9aa7b4;
  --line: #2a3441;
  --accent: #3b82f6;
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  color: var(--ink);
  background: var(--bg);
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}
button,
input,
select {
  font: inherit;
}
button,
select {
  background: #21262d;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 11px;
}
button {
  cursor: pointer;
  white-space: nowrap;
}
button:hover {
  background: #2b3542;
}
button.active,
button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
button.block {
  background: #a93747;
  border-color: #a93747;
}
button:disabled {
  opacity: 0.4;
  cursor: wait;
}
button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible,
[role="separator"]:focus-visible,
canvas:focus-visible {
  outline: 2px solid #74b3ff;
  outline-offset: 2px;
}
input[type="range"] {
  accent-color: var(--accent);
  min-width: 0;
  cursor: pointer;
}
input[type="checkbox"] {
  accent-color: var(--accent);
  margin: 0;
  cursor: pointer;
}
a {
  color: #80b8ff;
}
[hidden] {
  display: none !important;
}
#app,
#stage {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}
#stage {
  display: flex;
  min-width: 0;
  min-height: 0;
}
#viewwrap {
  flex: 1 1 0;
  display: flex;
  min-width: 0;
  min-height: 0;
}
#viewwrap.vstack {
  flex-direction: column;
}
#panel3d,
#panelEcg {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
#panel3d {
  background: var(--bg);
}
#viewer {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
#viewer > canvas {
  display: block;
  touch-action: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#gutter {
  flex: 0 0 7px;
  background: var(--line);
  cursor: col-resize;
  touch-action: none;
  z-index: 4;
}
#gutter:hover,
#gutter:focus-visible {
  background: var(--accent);
}
.vstack #gutter {
  cursor: row-resize;
}
.resizing {
  user-select: none;
}
.resizing iframe {
  pointer-events: none;
}
#controls {
  position: relative;
  flex: 0 0 244px;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-inline: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
}
#ctrlhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 5px;
  padding: 8px 9px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.ctrltitle {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.dockbtns {
  display: flex;
  gap: 3px;
}
.dockbtns button {
  padding: 2px 6px;
  font-size: 13px;
}
.dockbtns button:focus-visible {
  outline-offset: 0;
}
#cwgrip {
  position: absolute;
  right: 0;
  top: 36px;
  bottom: 0;
  width: 7px;
  z-index: 10;
  cursor: col-resize;
  touch-action: none;
}
#cwgrip[data-edge="left"] {
  left: 0;
  right: auto;
}
#cwgrip:hover {
  background: #3b82f680;
}
#ctrlbody {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  scrollbar-width: thin;
}
#ctrlbody > details {
  flex: none;
}
details {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #11161d;
}
summary {
  padding: 7px 8px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.035em;
  user-select: none;
}
details[open] > summary {
  border-bottom: 1px solid var(--line);
}
.sect {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.grp {
  display: flex;
  align-items: center;
  gap: 5px;
}
.grp > label {
  font-size: 10.5px;
  color: var(--muted);
  flex: 0 0 65px;
  white-space: nowrap;
}
.grp input[type="range"] {
  flex: 1;
  width: 0;
  height: 15px;
}
.grp output {
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  flex: 0 0 53px;
}
.grp select {
  min-width: 0;
  flex: 1;
}
.sect > select {
  width: 100%;
}
.btnrow {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  align-items: center;
}
.btnrow label {
  display: flex;
  gap: 4px;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
}
.wide {
  width: 100%;
  padding: 6px;
  font-weight: 600;
}
.help,
.scenario-description {
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--muted);
  margin: 0;
}
.small-note {
  font-size: 10px;
  color: #8494a6;
  line-height: 1.5;
  margin: 4px 0;
}
.primary {
  background: #0e7490;
  border-color: #168faa;
}
.chambers {
  display: flex;
  gap: 8px;
  justify-content: space-between;
}
.chambers label {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
}
.chambers i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--chamber);
}
#paint-controls {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
#viewbar {
  position: absolute;
  left: 9px;
  top: 8px;
  max-width: calc(100% - 18px);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
  padding: 4px;
  background: #05090ec4;
  border-radius: 7px;
}
#viewbar button {
  padding: 3px 6px;
  font-size: 10px;
}
#viewbar .vblbl {
  font-size: 10px;
  color: var(--muted);
  margin-left: 5px;
}
.saved {
  outline: 1px solid #5ca2ff;
}
.vbsep {
  width: 1px;
  height: 16px;
  background: var(--line);
  margin: 0 3px;
}
#status {
  position: absolute;
  top: 43px;
  right: 10px;
  z-index: 3;
  font-size: 10px;
  padding: 4px 7px;
  border-radius: 5px;
  background: #05090ea8;
  color: var(--muted);
  max-width: calc(100% - 20px);
  pointer-events: none;
}
#legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 4;
  max-width: calc(100% - 20px);
  font-size: 10px;
  line-height: 1.6;
  background: #05090ecc;
  padding: 6px 9px;
  border-radius: 7px;
  color: var(--muted);
  pointer-events: none;
}
.legend-row {
  display: flex;
  flex-wrap: wrap;
  column-gap: 9px;
  align-items: center;
}
.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 3px;
  background: var(--dot);
}
#phase-label {
  color: #bbd3e2;
}
#loading {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-content: center;
  gap: 12px;
  text-align: center;
  background: var(--bg);
  color: var(--muted);
}
.loading-ring {
  width: 28px;
  height: 28px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: auto;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.marker-label {
  position: absolute;
  pointer-events: none;
  color: var(--label-color, #dde7ef);
  font-size: 10px;
  font-weight: 600;
  transform: translate(-50%, -100%);
  background: #05090e99;
  padding: 1px 3px;
  border-radius: 3px;
  z-index: 2;
}
.inset-label {
  position: absolute;
  z-index: 4;
  padding: 3px 6px;
  font-size: 9px;
  border: 0;
  background: #05090ec4;
}
.ortho-handle {
  position: absolute;
  z-index: 5;
  touch-action: none;
}
.ortho-handle.vertical {
  width: 7px;
  cursor: col-resize;
}
.ortho-handle.horizontal {
  height: 7px;
  cursor: row-resize;
}
.ortho-handle:hover {
  background: #3b82f680;
}
#panelEcg {
  display: flex;
  flex-direction: column;
  background: var(--panel);
}
.measurements {
  flex: none;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  padding: 8px 7px;
  border-bottom: 1px solid var(--line);
  background: #11161d;
}
.measurements > div {
  border-right: 1px solid var(--line);
  padding: 0 5px;
  min-width: 0;
}
.measurements > div:last-child {
  border: 0;
}
.measurements span {
  display: block;
  font-size: 9px;
  color: var(--muted);
  margin-bottom: 3px;
}
.measurements strong {
  font-size: 17px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.measurements small {
  font-size: 9px;
  color: var(--muted);
  margin-left: 2px;
}
.paper-heading {
  flex: none;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 9px;
  font-size: 10px;
  color: var(--muted);
}
#paper-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 7px;
  scrollbar-width: thin;
  position: relative;
}
#ecg {
  display: block;
  border-radius: 5px;
  background: white;
  cursor: crosshair;
  touch-action: pan-y;
}
.transport {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-top: 1px solid var(--line);
  flex: none;
}
.transport strong {
  font-size: 11px;
  min-width: 48px;
  font-variant-numeric: tabular-nums;
}
.transport input {
  min-width: 20px;
  flex: 1;
  width: 0;
}
#quality-note {
  font-size: 9px;
  color: #8192a3;
  padding: 0 9px 7px;
  line-height: 1.4;
  flex: none;
}
.popover {
  position: absolute;
  z-index: 15;
  background: #0b111bf5;
  border: 1px solid #384452;
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 12px 30px #0008;
  max-height: calc(100% - 80px);
  overflow: auto;
  max-width: calc(100% - 20px);
}
.popover header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}
.popover h3 {
  font-size: 11px;
  margin: 0;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.popover header button {
  border: 0;
  padding: 1px 5px;
}
#leadsel {
  right: 10px;
  top: 62px;
  width: 218px;
}
#lgrid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px 5px;
  margin: 10px 0;
}
.lchk {
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}
#models {
  left: 10px;
  top: 62px;
  width: 248px;
}
.model-tile {
  display: block;
  white-space: normal;
  text-align: left;
  width: 100%;
  margin-bottom: 7px;
  padding: 10px;
}
.model-tile strong {
  display: block;
  font-size: 12px;
}
.model-tile small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-top: 4px;
}
dialog {
  color: var(--ink);
  background: #161e28;
  border: 1px solid #405166;
  border-radius: 12px;
  width: min(640px, calc(100% - 28px));
  max-height: 88dvh;
  overflow: auto;
  padding: 24px;
  line-height: 1.65;
}
dialog::backdrop {
  background: #03080dc9;
}
dialog h2 {
  font-size: 22px;
  margin: 8px 0 14px;
}
dialog h3 {
  font-size: 14px;
  margin-top: 22px;
}
dialog p,
dialog li {
  font-size: 13px;
  color: #b5c3d1;
}
dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.12em;
}
dialog header button {
  font-size: 20px;
  border: 0;
}
dialog table {
  font-size: 12px;
  border-collapse: collapse;
  width: 100%;
}
dialog th,
dialog td {
  text-align: left;
  padding: 7px;
  border-bottom: 1px solid var(--line);
}
#toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  background: #29394c;
  border: 1px solid #62788f;
  border-radius: 7px;
  padding: 11px 16px;
  max-width: 90vw;
  font-size: 12px;
  box-shadow: 0 5px 30px #0009;
}
@media (max-width: 719px) {
  #stage {
    flex-direction: column;
  }
  #controls {
    border-top: 1px solid var(--line);
  }
  #ctrlbody {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
  }
  #ctrlbody > details {
    align-self: start;
  }
  #ctrlbody > .small-note {
    grid-column: 1/-1;
  }
  #cwgrip,
  .dockbtns {
    display: none;
  }
  #ctrlhead {
    padding: 6px 10px;
  }
  #viewbar {
    max-width: calc(100% - 18px);
  }
  #viewbar button {
    font-size: 9px;
    padding: 2px 5px;
  }
  #legend {
    font-size: 8px;
    padding: 4px 6px;
    bottom: 5px;
    left: 5px;
  }
  #legend .interaction-hint {
    display: none;
  }
  #status {
    font-size: 8px;
    top: 38px;
  }
  .measurements {
    padding: 5px;
  }
  .measurements strong {
    font-size: 14px;
  }
  .measurements small {
    display: none;
  }
  .paper-heading {
    padding: 4px 7px;
    font-size: 9px;
  }
  .transport {
    padding: 4px 7px;
  }
  #quality-note {
    display: none;
  }
  .grp {
    flex-wrap: wrap;
  }
  .grp > label {
    flex-basis: 100%;
    font-size: 10px;
  }
  .grp input[type="range"] {
    flex: 1;
  }
  .grp output {
    flex-basis: 48px;
  }
  .sect {
    padding: 7px;
  }
  .btnrow {
    gap: 4px;
  }
  .btnrow button {
    font-size: 10px;
    padding: 5px;
  }
  .popover {
    max-height: calc(100% - 65px);
    top: 55px !important;
  }
  .marker-label {
    font-size: 8px;
  }
}
