:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-muted: #edf3f3;
  --border: #cbd5da;
  --border-strong: #7a8991;
  --text: #20272d;
  --muted: #5d6872;
  --brand: #0d706f;
  --brand-dark: #075857;
  --action: #315f96;
  --action-dark: #254c79;
  --focus: #c46b28;
  --curve-a: #be453f;
  --curve-b: #2f74b8;
  --curve-c: #348b52;
  --curve-d: #6742b3;
  --shadow-domain: #167f7b;
  --shadow-range: #a84d86;
  --grid: #dbe1e5;
  --axis: #2b3339;
  --paper: #fffefa;
  --panel-shadow: 0 18px 45px rgba(31, 45, 52, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-width: 1024px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 84% 9%, rgba(13, 112, 111, 0.08), transparent 27rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button,
select {
  font: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 0.9rem;
  border: 2px solid var(--text);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: translateY(0);
}

.lab-header {
  display: grid;
  width: min(100% - 2.5rem, 92rem);
  min-height: 5.2rem;
  margin: 0 auto;
  align-items: center;
  grid-template-columns: 11rem 1fr auto;
  gap: 1.25rem;
}

.brand {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.22rem;
  color: #1e293b;
  font-size: 1.4rem;
  font-weight: 850;
  letter-spacing: -0.035em;
}

.brand-mark {
  color: var(--brand);
  font-size: 1.05rem;
  line-height: 1;
}

.title-copy {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
}

.title-copy h1 {
  margin: 0;
}

.title-copy h1 {
  font-size: clamp(1.35rem, 2vw, 1.75rem);
  letter-spacing: -0.025em;
}

.step-label {
  margin: 0;
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.local-badge {
  padding: 0.38rem 0.65rem;
  border: 1px solid #9fc3c0;
  border-radius: 999px;
  background: #edf8f6;
  color: #225f5d;
  font-size: 0.76rem;
  font-weight: 800;
}

.lab-shell {
  display: grid;
  width: min(100% - 2.5rem, 92rem);
  margin: 0 auto 2rem;
  grid-template-columns: minmax(18rem, 22rem) minmax(0, 1fr);
  gap: 1rem;
}

.control-panel,
.graph-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--panel-shadow);
}

.control-panel {
  padding: 1.1rem;
}

.graph-heading {
  margin-bottom: 1rem;
}

.field {
  display: grid;
  gap: 0.42rem;
  margin-bottom: 1rem;
  color: #344149;
  font-size: 0.82rem;
  font-weight: 800;
}

.field select {
  width: 100%;
  min-height: 2.8rem;
  padding: 0.58rem 2.2rem 0.58rem 0.72rem;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font-weight: 650;
}

.reveal-panel {
  padding: 0.88rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fafcfc;
}

