:root {
  color-scheme: light;
  --ink: #182724;
  --muted: #66736f;
  --line: #d9ddd7;
  --teal: #0072b2;
  --teal-dark: #005a8c;
  --coral: #d55e00;
  --focus: #0072b2;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: #fff; color: var(--ink); }
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; }

.site-header {
  height: 62px;
  padding: 0 clamp(20px, 5vw, 72px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgba(24, 39, 36, 0.1);
}

.course-title { display: flex; flex-direction: column; color: var(--ink); font-size: 1.05rem; font-weight: 750; line-height: 1.05; text-decoration: none; }
.course-title small { margin-top: 4px; color: var(--muted); font-size: 0.68rem; font-weight: 500; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.top-link { padding: 8px 12px; color: var(--ink); background: #e5e7eb; border-radius: 7px; font-size: 0.8rem; font-weight: 700; line-height: 1; text-decoration: none; }
.top-link:hover { background: #d1d5db; }
.book-reference { color: var(--muted); font-size: 0.82rem; text-underline-offset: 3px; }

main { width: min(1050px, calc(100% - 32px)); margin: 0 auto; padding: 22px 0 20px; }
.intro h1 { margin: 0; font: 500 clamp(2.2rem, 4vw, 3.7rem)/0.98 Georgia, "Times New Roman", serif; letter-spacing: -0.045em; }
.title-row { display: flex; align-items: center; gap: 22px; }
.demo-qr { flex: 0 0 auto; line-height: 0; }
.demo-qr img { width: 112px; height: 112px; display: block; }
.book-reference { margin-top: 8px; display: inline-block; }
.equation { margin-top: 14px; padding: 8px 18px; border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }

.controls { margin-top: 10px; padding: 12px 16px; display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 18px; border: 1px solid var(--line); border-radius: 8px; }
.control { min-width: 0; }
.control label { margin-bottom: 11px; display: flex; justify-content: space-between; gap: 12px; font-size: 0.82rem; font-weight: 700; }
.control output { color: var(--teal-dark); font-variant-numeric: tabular-nums; white-space: nowrap; }
input[type="range"] { width: 100%; margin: 0; accent-color: var(--teal); cursor: pointer; }
input:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.range { margin-top: 5px; display: flex; justify-content: space-between; color: var(--muted); font-size: 0.68rem; }

.plot-card { margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.plot-heading { min-height: 35px; display: flex; align-items: baseline; justify-content: space-between; gap: 18px; }
.plot-heading h2 { margin: 0; font: 500 1.4rem Georgia, "Times New Roman", serif; }
.plot-heading > output { color: var(--muted); font: italic 0.82rem Georgia, "Times New Roman", serif; font-variant-numeric: tabular-nums; }
.canvas-wrap { width: min(100%, calc(100vh - 588px), 430px); margin: 6px auto 0; position: relative; aspect-ratio: 1 / 1; }
canvas { width: 100%; height: 100%; display: block; border: 1px solid var(--line); }
.axes { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.axes line { stroke: var(--ink); stroke-width: 0.35; }
.axes marker path { fill: var(--ink); }
.axes text { fill: var(--ink); font: italic 4px Georgia, serif; }
.scale { width: min(100%, 720px); margin: 12px auto 0; display: grid; grid-template-columns: auto 1fr auto 1fr auto; gap: 8px; align-items: center; color: var(--muted); font-size: 0.7rem; font-variant-numeric: tabular-nums; }
.scale span:first-of-type { height: 5px; background: linear-gradient(90deg, #0072b2, #fff); border: 1px solid var(--line); }
.scale span:last-of-type { height: 5px; background: linear-gradient(90deg, #fff, var(--coral)); border: 1px solid var(--line); }
.site-footer { padding: 0 20px 14px; color: var(--muted); font-size: 0.72rem; text-align: center; }

@media (max-width: 820px) { .controls { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) {
  .site-header { height: auto; padding-top: 12px; padding-bottom: 12px; align-items: flex-start; flex-direction: column; gap: 10px; }
  .top-actions { width: 100%; }
  .top-link { flex: 1; text-align: center; }
  main { width: calc(100% - 16px); padding: 14px 0 10px; }
  .intro h1 { font-size: 2rem; }
  .book-reference { margin-top: 5px; font-size: 0.68rem; }
  .equation { margin-top: 8px; padding: 4px 8px; font-size: 0.76rem; }
  .controls { margin-top: 8px; padding: 9px; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
  .control label { margin-bottom: 3px; font-size: 0.68rem; }
  .range { display: none; }
  .plot-card { margin-top: 8px; padding: 8px; }
  .plot-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
  .canvas-wrap { width: min(100%, calc(100vh - 390px), 300px); margin-top: 3px; }
  .scale { margin-top: 5px; }
  .site-footer { padding-bottom: 8px; }
}
@media (max-width: 720px) { .demo-qr { display: none; } }
