:root {
  color-scheme: light dark;
  --page: #f3f6f5;
  --surface: #ffffff;
  --surface-subtle: #eef3f1;
  --surface-strong: #182522;
  --text: #17211f;
  --muted: #61706c;
  --border: #d5dfdc;
  --border-strong: #aebdb8;
  --primary: #087d6c;
  --primary-strong: #056052;
  --primary-soft: #d9f0eb;
  --primary-text: #ffffff;
  --accent: #b9612c;
  --accent-soft: #f5e4d9;
  --focus: #006fbe;
  --shadow: 0 10px 30px rgba(20, 38, 33, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #111816;
    --surface: #18211f;
    --surface-subtle: #202c29;
    --surface-strong: #0b100f;
    --text: #edf4f2;
    --muted: #a8b7b2;
    --border: #34443f;
    --border-strong: #52655f;
    --primary: #4fc5ad;
    --primary-strong: #70d4c0;
    --primary-soft: #173d35;
    --primary-text: #07110f;
    --accent: #eea36f;
    --accent-soft: #422b1e;
    --focus: #77bfff;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  }
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background: var(--page);
  font-size: 16px;
  line-height: 1.55;
}

button,
input {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 50;
  padding: 8px 12px;
  color: var(--primary-text);
  background: var(--primary);
  border-radius: 4px;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  color: #ffffff;
  background: var(--surface-strong);
}

.header-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.8fr);
  gap: 48px;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 36px 0 28px;
}

.title-block,
.search-area {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary-strong);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.4;
  text-transform: uppercase;
}

.site-header .eyebrow {
  color: #77d8c4;
}

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

h1,
h2,
h3 {
  margin-top: 0;
  line-height: 1.25;
}

h1 {
  margin-bottom: 10px;
  font-size: 1.85rem;
  font-weight: 700;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.45rem;
  font-weight: 700;
}

h3 {
  font-size: 1rem;
}

.header-summary {
  max-width: 680px;
  margin: 0;
  color: #c7d4d0;
}

.search-area {
  position: relative;
  align-self: center;
}

.search-area > label {
  display: block;
  margin-bottom: 8px;
  color: #dce6e3;
  font-size: 0.88rem;
  font-weight: 600;
}

.search-field {
  display: flex;
  align-items: center;
  min-height: 46px;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #ffffff;
  border-radius: 6px;
}

.search-field:focus-within {
  outline: 3px solid #77bfff;
  outline-offset: 2px;
}

#site-search {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  color: #16201e;
  background: transparent;
  border: 0;
  outline: 0;
}

#site-search::placeholder {
  color: #667571;
}

.clear-search {
  align-self: stretch;
  padding: 0 14px;
  color: #31423e;
  background: #eef2f1;
  border: 0;
  border-left: 1px solid #d6dfdc;
  font-size: 0.86rem;
  font-weight: 600;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  z-index: 20;
  max-height: 380px;
  overflow-y: auto;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.search-status {
  margin: 0;
  padding: 10px 12px;
  color: var(--muted);
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}

.search-result-list {
  display: grid;
}

.search-result {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
}

.search-result:last-child {
  border-bottom: 0;
}

.search-result:hover,
.search-result:focus-visible {
  background: var(--primary-soft);
}

.search-result-title {
  font-weight: 700;
}

.search-result-path {
  color: var(--muted);
  font-size: 0.78rem;
}

.scope-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 13px 0 15px;
  color: #c7d4d0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.8rem;
}

.scope-bar span {
  padding: 0 12px;
  border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.scope-bar span:first-child {
  padding-left: 0;
}

.scope-bar span:last-child {
  border-right: 0;
}

main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.map-section,
.detail-section {
  padding: 44px 0;
}

.section-heading,
.detail-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 24px;
}

.section-heading > p {
  max-width: 400px;
  margin: 0;
  color: var(--muted);
  text-align: right;
}

.flow-map {
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.flow-stage {
  position: relative;
}

.stage-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
}

.input-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  max-width: 760px;
  margin: 0 auto;
}

