.lab-panel {
  --lab-plot-field: #fbfdfa;
  --lab-plot-grid: #e3ece7;
  --lab-plot-axes: #82968e;
  --lab-plot-text: #435952;
}

.lab-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: .85rem 1.5rem;
  margin: 0 0 1.15rem;
}
.lab-header h2 {
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  line-height: 1.15;
  margin: 0 0 .3rem;
}
.lab-header p {
  color: var(--muted, #51645f);
  margin: 0;
  max-width: 66ch;
}
.lab-header .lab-extension {
  color: #664694;
  font-size: .875rem;
  font-weight: 750;
  margin-bottom: .35rem;
}
.lab-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.77fr) minmax(295px, 1fr);
  gap: 1rem;
  align-items: start;
}
.lab-card {
  background: var(--panel, #fff);
  border: 1px solid var(--line, #dce8e3);
  border-radius: 15px;
  min-width: 0;
  margin: 0;
}
.lab-figure {
  padding: 1.15rem 1.25rem;
}
.lab-chart-header {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 0 .4rem;
}
.lab-chart-header h3,
.lab-controls h3,
.lab-result h3,
.lab-spectrum h3 {
  font-size: 1.05rem;
  margin: 0;
  line-height: 1.3;
}
.lab-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .28rem .95rem;
  color: var(--muted, #51645f);
  font-size: .8rem;
  font-weight: 620;
}
.lab-legend span {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.lab-signal-a { --signal: #087965; --dash: none; }
.lab-signal-b { --signal: #af4e1b; --dash: 7 5; }
.lab-signal-c { --signal: #236c9d; --dash: 2 5; }
.lab-signal-reference { --signal: #6e45ad; --dash: 11 3; }
.lab-signal-sum { --signal: #6e45ad; --dash: none; }
.lab-legend-stroke {
  display: inline-block;
  width: 1.3rem;
  height: 0;
  border-top: 2px solid var(--signal);
}
.lab-legend-stroke.lab-signal-b, .lab-legend-stroke.lab-signal-reference { border-top-style: dashed; }
.lab-legend-stroke.lab-signal-c { border-top-style: dotted; }
.lab-legend-stroke.lab-signal-sum { border-top-width: 3px; }

.lab-wave-svg,
.lab-circle-svg,
.lab-spectrum-svg {
  display: block;
  width: 100%;
  height: clamp(255px, 29vw, 320px);
  overflow: hidden;
  color: var(--lab-plot-text);
  font-family: inherit;
}
.lab-wave-svg {
  cursor: crosshair;
  touch-action: pan-y;
}
.lab-circle-svg {
  cursor: grab;
  touch-action: none;
}
.lab-circle-svg:active { cursor: grabbing; }
.lab-spectrum-svg { height: 210px; }
.lab-plots-circle {
  display: grid;
  grid-template-columns: minmax(225px, .9fr) minmax(0, 1.25fr);
  align-items: center;
  gap: 1rem;
}
.lab-plots-circle .lab-circle-svg { height: clamp(220px, 25vw, 270px); }
.lab-plots-phase .lab-wave-svg { height: clamp(216px, 19vw, 245px); }
.lab-result { border-top: 1px solid var(--line, #dce8e3); padding-top: .62rem; }
.lab-result h3 { color: #5f388e; }
.lab-plot-field { fill: var(--lab-plot-field); }
.lab-plot-grid { stroke: var(--lab-plot-grid); stroke-width: 1; }
.lab-plot-axis { stroke: var(--lab-plot-axes); stroke-width: 1; }
.lab-plot-equilibrium { stroke: #a1b3ac; stroke-width: 1.25; }
.lab-plot-guide { stroke: #7ba899; stroke-width: 1; stroke-dasharray: 3 4; }
.lab-plot-guide-strong,
.lab-plot-bracket {
  stroke: #5a8476;
  stroke-width: 1.1;
  fill: none;
}
.lab-plot-event-a { stroke: #087965; stroke-width: 1; stroke-dasharray: 2 4; }
.lab-plot-event-b { stroke: #af4e1b; stroke-width: 1; stroke-dasharray: 2 4; }
.lab-plot-tick, .lab-plot-label, .lab-plot-note {
  fill: var(--lab-plot-text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.lab-plot-label, .lab-plot-note { font-weight: 650; }
.lab-plot-note-halo {
  paint-order: stroke;
  stroke: var(--lab-plot-field);
  stroke-width: 3;
  stroke-linejoin: round;
}
.lab-plot-emphasis { fill: var(--accent, #087965); }
.lab-plot-curve {
  fill: none;
  stroke: var(--signal);
  stroke-width: 2.45;
  stroke-dasharray: var(--dash);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.lab-plot-curve.lab-signal-sum { stroke-width: 3.05; }
.lab-plot-cursor { stroke: #283f38; stroke-width: 1.15; stroke-dasharray: 2 4; }
.lab-plot-dot {
  fill: var(--signal);
  stroke: #fff;
  stroke-width: 1.55;
}
.lab-plot-landmark { fill: #fff; stroke: #66877b; stroke-width: 1.35; }
.lab-circle-outline { stroke: #a3b8af; stroke-width: 1.5; fill: none; }
.lab-circle-radius { stroke: #087965; stroke-width: 1.8; }
.lab-circle-arc { stroke: #6e45ad; stroke-width: 1.4; fill: none; }
.lab-circle-projection-guide { stroke: #087965; stroke-width: 1.1; stroke-dasharray: 4 3; }
.lab-circle-projection { stroke: #087965; stroke-width: 3; }
.lab-spectrum-bar { stroke: var(--signal); stroke-width: 4; stroke-dasharray: var(--dash); }

.lab-measure {
  border: 1px solid var(--line, #dce8e3);
  border-radius: 10px;
  background: #f8fbf8;
  padding: .65rem .8rem .7rem;
}
.lab-measure-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .75rem;
  justify-content: space-between;
  font-weight: 680;
  font-size: .875rem;
}
.lab-panel input[type="range"] {
  display: block;
  width: 100%;
  min-width: 0;
  height: 1.6rem;
  margin: .15rem 0 0;
  accent-color: var(--accent, #087965);
  cursor: pointer;
}
.lab-motion-note {
  color: var(--muted, #51645f);
  font-size: .78rem;
  line-height: 1.4;
  margin: .12rem 0 .45rem;
}
.lab-readings, .lab-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: .375rem .825rem;
  margin: 0;
}
.lab-readings dt, .lab-metrics dt {
  color: var(--muted, #51645f);
  font-size: .8rem;
  font-weight: 600;
}
.lab-readings dd, .lab-metrics dd {
  font-weight: 700;
  margin: 0;
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.lab-metrics dd { font-size: 1.04rem; }
.lab-formula {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .2rem .6rem;
  margin: .85rem 0 .65rem;
}
.lab-formula span {
  font-size: clamp(.95rem, 2vw, 1.18rem);
  font-weight: 680;
  font-variant-numeric: tabular-nums;
}
.lab-formula small {
  font-size: .79rem;
  color: var(--muted, #51645f);
}
.lab-scale-message {
  color: #86501d;
  font-size: .85rem;
  margin: -.25rem 0 .65rem;
}
.lab-spectrum {
  border-top: 1px solid var(--line, #dce8e3);
  margin-top: .8rem;
  padding-top: .8rem;
}

.lab-controls {
  padding: .95rem 1.1rem 1.1rem;
  display: grid;
  gap: .72rem;
}
.lab-prediction {
  background: var(--soft, #e9f5ef);
  border-left: 3px solid var(--accent, #087965);
  color: var(--ink, #152725);
  border-radius: 8px;
  padding: .65rem .75rem;
}
.lab-prediction strong {
  color: #075a4d;
  font-size: .875rem;
}
.lab-prediction p { margin: .15rem 0 0; font-size: .92rem; line-height: 1.42; }
.lab-field { min-width: 0; }
.lab-field[hidden] { display: none; }
.lab-field-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .65rem;
}
.lab-field-head > label {
  font-size: .88rem;
  font-weight: 670;
}
.lab-inline-number {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  justify-content: flex-end;
  gap: .3rem;
  white-space: nowrap;
  color: var(--muted, #51645f);
  font-size: .8rem;
}
.lab-inline-number input {
  font: inherit;
  font-size: .875rem;
  color: var(--ink, #152725);
  font-variant-numeric: tabular-nums;
  width: 5.55rem;
  min-height: 2rem;
  padding: .25rem .4rem;
  border: 1px solid #cbdad2;
  border-radius: 6px;
  background: #fff;
}
.lab-field-note {
  color: var(--muted, #51645f);
  font-size: .875rem;
  margin: -.38rem 0 0;
}
.lab-choice,
.lab-harmonic {
  min-width: 0;
  border: 0;
  padding: 0;
  margin: 0;
}
.lab-choice legend,
.lab-harmonic legend {
  font-size: .875rem;
  font-weight: 680;
  padding: 0;
  margin: 0 0 .32rem;
}
.lab-harmonic {
  border: 1px solid var(--line, #dce8e3);
  border-radius: 8px;
  padding: 0 .65rem .3rem;
}
.lab-harmonic legend { padding: 0 .25rem; }
.lab-harmonic-1 legend { color: #087965; }
.lab-harmonic-2 legend { color: #af4e1b; }
.lab-harmonic-3 legend { color: #236c9d; }
.lab-pills,
.lab-preset-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .38rem;
}
.lab-pills label {
  display: inline-grid;
  position: relative;
  min-width: 0;
  line-height: 1.2;
}
.lab-pills input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.lab-pills span,
.lab-small-button {
  border: 1px solid var(--line, #dce8e3);
  background: var(--panel, #fff);
  color: var(--ink, #152725);
  border-radius: 7px;
  padding: .45rem .65rem;
  font-family: inherit;
  font-size: .875rem;
  font-weight: 640;
  line-height: 1.2;
  min-height: 2.1rem;
  display: inline-flex;
  align-items: center;
}
.lab-small-button {
  cursor: pointer;
  gap: .34rem;
}
.lab-small-button:hover,
.lab-pills label:hover span {
  background: #eef7f1;
  border-color: #b1cbc0;
}
.lab-small-button:focus-visible,
.lab-pills input:focus-visible + span {
  outline: 2px solid var(--accent, #087965);
  outline-offset: 2px;
}
.lab-pills input:checked + span,
.lab-motion[aria-pressed="true"] {
  background: var(--soft, #e9f5ef);
  border-color: #88b8a8;
  color: #075a4d;
}
.lab-motion { min-height: 1.95rem; padding: .32rem .55rem; font-size: .8rem; }
.lab-reset { flex: 0 0 auto; margin-top: .04rem; }
.lab-audio-shortcut { justify-self: start; color: var(--accent, #087965); }
.lab-audio-shortcut[hidden] { display: none; }
.lab-preset-group > p {
  margin: 0 0 .3rem;
  font-weight: 680;
  font-size: .875rem;
}
.lab-toggle {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .45rem;
  margin: .35rem 0;
  font-size: .87rem;
}
.lab-toggle input { width: 1rem; height: 1rem; accent-color: var(--accent, #087965); }
.lab-scale-controls {
  border-top: 1px solid var(--line, #dce8e3);
  padding-top: .6rem;
  font-size: .87rem;
}
.lab-scale-controls summary,
.lab-explanation summary {
  font-weight: 650;
  cursor: pointer;
}
.lab-scale-controls[open] > summary { margin-bottom: .55rem; }
.lab-scale-controls > p { color: var(--muted, #51645f); margin: 0 0 .5rem; }
.lab-explanation {
  grid-column: 1 / -1;
  border: 1px solid var(--line, #dce8e3);
  background: var(--panel, #fff);
  border-radius: 10px;
  padding: .7rem 1rem;
}
.lab-explanation p {
  color: var(--muted, #51645f);
  margin: .5rem 0 0;
  max-width: 95ch;
}

@media (max-width: 920px) {
  .lab-grid { grid-template-columns: minmax(0, 1fr) minmax(255px, .8fr); }
  .lab-plots-circle { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .lab-plots-circle .lab-circle-svg { width: min(100%, 370px); margin-inline: auto; }
}
@media (max-width: 680px) {
  .lab-grid { grid-template-columns: minmax(0, 1fr); }
  .lab-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .48rem .6rem;
  }
  .lab-header > div { display: contents; }
  .lab-header h2 { grid-area: 1 / 1; margin: 0; }
  .lab-header p { grid-area: 2 / 1 / 3 / -1; }
  .lab-header .lab-reset { grid-area: 1 / 2; margin: 0; }
  .lab-header-optional h2 { grid-row: 2; }
  .lab-header-optional .lab-reset { grid-row: 2; }
  .lab-header-optional p { grid-row: 3; }
  .lab-header-optional .lab-extension { grid-row: 1; margin: 0; }
  .lab-figure { padding: .85rem .75rem; }
  .lab-controls { padding: .85rem .75rem; }
  .lab-explanation { padding-inline: .75rem; }
  .lab-card { border-radius: 11px; }
}
@media (max-width: 370px) {
  .lab-panel { min-width: 0; }
  .lab-inline-number input { width: 4.8rem; }
  .lab-readings, .lab-metrics { grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); }
  .lab-legend { gap: .22rem .65rem; }
}
@media (pointer: coarse) {
  .lab-panel input[type="range"] { min-height: 2rem; }
  .lab-small-button,
  .lab-pills span { min-height: 2.45rem; }
}
