:root {
  --accent: #107872;
  --accent-deep: #075c58;
  --accent-soft: #e3f2ef;
  --accent-pale: #f2f9f7;
  --ink: #202c2b;
  --muted: #63706f;
  --line: #dbe3e0;
  --paper: #fffefa;
  --canvas: #f4f3ed;
  --white: #ffffff;
  --auto: #f2f4f3;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: var(--canvas);
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

:focus-visible {
  outline: 3px solid rgba(16, 120, 114, .45);
  outline-offset: 4px;
}

.page {
  width: min(100% - 40px, 1440px);
  margin: 24px auto;
  background: var(--paper);
  border: 1px solid var(--line);
}

.site-header {
  padding: 34px clamp(24px, 5vw, 76px) 42px;
  border-bottom: 1px solid var(--line);
}

.back-link {
  display: inline-block;
  margin-bottom: 36px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-underline-offset: 4px;
}

.eyebrow,
.phase-code,
.figure-index,
.tag,
.legend-title,
.compare-label {
  font-family: Arial, sans-serif;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 11px;
  color: var(--accent);
  font-size: .68rem;
}

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

h1 {
  max-width: 980px;
  margin-bottom: 14px;
  font-size: clamp(2rem, 4.2vw, 4.35rem);
  font-weight: 900;
  line-height: 1.18;
  letter-spacing: -.045em;
}

.lead {
  max-width: 950px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(.98rem, 1.5vw, 1.16rem);
}

main { padding: 0 clamp(24px, 5vw, 76px) 64px; }

.section {
  padding: 70px 0;
  border-bottom: 1px solid var(--line);
}

.section:last-of-type { border-bottom: 0; }

.section-heading {
  display: grid;
  grid-template-columns: 122px minmax(0, 1fr);
  gap: 28px;
  align-items: end;
  margin-bottom: 34px;
}

.figure-index {
  color: var(--accent);
  font-size: .68rem;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(1.5rem, 2.5vw, 2.25rem);
  line-height: 1.4;
  letter-spacing: -.025em;
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow-wrap: anywhere;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 10px;
  color: var(--accent-deep);
  background: var(--white);
  border: 1px solid #b9cbc7;
  border-radius: 999px;
  font-size: .6rem;
  line-height: 1.4;
}

.tag.auto {
  color: #53605e;
  background: var(--auto);
  border-color: #cfd8d5;
}

.tag.done {
  color: var(--white);
  background: var(--accent);
  border-color: var(--accent);
}

.premise-card {
  display: grid;
  grid-template-columns: minmax(190px, .58fr) minmax(0, 1.55fr);
  gap: clamp(28px, 5vw, 78px);
  align-items: start;
  padding: clamp(28px, 5vw, 58px);
  border-top: 4px solid var(--accent);
}

.premise-card h2 {
  margin: 0;
  font-size: clamp(1.45rem, 2.5vw, 2.2rem);
  line-height: 1.42;
}

.premise-card p {
  margin: 0;
  font-size: clamp(.98rem, 1.4vw, 1.12rem);
}

.premise-card strong { color: var(--accent-deep); }

.flow {
  display: grid;
  gap: 0;
}

.flow-step {
  display: grid;
  grid-template-columns: 122px 42px minmax(0, 1fr);
  gap: 18px;
  min-width: 0;
}

.phase-label { padding-top: 19px; }

.phase-code {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
  font-size: .64rem;
}

.phase-name {
  display: block;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 700;
  line-height: 1.55;
}

.flow-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.flow-dot {
  display: grid;
  place-items: center;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  margin-top: 20px;
  color: var(--accent);
  background: var(--paper);
  border: 1px solid var(--accent);
  border-radius: 50%;
  font-family: Arial, sans-serif;
  font-size: .62rem;
  font-weight: 700;
}

.flow-line {
  flex: 1 1 auto;
  width: 1px;
  min-height: 34px;
  background: var(--line);
  position: relative;
}

.flow-step:not(:last-child) .flow-line::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 50%;
  width: 7px;
  height: 7px;
  border-right: 1px solid var(--muted);
  border-bottom: 1px solid var(--muted);
  transform: translateX(-50%) rotate(45deg);
}

.flow-card {
  margin-bottom: 28px;
  padding: clamp(24px, 3vw, 36px);
}

.flow-card.auto { background: var(--auto); }

.flow-card.done {
  background: var(--accent-pale);
  border-color: #9ec9c3;
}

.flow-card h3 {
  margin: 14px 0 9px;
  font-size: clamp(1.12rem, 2vw, 1.48rem);
  line-height: 1.5;
}

