:root {
  color-scheme: light;
  --paper: #f5f1e8;
  --paper-soft: #ebe5d9;
  --ink: #1e2925;
  --muted: #68716c;
  --line: #d5cfc3;
  --accent: #17624f;
  --accent-soft: #d6e8df;
  --signal: #d96c3f;
  --code: #17221f;
  --code-ink: #eaf2ed;
  --shadow: 0 18px 55px rgba(41, 48, 44, 0.08);
  --serif: Charter, 'Bitstream Charter', 'Sitka Text', Cambria, serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --paper: #18201d;
  --paper-soft: #202b27;
  --ink: #e7e8df;
  --muted: #a7afa9;
  --line: #39443f;
  --accent: #6fc4a6;
  --accent-soft: #25463b;
  --signal: #f29369;
  --code: #101613;
  --code-ink: #e7eee9;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.2);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 4%, color-mix(in srgb, var(--accent-soft) 65%, transparent) 0, transparent 24rem),
    var(--paper);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

::selection { color: var(--paper); background: var(--accent); }

a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent);
  text-decoration-thickness: .08em;
  text-underline-offset: .18em;
}

a:hover { color: var(--accent); }

button, input { font: inherit; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: .75rem;
  left: .75rem;
  padding: .55rem .8rem;
  color: var(--paper);
  background: var(--ink);
  transform: translateY(-180%);
}

.skip-link:focus { transform: translateY(0); }

.reading-progress {
  position: fixed;
  z-index: 50;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--signal);
  transform: scaleX(0);
  transform-origin: left;
}

.site-shell {
  width: min(1120px, calc(100% - 2.5rem));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 92px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: .72rem;
  align-items: center;
  color: var(--ink);
  font-weight: 720;
  letter-spacing: -.02em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 2.35rem;
  height: 2.35rem;
  place-items: center;
  color: var(--paper);
  background: var(--ink);
  border-radius: 50%;
  font-family: var(--mono);
  font-size: .75rem;
  letter-spacing: -.08em;
}

.site-nav { display: flex; gap: .2rem; align-items: center; }

.site-nav a,
.theme-toggle {
  padding: .55rem .68rem;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: .86rem;
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current='page'],
.theme-toggle:hover { color: var(--ink); }

.theme-toggle {
  display: grid;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  place-items: center;
  cursor: pointer;
}

.theme-toggle::before { content: '◐'; font-size: 1.05rem; }

.eyebrow {
  display: flex;
  gap: .7rem;
  align-items: center;
  margin: 0 0 1.2rem;
  color: var(--accent);
  font-family: var(--mono);
  font-size: .73rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.eyebrow::before {
  width: 1.6rem;
  height: 2px;
  background: currentColor;
  content: '';
}

h1, h2, h3, h4 {
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -.035em;
  line-height: 1.12;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: .9rem;
  border-bottom: 1px solid var(--ink);
}

.section-heading h2 {
  margin: 0;
  font-family: var(--sans);
  font-size: .78rem;
  font-weight: 750;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.section-heading span { color: var(--muted); font-family: var(--mono); font-size: .72rem; }

.article-list { margin-bottom: 5rem; }
.home-articles {
  min-height: calc(100vh - 190px);
  padding-block: clamp(5rem, 12vw, 10rem);
}

.article-card {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) auto;
  gap: 1.2rem;
  padding: 2rem 0;
  border-bottom: 1px solid var(--line);
}

.article-number {
  padding-top: .28rem;
  color: var(--signal);
  font-family: var(--mono);
  font-size: .72rem;
}

.article-card h3 { margin: 0 0 .55rem; font-size: clamp(1.55rem, 3vw, 2.1rem); }
.article-card h3 a { text-decoration: none; }
.article-card p { max-width: 680px; margin: 0; color: var(--muted); }

.article-meta {
  min-width: 9rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: .71rem;
  line-height: 1.8;
  text-align: right;
  text-transform: uppercase;
}

.tag-row { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: 1rem; }

.tag {
  padding: .15rem .48rem;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: .67rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-decoration: none;
  text-transform: uppercase;
}

.page-intro {
  max-width: 760px;
  padding: clamp(4rem, 9vw, 7.5rem) 0 3rem;
}

.page-intro h1 { margin: 0 0 1rem; font-size: clamp(2.9rem, 7vw, 5.5rem); }
.page-intro > p:last-child { max-width: 650px; margin: 0; color: var(--muted); font-family: var(--serif); font-size: 1.3rem; }

.article-header {
  max-width: 900px;
  padding: clamp(4rem, 10vw, 8rem) 0 3rem;
}

.article-header h1 { margin: 0 0 1.5rem; font-size: clamp(2.8rem, 7vw, 5.7rem); text-wrap: balance; }
.article-dek { max-width: 720px; margin: 0 0 1.5rem; color: var(--muted); font-family: var(--serif); font-size: clamp(1.15rem, 2.5vw, 1.45rem); }
.byline { display: flex; flex-wrap: wrap; gap: .65rem 1.2rem; color: var(--muted); font-family: var(--mono); font-size: .73rem; text-transform: uppercase; }

.article-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 720px);
  gap: clamp(2rem, 7vw, 6rem);
  justify-content: center;
  padding: 3rem 0 6rem;
  border-top: 1px solid var(--line);
}

