* {
  box-sizing: border-box;
}
:root {
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  color: #163c37;
  background: #f1f5f1;
  font-synthesis: none;
  --green: #087548;
  --border: #d5e2db;
}
body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
button,
select,
input {
  font: inherit;
}
button,
select {
  border: 1px solid #b9cfc3;
  border-radius: 8px;
  background: white;
  color: #173d35;
  padding: 9px 12px;
  font-size: 13px;
}
button {
  cursor: pointer;
  font-weight: 650;
}
button:hover {
  background: #e4f4ea;
  border-color: #198557;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
button.primary {
  background: #087548;
  color: white;
  border-color: #087548;
}
button[aria-pressed="true"]:not(.primary) {
  background: #d9f2e2;
}
button:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid #be7313;
  outline-offset: 3px;
}
label {
  font-size: 13px;
  font-weight: 600;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: clamp(20px, 2.1vw, 29px);
  letter-spacing: -0.7px;
}
h2 {
  font-size: 16px;
  letter-spacing: -0.3px;
}
p {
  line-height: 1.5;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 22px;
  background: white;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.topbar img {
  width: 119px;
  display: block;
}
.lab-name {
  font-size: 14px;
  font-weight: 700;
  border-left: 1px solid var(--border);
  padding-left: 20px;
}
.topbar nav {
  display: flex;
  gap: 7px;
  margin-left: auto;
}
#count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  background: #e9f1ec;
  border-radius: 4px;
  margin-left: 3px;
}
main {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  flex-shrink: 0;
}
.eyebrow {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #51766b;
  margin-bottom: 5px;
}
.course {
  display: flex;
  align-items: center;
  gap: 8px;
}
.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 1fr);
  grid-template-rows: minmax(360px, 1fr) auto minmax(170px, 0.45fr);
  gap: 12px;
  flex: 1;
  min-height: 610px;
}
.panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: 13px;
  overflow: hidden;
  min-width: 0;
}
.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 18px;
  gap: 10px;
}
.badge {
  font-size: 12px;
  font-weight: 750;
  background: #fff1d8;
  color: #80520e;
  padding: 6px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.micro {
  display: flex;
  flex-direction: column;
}
.scene-wrap {
  position: relative;
  flex: 1;
  min-height: 210px;
  background: #102b2b;
}
.scene-wrap #scene {
  position: absolute;
  inset: 0;
}
#scene canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.legend {
  position: absolute;
  top: 12px;
  left: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: #dbece6;
  font-size: 10px;
  pointer-events: none;
}
.legend > span {
  display: flex;
  align-items: center;
  gap: 5px;
}
.legend i {
  height: 7px;
  width: 7px;
  border-radius: 50%;
  background: #dc9b5a;
}
.legend i.electron {
  background: #68e5ed;
}
.legend i.tracked {
  background: #ffeea3;
}
.scene-actions {
  position: absolute;
  bottom: 37px;
  right: 10px;
  display: flex;
  gap: 5px;
}
.scene-actions button {
  font-size: 10px;
  background: #143e39;
  color: #e0f2e9;
  border-color: #487469;
  padding: 6px 8px;
}
.direction {
  position: absolute;
  bottom: 10px;
  left: 14px;
  color: #d5ede3;
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
}
.transport {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 10px 12px;
  flex-wrap: wrap;
}
.transport button,
.transport select {
  font-size: 12px;
  padding: 8px;
}
.clock {
  margin-left: auto;
  font:
    11px ui-monospace,
    monospace;
}
.scale-note {
  font-size: 10px;
  color: #557269;
  padding: 0 12px 10px;
}
.circuit {
  display: flex;
  flex-direction: column;
}
#circuit-drawing {
  flex: 1;
  min-height: 120px;
  display: grid;
  place-items: center;
  padding: 0 12px;
}
#circuit-drawing svg {
  width: 100%;
  max-height: 210px;
}
.circuit-actions {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 8px;
}
.circuit-actions button {
  font-size: 12px;
}
.meters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: #e2ebe5;
  margin: 6px 12px 0;
  border-radius: 8px;
  overflow: hidden;
}
.meters > div {
  background: #f4f8f5;
  text-align: center;
  padding: 12px 4px;
}
.meters span {
  font-size: 10px;
  color: #587368;
  display: block;
  margin-bottom: 5px;
}
.meters strong {
  font-size: clamp(14px, 1.5vw, 21px);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.energy {
  font-size: 12px;
  margin: 10px 16px 13px;
  color: #44655b;
}
.quick {
  grid-column: 1/-1;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 25px;
}
.quick label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}
.quick output {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.quick input {
  width: 100%;
  accent-color: var(--green);
  height: 5px;
}
.quick select {
  width: 100%;
  padding: 6px;
}
.quick button {
  align-self: center;
  white-space: nowrap;
}
.evidence {
  grid-column: 1/-1;
  display: grid;
  grid-template-columns: 220px minmax(240px, 1fr) minmax(240px, 1fr);
  gap: 16px;
  padding: 14px 18px;
}
.evidence h2 {
  font-size: 15px;
}
.evidence p {
  font-size: 11px;
  color: #527166;
  margin: 7px 0;
}
.evidence select {
  padding: 5px;
  max-width: 160px;
  margin: 6px 0 0 8px;
  font-size: 11px;
}
.evidence label {
  font-size: 11px;
}
#graph {
  min-height: 140px;
  display: flex;
  align-items: center;
}
#graph svg {
  width: 100%;
  height: 100%;
  max-height: 210px;
}
.insight {
  border-left: 1px solid var(--border);
  padding-left: 18px;
}
.insight p {
  color: #244c3d;
  font-size: 13px;
  margin: 0 0 8px;
}
.insight button {
  font-size: 11px;
  padding: 6px 9px;
}
#advanced {
  font-size: 11px;
  line-height: 1.7;
  color: #45665a;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
