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

:root {
  /* Light mode (default) */
  --bg: #ffffff;
  --surface: #f6f8fa;
  --border: #d0d7de;
  --text: #1f2328;
  --text-dim: #656d76;
  --bright: #1f2328;
  --accent: #0969da;
  --accent-dim: #0969da20;
  --green: #1a7f37;
  --amber: #9a6700;
  --red: #cf222e;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", Menlo, Consolas, monospace;

  --wrap: 720px;
  --wrap-wide: 960px;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #c9d1d9;
  --text-dim: #8b949e;
  --bright: #e6edf3;
  --accent: #58a6ff;
  --accent-dim: #388bfd40;
  --green: #3fb950;
  --amber: #d29922;
  --red: #f85149;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1.25rem; }
.wrap-wide { max-width: var(--wrap-wide); margin: 0 auto; padding: 0 1.25rem; }

/* Header */
header {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
}
header .wrap {
  max-width: var(--wrap-wide);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--bright);
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
}
.logo:hover { text-decoration: none; color: var(--accent); }
nav { display: flex; gap: 1.25rem; align-items: center; font-size: 0.875rem; }
nav a { color: var(--text-dim); }
nav a:hover { color: var(--bright); text-decoration: none; }

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 0.8rem;
  font-family: var(--font-sans);
}
.theme-toggle:hover { color: var(--bright); border-color: var(--text-dim); }

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  margin-top: 4rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}
footer .wrap {
  max-width: var(--wrap-wide);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Main content */
main { padding: 2rem 0; }

/* Essay / article */
.essay-header { margin-bottom: 2rem; }
.essay-header h1 {
  font-size: 2rem;
  line-height: 1.2;
  color: var(--bright);
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}
.essay-header .subtitle {
  font-size: 1.1rem;
  color: var(--text-dim);
  font-style: italic;
}
.essay-header .author {
  font-size: 0.875rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
}
.essay-header .meta {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

.essay-body h2 {
  font-size: 1.4rem;
  color: var(--bright);
  margin: 2.5rem 0 0.75rem;
  letter-spacing: -0.01em;
}
.essay-body h3 {
  font-size: 1.1rem;
  color: var(--bright);
  margin: 2rem 0 0.5rem;
}
.essay-body p {
  margin-bottom: 1rem;
}
.essay-body ul, .essay-body ol {
  margin: 0.5rem 0 1rem 1.5rem;
}
.essay-body li {
  margin-bottom: 0.4rem;
}
.essay-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  color: var(--text-dim);
  background: var(--accent-dim);
  border-radius: 0 4px 4px 0;
}
.essay-body code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--surface);
  padding: 0.15em 0.35em;
  border-radius: 3px;
  border: 1px solid var(--border);
}
.essay-body pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
  font-size: 0.85rem;
  line-height: 1.5;
}
.essay-body pre code {
  background: none;
  border: none;
  padding: 0;
}
.essay-body strong { color: var(--bright); }

.essay-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.875rem;
}
.essay-body th, .essay-body td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  text-align: left;
}
.essay-body th {
  background: var(--surface);
  color: var(--bright);
  font-weight: 600;
}
.essay-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* Hero (landing page) */
.hero {
  padding: 3rem 0;
  text-align: center;
}
.hero h1 {
  font-size: 1.8rem;
  color: var(--bright);
  line-height: 1.3;
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}
.hero .lead {
  font-size: 1.05rem;
  color: var(--text);
  max-width: 600px;
  margin: 0 auto 2rem;
}

/* Evidence cards */
.evidence-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}
.evidence-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
}
.evidence-card h3 {
  font-size: 0.9rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}
.evidence-card .number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--bright);
  font-family: var(--font-mono);
  line-height: 1.2;
}
.evidence-card .detail {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

/* Pipeline diagram */
.pipeline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
  justify-content: center;
  margin: 2rem 0;
  font-size: 0.8rem;
  font-family: var(--font-mono);
}
.pipeline .step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.65rem;
  color: var(--text);
  white-space: nowrap;
}
.pipeline .arrow {
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* Status table */
.status-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin: 1rem 0;
}
.status-table th, .status-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.status-table th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge {
  display: inline-block;
  padding: 0.15em 0.5em;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-green { background: color-mix(in srgb, var(--green) 12%, transparent); color: var(--green); }
.badge-amber { background: color-mix(in srgb, var(--amber) 12%, transparent); color: var(--amber); }
.badge-dim { background: var(--surface); color: var(--text-dim); }

/* Nav links at bottom of essays */
.essay-nav {
  display: flex;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

/* Callout box */
.callout {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--accent-dim);
  font-size: 0.9rem;
}

/* As-of badge */
.as-of {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* Table scroll wrapper for mobile */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Responsive */
@media (max-width: 640px) {
  .hero h1 { font-size: 1.4rem; }
  .essay-header h1 { font-size: 1.6rem; }
  .evidence-grid { grid-template-columns: 1fr; }
  nav { flex-wrap: wrap; gap: 0.5rem 0.75rem; font-size: 0.8rem; }
  .pipeline { font-size: 0.7rem; }
  .essay-nav { flex-direction: column; }
}

@media print {
  header, footer, .theme-toggle { display: none; }
  body { background: white; color: black; }
  a { color: inherit; }
  .evidence-card { border: 1px solid var(--border); }
}
