:root {
  --brand-blue: #0a84ff;
  --blue-700: #075bb8;
  --brand-green: #30d158;
  --green-700: #11845b;
  --ink: #0a0a0a;
  --body: #24303f;
  --muted: #667085;
  --border: #d9e0e7;
  --border-strong: #c7d0da;
  --canvas: #f5f7f9;
  --surface: #ffffff;
  --soft-blue: #eef6ff;
  --soft-green: #eaf8f0;
  --soft-amber: #fff7e8;
  --soft-red: #fdedec;
  --warning: #a96c08;
  --error: #b6433d;
  --font-sans:
    Inter, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--surface);
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--body);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.algorithm-visual {
  width: min(100%, 1920px);
  min-width: 0;
  margin-inline: auto;
  padding: clamp(26px, 2vw, 38px) clamp(24px, 4.15vw, 80px) 18px;
  background: var(--surface);
}

.visual-header {
  position: relative;
  max-width: 1500px;
}

.brand-line {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  color: var(--ink);
}

.brand-word {
  font-size: 25px;
  font-weight: 800;
  letter-spacing: 0.15em;
  line-height: 1;
}

.brand-dot {
  width: 8px;
  height: 8px;
  margin: -2px 0 0 7px;
  border-radius: 2px;
  background: var(--brand-green);
}

.kicker {
  margin: 0 0 12px;
  color: var(--blue-700);
  font-family: var(--font-mono);
  font-size: clamp(11px, 0.78vw, 14px);
  font-weight: 700;
  letter-spacing: 0.13em;
  line-height: 1.4;
}

.visual-header h1 {
  max-width: 1120px;
  margin: 0;
  color: var(--ink);
  font-size: clamp(35px, 2.3vw, 44px);
  font-weight: 780;
  letter-spacing: -0.045em;
  line-height: 1.16;
}

.visual-header h1 span {
  color: var(--blue-700);
}

.mobile-title-break {
  display: none;
}

.lead {
  max-width: 1120px;
  margin: 15px 0 0;
  color: var(--muted);
  font-size: clamp(14px, 0.96vw, 18px);
  line-height: 1.75;
}

.governed-flow {
  min-width: 0;
  margin: clamp(22px, 1.55vw, 30px) 0 0;
}

.macro-story {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  padding: 0 0 19px;
}

.macro-story::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(
    90deg,
    rgb(10 132 255 / 25%) 0%,
    var(--brand-blue) 63%,
    var(--brand-green) 100%
  );
  content: "";
}

