:root {
  color-scheme: light;
  --ink: #173e35;
  --muted: #587268;
  --line: #d6e0da;
  --paper: #f6f8f4;
  --green: #215c47;
  font-family: Inter, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
[hidden] {
  display: none !important;
}
button,
input,
select {
  font: inherit;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 7px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
button:hover {
  background: #e5eee7;
  border-color: #9bad9e;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #b5823c;
  outline-offset: 3px;
}
.primary {
  background: var(--green);
  color: white;
  border-color: var(--green);
}
.primary:hover {
  background: #31715a;
  border-color: #31715a;
}
.quiet {
  background: transparent;
  border-color: transparent;
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 1.7px;
  font-weight: 700;
  color: var(--muted);
}
#lab {
  height: 100dvh;
  min-height: 530px;
  display: grid;
  grid-template-rows: 74px minmax(0, 1fr) 30px;
}
header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: #fbfcf8;
}
.brand {
  text-decoration: none;
  color: var(--ink);
}
.brand img {
  object-fit: contain;
  display: block;
}
.brand small {
  display: block;
  font-size: 8px;
  letter-spacing: 1.8px;
  margin-top: 3px;
}
nav {
  display: flex;
  gap: 5px;
  flex: 1;
  justify-content: center;
}
nav button {
  background: transparent;
  border-color: transparent;
}
nav button[aria-pressed="true"] {
  background: #e2ece4;
  border-color: #c9d9cd;
}
main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  min-height: 0;
}
#stage {
  position: relative;
  overflow: hidden;
  min-height: 0;
  background: #e7efeb;
}
#stage > canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.stage-heading {
  position: absolute;
  top: 23px;
  left: 28px;
  z-index: 2;
  pointer-events: none;
}
.stage-heading p {
  margin: 0 0 9px;
}
.stage-heading h1 {
  font:
    400 clamp(26px, 3vw, 39px)/1.1 Georgia,
    serif;
  margin: 0 0 10px;
  letter-spacing: -0.7px;
}
#question {
  font-size: 12px;
  color: var(--muted);
}
.view-tools {
  position: absolute;
  right: 18px;
  top: 24px;
  display: flex;
  gap: 5px;
  z-index: 3;
}
.view-tools button {
  font-size: 10px;
  padding: 8px;
  background: #f8faf6e8;
}
.view-tools button[aria-pressed="false"] {
  opacity: 0.65;
}
.annotation {
  position: absolute;
  left: 26px;
  bottom: 180px;
  max-width: 320px;
  background: #f8faf6eb;
  border-left: 3px solid #b08a51;
  padding: 12px 14px;
  pointer-events: none;
}
.annotation p {
  font-size: 12px;
  line-height: 1.55;
  margin: 7px 0;
}
.annotation small {
  font-size: 10px;
  color: var(--muted);
}
.stage-footer {
  position: absolute;
  bottom: 20px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 9px;
  z-index: 3;
}
.bench-controls {
  display: flex;
  justify-content: center;
  gap: 8px;
  width: min(650px, 100%);
}
.direct-control {
  background: #f8faf6eb;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  width: min(440px, 100%);
}
.direct-control label {
  font-size: 11px;
  display: flex;
  justify-content: space-between;
}
.direct-control output {
  white-space: nowrap;
  margin-left: 8px;
}
.direct-control input {
  width: 100%;
  accent-color: var(--green);
  margin: 7px 0 0;
}
.actions {
  display: flex;
  justify-content: center;
  gap: 5px;
  padding: 7px;
  background: #f9fbf7f2;
  border: 1px solid #c9d8cc;
  border-radius: 11px;
  box-shadow: 0 8px 28px #1d3f3510;
  flex-wrap: wrap;
}
.speed-row {
  display: flex;
  gap: 20px;
  align-items: center;
  font-size: 11px;
  background: #edf3eddd;
  border-radius: 6px;
  padding: 4px 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.speed-row select {
  padding: 3px;
  background: transparent;
  border: 0;
  color: var(--ink);
  font-size: 11px;
}
.scene-label {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  font-size: 10px;
  letter-spacing: 0.6px;
  background: #f6faf1df;
  color: #38584b;
  padding: 4px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.scene-label.pole {
  font-weight: 800;
  font-size: 16px;
  background: none;
  color: white;
}
.scene-label.vector {
  font-weight: 700;
  color: #215c47;
}
#scene-error {
  position: absolute;
  top: 170px;
  left: 20px;
  right: 20px;
  background: white;
  border: 1px solid #b6634b;
  padding: 20px;
  z-index: 5;
}
#evidence {
  padding: 23px 22px 18px;
  border-left: 1px solid var(--line);
  background: #f8faf6;
  overflow: auto;
  min-height: 0;
}
.evidence-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#phase {
  font-size: 10px;
  color: #467961;
}
#readings {
  display: grid;
  gap: 15px;
  padding: 23px 0 18px;
}
.reading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.reading span {
  font-size: 12px;
  color: var(--muted);
}
.reading strong {
  font-weight: 500;
  font-size: 25px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}
