:root {
  --header-height: 4.25rem;
  --bg: #f8fbfa;
  --bg-soft: #edf6f2;
  --surface: #ffffff;
  --surface-strong: #e4f0ec;
  --text: #16211f;
  --muted: #5b6d68;
  --line: #d5e4de;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --accent: #9a5f22;
  --code-bg: #13211f;
  --code-text: #e8fff8;
  --shadow: 0 22px 70px rgba(22, 33, 31, 0.12);
}

body.dark-theme {
  --bg: #101615;
  --bg-soft: #17211f;
  --surface: #1d2926;
  --surface-strong: #263934;
  --text: #eef8f4;
  --muted: #b6c7c1;
  --line: #314842;
  --brand: #5eead4;
  --brand-dark: #99f6e4;
  --accent: #f5c57d;
  --code-bg: #07110f;
  --code-text: #e8fff8;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
}

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

img,
svg {
  max-width: 100%;
}

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

.reading-progress {
  position: fixed;
  inset: 0 auto auto 0;
  z-index: 200;
  width: 0%;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.nav {
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav__brand {
  font-weight: 800;
  letter-spacing: 0;
}

.nav__links {
  display: flex;
  align-items: center;
  gap: 1.35rem;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 700;
}

.nav__links a:hover {
  color: var(--brand-dark);
}

.nav__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-button {
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}

.nav__toggle {
  display: none;
}

.hero,
.article-hero {
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--brand) 18%, transparent), transparent 32rem),
    linear-gradient(180deg, var(--bg-soft), var(--bg));
}

.hero {
  padding: 6rem 0 4rem;
}

.hero__grid,
.article-hero__grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: 3rem;
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--brand-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 1rem;
  max-width: 820px;
  font-size: clamp(2.7rem, 6vw, 5.3rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 1rem;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.08;
  letter-spacing: 0;
}

h3 {
  font-size: 1.2rem;
}

.hero__subtitle,
.article-hero__subtitle {
  max-width: 720px;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.25rem);
}

.hero__actions,
.card-grid,
.resource-links,
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3rem;
  padding: 0.85rem 1.1rem;
  border-radius: 999px;
  color: #ffffff;
  background: var(--brand);
  font-weight: 800;
  box-shadow: 0 14px 32px rgba(15, 118, 110, 0.24);
}

.button--ghost {
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--surface);
  box-shadow: none;
}

.hero-panel,
.article-card,
.guide-card,
.resource-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 1.35rem;
}

.hero-panel__label,
.article-card__label {
  display: inline-flex;
  margin-bottom: 0.8rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-panel ul {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
}

.section {
  padding: 5rem 0;
}

.section--soft {
  background: var(--bg-soft);
}

.section__heading {
  margin-bottom: 2rem;
}

.section__heading p:not(.eyebrow) {
  max-width: 760px;
  color: var(--muted);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.topic-map {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1rem;
  align-items: stretch;
}

.map-node {
  position: relative;
  min-height: 17rem;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.map-node::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -1rem;
  width: 1rem;
  height: 2px;
  background: linear-gradient(90deg, var(--brand), transparent);
}

.map-node:last-child::after {
  display: none;
}

.map-node--foundation,
.map-node--core {
  grid-column: span 3;
}

.map-node--analysis,
.map-node--frontier,
.map-node--future {
  grid-column: span 2;
}

.map-node span {
  display: inline-flex;
  margin-bottom: 0.7rem;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.map-node h3 {
  margin-bottom: 0.65rem;
}

.map-node p {
  color: var(--muted);
}

.map-node a {
  display: inline-flex;
  align-items: center;
  margin: 0.35rem 0.55rem 0 0;
  color: var(--brand-dark);
  font-weight: 800;
}

.series-path {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.series-step {
  position: relative;
  display: grid;
  gap: 0.55rem;
  min-height: 12rem;
  padding: 1.2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.series-step::after {
  content: "";
  position: absolute;
  top: 2rem;
  right: -1rem;
  width: 1rem;
  height: 2px;
  background: linear-gradient(90deg, var(--brand), transparent);
}

.series-step:nth-child(4n)::after,
.series-step:last-child::after {
  display: none;
}

.series-step span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  border: 1px solid color-mix(in srgb, var(--brand) 45%, var(--line));
  border-radius: 999px;
  color: var(--brand-dark);
  background: var(--surface-strong);
  font-size: 0.8rem;
  font-weight: 900;
}

.series-step strong {
  font-size: 1.02rem;
  line-height: 1.25;
}

.series-step em {
  color: var(--muted);
  font-style: normal;
  font-size: 0.9rem;
}

.series-step--active {
  border-color: color-mix(in srgb, var(--brand) 50%, var(--line));
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 10%, var(--surface)), var(--surface));
}

.series-step--muted {
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 88%, var(--line));
  box-shadow: none;
}

.series-step--muted span {
  color: var(--muted);
  border-color: var(--line);
}

.side-quest-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) repeat(3, minmax(0, 1fr));
  gap: 1rem;
  align-items: stretch;
  margin-top: 1.25rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.side-quest-panel h3 {
  margin-bottom: 0;
}

.side-quest-panel a {
  display: flex;
  align-items: center;
  min-height: 4rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--brand-dark);
  background: var(--surface-strong);
  font-weight: 800;
}

.guide-card,
.resource-card {
  padding: 1.3rem;
}

.guide-card--next {
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 8%, var(--surface)), var(--surface));
}

.guide-card h3,
.resource-card h3 {
  margin-bottom: 0.6rem;
}

