:root {
  --bg: #ffffff;
  --text: #1d1d1f;
  --muted: #86868b;
  --rule: #d2d2d7;
  --rule-light: #e8e8ed;
  --link: #1d1d1f;
  --link-underline: #d2d2d7;
  --max-width: 680px;
  --serif: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Layout */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* Header */
.site-header {
  padding: 40px 0 0;
}

.header-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--rule-light);
}

.site-name {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 24px;
}

.site-nav a {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.site-nav a:hover {
  color: var(--text);
}

/* Main */
main {
  padding: 56px 0 80px;
}

/* Index hero */
.index-header {
  margin-bottom: 56px;
}

.index-header h1 {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}

.index-header p {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0;
  max-width: 520px;
}

/* Post list */
.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post-list li {
  padding: 24px 0;
  border-bottom: 1px solid var(--rule-light);
}

.post-list li:first-child {
  border-top: 1px solid var(--rule-light);
}

.post-list a {
  text-decoration: none;
  color: inherit;
  display: block;
}

.post-list a:hover h3 {
  color: var(--muted);
}

.post-list time {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  display: block;
  margin-bottom: 4px;
}

.post-list h3 {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 400;
  line-height: 1.35;
  margin: 0;
  transition: color 0.15s;
}

.post-list .summary {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
  margin: 6px 0 0;
}

/* Reading list */
.reading-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.reading-list li {
  padding: 16px 0;
  border-bottom: 1px solid var(--rule-light);
}

.reading-list li:first-child {
  border-top: 1px solid var(--rule-light);
}

.reading-list .topic {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.reading-list h3 {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 400;
  line-height: 1.4;
  margin: 2px 0 0;
}

.reading-list h3 a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--link-underline);
  transition: border-color 0.15s;
}

.reading-list h3 a:hover {
  border-color: var(--text);
}

.reading-list .cite {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  margin: 2px 0 0;
}

.reading-list .desc {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  margin: 4px 0 0;
}

/* Post view */
.post-header {
  margin-bottom: 48px;
}

.post-header .eyebrow {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 12px;
}

.post-header h1 {
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}

.post-header .meta {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.post-header .meta .sep {
  margin: 0 6px;
}

.post-header .lede {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--muted);
  margin: 16px 0 0;
  max-width: 580px;
}

.canonical-link {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  margin: 12px 0 0;
  word-break: break-all;
}

/* Post content */
.post-content {
  font-size: 17px;
  line-height: 1.75;
}

.post-content h2 {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 400;
  line-height: 1.3;
  margin: 48px 0 16px;
}

.post-content h3 {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.35;
  margin: 36px 0 12px;
}

.post-content h4 {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 32px 0 8px;
}

.post-content p {
  margin: 0 0 20px;
}

.post-content ul, .post-content ol {
  margin: 0 0 20px;
  padding-left: 24px;
}

.post-content li {
  margin: 6px 0;
}

.post-content a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--link-underline);
  transition: border-color 0.15s;
}

.post-content a:hover {
  border-color: var(--text);
}

.post-content blockquote {
  margin: 24px 0;
  padding: 0 0 0 20px;
  border-left: 2px solid var(--rule);
  color: var(--muted);
}

.post-content code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: #f5f5f7;
  padding: 2px 6px;
  border-radius: 3px;
}

.post-content pre {
  background: #f5f5f7;
  border: 1px solid var(--rule-light);
  border-radius: 6px;
  padding: 16px 20px;
  overflow-x: auto;
  margin: 24px 0;
  -webkit-overflow-scrolling: touch;
}

.post-content pre code {
  background: none;
  padding: 0;
  font-size: 14px;
  line-height: 1.6;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 15px;
}

.post-content th, .post-content td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule-light);
}

.post-content th {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
}

.post-content img, .post-content svg, .post-content video {
  max-width: 100%;
  height: auto;
}

.post-content mjx-container[display="true"] {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}

/* Post footer */
.post-footer {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--rule-light);
}

.tag-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-list li {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--rule-light);
  border-radius: 4px;
  padding: 3px 10px;
}

.back-link {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.back-link:hover {
  color: var(--text);
}

/* Trail page */
.trail-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.trail-list li {
  padding: 20px 0;
  border-bottom: 1px solid var(--rule-light);
}

.trail-list li:first-child {
  border-top: 1px solid var(--rule-light);
}

.trail-list time {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  display: block;
}

.trail-list strong {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 400;
  display: block;
  margin-top: 2px;
}

.trail-list strong a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--link-underline);
}

.trail-list strong a:hover {
  border-color: var(--text);
}

.trail-list p {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--muted);
  margin: 4px 0 0;
  line-height: 1.5;
}

/* Assets panel */
.assets-section {
  margin-top: 48px;
}

.assets-section h3 {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule-light);
}

.assets-section ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.assets-section li {
  padding: 8px 0;
  font-family: var(--sans);
  font-size: 14px;
}

.assets-section a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--link-underline);
}

.assets-section a:hover {
  border-color: var(--text);
}

/* Footer */
.site-footer {
  padding: 24px 0 48px;
  border-top: 1px solid var(--rule-light);
  margin-top: 0;
}

.site-footer p {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

/* Links (global) */
a { color: var(--link); }

/* Mobile */
@media (max-width: 640px) {
  body { font-size: 16px; }

  .container { padding: 0 16px; }

  .site-header { padding: 24px 0 0; }

  .header-inner {
    flex-direction: column;
    gap: 8px;
    padding-bottom: 24px;
  }

  .site-nav { gap: 16px; }

  main { padding: 36px 0 60px; }

  .index-header { margin-bottom: 40px; }
  .index-header h1 { font-size: 26px; }

  .post-header h1 { font-size: 28px; }

  .post-content { font-size: 16px; }
  .post-content h2 { font-size: 21px; }

  .post-content table {
    display: block;
    overflow-x: auto;
    font-size: 14px;
  }
}