.toc { position: sticky; top: 2rem; align-self: start; padding-top: .3rem; }
.toc p { margin: 0 0 .8rem; color: var(--ink); font-family: var(--mono); font-size: .69rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.toc ol { margin: 0; padding: 0; list-style: none; }
.toc li { margin: .55rem 0; line-height: 1.35; }
.toc a { color: var(--muted); font-size: .78rem; text-decoration: none; }
.toc a:hover { color: var(--accent); }

.prose { min-width: 0; font-family: var(--serif); font-size: 1.09rem; }
.prose > *:first-child { margin-top: 0; }
.prose h2 { margin: 3.2rem 0 1rem; font-size: 2.15rem; scroll-margin-top: 2rem; }
.prose h3 { margin: 2.4rem 0 .8rem; font-size: 1.55rem; scroll-margin-top: 2rem; }
.prose p { margin: 1.15rem 0; }
.prose a { color: var(--accent); }
.prose ul, .prose ol { padding-left: 1.35rem; }
.prose li { margin: .4rem 0; padding-left: .25rem; }
.prose blockquote { margin: 2rem 0; padding: .2rem 0 .2rem 1.5rem; border-left: 3px solid var(--signal); color: var(--muted); font-style: italic; }
.prose code { padding: .12em .32em; background: var(--paper-soft); border-radius: 4px; font-family: var(--mono); font-size: .85em; }

.prose pre {
  position: relative;
  overflow-x: auto;
  margin: 1.8rem 0;
  padding: 1.35rem 1.25rem;
  color: var(--code-ink);
  background: var(--code);
  border-radius: 8px;
  box-shadow: var(--shadow);
  line-height: 1.55;
  tab-size: 2;
}

.prose pre code { padding: 0; color: inherit; background: none; font-size: .82rem; }
.copy-code { position: absolute; top: .6rem; right: .6rem; padding: .28rem .5rem; border: 1px solid #43504b; color: #bfcac4; background: #23302b; border-radius: 4px; cursor: pointer; font-family: var(--mono); font-size: .65rem; }
.copy-code:hover { color: white; }

.callout { margin: 2rem 0; padding: 1.25rem 1.4rem; background: var(--accent-soft); border-radius: 6px; }
.callout strong { color: var(--accent); font-family: var(--sans); font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; }
.callout p { margin: .4rem 0 0; }

.article-footer { margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--line); color: var(--muted); font-family: var(--sans); font-size: .88rem; }
.back-link { display: inline-flex; gap: .45rem; align-items: center; color: var(--accent); font-weight: 650; text-decoration: none; }

.empty-state { padding: 4rem 0 7rem; color: var(--muted); }

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.site-footer p { margin: 0; }

@media (max-width: 760px) {
  .site-shell { width: min(100% - 1.4rem, 1120px); }
  .site-header { min-height: 74px; }
  .brand > span:last-child { display: none; }
  .site-nav a { padding-inline: .45rem; }
  .article-card { grid-template-columns: 2rem 1fr; gap: .65rem; }
  .article-meta { grid-column: 2; min-width: 0; text-align: left; }
  .article-layout { grid-template-columns: minmax(0, 720px); padding-top: 2rem; }
  .toc { display: none; }
  .site-footer { flex-direction: column; gap: .4rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@media print {
  .site-header, .site-footer, .toc, .reading-progress, .copy-code { display: none; }
  body { background: white; color: black; }
  .article-layout { display: block; border: 0; padding-top: 0; }
  .prose { max-width: none; }
}
