:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --ink: #23211d;
  --muted: #6e6a61;
  --line: #d8d0c2;
  --panel: #fffdf8;
  --teal: #147c78;
  --teal-ink: #0e4f4c;
  --coral: #d45c42;
  --gold: #b7831f;
  --shadow: 0 18px 50px rgba(40, 32, 20, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(20, 124, 120, 0.08), transparent 320px),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

code,
pre,
input {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

code {
  overflow-wrap: anywhere;
}

a {
  color: inherit;
}

.topbar,
main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 26px 0 18px;
}

.mark,
.eyebrow {
  color: var(--teal-ink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(28px, 4vw, 56px);
  line-height: 1.05;
}

h3 {
  margin-bottom: 12px;
  font-size: 22px;
  line-height: 1.15;
}

.repo-link {
  border: 1px solid var(--line);
  padding: 10px 14px;
  background: rgba(255, 253, 248, 0.76);
  text-decoration: none;
}

.overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 470px);
  gap: 42px;
  align-items: center;
  min-height: 520px;
  padding: 44px 0 26px;
}

.overview-copy p:last-child {
  max-width: 700px;
  color: var(--muted);
  font-size: 18px;
}

.mental-model {
  display: inline-block;
  margin-top: 12px;
  border-left: 4px solid var(--coral);
  padding: 12px 14px;
  background: rgba(255, 253, 248, 0.8);
  color: var(--ink) !important;
  font-weight: 800;
}

.overview-copy,
.flow-nav,
.step-panel,
.calculator > *,
.compare article,
.source-card,
.history-compare article,
.details-grid article,
.myth-list article,
.glossary,
.glossary > * {
  min-width: 0;
}

.overview img {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.facts,
.compare-grid,
.source-grid,
.history-compare,
.details-grid,
.myth-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.facts article,
.compare article,
.source-card,
.step-panel,
.calculator,
.history-compare article,
.details-grid article,
.myth-list article,
.glossary {
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.88);
  box-shadow: 0 10px 28px rgba(40, 32, 20, 0.06);
}

.facts article {
  min-height: 158px;
  padding: 18px;
}

.facts span,
.source-card span,
.calculator label span,
.calc-output span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.facts strong {
  display: block;
  margin: 8px 0;
  color: var(--teal-ink);
  font-size: 20px;
}

.facts p,
.source-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

section {
  padding: 64px 0 0;
}

.section-heading {
  max-width: 760px;
  margin-bottom: 20px;
}

.section-heading h2 {
  font-size: 34px;
}

.flow-layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.flow-nav {
  display: grid;
  gap: 8px;
}

.flow-step {
  width: 100%;
  border: 1px solid var(--line);
  padding: 14px;
  background: rgba(255, 253, 248, 0.7);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.flow-step span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.flow-step strong {
  display: block;
  font-size: 15px;
}

.flow-step.is-active {
  border-color: var(--teal);
  background: #e7f2ef;
  box-shadow: inset 4px 0 0 var(--teal);
}

.step-panel {
  min-height: 562px;
  padding: 28px;
}

.step-panel p,
.compare p {
  color: var(--muted);
}

.step-panel ul {
  display: grid;
  gap: 10px;
  margin: 22px 0;
  padding-left: 18px;
}

.source-pill {
  display: inline-block;
  max-width: 100%;
  margin-bottom: 16px;
  border: 1px solid rgba(20, 124, 120, 0.3);
  padding: 8px 10px;
  background: #e7f2ef;
  color: var(--teal-ink);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

pre {
  overflow-x: auto;
  max-width: 100%;
  margin: 0;
  padding: 18px;
  background: #24201b;
  color: #fff6e8;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

pre code {
  white-space: pre-wrap;
}

.calculator {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(320px, 1.2fr);
  gap: 16px;
  overflow: hidden;
  padding: 22px;
}

.calculator label {
  display: grid;
  align-content: start;
  gap: 8px;
}

.calculator input {
  width: 100%;
  border: 1px solid var(--line);
  padding: 14px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
}

.calculator input:focus,
.flow-step:focus-visible,
.repo-link:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px rgba(212, 92, 66, 0.35);
}

.calc-output {
  display: grid;
  gap: 10px;
}

.calc-output div:not(.meter) {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.calc-output strong {
  color: var(--teal-ink);
  text-align: right;
}

.meter {
  height: 12px;
  overflow: hidden;
  width: 100%;
  border: 0;
  background: #eadfce;
}

.meter::-webkit-progress-bar {
  background: #eadfce;
}

.meter::-webkit-progress-value {
  background: linear-gradient(90deg, var(--teal), var(--coral));
}

.meter::-moz-progress-bar {
  background: linear-gradient(90deg, var(--teal), var(--coral));
}

.calc-output p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.compare-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compare article,
.history-compare article,
.details-grid article,
.myth-list article {
  padding: 24px;
}

.history-compare {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.history-stack {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  counter-reset: history-step;
  list-style: none;
}

.history-stack li {
  position: relative;
  border: 1px solid var(--line);
  padding: 12px 12px 12px 44px;
  background: #fff;
}

.history-stack li::before {
  position: absolute;
  left: 12px;
  top: 12px;
  width: 22px;
  height: 22px;
  background: var(--teal);
  color: white;
  content: counter(history-step);
  counter-increment: history-step;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
}

.history-stack.compacted li::before {
  background: var(--coral);
}

.details-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.details-grid p,
.myth-list p {
  margin-bottom: 0;
  color: var(--muted);
}

.myth-list {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.myth-list strong {
  display: block;
  margin-bottom: 8px;
  color: var(--teal-ink);
}

.glossary {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0;
  margin: 0;
}

.glossary dt,
.glossary dd {
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}

.glossary dt {
  color: var(--gold);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-weight: 800;
}

.glossary dd {
  color: var(--muted);
}

dl {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 10px 16px;
  margin: 20px 0 0;
}

dt {
  color: var(--gold);
  font-weight: 800;
}

dd {
  margin: 0;
  color: var(--muted);
}

.source-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding-bottom: 64px;
}

.source-card {
  padding: 18px;
  color: inherit;
  text-decoration: none;
  transition:
    border-color 160ms ease,
    transform 160ms ease;
}

.source-card:hover {
  border-color: var(--teal);
  transform: translateY(-2px);
}

.source-card strong {
  display: block;
  margin: 8px 0;
  overflow-wrap: anywhere;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

@media (max-width: 900px) {
  .overview,
  .flow-layout,
  .calculator,
  .compare-grid,
  .history-compare,
  .details-grid,
  .myth-list,
  .glossary {
    grid-template-columns: 1fr;
  }

  .facts,
  .source-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview {
    min-height: auto;
  }

  .step-panel {
    min-height: auto;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .facts,
  .source-grid {
    grid-template-columns: 1fr;
  }

  h2 {
    font-size: 34px;
  }

  .overview-copy p:last-child {
    font-size: 16px;
  }

  .calc-output div:not(.meter) {
    display: grid;
  }

  .calc-output strong {
    text-align: left;
  }

  .glossary dt {
    border-bottom: 0;
    padding-bottom: 4px;
  }

  .glossary dd {
    padding-top: 4px;
  }
}