.flow-card p { margin-bottom: 0; }

.flow-card ul {
  display: grid;
  gap: 5px;
  margin: 16px 0 0;
  padding-left: 1.35em;
}

.flow-card li::marker { color: var(--accent); }

.hand-note {
  max-width: 750px;
  margin: 22px 0 0 auto;
  padding-left: 22px;
  color: var(--accent-deep);
  border-left: 1px solid var(--accent);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(1rem, 1.8vw, 1.3rem);
  font-style: italic;
  line-height: 1.9;
  transform: rotate(-.35deg);
}

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

.compare-card { padding: clamp(26px, 4vw, 42px); }
.compare-card.after { background: var(--accent-pale); border-color: #b4d7d2; }

.compare-label {
  display: block;
  margin-bottom: 13px;
  color: var(--muted);
  font-size: .65rem;
}

.compare-card.after .compare-label { color: var(--accent-deep); }
.compare-card p { margin: 0; font-weight: 700; }

.legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 24px;
  padding: 28px 0 0;
}

.legend-title {
  margin-right: 12px;
  font-size: .66rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: .78rem;
}

.legend-swatch {
  width: 24px;
  height: 14px;
  background: var(--white);
  border: 1px solid var(--line);
}

.legend-swatch.auto { background: var(--auto); }
.legend-swatch.done { background: var(--accent-pale); border-color: var(--accent); }

.tree-wrap {
  padding: 18px 0 8px;
}

.tree-root {
  width: min(100%, 620px);
  margin: 0 auto 66px;
  padding: 27px 30px;
  text-align: center;
  background: var(--accent-pale);
  border-color: #9ec9c3;
  position: relative;
}

.tree-root::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  width: 1px;
  height: 67px;
  background: var(--line);
}

.tree-root h3 { margin: 9px 0 0; font-size: 1.35rem; }

.tree-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px 18px;
  position: relative;
}

.tree-grid::before {
  content: "";
  position: absolute;
  top: -1px;
  left: calc(16.6667% - 9px);
  right: calc(16.6667% - 9px);
  height: 1px;
  background: var(--line);
}

.tree-card {
  min-width: 0;
  padding: 28px 24px 25px;
  position: relative;
}

.tree-card::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  width: 1px;
  height: 29px;
  background: var(--line);
}

.tree-card.important { background: var(--accent-pale); border-color: #b4d7d2; }
.tree-card.auto { background: var(--auto); }

.tree-card h3 {
  margin: 14px 0 8px;
  font-size: 1.08rem;
  line-height: 1.45;
  word-break: break-word;
}

.tree-card p { margin: 0; color: var(--muted); font-size: .88rem; }
.tree-card .rule-note { margin-top: 10px; color: var(--accent-deep); font-size: .78rem; font-weight: 700; }

.cycle-flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 34px;
}

.cycle-card {
  min-width: 0;
  padding: 26px 24px;
  position: relative;
}

.cycle-card.auto { background: var(--auto); }
.cycle-card.important { background: var(--accent-pale); border-color: #b4d7d2; }

.cycle-card:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  left: calc(100% + 1px);
  width: 34px;
  height: 1px;
  background: var(--line);
}

.cycle-card:not(:last-child)::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: calc(50% - 4px);
  left: calc(100% + 27px);
  width: 7px;
  height: 7px;
  border-top: 1px solid var(--muted);
  border-right: 1px solid var(--muted);
  transform: rotate(45deg);
}

.cycle-card h3 { margin: 14px 0 8px; font-size: 1.05rem; line-height: 1.5; }
.cycle-card p { margin: 0; color: var(--muted); font-size: .87rem; }

.safety-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.safety-card { padding: 28px 26px; }
.safety-card:nth-child(3) { background: var(--accent-pale); border-color: #b4d7d2; }
.safety-card h3 { margin: 0 0 7px; color: var(--accent-deep); font-size: 1rem; }
.safety-card p { margin: 0; color: var(--muted); font-size: .86rem; }

/* AI terms guide */
.terms-page .site-header h1 { max-width: none; }

.term-definition {
  display: grid;
  grid-template-columns: minmax(260px, .9fr) minmax(0, 1.1fr);
  gap: clamp(28px, 5vw, 76px);
  align-items: center;
  margin-bottom: 42px;
  padding: clamp(30px, 4vw, 48px);
  border-top: 4px solid var(--accent);
}

.term-definition h3 {
  margin: 0;
  font-size: clamp(1.35rem, 2.3vw, 2.05rem);
  line-height: 1.45;
  letter-spacing: -.025em;
}

.term-definition p {
  margin: 0;
  font-size: clamp(.98rem, 1.3vw, 1.1rem);
}

.horizontal-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 40px;
  margin-bottom: 24px;
}

