:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: #263c44;
  background: #f4f7f7;
  --selected: #b84622;
  --rotated: #784289;
  --reference: #204f71;
}

* { box-sizing: border-box; }
body { margin: 0; }
main { padding: 16px; }
p { margin: 0; }

.eyebrow {
  text-transform: uppercase;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .12em;
  color: #426b70;
}

h1 { font-size: clamp(1.08rem, 3vw, 1.56rem); line-height: 1.23; margin: .32rem 0 .42rem; }
.intro > p:last-child { font-size: .87rem; line-height: 1.48; }

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 18px;
  background: #e9f0f0;
  border: 1px solid #d4e1e0;
  border-radius: 8px;
  padding: 12px 14px;
  margin: 14px 0 12px;
}

.controls label {
  display: flex;
  gap: 6px;
  justify-content: space-between;
  align-items: center;
  font-size: .82rem;
  font-weight: 680;
}

output { color: #0b6470; font-variant-numeric: tabular-nums; }
input[type="range"] { display: block; width: 100%; min-height: 28px; margin: 2px 0; accent-color: #0c7280; cursor: pointer; }
button { font: inherit; color: inherit; }
.presets { display: flex; flex-wrap: wrap; gap: 4px; }
.presets button, .starts button {
  border: 1px solid #bfd1d4;
  border-radius: 4px;
  background: #fff;
  padding: 4px 7px;
  font-size: .7rem;
  line-height: 1.2;
  cursor: pointer;
}
.presets button[aria-pressed="true"], .starts button[aria-pressed="true"] { background: #d6ebed; border-color: #63888d; color: #17464c; font-weight: 650; }
.presets button:hover, .starts button:hover { border-color: #456e76; }
:focus-visible { outline: 2px solid #88471c; outline-offset: 3px; }
.control-note { font-size: .73rem; color: #486068; line-height: 1.4; }
.start-controls, .starts, .baseline, .start-key {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}
.start-controls { justify-content: space-between; margin: 0 0 10px; gap: 6px 14px; font-size: .75rem; }
.starts, .baseline, .start-key { gap: 5px; }
.starts span:first-child { font-weight: 650; margin-right: 3px; }
.starts button[data-start]:not([data-start="all"]) { color: var(--run-color); min-width: 25px; font-weight: 750; }
.starts button[data-start]:not([data-start="all"])[aria-pressed="true"] { border-color: var(--run-color); }
.baseline { cursor: pointer; white-space: nowrap; }
.baseline input { accent-color: #0c7280; }
.baseline:has(input:disabled) { opacity: .65; cursor: default; }
.start-key span { color: var(--run-color); font-weight: 750; }
.start-key span[hidden] { display: none; }

.plots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.panel { min-width: 0; border: 1px solid #d3dfe0; border-radius: 8px; padding: 10px 7px 6px; background: #fff; }
.panel h2 { margin: 0 0 3px; text-align: center; font-size: .92rem; line-height: 1.3; }
canvas { display: block; width: 100%; }
.plots canvas { aspect-ratio: 1; height: auto; max-width: 100%; }

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px 17px;
  margin: 9px 0 10px;
  color: #3c5259;
  font-size: .74rem;
}
.key { display: inline-flex; align-items: center; gap: 6px; }
.key[hidden] { display: none; }
.sample { display: inline-block; width: 19px; height: 0; border-top: 2px solid var(--selected); }
.sample.rotated { border-color: var(--rotated); }
.sample.reference { border-top: 2px dashed var(--reference); }
.sample.current { width: 9px; height: 9px; border: 2px solid #526c71; border-radius: 50%; }
.loss-legend { margin: 1px 0 6px; }
.convergence { padding: 10px 8px; }
.convergence canvas { height: 176px; }
.metrics { text-align: center; font-size: .73rem; line-height: 1.45; min-height: 1.45em; color: #3d545a; font-variant-numeric: tabular-nums; }
.reading-note { margin-top: 9px; font-size: .74rem; line-height: 1.48; color: #45616a; }

@media (max-width: 690px) {
  .controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .controls > :last-child { grid-column: 1 / -1; }
}

@media (max-width: 510px) {
  main { padding: 11px; }
  .controls, .plots { grid-template-columns: minmax(0, 1fr); }
  .controls { padding: 9px 11px; }
  .panel h2 { font-size: .86rem; }
}

@media (max-width: 360px) {
  .starts > span:first-child { flex-basis: 100%; }
}

@media (max-width: 360px) {
  .starts > span:first-child { flex-basis: 100%; }
}
