:root {
  color-scheme: light dark;
  --bg: #fbfbfa;
  --surface: #ffffff;
  --text: #1c1917;
  --muted: #57534e;
  --border: #e7e5e4;
  --accent: #0f766e;
  --accent-contrast: #ffffff;
  --code-bg: #f5f5f4;
  --max: 1120px;
  --content: 72ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0a09;
    --surface: #171412;
    --text: #f5f5f4;
    --muted: #a8a29e;
    --border: #292524;
    --accent: #5eead4;
    --accent-contrast: #042f2e;
    --code-bg: #1c1917;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0.6rem 1rem;
  text-decoration: none;
  font-weight: 700;
}

.skip-link:focus { left: 1rem; top: 1rem; }

.wrap {
  width: min(100% - 2rem, var(--max));
  margin-inline: auto;
}

header.site {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.site-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
}

.brand {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

.brand span { color: var(--accent); }

nav.main ul {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

nav.main a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}

nav.main a:hover,
nav.main a[aria-current="page"] { color: var(--text); }

main { padding: 2.5rem 0 4rem; }

.hero { padding: 2rem 0 1rem; }

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
}

.lede {
  font-size: 1.2rem;
  color: var(--muted);
  max-width: 62ch;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--accent);
  margin: 0 0 0.75rem;
}

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin: 2rem 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}

.card h2, .card h3 { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }

.article { max-width: var(--content); }

.article h1 {
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.article h2 {
  margin-top: 2.5rem;
  font-size: 1.55rem;
  line-height: 1.25;
}

.article h3 {
  margin-top: 1.75rem;
  font-size: 1.2rem;
}

.article ul, .article ol { padding-left: 1.4rem; }
.article li { margin: 0.35rem 0; }

.meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.75rem 0 1.5rem;
}

.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0 2rem;
}

.toc h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.toc ol {
  margin: 0;
  padding-left: 1.2rem;
  columns: 2;
  column-gap: 2rem;
}

@media (max-width: 640px) {
  .toc ol { columns: 1; }
}

.callout {
  background: var(--surface);
  border-left: 4px solid var(--accent);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border-radius: 0 8px 8px 0;
}

.callout.warning { border-left-color: #d97706; }
.callout p:first-child { margin-top: 0; }
.callout p:last-child { margin-bottom: 0; }

.table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th, td {
  text-align: left;
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: var(--code-bg);
  font-weight: 700;
}

caption {
  caption-side: top;
  text-align: left;
  color: var(--muted);
  font-size: 0.85rem;
  padding-bottom: 0.4rem;
}

code {
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 4px;
  font-size: 0.9em;
}

pre {
  background: var(--code-bg);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.5;
}

pre code { background: none; padding: 0; }

.author-box {
  border-top: 1px solid var(--border);
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
}

footer.site {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
}

.footer-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.button {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0.7rem 1rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
}

.button:hover { filter: brightness(1.05); }

.button.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.checklist {
  list-style: none;
  padding-left: 0;
}

.checklist li {
  padding-left: 1.6rem;
  position: relative;
}

.checklist li::before {
  content: "\2610";
  position: absolute;
  left: 0;
  color: var(--muted);
}

.small { font-size: 0.9rem; color: var(--muted); }

@media (max-width: 480px) {
  main { padding: 1.5rem 0 3rem; }
  .hero h1 { font-size: clamp(1.8rem, 9vw, 2.4rem); }
  .lede { font-size: 1.05rem; }
  .button {
    display: block;
    width: 100%;
    text-align: center;
    margin: 0 0 0.5rem;
  }
  .article h2 { font-size: 1.35rem; }
  .article h3 { font-size: 1.1rem; }
  .toc { padding: 0.9rem 1rem; }
  th, td { padding: 0.5rem; }
  table { font-size: 0.9rem; }
}

@media print {
  header.site, footer.site, .toc, .button { display: none; }
  body { background: #fff; color: #000; }
  a { color: #000; }
}
