:root {
  color-scheme: light dark;

  --bg: #fcfcfb;
  --fg: #171717;
  --fg-secondary: #525252;
  --fg-muted: #828282;
  --border: #e7e5e4;
  --underline: #c8c5c0;
  --underline-hover: #171717;

  --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: ui-serif, "Iowan Old Style", "New York", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111111;
    --fg: #ededed;
    --fg-secondary: #a1a1a1;
    --fg-muted: #6e6e6e;
    --border: #242424;
    --underline: #454545;
    --underline-hover: #ededed;
  }
}

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

html {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
}

main {
  max-width: 680px;
  margin: 0 auto;
  padding: clamp(3.25rem, 9vh, 6rem) 1.5rem 4rem;
}

h1,
h2,
h3,
p,
ul,
ol,
dl,
dd {
  margin: 0;
}

/* Header / Intro */

.intro h1 {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.subtitle {
  margin-top: 0.35rem;
  color: var(--fg-muted);
  font-size: 0.9rem;
}

.intro p + p {
  margin-top: 1rem;
}

.intro p:not(.subtitle) {
  margin-top: 1.5rem;
  color: var(--fg);
  font-size: 0.975rem;
}

.intro em {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.05em;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-top: 1.5rem;
  font-size: 0.9rem;
}

/* Links */

a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--underline);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: text-decoration-color 0.15s ease, color 0.15s ease;
}

a:hover,
a:focus-visible {
  text-decoration-color: var(--underline-hover);
}

a:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
  border-radius: 2px;
}

.arrow {
  display: inline-block;
  margin-left: 0.1rem;
  color: var(--fg-muted);
  font-size: 0.85em;
  text-decoration: none;
  transition: transform 0.15s ease, color 0.15s ease;
}

a:hover .arrow {
  color: var(--fg);
  transform: translate(1px, -1px);
}

/* 3-column index (Paco-inspired) */

.columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2rem 1.75rem;
  margin-top: 3.5rem;
}

.columns h2,
.section h2 {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--fg-muted);
  margin-bottom: 1rem;
}

.columns ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.columns li a,
.item-title {
  display: inline-block;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--fg);
}

.columns li p {
  margin-top: 0.2rem;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--fg-secondary);
}

/* Dated sections (Lee / Karpathy-inspired) */

.section {
  margin-top: 3.5rem;
}

.entries {
  list-style: none;
  padding: 0;
  border-top: 1px solid var(--border);
}

.entry {
  padding: 1.15rem 0;
  border-bottom: 1px solid var(--border);
}

.entry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.entry h3 {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.4;
}

.role {
  font-weight: 400;
  color: var(--fg-secondary);
}

.entry time {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--fg-muted);
}

.entry p {
  margin-top: 0.45rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--fg-secondary);
}

/* Tools / Stack */

.stack {
  border-top: 1px solid var(--border);
}

.stack > div {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 0.5rem 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8875rem;
}

.stack dt {
  color: var(--fg-muted);
}

.stack dd {
  color: var(--fg-secondary);
}

/* Footer */

footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-top: 4rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--fg-muted);
}

footer a {
  color: var(--fg-muted);
  text-decoration-color: transparent;
}

footer a:hover {
  color: var(--fg);
  text-decoration-color: var(--underline-hover);
}

/* Responsive */

@media (max-width: 640px) {
  .columns {
    grid-template-columns: 1fr;
    gap: 2.25rem;
  }

  .entry-head {
    flex-direction: column;
    gap: 0.15rem;
  }

  .stack > div {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }
}

@media print {
  main {
    max-width: 100%;
    padding: 0;
  }

  a {
    text-decoration: none;
  }
}