.module-node {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-rows: max-content;
  place-content: center;
  place-items: center;
  gap: 4px;
  width: 100%;
  height: 100%;
  min-height: 104px;
  padding: 14px 12px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

.module-node:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.module-node[aria-pressed="true"] {
  color: var(--primary-text);
  background: var(--primary);
  border-color: var(--primary);
}

.module-number {
  color: var(--primary-strong);
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1.2;
}

.module-node[aria-pressed="true"] .module-number {
  color: var(--primary-text);
}

.module-title {
  font-weight: 700;
  line-height: 1.3;
}

.module-role {
  max-width: 100%;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.module-node[aria-pressed="true"] .module-role {
  color: var(--primary-text);
  opacity: 0.86;
}

.vertical-connector {
  display: grid;
  place-items: center;
  height: 46px;
  color: var(--border-strong);
  font-size: 1.2rem;
}

.decision-node,
.single-node {
  max-width: 520px;
  margin: 0 auto;
}

.operation-chain {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr) 28px minmax(0, 1fr) 28px minmax(0, 1fr);
  gap: 6px;
  align-items: stretch;
}

.horizontal-arrow {
  display: grid;
  place-items: center;
  color: var(--border-strong);
  font-size: 1.15rem;
  text-align: center;
}

.review-node {
  border-color: var(--accent);
}

.feedback-loop {
  max-width: 680px;
  margin: 12px auto 0;
  padding: 8px 12px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
}

.flow-summary {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.detail-section {
  border-top: 1px solid var(--border);
}

.detail-heading {
  align-items: center;
  margin-bottom: 18px;
}

.detail-heading h2 {
  margin-bottom: 6px;
}

.detail-role {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
}

.text-action {
  flex: 0 0 auto;
  padding: 9px 12px;
  color: var(--primary-strong);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 700;
}

.text-action:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.detail-context {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-bottom: 16px;
  padding: 11px 0;
  color: var(--muted);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

.detail-list,
.nested-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.detail-list {
  counter-reset: detail-node;
}

.detail-item {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  min-height: 58px;
  padding: 15px 0;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 24px;
}

.detail-item:last-child {
  border-bottom: 0;
}

.detail-item::before {
  counter-increment: detail-node;
  content: counter(detail-node, decimal-leading-zero);
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--primary-strong);
  background: var(--primary-soft);
  border-radius: 4px;
  font-size: 0.76rem;
  font-weight: 800;
}

.node-title {
  margin: 4px 0 0;
  font-size: 0.98rem;
  font-weight: 700;
}

.detail-item > details {
  min-width: 0;
  width: 100%;
}

.detail-item summary {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  gap: 3px 12px;
  align-items: center;
  min-height: 44px;
  padding: 2px 0;
  cursor: pointer;
  list-style: none;
}

.detail-item summary::-webkit-details-marker {
  display: none;
}

.detail-item summary::after {
  grid-column: 2;
  grid-row: 1 / span 2;
  place-self: center;
  content: "+";
  color: var(--primary-strong);
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1;
}

.detail-item details[open] > summary::after {
  content: "−";
}

.node-summary-title {
  grid-column: 1;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.35;
}

.node-description {
  grid-column: 1;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.node-definition {
  margin-top: 12px;
  padding: 15px 16px 16px;
  background: var(--surface-subtle);
  border-left: 3px solid var(--primary);
  border-radius: 0 4px 4px 0;
}

.node-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin: 0;
}

.node-meta-item {
  min-width: 0;
}

.node-meta dt,
.node-question-block h4 {
  margin: 0 0 5px;
  color: var(--primary-strong);
  font-size: 0.78rem;
  font-weight: 800;
}

.node-meta dd {
  margin: 0;
  font-size: 0.88rem;
}

.node-question-block {
  margin-top: 15px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
}

.node-questions {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 1.2em;
  font-size: 0.88rem;
}

.nested-list {
  display: grid;
  gap: 7px;
  margin-top: 10px;
  padding-left: 14px;
  border-left: 2px solid var(--primary-soft);
}

.nested-item {
  padding: 7px 9px;
  background: var(--surface-subtle);
  border-radius: 4px;
}

.is-highlighted {
  animation: highlight-node 1.8s ease-out;
}

@keyframes highlight-node {
  0%,
  35% {
    background: var(--accent-soft);
  }
  100% {
    background: transparent;
  }
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 36px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
}

footer p {
  margin: 0;
}

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 900px) {
  .header-inner {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .operation-chain {
    grid-template-columns: 1fr;
    gap: 8px;
    max-width: 560px;
    margin: 0 auto;
  }

  .horizontal-arrow {
    font-size: 0;
  }

  .horizontal-arrow::after {
    content: "↓";
    font-size: 1.15rem;
  }
}

@media (max-width: 700px) {
  .header-inner,
  .scope-bar,
  main,
  footer {
    width: min(100% - 24px, 1180px);
  }

  .header-inner {
    padding-top: 26px;
  }

  h1 {
    font-size: 1.55rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  .scope-bar {
    row-gap: 7px;
  }

  .scope-bar span {
    width: 50%;
    padding: 0 8px;
    border-right: 0;
  }

  .scope-bar span:nth-child(odd) {
    padding-left: 0;
  }

  .map-section,
  .detail-section {
    padding: 32px 0;
  }

  .section-heading,
  .detail-heading {
    display: grid;
    gap: 14px;
  }

  .section-heading > p {
    max-width: none;
    text-align: left;
  }

  .flow-map {
    padding: 18px 12px;
  }

  .input-pair {
    gap: 8px;
  }

  .module-node {
    min-height: 104px;
    padding: 11px;
  }

  .text-action {
    justify-self: start;
  }

  .detail-item {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 9px;
  }

  .detail-item::before {
    width: 32px;
    height: 32px;
  }

  .node-meta {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  footer {
    display: grid;
  }
}

@media (max-width: 420px) {
  .scope-bar span {
    width: 100%;
    padding-left: 0;
  }

  .input-pair {
    grid-template-columns: 1fr;
  }

  .module-node {
    min-height: 88px;
  }

  .search-results {
    right: -4px;
    left: -4px;
  }
}