.term-flow-card {
  min-width: 0;
  padding: 26px 24px;
  position: relative;
}

.term-flow-card.auto { background: var(--auto); }
.term-flow-card.done { background: var(--accent-pale); border-color: #9ec9c3; }

.term-flow-card:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  left: calc(100% + 1px);
  width: 40px;
  height: 1px;
  background: var(--line);
}

.term-flow-card:not(:last-child)::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: calc(50% - 4px);
  left: calc(100% + 32px);
  width: 7px;
  height: 7px;
  border-top: 1px solid var(--muted);
  border-right: 1px solid var(--muted);
  transform: rotate(45deg);
}

.term-flow-card p {
  margin: 14px 0 0;
  font-weight: 700;
  line-height: 1.65;
}

.term-compare { margin-top: 24px; }

.agent-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 42px;
}

.agent-compare-card { padding: clamp(26px, 4vw, 42px); }
.agent-compare-card.featured { background: var(--accent-pale); border-color: #b4d7d2; }
.agent-compare-card.featured .compare-label { color: var(--accent-deep); }
.agent-compare-card p { margin: 0; font-weight: 700; }

.agent-process-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(220px, .75fr);
  gap: clamp(34px, 6vw, 82px);
  align-items: center;
  max-width: 980px;
  margin: 0 auto;
}

.agent-process { display: grid; gap: 24px; }

.agent-step {
  display: grid;
  grid-template-columns: 34px auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 78px;
  padding: 18px 22px;
  background: var(--auto);
  position: relative;
}

.agent-step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 38px;
  width: 1px;
  height: 24px;
  background: var(--line);
}

.agent-step:not(:last-child)::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: calc(100% + 16px);
  left: 34px;
  width: 7px;
  height: 7px;
  border-right: 1px solid var(--muted);
  border-bottom: 1px solid var(--muted);
  transform: rotate(45deg);
}

.step-number {
  color: var(--accent);
  font-family: Arial, sans-serif;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .08em;
}

.agent-step p { margin: 0; font-weight: 700; }

.agent-side-note {
  margin: 0;
  padding: 18px 0 18px 22px;
  color: var(--accent-deep);
  border-left: 1px solid var(--accent);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(1rem, 1.6vw, 1.2rem);
  font-style: italic;
  line-height: 1.9;
  transform: rotate(-.35deg);
}

.orchestration-flow { padding: 2px 0 14px; }

.orchestration-root,
.orchestration-result {
  width: min(100%, 650px);
  margin-inline: auto;
  padding: 28px 30px;
  text-align: center;
  position: relative;
}

.orchestration-root {
  margin-bottom: 64px;
  background: var(--accent-pale);
  border-color: #9ec9c3;
}

.orchestration-root::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  width: 1px;
  height: 65px;
  background: var(--line);
}

.orchestration-root p,
.orchestration-result p,
.branch-card p { margin: 13px 0 0; font-weight: 700; }

.orchestration-branches {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
  margin-bottom: 64px;
  position: relative;
}

.orchestration-branches::before,
.orchestration-branches::after {
  content: "";
  position: absolute;
  left: calc(16.6667% - 9px);
  right: calc(16.6667% - 9px);
  height: 1px;
  background: var(--line);
}

.orchestration-branches::before { top: -1px; }
.orchestration-branches::after { bottom: -1px; }

.branch-card {
  min-width: 0;
  min-height: 146px;
  padding: 27px 24px;
  background: var(--auto);
  position: relative;
}

.branch-card::before,
.branch-card::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 1px;
  height: 29px;
  background: var(--line);
}

.branch-card::before { bottom: 100%; }
.branch-card::after { top: 100%; }

.orchestration-result {
  background: var(--accent-pale);
  border-color: var(--accent);
}

.orchestration-result::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  width: 1px;
  height: 65px;
  background: var(--line);
}

.orchestration-result::after {
  content: "";
  position: absolute;
  z-index: 1;
  bottom: calc(100% + 1px);
  left: calc(50% - 4px);
  width: 7px;
  height: 7px;
  border-right: 1px solid var(--muted);
  border-bottom: 1px solid var(--muted);
  transform: rotate(45deg);
}