.macro-story div {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.macro-story span {
  color: var(--blue-700);
  font-family: var(--font-mono);
  font-size: clamp(9px, 0.67vw, 12px);
  font-weight: 720;
  letter-spacing: 0.08em;
}

.macro-story div:last-child span {
  color: var(--green-700);
}

.macro-story strong {
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(13px, 0.84vw, 16px);
  font-weight: 720;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.focus-line {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: clamp(11px, 0.72vw, 13px);
  line-height: 1.55;
}

.focus-prefix {
  flex: 0 0 auto;
  color: var(--blue-700);
  font-family: var(--font-mono);
  font-weight: 720;
}

.focus-line strong {
  color: var(--body);
  font-weight: 720;
}

.focus-line [data-focus-detail] {
  margin-left: auto;
  text-align: right;
}

.journey {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin: 0;
  padding: 24px 0 0;
  list-style: none;
}

.journey::before {
  position: absolute;
  top: 76px;
  right: 2.1%;
  left: 2.1%;
  height: 2px;
  background: linear-gradient(
    90deg,
    rgb(10 132 255 / 25%) 0%,
    var(--brand-blue) 76%,
    var(--brand-green) 100%
  );
  content: "";
}

.stage {
  position: relative;
  min-width: 0;
  border-right: 1px solid var(--border);
  transition: opacity 200ms ease;
}

.stage:last-child {
  border-right: 0;
}

.stage-trigger {
  display: grid;
  width: 100%;
  min-height: 344px;
  grid-template-rows: auto 28px 76px auto auto auto auto auto;
  gap: 0;
  align-content: start;
  padding: 0 clamp(13px, 1.25vw, 24px);
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.stage:first-child .stage-trigger {
  padding-left: 0;
}

.stage:last-child .stage-trigger {
  padding-right: 0;
}

.stage-trigger:focus-visible {
  outline: 3px solid rgb(10 132 255 / 35%);
  outline-offset: -3px;
}

.stage-number {
  min-height: 28px;
  color: var(--blue-700);
  font-family: var(--font-mono);
  font-size: clamp(9px, 0.64vw, 12px);
  font-weight: 720;
  line-height: 1.4;
}

.stage-trust .stage-number {
  color: var(--green-700);
}

.stage-node {
  position: relative;
  z-index: 2;
  display: block;
  width: 22px;
  height: 22px;
  align-self: center;
  margin-left: 0;
  border: 4px solid var(--brand-blue);
  border-radius: 50%;
  background: var(--surface);
  transition:
    transform 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.stage-trust .stage-node {
  border-color: var(--brand-green);
}

.stage-icon {
  display: block;
  width: min(100%, 170px);
  height: 72px;
  align-self: center;
  overflow: visible;
}

.icon-blue-soft {
  fill: var(--soft-blue);
  stroke: var(--brand-blue);
  stroke-width: 1.4;
}

.icon-green-soft {
  fill: var(--soft-green);
  stroke: var(--brand-green);
  stroke-width: 1.4;
}

.icon-neutral,
.icon-paper {
  fill: var(--surface);
  stroke: var(--border-strong);
  stroke-width: 1.5;
}

.icon-line-blue,
.icon-line,
.icon-line-green {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-line-blue {
  stroke: var(--brand-blue);
}

.icon-line {
  stroke: var(--muted);
}

.icon-line-green {
  stroke: var(--green-700);
}

.icon-check {
  fill: none;
  stroke: var(--blue-700);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-thick {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 4;
  stroke-linecap: round;
}

.icon-point {
  fill: var(--surface);
  stroke: var(--muted);
  stroke-width: 1.7;
}

.icon-point-blue-soft {
  fill: var(--soft-blue);
  stroke: var(--brand-blue);
  stroke-width: 1.7;
}

.icon-point-blue {
  fill: var(--brand-blue);
  stroke: none;
}

.icon-point-green {
  fill: var(--brand-green);
  stroke: none;
}

.icon-point-amber {
  fill: var(--warning);
  stroke: none;
}

.icon-point-red {
  fill: var(--error);
  stroke: none;
}

.icon-path-blue,
.icon-path-amber,
.icon-path-red {
  fill: none;
  stroke-width: 2.6;
  stroke-linecap: round;
}

.icon-path-blue {
  stroke: var(--brand-blue);
}

.icon-path-amber {
  stroke: var(--warning);
}

.icon-path-red {
  stroke: var(--error);
  stroke-dasharray: 6 6;
}

.icon-person {
  fill: var(--surface);
  stroke: var(--brand-blue);
  stroke-width: 1.7;
}

.icon-person-body {
  fill: var(--soft-blue);
  stroke: var(--brand-blue);
  stroke-width: 1.7;
}

.stage-title {
  margin-top: 7px;
  color: var(--ink);
  font-size: clamp(16px, 1.15vw, 22px);
  font-weight: 760;
  letter-spacing: -0.025em;
  line-height: 1.35;
}

.stage-copy {
  min-height: 57px;
  margin-top: 9px;
  color: var(--body);
  font-size: clamp(12px, 0.77vw, 15px);
  line-height: 1.7;
}

.stage-detail {
  margin-top: 5px;
  color: var(--muted);
  font-size: clamp(10px, 0.68vw, 13px);
  line-height: 1.45;
}

.stage-tech {
  margin-top: 12px;
  color: var(--blue-700);
  font-family: var(--font-mono);
  font-size: clamp(9px, 0.64vw, 12px);
  font-weight: 720;
  line-height: 1.45;
}

.stage-tech-warning {
  color: var(--warning);
  font-family: var(--font-sans);
}

.stage-tech-trust {
  color: var(--green-700);
  font-family: var(--font-sans);
}

.journey[data-has-active="true"] .stage:not(.is-active) {
  opacity: 0.38;
}

.stage.is-active {
  opacity: 1;
}

.stage.is-active .stage-node {
  transform: scale(1.18);
  background: var(--brand-blue);
  box-shadow: 0 0 0 7px rgb(10 132 255 / 10%);
}

.stage-trust.is-active .stage-node {
  background: var(--brand-green);
  box-shadow: 0 0 0 7px rgb(48 209 88 / 12%);
}

.stage.is-active .stage-title {
  color: var(--blue-700);
}

.stage-trust.is-active .stage-title {
  color: var(--green-700);
}

.gate-rail {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin: 0 0 14px;
  padding: 11px 0 12px;
  border-block: 1px solid var(--border);
  list-style: none;
}

.gate-rail::before {
  position: absolute;
  top: 26px;
  right: 3%;
  left: 3%;
  height: 1px;
  background: linear-gradient(
    90deg,
    rgb(10 132 255 / 26%),
    var(--brand-blue),
    var(--brand-green)
  );
  content: "";
}

.gate-rail li {
  position: relative;
  z-index: 1;
  display: grid;
  min-width: 0;
  justify-items: start;
  gap: 2px;
  padding: 0 clamp(10px, 1vw, 19px);
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.gate-rail li:first-child {
  padding-left: 0;
}

.gate-rail li:last-child {
  padding-right: 0;
  border-right: 0;
}

.gate-rail span {
  padding-right: 7px;
  background: var(--surface);
  color: var(--blue-700);
  font-family: var(--font-mono);
  font-size: clamp(8px, 0.54vw, 10px);
  font-weight: 720;
  letter-spacing: 0.06em;
}

.gate-rail li:last-child span {
  color: var(--green-700);
}

.gate-rail strong {
  margin-top: 7px;
  color: var(--body);
  font-size: clamp(12px, 0.74vw, 14px);
  font-weight: 740;
  line-height: 1.35;
}

.gate-rail small {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: clamp(10px, 0.63vw, 12px);
  line-height: 1.4;
}

.governance-band {
  display: grid;
  grid-template-columns: minmax(230px, 0.72fr) minmax(520px, 1.75fr);
  gap: 16px 38px;
  padding: clamp(20px, 1.6vw, 30px);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--canvas);
}

.governance-band header h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(17px, 1.04vw, 20px);
  font-weight: 760;
  line-height: 1.4;
}

.governance-band header p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: clamp(11px, 0.68vw, 13px);
  line-height: 1.6;
}

.guardrails {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.guardrails li {
  position: relative;
  min-width: 0;
  padding-left: 17px;
}

.guardrails li::before {
  position: absolute;
  top: 7px;
  left: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-blue);
  content: "";
}

.guardrails li:last-child::before {
  background: var(--brand-green);
}

.guardrails strong,
.guardrails span {
  display: block;
}

.guardrails strong {
  color: var(--body);
  font-size: clamp(12px, 0.74vw, 14px);
  font-weight: 740;
  line-height: 1.5;
}

.guardrails span {
  margin-top: 4px;
  color: var(--muted);
  font-size: clamp(10px, 0.63vw, 12px);
  line-height: 1.5;
}

.outcome-rule {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.outcome-rule p {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 0;
  white-space: nowrap;
}

.outcome-rule p span {
  color: var(--muted);
  font-size: clamp(11px, 0.68vw, 13px);
}

.outcome-rule p strong {
  color: var(--body);
  font-size: clamp(12px, 0.74vw, 14px);
}

.outcome-rule p b {
  color: var(--muted);
}

.outcome-rule ul {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.outcome-rule li {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: clamp(11px, 0.68vw, 13px);
  font-weight: 720;
  line-height: 1.4;
}

.is-success {
  background: var(--soft-green);
  color: var(--green-700);
}

.is-failure {
  background: var(--soft-red);
  color: var(--error);
}

.is-returned,
.is-unknown {
  background: var(--soft-amber);
  color: var(--warning);
}

.no-retry {
  justify-self: end;
  color: var(--error);
  font-size: clamp(12px, 0.74vw, 14px);
  line-height: 1.5;
  text-align: right;
}

.return-line {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  color: var(--blue-700);
  font-size: clamp(10px, 0.68vw, 13px);
  line-height: 1.5;
  text-align: center;
}

.return-line::before,
.return-line::after {
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, var(--brand-blue), var(--brand-green));
  content: "";
}

.return-line::after {
  background: linear-gradient(90deg, var(--brand-green), var(--brand-blue));
}

.return-arrow {
  font-size: 26px;
  line-height: 1;
}

.return-line strong {
  font-family: var(--font-mono);
  font-weight: 720;
  letter-spacing: 0.05em;
}

.visual-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.5;
}

.visual-footer p {
  margin: 0;
}

@media (max-width: 1540px) {
  .algorithm-visual {
    padding-top: 18px;
  }

  .visual-header h1 {
    font-size: 36px;
  }

  .governed-flow {
    margin-top: 12px;
  }

  .journey {
    padding-top: 18px;
  }

  .journey::before {
    top: 67px;
  }

  .stage-trigger {
    min-height: 290px;
    grid-template-rows: auto 24px 62px auto auto auto auto auto;
    padding-inline: 15px;
  }

  .stage-icon {
    height: 58px;
  }

  .stage-copy {
    min-height: 52px;
  }

  .governance-band {
    padding: 14px 22px;
  }

  .gate-rail {
    padding-block: 9px 10px;
  }
}

@media (max-width: 1180px) {
  .brand-line {
    display: none;
  }

  .macro-story {
    grid-template-columns: repeat(2, 1fr);
    row-gap: 12px;
  }

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

  .journey::before {
    display: none;
  }

  .stage {
    border-bottom: 1px solid var(--border);
  }

  .stage:nth-child(3) {
    border-right: 0;
  }

  .stage:nth-child(n + 4) {
    border-bottom: 0;
    padding-top: 20px;
  }

  .stage-trigger {
    min-height: 388px;
    grid-template-rows: auto 28px 82px auto auto auto auto auto;
  }

  .stage:first-child .stage-trigger,
  .stage:last-child .stage-trigger {
    padding-inline: 15px;
  }

  .stage-node {
    margin-left: 0;
  }

  .gate-rail {
    grid-template-columns: repeat(3, 1fr);
  }

  .gate-rail::before {
    display: none;
  }

  .gate-rail li {
    padding: 9px 14px;
    border-bottom: 1px solid var(--border);
  }

  .gate-rail li:first-child {
    padding-left: 14px;
  }

  .gate-rail li:nth-child(3) {
    border-right: 0;
  }

  .gate-rail li:nth-child(n + 4) {
    border-bottom: 0;
  }

  .gate-rail li:last-child {
    padding-right: 14px;
  }

  .gate-rail strong {
    margin-top: 2px;
  }

  .governance-band {
    grid-template-columns: 1fr;
  }

  .guardrails {
    grid-template-columns: repeat(3, 1fr);
  }

  .outcome-rule {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .no-retry {
    justify-self: start;
    text-align: left;
  }
}

@media (max-width: 700px) {
  .algorithm-visual {
    padding: 28px 20px 22px;
  }

  .kicker {
    font-size: 10px;
  }

  .visual-header h1 {
    font-size: 32px;
    line-height: 1.2;
  }

  .mobile-title-break {
    display: block;
  }

  .lead {
    margin-top: 14px;
    font-size: 14px;
    line-height: 1.75;
  }

  .macro-story {
    grid-template-columns: 1fr;
    gap: 7px;
    padding-left: 19px;
  }

  .macro-story::after {
    top: 5px;
    right: auto;
    bottom: 5px;
    left: 0;
    width: 3px;
    height: auto;
    background: linear-gradient(
      180deg,
      rgb(10 132 255 / 25%) 0%,
      var(--brand-blue) 63%,
      var(--brand-green) 100%
    );
  }

  .macro-story div {
    align-items: center;
  }

  .macro-story strong {
    overflow: visible;
    font-size: 14px;
    text-overflow: clip;
    white-space: normal;
  }

  .focus-line {
    display: grid;
    gap: 3px;
    padding: 12px 0;
  }

  .focus-line [data-focus-detail] {
    margin-left: 0;
    text-align: left;
  }

  .journey {
    display: block;
    padding: 0 0 0 28px;
  }

  .journey::after {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 10px;
    width: 2px;
    background: linear-gradient(
      180deg,
      rgb(10 132 255 / 28%),
      var(--brand-blue) 75%,
      var(--brand-green)
    );
    content: "";
  }

  .stage,
  .stage:nth-child(3),
  .stage:nth-child(n + 4) {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding-top: 0;
  }

  .stage:last-child {
    border-bottom: 0;
  }

  .stage-trigger,
  .stage:first-child .stage-trigger,
  .stage:last-child .stage-trigger {
    min-height: 0;
    grid-template-rows: auto auto;
    grid-template-columns: minmax(0, 1fr) 96px;
    column-gap: 12px;
    padding: 23px 0 23px 13px;
  }

  .stage-number,
  .stage-title,
  .stage-copy,
  .stage-detail,
  .stage-tech {
    grid-column: 1;
  }

  .stage-number {
    min-height: 0;
  }

  .stage-node {
    position: absolute;
    top: 29px;
    left: -26px;
    width: 18px;
    height: 18px;
    border-width: 3px;
  }

  .stage-icon {
    grid-column: 2;
    grid-row: 1 / span 7;
    width: 96px;
    height: 80px;
    align-self: start;
  }

  .stage-title {
    margin-top: 7px;
    font-size: 19px;
  }

  .stage-copy {
    min-height: 0;
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.7;
  }

  .stage-detail {
    margin-top: 4px;
    font-size: 11px;
  }

  .stage-tech {
    margin-top: 9px;
    font-size: 10px;
  }

  .journey[data-has-active="true"] .stage:not(.is-active) {
    opacity: 0.55;
  }

  .gate-rail {
    display: block;
    margin-left: 28px;
    border-top: 0;
  }

  .gate-rail li,
  .gate-rail li:first-child,
  .gate-rail li:last-child,
  .gate-rail li:nth-child(n + 4) {
    display: grid;
    grid-template-columns: 58px 1fr;
    gap: 2px 8px;
    padding: 10px 0;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .gate-rail li:last-child {
    border-bottom: 0;
  }

  .gate-rail span {
    grid-row: 1 / span 2;
    padding-right: 0;
    background: transparent;
  }

  .gate-rail strong {
    margin-top: 0;
    font-size: 11px;
  }

  .gate-rail small {
    font-size: 9px;
  }

  .governance-band {
    gap: 18px;
    padding: 22px 20px;
  }

  .governance-band header h2 {
    font-size: 18px;
  }

  .governance-band header p {
    font-size: 12px;
  }

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

  .guardrails strong {
    font-size: 13px;
  }

  .guardrails span {
    font-size: 11px;
  }

  .outcome-rule p {
    flex-wrap: wrap;
  }

  .no-retry {
    font-size: 12px;
  }

  .return-line {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 3px 7px;
    padding: 14px 0;
    text-align: left;
  }

  .return-line::before,
  .return-line::after {
    display: none;
  }

  .return-line span:last-child {
    grid-column: 2;
  }

  .visual-footer {
    display: grid;
    gap: 6px;
    font-size: 9px;
  }
}

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