.history-actions {
  display: grid;
  margin-bottom: 0.85rem;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.button {
  min-height: 2.62rem;
  padding: 0.55rem 0.82rem;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 800;
  cursor: pointer;
}

.button.primary {
  background: var(--action);
  color: #fff;
}

.button.primary:hover {
  background: var(--action-dark);
}

.button.secondary {
  border-color: #aebbc4;
  background: #fff;
  color: #31404a;
}

.button.secondary:hover {
  background: #edf2f4;
}

.button:disabled {
  border-color: #d7dfe3;
  background: #eef1f2;
  color: #89949a;
  cursor: not-allowed;
}

.reveal-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.button[aria-pressed="true"] {
  border-color: var(--brand-dark);
  background: var(--brand);
  color: #fff;
}

.answer-panel {
  margin-top: 0.85rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid #9fc3c0;
  border-radius: 9px;
  background: #edf8f6;
}

.answer-panel p {
  display: grid;
  margin: 0;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.2rem;
}

.answer-panel p[hidden] {
  display: none;
}

.answer-panel p:not([hidden]) + p:not([hidden]) {
  margin-top: 0.42rem;
  padding-top: 0.42rem;
  border-top: 1px solid #c4dddb;
}

.answer-label {
  color: #356c69;
  font-size: 0.8rem;
  font-weight: 850;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.answer-expression {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  row-gap: 0.65rem;
  min-width: 0;
  color: var(--text);
}

.answer-math-term {
  display: inline-flex;
  flex: none;
  flex-wrap: wrap;
  align-items: baseline;
  row-gap: 0.65rem;
  width: max-content;
  max-width: 100%;
}

.answer-expression math {
  flex: none;
  font-family: "STIX Two Math", "STIX Math", "Cambria Math", "Times New Roman", serif;
  font-size: 1.55rem;
  font-weight: 400;
}

.answer-expression math mo[fence="true"] {
  font-size: 1.15em;
}

.graph-panel {
  min-width: 0;
  padding: 1.1rem 1.1rem 0.8rem;
}

.svg-wrap {
  overflow: hidden;
  border: 1px solid #bdc8ce;
  border-radius: 9px;
  background: var(--paper);
}

#labGraph {
  display: block;
  width: 100%;
  height: min(70vh, 690px);
  min-height: 570px;
}

.grid-line {
  stroke: var(--grid);
  stroke-width: 1;
}

.grid-axis {
  stroke: var(--axis);
  stroke-width: 2.2;
}

.grid-tick-label,
.line-label,
.line-tick-label,
.infinity-label {
  fill: #536069;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
  user-select: none;
}

.line-label {
  fill: #34434b;
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.projection-axis {
  stroke: #8a969d;
  stroke-width: 2;
}

.projection-axis-arrow {
  fill: #8a969d;
}

.projection-tick {
  stroke: #8a969d;
  stroke-width: 1.3;
}

.graph-component {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 7;
}

.component-a { stroke: var(--curve-a); }
.component-b { stroke: var(--curve-b); }
.component-c { stroke: var(--curve-c); }
.component-d { stroke: var(--curve-d); }

.graph-arrow {
  fill: currentColor;
  stroke: none;
}

.graph-arrow.component-a { fill: var(--curve-a); }
.graph-arrow.component-b { fill: var(--curve-b); }
.graph-arrow.component-c { fill: var(--curve-c); }
.graph-arrow.component-d { fill: var(--curve-d); }

.point-marker {
  vector-effect: non-scaling-stroke;
  stroke-width: 5;
}

.point-marker.is-open {
  fill: var(--paper);
}

.point-marker.is-filled {
  fill: currentColor;
}

.lattice-hit {
  fill: transparent;
  cursor: crosshair;
}

.lattice-hit:hover {
  fill: rgba(196, 107, 40, 0.14);
  stroke: rgba(196, 107, 40, 0.5);
  stroke-width: 1.5;
}

.grid-cursor {
  cursor: crosshair;
  outline: none;
}

#labGraph[data-template="fn31"] .grid-cursor:not(:focus),
#labGraph[data-template="absDown"] .grid-cursor:not(:focus) {
  opacity: 0;
}

.grid-cursor-ring {
  fill: rgba(255, 248, 239, 0.7);
  stroke: var(--focus);
  stroke-width: 2.5;
  stroke-dasharray: 4 3;
}

.grid-cursor:not(:focus) .grid-cursor-ring {
  opacity: 0.72;
}

.grid-cursor:focus .grid-cursor-ring {
  fill: rgba(255, 239, 218, 0.9);
  stroke-width: 4;
}

.grid-cursor-cross {
  stroke: var(--focus);
  stroke-width: 2;
  pointer-events: none;
}

.projection-beams {
  pointer-events: none;
}

.projection-beam {
  stroke: none;
}

.projection-beam-domain {
  fill: url(#domainProjectionLight);
}

.projection-beam-range {
  fill: url(#rangeProjectionLight);
}

.projection-beam-haze {
  filter: url(#projectionSoftness);
  opacity: 0.51;
}

.projection-beam-core {
  opacity: 0.442;
}

.shadow-domain,
.shadow-range {
  fill: none;
  stroke-linecap: round;
  stroke-width: 7;
}

.shadow-domain { stroke: var(--shadow-domain); }
.shadow-range { stroke: var(--shadow-range); }

.shadow-endpoint-domain,
.shadow-endpoint-range {
  stroke-width: 3;
}

.shadow-endpoint-domain { stroke: var(--shadow-domain); }
.shadow-endpoint-range { stroke: var(--shadow-range); }

.shadow-open { fill: var(--paper); }
.shadow-closed.shadow-endpoint-domain { fill: var(--shadow-domain); }
.shadow-closed.shadow-endpoint-range { fill: var(--shadow-range); }

.shadow-arrow-domain { fill: var(--shadow-domain); }
.shadow-arrow-range { fill: var(--shadow-range); }

.shadow-caption {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
  font-weight: 700;
}

.shadow-caption-domain { fill: var(--shadow-domain); }
.shadow-caption-range { fill: var(--shadow-range); }

button:focus-visible,
select:focus-visible,
.skip-link:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

@media (max-height: 760px) {
  .lab-header {
    min-height: 4.4rem;
  }

  .control-panel,
  .graph-panel {
    padding: 0.85rem;
  }

  #labGraph {
    height: 615px;
    min-height: 0;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