dialog {
  border: 1px solid var(--border);
  border-radius: 16px;
  width: min(570px, calc(100% - 24px));
  max-height: 88dvh;
  padding: 0;
  color: #173d35;
  box-shadow: 0 25px 90px #001e2850;
}
dialog.wide {
  width: min(950px, calc(100% - 24px));
}
dialog::backdrop {
  background: #092b2d65;
}
dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}
dialog header button {
  font-size: 22px;
  border: 0;
  padding: 0 8px;
}
dialog .dialog-body {
  padding: 18px 22px;
  overflow: auto;
}
dialog p {
  font-size: 13px;
  margin: 0 0 15px;
}
.precise {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 12px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid #e5eee8;
}
.precise input {
  width: 100%;
  padding: 8px;
  border: 1px solid #b7cbbc;
  border-radius: 7px;
}
details {
  margin-top: 16px;
}
summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
}
#presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
#presets button {
  text-align: left;
  line-height: 1.4;
  padding: 14px;
}
.task {
  background: #f0f6f1;
  padding: 16px;
  border-radius: 10px;
  margin: 16px 0;
}
.task h3 {
  font-size: 15px;
  margin-bottom: 8px;
}
.file-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 15px;
}
.table-wrap {
  overflow: auto;
  max-height: 40vh;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
  white-space: nowrap;
}
th,
td {
  text-align: right;
  padding: 10px;
  border-bottom: 1px solid #dfe9e2;
}
th {
  background: #f0f6f1;
  position: sticky;
  top: 0;
}
#storage-note {
  margin-top: 16px;
  font-size: 11px;
}
#message {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #143f34;
  color: white;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 13px;
  z-index: 10;
  max-width: 90vw;
  pointer-events: none;
}
#message:empty {
  display: none;
}
.skip,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.skip:focus {
  clip-path: none;
  width: auto;
  height: auto;
  top: 10px;
  left: 10px;
  background: white;
  padding: 15px;
  z-index: 20;
}
.teaching .workbench {
  grid-template-rows: minmax(440px, 1fr) auto minmax(170px, 0.4fr);
}
.teaching .meters strong {
  font-size: 25px;
}
.fallback {
  padding: 65px 25px;
  color: white;
  font-size: 14px;
}
@media (min-width: 1600px) {
  main {
    padding: 20px 32px;
  }
  .workbench {
    grid-template-rows: minmax(400px, 1fr) auto minmax(200px, 0.4fr);
  }
  h2 {
    font-size: 19px;
  }
  .evidence {
    grid-template-columns: 260px 1fr 1fr;
  }
  .scale-note {
    font-size: 12px;
  }
  .legend {
    font-size: 12px;
  }
  .direction {
    font-size: 13px;
  }
}
@media (max-width: 1000px) {
  .topbar {
    padding: 9px 14px;
    gap: 10px;
  }
  .lab-name {
    display: none;
  }
  main {
    padding: 12px;
  }
  .workbench {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.9fr);
    grid-template-rows: minmax(380px, 1fr) auto 210px;
  }
  .evidence {
    grid-template-columns: 170px 1fr;
  }
  .insight {
    display: none;
  }
  .quick {
    gap: 15px;
  }
  .meters {
    grid-template-columns: repeat(2, 1fr);
  }
  .meters > div {
    padding: 6px;
  }
  .meters strong {
    font-size: 16px;
  }
  .circuit-actions {
    flex-wrap: wrap;
  }
  .transport {
    gap: 4px;
  }
  .clock {
    display: none;
  }
}
@media (max-width: 650px) {
  .topbar {
    flex-wrap: wrap;
    padding: 8px 10px;
    gap: 8px;
  }
  .topbar img {
    width: 95px;
  }
  .topbar nav {
    gap: 4px;
  }
  .topbar button {
    font-size: 10px;
    padding: 7px;
  }
  .topbar #fullscreen {
    display: none;
  }
  main {
    padding: 10px;
    gap: 10px;
  }
  .heading {
    align-items: flex-start;
  }
  .eyebrow {
    font-size: 8px;
    letter-spacing: 1px;
  }
  .heading h1 {
    font-size: 20px;
  }
  .course {
    display: block;
    font-size: 10px;
  }
  .course select {
    display: block;
    padding: 6px;
    font-size: 11px;
    margin-top: 5px;
  }
  .workbench {
    display: flex;
    flex-direction: column;
    min-height: auto;
    flex: none;
  }
  .micro {
    min-height: 370px;
  }
  .scene-wrap {
    min-height: 235px;
  }
  .panel-title {
    padding: 12px;
  }
  .panel-title h2 {
    font-size: 14px;
  }
  .circuit {
    min-height: 350px;
  }
  .meters {
    grid-template-columns: repeat(4, 1fr);
  }
  .meters strong {
    font-size: 14px;
  }
  .meters span {
    font-size: 9px;
  }
  .quick {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    padding: 15px;
    order: -1;
  }
  .quick button {
    font-size: 11px;
    white-space: normal;
  }
  .quick label {
    font-size: 11px;
  }
  .quick select {
    font-size: 11px;
  }
  .evidence {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
  .evidence #graph {
    height: 180px;
  }
  .insight {
    display: block;
    border-left: 0;
    padding: 12px 0 0;
    border-top: 1px solid var(--border);
  }
  .legend {
    font-size: 9px;
    gap: 7px;
  }
  .scale-note {
    font-size: 9px;
  }
  #presets {
    grid-template-columns: 1fr;
  }
  .transport button,
  .transport select {
    font-size: 11px;
  }
  .direction {
    font-size: 10px;
  }
  .teaching .meters strong {
    font-size: 15px;
  }
}
#circuit-drawing {
  position: relative;
}
#circuit-drawing svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
}
.panel-title,
.transport,
.scale-note,
.circuit-actions,
.meters,
.energy {
  flex-shrink: 0;
}
.micro .meters {
  margin-bottom: 10px;
}
.micro .meters > div {
  padding: 8px 4px;
}
.flow-status {
  position: absolute;
  top: 36px;
  left: 14px;
  font-size: 10px;
  color: #e2eee8;
  background: #25483e;
  border: 1px solid #628477;
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
}
.flow-status[data-flowing="true"] {
  background: #124958;
  border-color: #428f9e;
}
.current-key {
  color: #8ef0b5;
}
.drift-key {
  color: #72e9ff;
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto;
  }
}
