:root {
  --bg: #f6f4ef;
  --bg-soft: #fbfaf7;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: rgba(255, 255, 255, 0.95);
  --line: rgba(15, 23, 42, 0.1);
  --line-strong: rgba(15, 23, 42, 0.2);
  --text: #1b2430;
  --muted: #5a6472;
  --muted-strong: #384252;
  --accent: #1f5d87;
  --accent-2: #bb6d45;
  --shadow: 0 18px 42px rgba(15, 23, 42, 0.06);
  --radius: 22px;
  --max: 1180px;
  --reading-max: 740px;
}

html[data-theme="dark"] {
  --bg: #101418;
  --bg-soft: #151b20;
  --surface: rgba(23, 29, 36, 0.9);
  --surface-strong: rgba(21, 27, 32, 0.96);
  --line: rgba(226, 232, 240, 0.1);
  --line-strong: rgba(226, 232, 240, 0.18);
  --text: #ebf0f5;
  --muted: #a5b0bd;
  --muted-strong: #d8e0ea;
  --accent: #7ec0ea;
  --accent-2: #f0a06c;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(31, 93, 135, 0.05), transparent 24%),
    linear-gradient(180deg, var(--bg-soft) 0%, var(--bg) 100%);
  font-family: "Manrope", sans-serif;
  font-size: 17px;
  line-height: 1.65;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0));
  opacity: 0.4;
  z-index: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.story-nav {
  position: fixed;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 10;
}

.story-link {
  position: relative;
  padding-left: 18px;
  color: color-mix(in srgb, var(--muted) 76%, transparent);
  font-size: 0.76rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: color 0.25s ease, transform 0.25s ease;
}

.story-link::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  transform: translateY(-50%);
  transition: all 0.25s ease;
}

.story-link:hover,
.story-link.is-active {
  color: var(--text);
  transform: translateX(4px);
}

.story-link.is-active::before {
  background: var(--accent);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 14%, transparent);
}

.story-progress {
  margin-top: 6px;
  width: 2px;
  height: 110px;
  background: rgba(16, 32, 51, 0.08);
  overflow: hidden;
  border-radius: 999px;
}

.story-progress span {
  display: block;
  width: 100%;
  height: 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-radius: inherit;
  transition: height 0.2s linear;
}

.shell,
.site-shell {
  position: relative;
  z-index: 1;
  width: min(calc(100% - 48px), var(--max));
  margin: 0 auto;
}

.site-shell {
  padding: 40px 0 120px;
}

.post-page .site-shell {
  padding-top: 10px;
}

.site-header,
.site-footer {
  position: relative;
  z-index: 2;
}

.site-header .shell,
.site-footer .shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 0;
}

.brand {
  font-weight: 800;
  font-size: 1.32rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.footer-meta,
.section-note,
.post-summary,
.site-footer p {
  color: var(--muted);
}

.site-footer p {
  margin: 0;
  max-width: 38rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--muted-strong);
  border-radius: 999px;
  min-height: 42px;
  padding: 0;
  font: inherit;
  cursor: pointer;
  transition: color 0.2s ease, transform 0.2s ease;
}

.theme-toggle:hover {
  color: var(--text);
  transform: translateY(-1px);
}

.theme-toggle-track {
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 14%, var(--bg));
  border: 1px solid var(--line);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.theme-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
  transition: transform 0.2s ease, background 0.2s ease;
}