.terms-summary { padding-bottom: 18px; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.summary-card {
  padding: 25px 24px;
  border-top: 3px solid var(--accent);
}

.summary-card p { margin: 0; color: var(--accent-deep); font-size: .92rem; font-weight: 700; }

footer {
  padding: 25px clamp(24px, 5vw, 76px) 29px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: .78rem;
  text-align: right;
}

footer p { margin: 0; }

@media (max-width: 980px) {
  .tree-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tree-grid::before { left: calc(25% - 9px); right: calc(25% - 9px); }
  .cycle-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 34px; }
  .cycle-card:nth-child(2)::after,
  .cycle-card:nth-child(2)::before { display: none; }
  .horizontal-flow { gap: 28px; }
  .term-flow-card:not(:last-child)::after { width: 28px; }
  .term-flow-card:not(:last-child)::before { left: calc(100% + 20px); }
  .orchestration-branches { gap: 18px; }
}

@media (max-width: 640px) {
  body { font-size: 15px; }

  .page {
    width: min(100% - 16px, 1440px);
    margin: 8px auto;
  }

  .site-header { padding: 22px 18px 30px; }
  .back-link { margin-bottom: 26px; }
  h1 { font-size: 2.12rem; }
  .lead { line-height: 1.75; }
  main { padding: 0 18px 42px; }
  .section { padding: 50px 0; }

  .section-heading {
    grid-template-columns: 1fr;
    gap: 6px;
    margin-bottom: 25px;
  }

  .premise-card {
    grid-template-columns: 1fr;
    gap: 15px;
    padding: 27px 22px;
  }

  .flow-step {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
  }

  .phase-label {
    grid-column: 2;
    padding: 0 0 8px;
  }

  .flow-rail {
    grid-column: 1;
    grid-row: 1 / span 2;
  }

  .flow-dot { margin-top: 3px; }
  .flow-card { grid-column: 2; margin-bottom: 24px; padding: 23px 20px; }
  .hand-note { margin-top: 12px; padding-left: 16px; }
  .compare-grid { grid-template-columns: 1fr; }
  .legend { align-items: flex-start; flex-direction: column; gap: 10px; }
  .legend-title { margin-bottom: 4px; }

  .tree-root { margin-bottom: 32px; padding: 24px 20px; }
  .tree-root::after { height: 33px; }
  .tree-grid { grid-template-columns: 1fr; gap: 18px; }
  .tree-grid::before { display: none; }
  .tree-card { padding: 25px 21px 22px; }
  .tree-card::before { left: 20px; height: 19px; }

  .cycle-flow { grid-template-columns: 1fr; gap: 30px; }
  .cycle-card { padding: 24px 21px; }
  .cycle-card:not(:last-child)::after {
    top: 100%;
    left: 20px;
    width: 1px;
    height: 30px;
  }
  .cycle-card:not(:last-child)::before {
    top: calc(100% + 22px);
    left: 16px;
    transform: rotate(135deg);
  }
  .cycle-card:nth-child(2)::after,
  .cycle-card:nth-child(2)::before { display: block; }

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

  .term-definition {
    grid-template-columns: 1fr;
    gap: 14px;
    margin-bottom: 30px;
    padding: 27px 22px;
  }

  .horizontal-flow { grid-template-columns: 1fr; gap: 30px; }
  .term-flow-card { padding: 23px 20px; }
  .term-flow-card:not(:last-child)::after {
    top: 100%;
    left: 20px;
    width: 1px;
    height: 30px;
  }
  .term-flow-card:not(:last-child)::before {
    top: calc(100% + 22px);
    left: 16px;
    transform: rotate(135deg);
  }

  .agent-compare { grid-template-columns: 1fr; margin-bottom: 32px; }
  .agent-process-layout { grid-template-columns: 1fr; gap: 24px; }
  .agent-step { grid-template-columns: 28px auto minmax(0, 1fr); padding: 17px 18px; }
  .agent-side-note { margin-left: 10px; padding: 8px 0 8px 16px; }

  .orchestration-root { margin-bottom: 30px; padding: 25px 20px; }
  .orchestration-root::after { height: 31px; }
  .orchestration-branches { grid-template-columns: 1fr; gap: 30px; margin-bottom: 30px; }
  .orchestration-branches::before,
  .orchestration-branches::after { display: none; }
  .branch-card { min-height: 0; padding: 24px 20px; }
  .branch-card::before { left: 20px; height: 31px; }
  .branch-card::after { top: 100%; left: 20px; height: 30px; }
  .orchestration-result { padding: 25px 20px; }
  .orchestration-result::before { left: 20px; height: 31px; }
  .orchestration-result::after { left: 16px; }

  .summary-grid { grid-template-columns: 1fr; gap: 12px; }
  .summary-card { padding: 22px 20px; }
  footer { padding: 22px 18px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
