:root {
  --bg: #f4f2ec;
  --ink: #141414;
  --muted: #5a5a5a;
  --accent: #0a5c45;
  --accent-soft: #e4efe9;
  --line: #d4cfc4;
  --card: #fffcf6;
  --max: 48rem;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  background:
    radial-gradient(1200px 600px at 10% -10%, #e8efe9 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #ebe6dc 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
  line-height: 1.65;
}

.wrap {
  max-width: calc(var(--max) + 4rem);
  margin: 0 auto;
  padding: 0 1.5rem;
}

body:has(.tour-section) .wrap,
body:has(.tour-layout) .wrap {
  max-width: calc(72rem + 4rem);
}

.tour-layout {
  display: grid;
  grid-template-columns: 13.5rem minmax(0, 1fr);
  gap: 2rem 2.5rem;
  align-items: start;
  margin-bottom: 2rem;
}

.tour-nav {
  position: sticky;
  top: 1.25rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: 0.85rem 0.9rem 1rem;
  background: color-mix(in srgb, var(--card) 92%, var(--accent-soft));
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

.tour-nav-title {
  margin: 0 0 0.65rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.tour-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tour-nav-list li {
  margin: 0;
}

.tour-nav-list a {
  display: block;
  padding: 0.35rem 0.45rem;
  margin: 0.1rem 0;
  border-radius: 4px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  line-height: 1.35;
  border-left: 2px solid transparent;
}

.tour-nav-list a:hover {
  color: var(--ink);
  background: var(--accent-soft);
}

.tour-nav-list a.is-active {
  color: var(--accent);
  font-weight: 600;
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.tour-nav-aside {
  margin: 0.9rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
}

.tour-nav-aside a {
  color: var(--accent);
  text-decoration: none;
}

.tour-nav-aside a:hover {
  text-decoration: underline;
}

.tour-main {
  min-width: 0;
}

.tour-main section[id] {
  scroll-margin-top: 1.5rem;
}

@media (max-width: 900px) {
  .tour-main section[id] {
    scroll-margin-top: 5.5rem;
  }

  .tour-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .tour-nav {
    position: sticky;
    top: 0;
    z-index: 20;
    max-height: none;
    overflow: visible;
    padding: 0.7rem 0.75rem;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 6px 18px rgba(20, 20, 20, 0.06);
  }

  .tour-nav-list {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.35rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.15rem;
  }

  .tour-nav-list li {
    flex: 0 0 auto;
  }

  .tour-nav-list a {
    border-left: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    padding: 0.4rem 0.55rem;
  }

  .tour-nav-list a.is-active {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
  }

  .tour-nav-aside {
    display: none;
  }
}

.site-main {
  padding-top: 2rem;
}

.site-header .wrap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}

nav a {
  color: var(--muted);
  text-decoration: none;
  margin-left: 1rem;
  font-size: 0.95rem;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

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

h1, h2, h3 {
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.hero-home {
  padding: 1rem 0 2.5rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2.5rem;
  animation: rise 0.7s ease-out both;
}

.eyebrow {
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.85rem;
}

.hero-home h1 {
  font-size: clamp(1.85rem, 4.5vw, 2.65rem);
  margin: 0 0 1rem;
  max-width: 22ch;
}

.lede {
  color: var(--muted);
  margin: 0 0 1.5rem;
  max-width: 38rem;
  font-size: 1.08rem;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin: 0;
}

.cta {
  display: inline-block;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0.55rem 1rem;
  border-radius: 4px;
  background: var(--accent);
  color: #f7fff9;
  transition: transform 0.15s ease, background 0.15s ease;
}

.cta:hover { background: #084a37; transform: translateY(-1px); }

.cta-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
}

.cta-secondary:hover { background: var(--accent-soft); }

.home-section {
  margin-bottom: 2.75rem;
  animation: rise 0.75s ease-out both;
  animation-delay: 0.08s;
}

.home-section h2 {
  font-size: 1.35rem;
  margin: 0 0 0.85rem;
}

.home-section > p {
  color: var(--muted);
  margin: 0 0 1rem;
  max-width: 40rem;
}

.home-section a { color: var(--accent); }

.vision-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.vision-list li {
  padding: 0.9rem 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.vision-list li:last-child { border-bottom: 1px solid var(--line); }

.vision-list strong {
  display: block;
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  margin-bottom: 0.2rem;
}

.arch-figure { margin: 1.25rem 0; }

.arch-diagram {
  margin: 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.35;
  background: #1c1d1b;
  color: #e8e4da;
  border-radius: 6px;
}

.arch-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem 1.5rem;
  margin-top: 1.5rem;
}

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

.arch-grid h3 {
  font-size: 1rem;
  margin: 0 0 0.35rem;
}

.arch-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.notes-section {
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.post-group.start-here {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  padding: 1.25rem 1.35rem 1rem;
  margin-bottom: 2rem;
  border-radius: 4px;
}

.series-label {
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.35rem;
}

.depth-intro {
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 1.25rem;
}

.muted-inline {
  font-weight: 500;
  color: var(--muted);
}

.notes-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  margin: 0 0 1.25rem;
  padding: 0;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  font-size: 0.88rem;
}

.notes-toc a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

.notes-toc a:hover {
  border-bottom-color: var(--accent);
}

.post-group {
  margin: 0 0 2.25rem;
  padding: 0 0 0.25rem;
}

.post-group h3 {
  font-size: 1.15rem;
  margin: 0 0 0.4rem;
}

.group-lede {
  color: var(--muted);
  margin: 0 0 0.75rem !important;
  font-size: 0.98rem;
  max-width: 40rem;
}

.post-group.all-posts {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.section-intro {
  margin-bottom: 0.5rem !important;
}

.hero h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); margin: 0 0 0.5rem; }
.hero:not(.hero-home) p { color: var(--muted); margin: 0 0 2rem; max-width: 36rem; }

.post-list { list-style: none; padding: 0; margin: 0 0 0.5rem; }
.post-list.ordered {
  list-style: decimal;
  padding-left: 1.35rem;
}
.post-list.ordered li {
  padding-left: 0.35rem;
}
.post-list li {
  padding: 0.95rem 0;
  border-top: 1px solid var(--line);
}
.post-list li:first-child {
  border-top: none;
  padding-top: 0.35rem;
}
.post-list a {
  color: var(--ink);
  text-decoration: none;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
}
.post-list a:hover { color: var(--accent); }
.post-list .meta { color: var(--muted); font-size: 0.88rem; margin: 0.3rem 0 0; }

.post-header { margin-bottom: 1.75rem; }
.post-header h1 { margin: 0.25rem 0 0.75rem; font-size: clamp(1.6rem, 3vw, 2.1rem); }
.post-header .meta, .canonical { color: var(--muted); font-size: 0.95rem; }
.canonical code {
  font-size: 0.85em;
  background: #eeeae2;
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

.post-body a { color: var(--accent); }
.post-body code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: #eeeae2;
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
.post-body pre {
  background: #1e1e1c;
  color: #f2efe8;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  border-radius: 6px;
}
.post-body pre code { background: none; padding: 0; color: inherit; }
.post-body .mermaid {
  margin: 1.5rem 0;
  padding: 1rem;
  overflow-x: auto;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.post-body .mermaid svg {
  max-width: 100%;
  height: auto;
}
.post-body table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: 0.95rem; }
.post-body th, .post-body td { border: 1px solid var(--line); padding: 0.45rem 0.6rem; text-align: left; }
.post-body th { background: #eeeae2; }

.back { margin: 2.5rem 0; }
.back a { color: var(--accent); text-decoration: none; }

.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 3rem;
  padding: 1.5rem 0 2.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.site-footer a { color: var(--accent); }

.tour-toc {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
  color: var(--muted);
  max-width: 40rem;
}

.tour-toc a { color: var(--accent); }

.tour-section .shot {
  margin: 1.5rem 0 2rem;
}

.tour-section .shot img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  box-shadow: 0 8px 24px rgba(20, 20, 20, 0.06);
}

.tour-section figcaption {
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.92rem;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .hero-home, .home-section { animation: none; }
  .cta:hover { transform: none; }
}
