:root {
  --page: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #f1f3f5;
  --line: #dfe4e9;
  --text: #171b20;
  --muted: #65717d;
  --gold: #303a44;
  --gold-dim: #8a959f;
  --code: #f4f6f8;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.8;
}

code,
pre {
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

.site-topbar {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
}

.topbar-inner {
  min-height: 4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-brand {
  color: var(--text);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0;
  text-decoration: none;
}

.github-link,
.copy-install {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease, transform 160ms ease;
}

.github-link {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 6px;
  font-size: 1.1rem;
  text-decoration: none;
}

.github-link:hover,
.copy-install:hover {
  border-color: #aab4be;
  background: #f0f2f4;
  color: var(--text);
  transform: translateY(-1px);
}

.hero {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.hero-inner {
  max-width: 920px;
  padding-top: 5.5rem;
  padding-bottom: 3.5rem;
  text-align: center;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(2.4rem, 5vw, 4.3rem);
  font-weight: 850;
  line-height: 1.12;
  letter-spacing: 0;
}

.install-panel {
  width: min(100%, 740px);
  margin: 2rem auto 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.install-copy {
  display: grid;
  gap: 0.2rem;
  margin-bottom: 0.8rem;
}

.install-copy strong {
  color: var(--gold);
  font-size: 0.95rem;
}

.install-copy span {
  color: var(--muted);
  font-size: 0.92rem;
}

.install-command {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 3rem;
  padding: 0.45rem 0.45rem 0.45rem 0.85rem;
  border: 1px solid #d8dde3;
  border-radius: 6px;
  background: var(--code);
  text-align: left;
}

.install-command code {
  min-width: 0;
  flex: 1;
  color: #27313b;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.copy-install {
  flex: 0 0 auto;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 5px;
}

.guide {
  max-width: 920px;
  padding-top: 2rem;
  padding-bottom: 4rem;
}

.chapter {
  padding: 3.5rem 0;
  border-top: 1px solid var(--line);
}

.chapter:first-child {
  border-top: 0;
}

.chapter-body {
  max-width: 760px;
  margin: 0 auto;
}

.chapter h2 {
  margin: 0 0 1.5rem;
  color: var(--text);
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  font-weight: 820;
  line-height: 1.25;
  letter-spacing: 0;
}

.chapter h3 {
  margin: 2.25rem 0 0.8rem;
  color: #3c4651;
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1.45;
  letter-spacing: 0;
}

.chapter p {
  margin: 0 0 1rem;
  color: var(--text);
  font-size: 1rem;
}

.chapter p + h3 {
  margin-top: 2.25rem;
}

.chapter code:not(pre code),
.install-copy code {
  padding: 0.08rem 0.3rem;
  border: 1px solid #d9dfe5;
  border-radius: 4px;
  background: #f0f2f4;
  color: #27313b;
  font-size: 0.9em;
}

pre {
  margin: 0.95rem 0 1.35rem;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  border: 1px solid #d9dfe5;
  border-radius: 6px;
  background: var(--code);
  color: #27313b;
  font-size: 0.9rem;
  line-height: 1.72;
  white-space: pre;
  transition: border-color 180ms ease, transform 180ms ease;
}

pre code {
  color: inherit;
}

pre:hover {
  border-color: #aeb8c2;
  transform: translateY(-1px);
}

.loop-visual {
  display: grid;
  gap: 1.15rem;
  margin: 1rem 0 1.35rem;
  padding: 1.25rem;
  border: 1px solid #d9dfe5;
  border-radius: 8px;
  background: #fbfcfd;
}

.flow-stack,
.flow-path {
  display: grid;
  justify-items: center;
}

.flow-branches {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.62fr);
  gap: 1.5rem;
  align-items: start;
  margin-top: 0.85rem;
}

.flow-path {
  position: relative;
  gap: 0.45rem;
  padding: 0.8rem 0.7rem 0.65rem;
  border: 1px solid #e1e5e9;
  border-radius: 6px;
  background: #ffffff;
}

.flow-path-final {
  align-self: center;
}

.flow-label {
  position: absolute;
  top: -0.95rem;
  left: 50%;
  padding: 0 0.32rem;
  background: #fbfcfd;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  transform: translateX(-50%);
}

.flow-node {
  width: min(100%, 27rem);
  padding: 0.48rem 0.75rem;
  border: 1px solid #d8dee4;
  border-radius: 5px;
  background: #ffffff;
  color: #27313b;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
}

.flow-arrow {
  position: relative;
  width: 1px;
  height: 1.2rem;
  background: #b7c0c9;
}

.flow-arrow::after {
  position: absolute;
  bottom: -0.32rem;
  left: 50%;
  width: 0;
  height: 0;
  border-top: 0.34rem solid #7f8a95;
  border-right: 0.24rem solid transparent;
  border-left: 0.24rem solid transparent;
  content: "";
  transform: translateX(-50%);
}

.flow-return {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.2rem;
  color: #5b6671;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
}

.plan-visual {
  display: grid;
  gap: 0.65rem;
  margin: 1rem 0 1.35rem;
  padding: 1rem;
  border: 1px solid #d9dfe5;
  border-radius: 8px;
  background: #fbfcfd;
}

.plan-row {
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr) 4.6rem;
  gap: 0.75rem;
  align-items: center;
  min-height: 3rem;
  padding: 0.62rem 0.75rem;
  border: 1px solid #e1e5e9;
  border-radius: 6px;
  background: #ffffff;
}

.plan-state {
  position: relative;
  width: 1.1rem;
  height: 1.1rem;
}

.plan-dot {
  position: absolute;
  inset: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
}

.plan-dot-pending {
  border: 1px solid #b8c1ca;
  background: #ffffff;
}

.plan-dot-active {
  border: 1px solid #596574;
  background: #596574;
}

.plan-dot-done {
  border: 1px solid #2f3a45;
  background: #2f3a45;
  color: #ffffff;
}

.plan-task {
  color: #27313b;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.5;
}

.plan-status {
  position: relative;
  min-height: 1.5rem;
  color: #5b6671;
  font-size: 0.82rem;
  font-weight: 800;
  text-align: right;
}

.plan-status span {
  position: absolute;
  top: 0;
  right: 0;
  opacity: 0;
  transform: translateY(0.2rem);
}

.plan-row-one .plan-dot-pending,
.plan-row-one .status-pending {
  animation: plan-pending-one 9s cubic-bezier(0.22, 0.8, 0.28, 1) infinite;
}

.plan-row-one .plan-dot-active,
.plan-row-one .status-active {
  animation: plan-active-one 9s cubic-bezier(0.22, 0.8, 0.28, 1) infinite;
}

.plan-row-one .plan-dot-done,
.plan-row-one .status-done {
  animation: plan-done-one 9s cubic-bezier(0.22, 0.8, 0.28, 1) infinite;
}

.plan-row-two .plan-dot-pending,
.plan-row-two .status-pending {
  animation: plan-pending-two 9s cubic-bezier(0.22, 0.8, 0.28, 1) infinite;
}

.plan-row-two .plan-dot-active,
.plan-row-two .status-active {
  animation: plan-active-two 9s cubic-bezier(0.22, 0.8, 0.28, 1) infinite;
}

.plan-row-two .plan-dot-done,
.plan-row-two .status-done {
  animation: plan-done-two 9s cubic-bezier(0.22, 0.8, 0.28, 1) infinite;
}

.plan-row-three .plan-dot-pending,
.plan-row-three .status-pending {
  animation: plan-pending-three 9s cubic-bezier(0.22, 0.8, 0.28, 1) infinite;
}

.plan-row-three .plan-dot-active,
.plan-row-three .status-active {
  animation: plan-active-three 9s cubic-bezier(0.22, 0.8, 0.28, 1) infinite;
}

.plan-row-three .plan-dot-done,
.plan-row-three .status-done {
  animation: plan-done-three 9s cubic-bezier(0.22, 0.8, 0.28, 1) infinite;
}

@keyframes plan-pending-one {
  0%,
  8% {
    opacity: 1;
    transform: translateY(0);
  }
  14%,
  100% {
    opacity: 0;
    transform: translateY(-0.2rem);
  }
}

@keyframes plan-active-one {
  0%,
  8% {
    opacity: 0;
    transform: translateY(0.2rem) scale(0.9);
  }
  15%,
  29% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  35%,
  100% {
    opacity: 0;
    transform: translateY(-0.2rem) scale(0.94);
  }
}

@keyframes plan-done-one {
  0%,
  29% {
    opacity: 0;
    transform: translateY(0.2rem) scale(0.9);
  }
  36%,
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes plan-pending-two {
  0%,
  36% {
    opacity: 1;
    transform: translateY(0);
  }
  42%,
  100% {
    opacity: 0;
    transform: translateY(-0.2rem);
  }
}

@keyframes plan-active-two {
  0%,
  36% {
    opacity: 0;
    transform: translateY(0.2rem) scale(0.9);
  }
  43%,
  57% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  63%,
  100% {
    opacity: 0;
    transform: translateY(-0.2rem) scale(0.94);
  }
}

@keyframes plan-done-two {
  0%,
  57% {
    opacity: 0;
    transform: translateY(0.2rem) scale(0.9);
  }
  64%,
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes plan-pending-three {
  0%,
  64% {
    opacity: 1;
    transform: translateY(0);
  }
  70%,
  100% {
    opacity: 0;
    transform: translateY(-0.2rem);
  }
}

@keyframes plan-active-three {
  0%,
  64% {
    opacity: 0;
    transform: translateY(0.2rem) scale(0.9);
  }
  71%,
  85% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  91%,
  100% {
    opacity: 0;
    transform: translateY(-0.2rem) scale(0.94);
  }
}

@keyframes plan-done-three {
  0%,
  85% {
    opacity: 0;
    transform: translateY(0.2rem) scale(0.9);
  }
  92%,
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 767.98px) {
  .hero-inner {
    padding-top: 3.8rem;
    padding-bottom: 2.6rem;
  }

  .guide {
    padding-top: 0.7rem;
  }

  .chapter {
    padding: 2.7rem 0;
  }

  .chapter h2 {
    margin-bottom: 1.2rem;
  }

  .chapter p {
    font-size: 0.98rem;
  }

  pre {
    margin-left: -0.15rem;
    margin-right: -0.15rem;
    padding: 0.85rem;
    font-size: 0.82rem;
  }

  .flow-branches {
    grid-template-columns: 1fr;
    gap: 1.8rem;
    margin-top: 0.55rem;
  }

  .plan-row {
    grid-template-columns: 1.5rem minmax(0, 1fr);
  }

  .plan-status {
    grid-column: 2;
    min-height: auto;
    text-align: left;
  }

  .plan-status span {
    right: auto;
    left: 0;
  }
}

@media (max-width: 575.98px) {
  .topbar-inner {
    min-height: 3.5rem;
  }

  .hero-inner {
    padding-top: 3.2rem;
    padding-bottom: 2.2rem;
  }

  h1 {
    font-size: clamp(2rem, 10vw, 2.7rem);
    line-height: 1.2;
  }

  .install-panel {
    margin-top: 1.45rem;
    padding: 0.8rem;
  }

  .install-copy span {
    font-size: 0.86rem;
  }

  .install-command {
    gap: 0.45rem;
    min-height: 2.7rem;
    padding: 0.38rem 0.38rem 0.38rem 0.65rem;
  }

  .install-command code {
    font-size: 0.8rem;
  }

  .copy-install {
    width: 2rem;
    height: 2rem;
  }

  .guide {
    padding-top: 0.3rem;
    padding-bottom: 2.5rem;
  }

  .chapter {
    padding: 2.25rem 0;
  }

  .chapter h3 {
    margin-top: 1.8rem;
  }

  .loop-visual,
  .plan-visual {
    margin-left: -0.1rem;
    margin-right: -0.1rem;
    padding: 0.8rem;
  }

  .flow-path {
    padding: 0.9rem 0.55rem 0.7rem;
  }

  .flow-node {
    padding-inline: 0.55rem;
    font-size: 0.84rem;
  }

  pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .plan-row {
    gap: 0.55rem;
    min-height: 0;
    padding: 0.65rem;
  }

  .plan-status {
    display: none;
  }

  .plan-task {
    font-size: 0.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .chapter.is-visible pre,
  h1,
  .install-panel,
  .plan-row,
  .plan-dot-active,
  .plan-row-one .plan-dot-pending,
  .plan-row-one .status-pending,
  .plan-row-one .plan-dot-active,
  .plan-row-one .status-active,
  .plan-row-one .plan-dot-done,
  .plan-row-one .status-done,
  .plan-row-two .plan-dot-pending,
  .plan-row-two .status-pending,
  .plan-row-two .plan-dot-active,
  .plan-row-two .status-active,
  .plan-row-two .plan-dot-done,
  .plan-row-two .status-done,
  .plan-row-three .plan-dot-pending,
  .plan-row-three .status-pending,
  .plan-row-three .plan-dot-active,
  .plan-row-three .status-active,
  .plan-row-three .plan-dot-done,
  .plan-row-three .status-done {
    animation: none;
  }

  .plan-dot-done,
  .status-done {
    opacity: 1;
  }

  .github-link,
  .copy-install,
  pre {
    transition: none;
  }
}
