:root {
  color-scheme: light dark;

  --bg: Canvas;
  --surface: Canvas;
  --surface2: ButtonFace;
  --text: CanvasText;
  --primary: LinkText;
  --border: GrayText;

  --chart-load: #1565c0;
  --chart-lactate: #c62828;
  --chart-axis: #5f6368;
  --chart-text: #1a1a1a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --chart-load: #64b5f6;
    --chart-lactate: #ef5350;
    --chart-axis: #9aa0a6;
    --chart-text: #e6e8eb;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.explorer-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.explorer-header h1 {
  font-size: 20px;
  margin: 0 0 8px 0;
}
.explorer-note {
  font-size: 13px;
  color: var(--text);
  margin: 0;
}
.explorer-note-fallback {
  color: var(--text);
  font-weight: 600;
}

.method-tabs {
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.method-tabs button {
  flex: 1 0 auto;
  padding: 12px 16px;
  background: transparent;
  color: var(--text);
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.method-tabs button[aria-selected="true"] {
  border-bottom-color: var(--primary);
  color: var(--primary);
}

main { padding: 0 0 32px 0; }

.chart-section {
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 260px;
  max-height: 60vh;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
#chart-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: pan-y;
  cursor: crosshair;
}

.section-label,
.section-heading {
  display: block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text);
  margin: 0 0 8px 0;
}

.section-hint {
  font-size: 12px;
  color: var(--text);
  margin: 8px 0 0 0;
  font-style: italic;
  line-height: 1.5;
}

.section-note {
  font-size: 12px;
  color: var(--text);
  margin: 12px 0 0 0;
  line-height: 1.5;
}

/*
  Intro paragraph under the Lactate curve model header, defining
  what an anchor point is before any model description uses the
  term. Slightly larger and not italic, so it reads as a definition
  rather than as a hint.
*/
.lactate-model-intro {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  margin: 8px 0 12px;
}

/*
  Collapsible sections.

  Every section uses the same structure: padding sits on the
  <summary>, so the whole header row is clickable, and the content
  sits in a direct child with matching horizontal padding.
*/

details.params-section,
details.explain-section {
  padding: 0;
  border-bottom: 1px solid var(--border);
}

details.params-section > summary,
details.explain-section > summary {
  display: block;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  padding: 16px;
}

details.params-section > summary::marker,
details.explain-section > summary::marker {
  color: var(--primary);
}

details.params-section > div,
details.params-section > p {
  padding: 0 16px 16px;
}

details.explain-section > div {
  padding: 0 16px 16px;
  font-size: 14px;
  line-height: 1.5;
}

#testhr-slider {
  width: 100%;
  margin: 8px 0;
}

.readouts {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 14px;
}
.readouts span {
  font-variant-numeric: tabular-nums;
}

.param-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
}
.param-row[hidden] {
  display: none;
}
.param-row label {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}
.param-row .param-readout {
  font-size: 12px;
  color: var(--text);
  margin-top: 4px;
}
.param-row .param-hint {
  font-size: 12px;
  color: var(--text);
  margin-top: 4px;
  line-height: 1.5;
  font-style: italic;
}
.param-row input[type="range"] {
  width: 100%;
}
.param-row select {
  width: 100%;
  padding: 8px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

/*
  End-of-range labels under the slider.
*/
.param-range-hints {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  line-height: 1.2;
  color: var(--text);
  margin-top: 2px;
}

/*
  Lactate curve model toggle.
*/
.model-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  margin-bottom: 8px;
}

.model-toggle button {
  padding: 6px 12px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.model-toggle button[aria-checked="true"] {
  color: var(--primary);
  border-color: var(--primary);
  font-weight: 700;
}

.model-toggle button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

#lactate-model-details {
  margin-top: 12px;
}

.model-formula {
  display: block;
  background: var(--surface2);
  border-left: 3px solid var(--primary);
  padding: 8px 12px;
  margin: 8px 0 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-x: auto;
}

:is(.explain-section, #lactate-model-details) h3 {
  font-size: 15px;
  margin: 16px 0 6px 0;
}

:is(.explain-section, #lactate-model-details) h4 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--text);
  margin: 18px 0 6px 0;
}

:is(.explain-section, #lactate-model-details) h4:first-child {
  margin-top: 4px;
}

:is(.explain-section, #lactate-model-details) ul {
  margin: 6px 0;
  padding-left: 20px;
}

:is(.explain-section, #lactate-model-details) li {
  margin-bottom: 4px;
}

:is(.explain-section, #lactate-model-details) code {
  background: var(--surface2);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

:is(.explain-section, #lactate-model-details) a {
  color: var(--primary);
}

:is(.explain-section, #lactate-model-details) .evidence-label {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--text);
  margin-left: 6px;
}

:is(.explain-section, #lactate-model-details) table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
}

:is(.explain-section, #lactate-model-details) th,
:is(.explain-section, #lactate-model-details) td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  font-size: 13px;
  text-align: left;
  vertical-align: top;
}

:is(.explain-section, #lactate-model-details) th {
  background: var(--surface2);
  font-weight: 700;
}