.reading small {
  font-size: 11px;
  color: var(--muted);
}
.graph-tools {
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 15px;
}
.graph-tools label {
  flex: 1;
  font-size: 10px;
  color: var(--muted);
}
select {
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 5px;
  background: white;
  max-width: 100%;
}
.graph-tools select {
  display: block;
  width: 100%;
  font-size: 11px;
  padding: 6px;
  margin-top: 5px;
}
#graph {
  display: block;
  width: 100%;
  height: 225px;
  touch-action: pan-y;
}
#linkage-graph {
  width: 100%;
  height: 135px;
  display: block;
}
#graph-note {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 8px;
}
#graph-cursor,
#large-cursor {
  font-size: 11px;
  min-height: 20px;
  color: var(--green);
}
.graph-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  margin: 7px 0 18px;
}
.graph-options button {
  font-size: 10px;
  padding: 6px;
}
.graph-options input {
  accent-color: var(--green);
}
#detail {
  font-size: 11px;
  line-height: 1.8;
  border-top: 1px solid var(--line);
  padding: 12px 0;
  margin-top: 15px;
}
.keep {
  width: 100%;
  margin: 6px 0;
  background: #e6eee6;
}
#comparisons {
  display: grid;
  gap: 7px;
  margin-top: 8px;
}
.comparison {
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.comparison label {
  flex: 1;
  overflow-wrap: anywhere;
}
.comparison button {
  padding: 3px 7px;
}
.comparison i {
  display: inline-block;
  width: 16px;
  height: 3px;
  margin-right: 5px;
  background: var(--curve);
}
footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  color: var(--muted);
}
footer button {
  border: 0;
  background: transparent;
  padding: 4px;
  font-size: 10px;
}
#status {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
dialog {
  border: 1px solid #c8d8cb;
  border-radius: 13px;
  box-shadow: 0 24px 80px #193e3540;
  padding: 0;
  width: min(400px, calc(100% - 24px));
  max-height: 88dvh;
  color: var(--ink);
  background: #fafbf8;
  margin: auto 20px auto auto;
}
dialog::backdrop {
  background: #14392c26;
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: #fafbf8;
  z-index: 2;
}
.dialog-head h2 {
  font:
    400 24px Georgia,
    serif;
  margin: 0;
}
.dialog-head button {
  font-size: 23px;
  border: 0;
  padding: 2px 8px;
  background: transparent;
}
#drawer-content {
  padding: 20px;
}
#drawer-content label {
  display: block;
  font-size: 12px;
  margin: 0 0 15px;
}
#drawer-content input:not([type="checkbox"]),
#drawer-content select {
  width: 100%;
  padding: 9px;
  border: 1px solid #c8d8cb;
  border-radius: 6px;
  background: white;
  color: var(--ink);
  margin-top: 6px;
}
#drawer-content p,
#drawer-content li {
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}
#drawer-content ul {
  padding-left: 18px;
}
#drawer-content h3 {
  font-size: 13px;
  margin: 22px 0 10px;
}
.full {
  width: 100%;
  margin: 6px 0;
}
.panel-error {
  color: #a13e34 !important;
}
#graph-dialog {
  width: min(1000px, calc(100% - 24px));
  margin: auto;
}
#large-graph {
  display: block;
  width: 100%;
  height: min(60dvh, 550px);
}
#graph-dialog > p,
#large-cursor {
  margin: 10px 20px;
}
#graph-dialog > p {
  font-size: 12px;
}
@media (min-width: 1500px) {
  main {
    grid-template-columns: minmax(0, 1fr) 390px;
  }
  #graph {
    height: 260px;
  }
  .reading strong {
    font-size: 29px;
  }
}
@media (max-width: 1150px) {
  .view-tools {
    top: 125px;
    left: 28px;
    right: auto;
  }
  .annotation {
    max-width: 270px;
  }
  .actions button {
    padding: 9px;
    font-size: 11px;
  }
}
@media (max-width: 800px) {
  header {
    padding: 0 12px;
    gap: 10px;
  }
  .brand img {
    width: 100px;
    height: 31px;
  }
  .brand small {
    font-size: 7px;
  }
  nav {
    gap: 0;
  }
  nav button {
    padding: 9px 8px;
    font-size: 11px;
  }
  #results-open {
    font-size: 11px;
    padding: 7px;
  }
  main {
    grid-template-columns: minmax(0, 1fr) 270px;
  }
  #evidence {
    padding: 18px 14px;
  }
  .annotation {
    left: 15px;
    max-width: 220px;
    bottom: 205px;
  }
  .stage-heading {
    left: 18px;
  }
  .view-tools {
    left: 18px;
  }
  .reading strong {
    font-size: 22px;
  }
  .actions {
    max-width: 360px;
  }
}
@media (max-width: 650px) {
  #lab {
    grid-template-rows: 96px minmax(0, 1fr) 28px;
    min-height: 760px;
  }
  header {
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0;
    padding: 7px 12px;
  }
  nav {
    order: 3;
    width: 100%;
    flex: auto;
  }
  nav button {
    flex: 1;
  }
  .brand img {
    height: 28px;
    width: 96px;
  }
  .brand small {
    font-size: 6px;
  }
  main {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(400px, 1.2fr) minmax(220px, 0.8fr);
  }
  .stage-heading {
    top: 12px;
    left: 16px;
  }
  .stage-heading h1 {
    font-size: 27px;
    margin-bottom: 6px;
  }
  .stage-heading .eyebrow {
    font-size: 8px;
  }
  #question {
    font-size: 11px;
  }
  .view-tools {
    top: 91px;
    left: 16px;
    gap: 4px;
  }
  .view-tools button {
    padding: 6px;
  }
  .annotation {
    display: none;
  }
  .stage-footer {
    bottom: 10px;
    left: 9px;
    right: 9px;
    gap: 5px;
  }
  .direct-control {
    max-width: 340px;
    padding: 6px 12px;
  }
  .actions {
    max-width: none;
    padding: 5px;
    gap: 4px;
  }
  .actions button {
    font-size: 10px;
    padding: 8px;
  }
  .speed-row {
    font-size: 10px;
  }
  .speed-row select {
    font-size: 10px;
  }
  #evidence {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 14px 18px;
  }
  #readings {
    grid-template-columns: repeat(3, 1fr);
    gap: 9px;
    padding: 13px 0;
  }
  .reading {
    display: block;
  }
  .reading span {
    display: block;
    font-size: 10px;
  }
  .reading strong {
    font-size: 20px;
  }
  .reading small {
    font-size: 10px;
  }
  #graph {
    height: 210px;
  }
  footer > span:first-child {
    display: none;
  }
  footer {
    padding: 0 12px;
  }
  dialog {
    margin: auto;
    width: calc(100% - 24px);
  }
  .graph-tools {
    padding-top: 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}

@media (max-width: 650px) {
  .scene-label.minor {
    visibility: hidden;
  }
  .scene-label {
    font-size: 9px;
  }
  .scene-label.pole {
    font-size: 15px;
  }
}

.relationships {
  font-size: 11px;
  margin-top: 12px;
}
.relationships summary {
  cursor: pointer;
  padding: 6px 0;
  color: var(--muted);
}
#graph-cursor:empty {
  display: none;
}
@media (min-width: 651px) and (max-height: 900px) {
  #evidence {
    padding: 18px 16px;
  }
  #readings {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 15px 0;
  }
  .reading {
    display: block;
  }
  .reading span {
    display: block;
    font-size: 10px;
  }
  .reading strong {
    font-size: 19px;
  }
  .reading small {
    display: block;
    font-size: 9px;
    margin-top: 3px;
  }
  #graph {
    height: 170px;
  }
  #linkage-graph {
    height: 105px;
  }
  .graph-options {
    margin: 4px 0 12px;
  }
  .graph-tools {
    padding-top: 10px;
  }
  #graph-note {
    font-size: 10px;
    margin-bottom: 4px;
  }
}

@media (max-width: 650px) {
  .reading small {
    display: block;
    margin-top: 3px;
  }
}
