:root {
  --ink: #1f2328;
  --muted: #57606a;
  --line: #d8dee4;
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --brand: #8b1a1a;
  --brand-dark: #6d1414;
  --focus: #0969da;
  --radius: 10px;
  --wrap: 72rem;
  --prose: 44rem;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
}

img { max-width: 100%; height: auto; }

a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: var(--brand-dark); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

h1, h2, h3 { line-height: 1.25; margin: 2rem 0 0.75rem; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); margin-top: 1rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
p, ul, ol, table { margin: 0 0 1rem; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1rem; }

.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 1rem; top: 1rem; background: #fff; padding: 0.5rem 1rem; z-index: 10; }

/* Header */
.site-header { border-bottom: 1px solid var(--line); background: #fff; }
.header-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1.5rem; padding-top: 0.75rem; padding-bottom: 0.75rem; }
.brand { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.2rem; }
.site-header nav ul { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; list-style: none; margin: 0; padding: 0; }
.site-header nav a { color: var(--ink); text-decoration: none; font-weight: 500; }
.site-header nav a:hover, .site-header nav a[aria-current="page"] { color: var(--brand); text-decoration: underline; }

/* Buttons */
.btn { display: inline-block; background: var(--brand); color: #fff; font-weight: 600; padding: 0.7rem 1.2rem; border-radius: 8px; text-decoration: none; }
.btn:hover { background: var(--brand-dark); color: #fff; }
.btn-secondary { background: transparent; color: var(--brand); border: 2px solid var(--brand); }
.btn-secondary:hover { background: var(--bg-soft); color: var(--brand-dark); }

/* Home */
.intro { padding: 3.5rem 0 2.5rem; }
.intro h1 { max-width: 20ch; }
.lead { font-size: 1.2rem; color: var(--muted); max-width: var(--prose); }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.5rem 0 0.75rem; }
.small { font-size: 0.9rem; color: var(--muted); }
.section { padding: 2.5rem 0; border-top: 1px solid var(--line); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1.25rem; list-style: none; padding: 0; }
.grid > li { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; background: #fff; }
.grid h3 { margin-top: 0; }
.notice { background: var(--bg-soft); border-left: 4px solid var(--brand); padding: 1rem 1.25rem; border-radius: 0 var(--radius) var(--radius) 0; max-width: var(--prose); }
.story { display: grid; grid-template-columns: minmax(0, 10rem) minmax(0, 1fr); gap: 1.5rem; align-items: start; max-width: 56rem; }
@media (max-width: 40rem) { .story { grid-template-columns: 1fr; } }

/* Tables */
.table-wrap { overflow-x: auto; max-width: 100%; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { background: var(--bg-soft); }

/* Blog */
.post { max-width: calc(var(--prose) + 2rem); padding-bottom: 2rem; }
.crumbs { font-size: 0.9rem; margin-top: 1.5rem; color: var(--muted); }
.byline { color: var(--muted); font-size: 0.95rem; }
.hero img { border-radius: var(--radius); display: block; }
figure.hero { margin: 1.5rem 0; }
.prose .lead { color: var(--ink); }
.prose .formula { background: var(--bg-soft); border-left: 4px solid var(--brand); padding: 0.9rem 1.1rem; margin: 1.25rem 0; font-weight: 600; border-radius: 0 var(--radius) var(--radius) 0; overflow-x: auto; }
.prose .example { border: 1px dashed var(--line); padding: 0.9rem 1.1rem; margin: 1.25rem 0; border-radius: var(--radius); }
.prose .example > :last-child { margin-bottom: 0; }
.prose table { display: block; overflow-x: auto; }
.prose code { background: var(--bg-soft); padding: 0.1rem 0.3rem; border-radius: 4px; }
.cta { background: var(--bg-soft); border-radius: var(--radius); padding: 1.25rem 1.5rem; margin: 2.5rem 0; }
.cta h2 { margin-top: 0; font-size: 1.25rem; }
.related ul { padding-left: 1.2rem; }
.group { margin-bottom: 1.5rem; }
.cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.card a { display: block; height: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; color: var(--ink); text-decoration: none; }
.card a:hover { border-color: var(--brand); }
.card h3 { margin: 0 0 0.5rem; font-size: 1.05rem; color: var(--brand); }
.card p { margin: 0; color: var(--muted); font-size: 0.95rem; }

/* Legal */
.legal { max-width: calc(var(--prose) + 2rem); padding-bottom: 2rem; }
.legal h2 { font-size: 1.3rem; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-soft); margin-top: 3rem; padding: 1.5rem 0 0.5rem; }
.footer-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem 2rem; }
.site-footer ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; }

@media (prefers-reduced-motion: no-preference) {
  .card a, .btn { transition: border-color 0.15s, background-color 0.15s; }
}