.guide-card p,
.resource-card p {
  color: var(--muted);
}

.guide-card a,
.resource-card a,
.article-card a,
.site-footer a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--brand-dark);
  font-weight: 800;
}

.article-hero {
  padding: 4.5rem 0 3.5rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  color: var(--muted);
  font-weight: 700;
}

.article-meta {
  margin-top: 1.6rem;
}

.article-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 0.88rem;
  font-weight: 700;
}

.article-card {
  padding: 1.4rem;
}

.article-card p {
  color: var(--muted);
}

.article-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 3rem;
  padding-top: 3rem;
  padding-bottom: 5rem;
}

.toc {
  position: sticky;
  top: calc(var(--header-height) + 1.5rem);
  align-self: start;
  max-height: calc(100vh - 7rem);
  overflow: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.toc__title {
  margin-bottom: 0.7rem;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.toc ul {
  margin: 0;
  padding-left: 1rem;
}

.toc li {
  margin: 0.35rem 0;
}

.toc a {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.toc a:hover {
  color: var(--brand-dark);
}

.article-content {
  min-width: 0;
  color: var(--text);
  font-size: 1.04rem;
}

.article-content > * {
  max-width: 760px;
}

.article-content h1 {
  display: none;
}

.article-content h2 {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: clamp(1.65rem, 3vw, 2.25rem);
}

.article-content h3 {
  margin-top: 2rem;
}

.article-content p,
.article-content li {
  color: color-mix(in srgb, var(--text) 82%, var(--muted));
  overflow-wrap: anywhere;
}

.article-content a {
  color: var(--brand-dark);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  overflow-wrap: anywhere;
}

.article-content table {
  display: block;
  width: 100%;
  max-width: 900px;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 1.5rem 0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.article-content th,
.article-content td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.article-content th {
  color: var(--text);
  background: var(--surface-strong);
}

.article-content pre {
  position: relative;
  width: 100%;
  max-width: 900px;
  overflow: auto;
  padding: 1.1rem;
  border-radius: 8px;
  color: var(--code-text);
  background: var(--code-bg);
  box-shadow: var(--shadow);
  contain: inline-size;
}

.article-content code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
}

.article-content pre code {
  display: block;
  width: max-content;
  min-width: 100%;
  white-space: pre;
}

.article-content :not(pre) > code {
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
  color: var(--brand-dark);
  background: var(--surface-strong);
}

.copy-code {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  color: var(--code-text);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.3rem 0.55rem;
}

.mermaid {
  max-width: 900px;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.article-engagement {
  width: 100%;
  max-width: 900px;
  margin-top: 4rem;
}

.engagement-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.engagement-card {
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.engagement-card h2 {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
  font-size: clamp(1.35rem, 3vw, 1.8rem);
}

.engagement-card p {
  max-width: 680px;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

.share-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.65rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: var(--surface-strong);
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  text-decoration: none;
}

.article-content .share-button {
  color: var(--text);
  text-decoration: none;
}

.share-button:hover {
  color: var(--brand-dark);
  border-color: color-mix(in srgb, var(--brand) 55%, var(--line));
}

.share-status {
  min-height: 1.5rem;
  margin: 0.9rem 0 0;
  color: var(--brand-dark);
  font-size: 0.9rem;
  font-weight: 800;
}

.discussion-note {
  margin-top: 1rem;
  padding: 1rem;
}

.discussion-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
}

.discussion-note strong {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.discussion-note p {
  margin-bottom: 0;
}

.discussion-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

.giscus-panel {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.giscus {
  max-width: 100%;
}

.site-footer {
  padding: 2rem 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.footer__grid {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.footer__grid p {
  margin-bottom: 0;
}

@media (max-width: 900px) {
  .nav__toggle {
    display: inline-grid;
    place-items: center;
  }

  .nav__links {
    position: fixed;
    top: calc(var(--header-height) - 0.4rem);
    left: 1rem;
    right: 1rem;
    display: grid;
    gap: 0.2rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-0.6rem);
    transition: 0.2s ease;
  }

  .nav__links.show {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .nav__links a {
    padding: 0.7rem;
  }

  .hero__grid,
  .article-hero__grid,
  .article-layout {
    grid-template-columns: 1fr;
  }

  .toc {
    position: static;
    max-height: none;
  }

  .article-engagement {
    max-width: 100%;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .topic-map {
    grid-template-columns: 1fr;
  }

  .map-node,
  .map-node--foundation,
  .map-node--core,
  .map-node--analysis,
  .map-node--frontier,
  .map-node--future {
    grid-column: auto;
  }

  .map-node::after {
    top: auto;
    right: auto;
    bottom: -1rem;
    left: 1.25rem;
    width: 2px;
    height: 1rem;
    background: linear-gradient(180deg, var(--brand), transparent);
  }

  .series-path,
  .side-quest-panel {
    grid-template-columns: 1fr;
  }

  .series-step {
    min-height: 0;
  }

  .series-step::after {
    top: auto;
    right: auto;
    bottom: -1rem;
    left: 1.75rem;
    width: 2px;
    height: 1rem;
    background: linear-gradient(180deg, var(--brand), transparent);
  }

  .series-step:nth-child(4n)::after {
    display: block;
  }

  .series-step:last-child::after {
    display: none;
  }
}

@media (max-width: 560px) {
  .hero,
  .article-hero,
  .section {
    padding-block: 3.5rem;
  }

  .hero__actions,
  .footer__grid {
    flex-direction: column;
  }

  .button {
    width: 100%;
  }

  .share-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .share-button {
    width: 100%;
  }
}