.theme-toggle[aria-pressed="true"] .theme-toggle-track {
  background: color-mix(in srgb, var(--accent) 28%, var(--bg));
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

.theme-toggle[aria-pressed="true"] .theme-toggle-thumb {
  transform: translateX(20px);
}

.theme-toggle-text {
  font-size: 0.9rem;
}

section {
  position: relative;
  margin-bottom: 76px;
}

.hero {
  min-height: auto;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  gap: 28px;
  align-items: start;
  padding-top: 10px;
}

.hero-copy,
.guide-card,
.post-shell,
.post-note {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.eyebrow,
.panel-label {
  margin: 0 0 12px;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.72rem;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.08;
  font-family: "Newsreader", serif;
  font-weight: 600;
}

h1 {
  font-size: clamp(3rem, 5.6vw, 4.7rem);
  max-width: 13ch;
}

h2 {
  font-size: clamp(1.95rem, 3.4vw, 3rem);
}

h3 {
  font-size: clamp(1.45rem, 1.9vw, 1.9rem);
}

p {
  margin: 0;
}

.hero-lead,
.hero-story,
.section-heading,
.track-card p,
.chapter-card p,
.post-card p,
.featured-post p,
.process-card p,
.signal-cluster p,
.editor-note p,
.rail-card p,
.prose p,
.prose li {
  color: var(--muted-strong);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.button:hover,
.inline-link:hover {
  transform: translateY(-1px);
}

.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 12px 24px color-mix(in srgb, var(--accent) 24%, transparent);
}

.secondary,
.tertiary {
  border-color: var(--line);
  background: var(--surface);
}

.inline-link {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  color: var(--accent);
  font-weight: 700;
}

.hero-copy,
.guide-card,
.post-note {
  border-radius: var(--radius);
  padding: 24px 26px;
}

.hero-copy {
  display: grid;
  gap: 14px;
}

.hero-copy h1 {
  font-size: clamp(2.8rem, 4.6vw, 4rem);
  max-width: 11ch;
}

.guide-card {
  align-self: start;
}

.guide-list {
  display: grid;
  gap: 14px;
}

.guide-list article {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.guide-list article:first-child {
  padding-top: 0;
  border-top: 0;
}

.guide-list h2 {
  font-family: "Manrope", sans-serif;
  font-size: clamp(1.25rem, 1.65vw, 1.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.08;
  margin-bottom: 8px;
}

.guide-list p {
  color: var(--muted-strong);
  max-width: 28ch;
}

.section-heading {
  display: grid;
  gap: 12px;
  max-width: 52rem;
  margin-bottom: 26px;
}

.stream,
.track-essays {
  width: 100%;
  max-width: 1000px;
}

.stream-item,
.track-essay {
  display: grid;
  gap: 12px;
  padding: 26px 0 28px;
  border-top: 1px solid var(--line);
}

.stream-item:first-child,
.track-essay:first-child {
  border-top: 0;
  padding-top: 0;
}

.stream-item h3 {
  font-size: clamp(1.55rem, 2.4vw, 2.1rem);
  max-width: 20ch;
}

.stream-item p,
.track-essay p {
  max-width: 52rem;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.stream-item .inline-link {
  width: fit-content;
  margin-top: 6px;
}

.post-hero {
  display: grid;
  gap: 14px;
  justify-items: center;
  text-align: center;
  margin-top: 12px;
  margin-bottom: 16px;
}

.back-link {
  color: var(--muted);
  font-size: 0.8rem;
}

.post-shell {
  max-width: var(--reading-max);
  margin: 0 auto;
  border-radius: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.post-page .post-hero h1 {
  font-size: clamp(2.2rem, 4.8vw, 3.5rem);
  max-width: 13ch;
}

.post-page .post-summary {
  max-width: 48rem;
}

.post-page .post-hero {
  justify-items: start;
  text-align: left;
  max-width: var(--reading-max);
  margin: 4px auto 10px;
}

.post-page .post-hero .article-meta {
  justify-content: flex-start;
}

.post-content {
  max-width: var(--reading-max);
  margin: 0 auto;
  padding: 12px 0 42px;
}

.prose {
  font-family: "Newsreader", serif;
  font-size: 1.32rem;
  line-height: 1.85;
}

.prose > * + * {
  margin-top: 1.15rem;
}

.prose h2,
.prose h3 {
  margin-top: 2.4rem;
  margin-bottom: 0.8rem;
}

.prose blockquote {
  margin: 2rem 0;
  padding: 1rem 1.2rem;
  border-left: 3px solid color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  border-radius: 0 18px 18px 0;
}

.diagram-block {
  margin: 2rem 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: color-mix(in srgb, var(--surface-strong) 92%, transparent);
}

.diagram-block figcaption {
  margin-top: 12px;
  color: var(--muted);
  font-family: "Manrope", sans-serif;
  font-size: 0.95rem;
  line-height: 1.6;
}

.diagram-block .mermaid {
  overflow-x: auto;
}

.diagram-block svg {
  max-width: 100%;
  height: auto;
}

.prose code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9em;
  background: rgba(16, 32, 51, 0.08);
  padding: 0.18rem 0.38rem;
  border-radius: 6px;
}

.prose pre {
  margin: 1.6rem 0;
  padding: 18px;
  border-radius: 20px;
  background: #0f1722;
  color: #edf2f5;
  overflow-x: auto;
}

.prose pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

@media (max-width: 1100px) {
  .story-nav {
    display: none;
  }

  .hero,
  .hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell,
  .site-shell {
    width: min(calc(100% - 28px), var(--max));
  }

  .site-header .shell,
  .site-footer .shell {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .site-shell {
    padding: 24px 0 80px;
  }

  .post-page .site-shell {
    padding-top: 4px;
  }

  h1 {
    font-size: clamp(2.45rem, 12vw, 3.8rem);
  }

  .brand {
    font-size: 1.12rem;
  }

  .hero-copy,
  .guide-card,
  .post-note,
  .post-content {
    padding: 22px;
  }

  .hero-copy h1 {
    font-size: clamp(2.4rem, 11vw, 3.4rem);
  }

  .prose {
    font-size: 1.17rem;
  }

  .post-page .post-hero h1 {
    font-size: clamp(2rem, 9vw, 2.9rem);
  }
}
