:root {
  --bg: #f1f3f2;
  --panel: #ffffff;
  --ink: #111315;
  --muted: #687076;
  --line: #d9dfdc;
  --soft: #eef3f1;
  --accent: #087f6f;
  --accent-2: #d04f32;
  --accent-3: #2e5aac;
  --done: #141414;
  --shadow: 0 22px 60px rgba(16, 24, 32, .12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

body {
  background:
    radial-gradient(circle at 12% 8%, rgba(8, 127, 111, .14), transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(46, 90, 172, .12), transparent 30%),
    linear-gradient(315deg, rgba(208, 79, 50, .08), transparent 34%),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC", "Noto Sans TC", "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.page {
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

.hud {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 142px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .84);
  backdrop-filter: blur(14px) saturate(150%);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 750;
  box-shadow: 0 12px 34px rgba(16, 24, 32, .12);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(8, 127, 111, .14);
}

.workspace {
  width: 100%;
  height: 100vh;
  min-width: 0;
  overflow: hidden;
}

.controls {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(760px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(12px) saturate(150%);
  border-radius: 8px;
  box-shadow: 0 10px 32px rgba(22, 30, 38, .08);
  transform: translateX(-50%);
}

.control {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 760;
  cursor: pointer;
}

.control--primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.control:disabled {
  opacity: .42;
  cursor: default;
}

.progress {
  flex: 1;
  min-width: 120px;
  height: 8px;
  background: var(--soft);
  border-radius: 999px;
  overflow: hidden;
}

.progress__bar {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-3), var(--accent-2));
  border-radius: inherit;
  transition: width .32s ease;
}

.counter {
  min-width: 62px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
  text-align: right;
}

.stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: auto;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background:
    linear-gradient(rgba(17, 19, 21, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 19, 21, .035) 1px, transparent 1px),
    rgba(255, 255, 255, .90);
  background-size: 36px 36px;
}

.stage__canvas {
  position: relative;
  width: 1120px;
  height: 820px;
}

.links {
  position: absolute;
  inset: 0;
  width: 1120px;
  height: 820px;
  pointer-events: none;
}

.flow-link {
  fill: none;
  stroke: #b7c0bd;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 8 8;
  opacity: .54;
  transition: stroke .25s ease, opacity .25s ease, stroke-width .25s ease;
}

.flow-link.is-active {
  stroke: var(--accent);
  stroke-width: 3;
  opacity: .96;
  animation: linkTravel 1.1s linear infinite;
}

.flow-link.is-done {
  stroke: var(--done);
  stroke-dasharray: 0;
  opacity: .42;
}

.node {
  position: absolute;
  width: 174px;
  min-height: 68px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  display: grid;
  align-content: center;
  gap: 5px;
  color: var(--muted);
  box-shadow: 0 10px 26px rgba(18, 25, 32, .08);
  opacity: .58;
  transform: scale(.96);
  transform-origin: center;
  transition: transform .28s ease, opacity .28s ease, border-color .28s ease, background .28s ease, color .28s ease, filter .28s ease;
}

.node__label {
  color: inherit;
  font-size: 14px;
  line-height: 1.25;
  font-weight: 820;
}

.node__tag {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
}

.node.is-done {
  opacity: .72;
  color: var(--ink);
  border-color: #bec7c3;
  background: #fbfcfc;
  transform: scale(1);
}

.node.is-active {
  z-index: 6;
  opacity: 1;
  color: var(--ink);
  border-color: var(--accent);
  background: #f8fffd;
  transform: scale(1.18);
  filter: saturate(1.08);
  animation: nodePulse 1.15s ease-in-out infinite;
}

.node-detail {
  position: absolute;
  z-index: 5;
  width: 300px;
  min-height: 164px;
  padding: 16px;
  border: 1px solid rgba(8, 127, 111, .32);
  background: rgba(255, 255, 255, .96);
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(18, 25, 32, .18);
  display: grid;
  gap: 10px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: left .28s ease, top .28s ease, opacity .22s ease, transform .22s ease;
}

.node-detail.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.node-detail__kicker {
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.node-detail h3 {
  margin: 0;
  color: var(--ink);
  font-size: 21px;
  line-height: 1.22;
}

.node-detail p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.node-detail__script {
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  font-weight: 650;
}

.node.is-decision {
  border-radius: 18px 4px 18px 4px;
  background: #fffaf7;
}

.node.is-finish {
  background: #111315;
  border-color: #111315;
  color: #fff;
}

.node.is-finish .node__tag {
  color: rgba(255, 255, 255, .72);
}

@keyframes nodePulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(8, 127, 111, .28), 0 18px 34px rgba(18, 25, 32, .12);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(8, 127, 111, 0), 0 18px 34px rgba(18, 25, 32, .12);
  }
}

@keyframes linkTravel {
  to {
    stroke-dashoffset: -32;
  }
}

@media (max-width: 980px) {
  .hud {
    top: 12px;
    left: 12px;
  }
}

@media (max-width: 640px) {
  .controls {
    bottom: 12px;
    flex-wrap: wrap;
  }

  .control {
    flex: 1 1 42%;
  }

  .progress {
    flex-basis: calc(100% - 78px);
  }

  .node-detail {
    width: 260px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
  }
}
