:root {
  color-scheme: light dark;
  --bg: #f4efe6;
  --ink: #1c1917;
  --muted: #57534e;
  --rule: #d6d3d1;
  --accent: #0f4c5c;
  --accent-soft: #0f4c5c14;
  --ok: #3f6212;
  --ok-bg: #ecfccb;
  --bad: #9f1239;
  --bad-bg: #ffe4e6;
  --card: #fffcf7;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --measure: 38rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141210;
    --ink: #f5f0e8;
    --muted: #a8a29e;
    --rule: #3f3a36;
    --accent: #7dd3d8;
    --accent-soft: #7dd3d81f;
    --ok: #bef264;
    --ok-bg: #1a2e05;
    --bad: #fda4af;
    --bad-bg: #4c0519;
    --card: #1c1917;
  }
}

* { box-sizing: border-box; }

html { font-size: 19px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.55;
}

a { color: var(--accent); }

code, kbd {
  font-family: var(--mono);
  font-size: 0.84em;
}

.wrap {
  width: min(calc(var(--measure) + 16rem), calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.75rem 0 4rem;
}

header.site {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.78rem;
}

header.site nav { display: flex; flex-wrap: wrap; gap: 0.75rem; }

header.site a { text-decoration: none; }
header.site a:hover { text-decoration: underline; }
header.site .here { color: var(--ink); font-weight: 600; }

h1, h2, h3 {
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h1 { font-size: 1.85rem; margin: 0 0 0.4rem; }
h2 { font-size: 1.2rem; margin: 2.2rem 0 0.6rem; }
h3 { font-size: 1rem; margin: 1.4rem 0 0.4rem; }

.lede {
  font-size: 1.08rem;
  color: var(--muted);
  margin: 0 0 1.5rem;
}

p { margin: 0 0 1rem; }

.meta {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 1.25rem;
}

.cite {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
}

aside.note {
  font-family: var(--sans);
  font-size: 0.84rem;
  line-height: 1.45;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: 0.7rem 0.9rem;
  margin: 1.25rem 0;
}

aside.note p:last-child { margin-bottom: 0; }

figure {
  margin: 1.4rem 0;
  padding: 0;
}

figcaption {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

pre {
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.45;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.85rem 1rem;
  overflow-x: auto;
  margin: 0 0 1rem;
}

table.compare {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.84rem;
  margin: 0 0 1.25rem;
}

table.compare th,
table.compare td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 0.6rem 0.5rem 0;
  border-bottom: 1px solid var(--rule);
}

table.compare th { color: var(--muted); font-weight: 600; }

.pipe {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.6rem;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  font-family: var(--sans);
}

.pipe .end {
  text-align: center;
  padding: 0.7rem 0.5rem;
  border: 1px dashed var(--accent);
  border-radius: 6px;
}

.pipe .end strong { display: block; font-size: 1rem; }
.pipe .end span { color: var(--muted); font-size: 0.78rem; }

.pipe .tube {
  height: 4px;
  background: var(--accent);
  border-radius: 99px;
  position: relative;
}

.pipe .tube::before,
.pipe .tube::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  transform: translateY(-50%);
}
.pipe .tube::before { left: -2px; }
.pipe .tube::after { right: -2px; }

.quiz {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1rem 1.1rem 1.1rem;
  margin: 0 0 1rem;
  font-family: var(--sans);
  font-size: 0.92rem;
}

.quiz .prompt {
  font-family: var(--serif);
  font-size: 1rem;
  margin: 0 0 0.7rem;
}

.quiz fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.quiz label {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem;
  align-items: start;
  padding: 0.35rem 0.4rem;
  border-radius: 4px;
  cursor: pointer;
}

.quiz label:hover { background: var(--accent-soft); }

.quiz menu {
  display: flex;
  gap: 0.5rem;
  margin: 0.85rem 0 0;
  padding: 0;
}

.quiz button {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--bg);
  padding: 0.35rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
}

.quiz .feedback {
  margin: 0.75rem 0 0;
  padding: 0.55rem 0.65rem;
  border-radius: 4px;
  font-size: 0.86rem;
}

.quiz .feedback.ok { background: var(--ok-bg); color: var(--ok); }
.quiz .feedback.bad { background: var(--bad-bg); color: var(--bad); }

.pipe-lab {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1rem;
  margin: 0 0 1rem;
  font-family: var(--sans);
}

.pipe-lab .status {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0 0 0.85rem;
}

.pipe-lab .status.done { color: var(--ok); font-weight: 600; }

.pipe-lab .ends {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.pipe-lab .end h3 { margin: 0 0 0.45rem; font-size: 0.92rem; }

.pipe-lab form {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.pipe-lab input[type="text"] {
  flex: 1;
  font: inherit;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg);
  color: var(--ink);
}

.pipe-lab button {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--bg);
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
}

.pipe-lab .log {
  min-height: 4.5rem;
  margin: 0;
  padding: 0.45rem 0.55rem;
  list-style: none;
  border: 1px dashed var(--rule);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.pipe-lab .log:empty::after {
  content: attr(data-empty);
  color: var(--muted);
}

.pipe-lab .status.paused { color: var(--muted); }
.pipe-lab .status.closed { color: var(--bad); font-weight: 600; }

.pipe-lab .steps {
  margin: 0 0 0.85rem;
  padding: 0 0 0 1.15rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.pipe-lab .steps li[data-done] { color: var(--ok); font-weight: 600; }

.pipe-lab .hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.pipe-lab .actions {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.pipe-lab button.ghost {
  background: transparent;
  color: var(--accent);
}

.pipe-lab button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pipe-lab iframe.frame {
  display: block;
  width: 100%;
  min-height: 9.5rem;
  border: 1px dashed var(--rule);
  border-radius: 4px;
  background: var(--bg);
}

.primary-source,
.ask {
  font-family: var(--sans);
  font-size: 0.88rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

footer.site {
  margin-top: 2.5rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
}

@media (max-width: 40rem) {
  html { font-size: 17px; }
  .pipe-lab .ends { grid-template-columns: 1fr; }
  .pipe { grid-template-columns: 1fr; }
  .pipe .tube { height: 36px; width: 4px; justify-self: center; }
}

@media print {
  body { background: white; color: black; }
  .quiz button, header.site nav { display: none; }
}
