:root {
  --ink: #272634;
  --muted: #69677a;
  --paper: #f7f5f0;
  --surface: #fffefa;
  --line: #dedbe2;
  --accent: #5749c6;
  --accent-soft: #ebe8ff;
  --night: #151525;
  --cyan: #24a8b5;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.72 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: #4336a0; text-underline-offset: 3px; }
img { max-width: 100%; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(222, 219, 226, .85);
  background: rgba(247, 245, 240, .91);
  backdrop-filter: blur(14px);
}
.nav {
  width: min(1180px, calc(100% - 36px));
  min-height: 58px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 850;
  text-decoration: none;
}
.brand img { width: 32px; height: 32px; }
.nav-links { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.nav-links a { color: var(--ink); text-decoration: none; }
.nav-links .button { color: white; }

.button {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

.article-hero {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 62px 0 38px;
}
.article-hero .copy { max-width: 900px; }
.eyebrow {
  margin-bottom: 14px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .14em;
  text-transform: uppercase;
}
h1, h2, h3 {
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", serif;
  letter-spacing: -.025em;
}
h1 {
  max-width: 1000px;
  margin: 0;
  font-size: clamp(42px, 7vw, 82px);
  line-height: .99;
}
.lede {
  max-width: 820px;
  margin: 25px 0 0;
  color: var(--muted);
  font-size: clamp(19px, 2.2vw, 24px);
  line-height: 1.52;
}
.byline { margin-top: 24px; color: var(--muted); font-size: 14px; }
.hero-image {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto 44px;
}
.hero-image img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid #ffffff80;
  border-radius: 28px;
  box-shadow: 0 26px 70px #24203b28;
}
.hero-image figcaption { margin-top: 10px; color: var(--muted); font-size: 13px; }

.article-layout {
  width: min(1100px, calc(100% - 36px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 760px) 220px;
  justify-content: space-between;
  gap: 70px;
  padding-bottom: 90px;
}
article { min-width: 0; }
article h2 {
  margin: 68px 0 17px;
  font-size: clamp(30px, 4vw, 43px);
  line-height: 1.12;
}
article h3 { margin: 38px 0 12px; font-size: 25px; line-height: 1.2; }
article p { margin: 0 0 22px; }
article li { margin-bottom: 10px; }
.part-label {
  display: block;
  margin-bottom: 7px;
  color: var(--accent);
  font: 850 11px/1 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.callout {
  margin: 34px 0;
  padding: 25px 28px;
  border: 1px solid #cfc9ef;
  border-left: 5px solid var(--accent);
  border-radius: 16px;
  background: var(--accent-soft);
}
.equation {
  overflow-x: auto;
  margin: 26px 0;
  padding: 20px 24px;
  border-radius: 14px;
  background: var(--night);
  color: #eeecff;
  font: 600 17px/1.7 ui-monospace, SFMono-Regular, Consolas, monospace;
}
pre {
  overflow-x: auto;
  margin: 28px 0;
  padding: 22px 24px;
  border: 1px solid #2e2d48;
  border-radius: 16px;
  background: #12121f;
  color: #ecebff;
  font: 500 13px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace;
  tab-size: 2;
}
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
p code, li code { padding: 2px 5px; border-radius: 5px; background: var(--accent-soft); font-size: .9em; }
.source-list {
  margin: 38px 0 0;
  padding: 22px 26px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  font-size: 14px;
}
.source-list h3 { margin-top: 0; }
.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.chapter-nav a { font-weight: 800; text-decoration: none; }
.toc {
  position: sticky;
  top: 82px;
  align-self: start;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  font-size: 13px;
}
.toc strong { display: block; margin-bottom: 9px; }
.toc a { display: block; padding: 4px 0; color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--accent); }
.next-posts {
  margin-top: 64px;
  padding-top: 30px;
  border-top: 1px solid var(--line);
}
.next-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; }
.next-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.index-hero {
  width: min(1180px, calc(100% - 36px));
  margin: auto;
  padding: 78px 0 46px;
}
.index-hero h1 { max-width: 800px; }
.post-grid {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto 90px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}
.post-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease;
}
.post-card:hover { transform: translateY(-3px); box-shadow: 0 20px 50px #28233d18; }
.post-card:first-child { grid-column: 1 / -1; display: grid; grid-template-columns: 1.15fr .85fr; }
.post-card img { display: block; width: 100%; height: 260px; object-fit: cover; }
.post-card:first-child img { height: 100%; min-height: 300px; }
.post-card .content { padding: 26px; }
.post-card h2 { margin: 8px 0 12px; font-size: clamp(27px, 3vw, 38px); line-height: 1.08; }
.post-card p { margin: 0; color: var(--muted); }
.post-card .meta { margin-top: 18px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.series-list {
  width: min(1000px, calc(100% - 36px));
  margin: 0 auto 90px;
  display: grid;
  gap: 12px;
}
.series-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
}
.series-number { color: var(--accent); font: 850 24px/1 ui-serif, Georgia, serif; }
.series-item h2 { margin: 0 0 4px; font-size: 24px; line-height: 1.1; }
.series-item p { margin: 0; color: var(--muted); font-size: 14px; }
.series-time { color: var(--muted); font-size: 12px; white-space: nowrap; }

@media (max-width: 840px) {
  .article-layout { grid-template-columns: 1fr; }
  .toc { display: none; }
  .post-grid { grid-template-columns: 1fr; }
  .post-card:first-child { grid-column: auto; display: block; }
  .post-card:first-child img { height: 280px; min-height: 0; }
  .series-item { grid-template-columns: 42px 1fr; }
  .series-time { display: none; }
  .nav-links a:not(.button) { display: none; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .article-hero { padding-top: 42px; }
  .hero-image img { border-radius: 18px; }
  .next-grid { grid-template-columns: 1fr; }
}
