/* ---------- tokens ---------- */
  .sb-pipe {
    --bg: #eaeff4;
    --panel: #ffffff;
    --panel-2: #f6f9fc;
    --ink: #16202e;
    --muted: #5c6a7a;
    --faint: #93a0af;
    --line: #dbe2ea;
    --line-hi: #c5d0db;
    --signal: #0d9488;
    --signal-2: #3aa9a0;
    --signal-3: #86c9c3;
    --insight: #d97706;
    --alert: #dc2626;
    --ok: #16a34a;
    --shadow: rgba(23, 45, 77, 0.12);
    --r: 14px;
    --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
    --sans: "Archivo", system-ui, sans-serif;
    --conn-w: clamp(34px, 3.6vw, 72px);
    --gap-rows: clamp(44px, 5vw, 72px);
  }
  .sb-pipe.dark {
    --bg: #0b1119;
    --panel: #141d29;
    --panel-2: #101724;
    --ink: #eef3f8;
    --muted: #93a3b5;
    --faint: #5f7182;
    --line: #253345;
    --line-hi: #33465d;
    --signal: #2dd4c4;
    --signal-2: #5fe0d2;
    --signal-3: #9be9de;
    --insight: #f5a524;
    --alert: #ff5d5d;
    --ok: #34d399;
    --shadow: rgba(0, 0, 0, 0.55);
  }

  body {
    margin: 0;
    background: transparent;
  }

  /* ---------- container (embeddable: sizes to content, no viewport lock) ---------- */
  .sb-pipe {
    position: relative;
    font-family: var(--sans);
    color: var(--ink);
    font-size: 13px;
    line-height: 1.35;
    padding: clamp(18px, 2.4vw, 34px);
    border-radius: 22px;
    background:
      radial-gradient(900px 520px at 10% -10%, #ffffff 0%, transparent 55%),
      radial-gradient(900px 560px at 108% 118%, #fdf3e6 0%, transparent 55%),
      var(--bg);
    overflow: hidden;
  }
  .sb-pipe.transparent {
    background: transparent;
    padding: 0;
    border-radius: 0;
  }
  .sb-pipe.dark {
    background:
      radial-gradient(
        900px 520px at 10% -10%,
        rgba(45, 212, 196, 0.1) 0%,
        transparent 55%
      ),
      radial-gradient(
        900px 560px at 108% 118%,
        rgba(245, 165, 36, 0.1) 0%,
        transparent 55%
      ),
      var(--bg);
  }
  .sb-pipe.dark::before {
    background-image:
      linear-gradient(to right, rgba(180, 200, 220, 0.05) 1px, transparent 1px),
      linear-gradient(to bottom, rgba(180, 200, 220, 0.05) 1px, transparent 1px);
  }
  .sb-pipe::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
      linear-gradient(to right, rgba(20, 45, 70, 0.045) 1px, transparent 1px),
      linear-gradient(to bottom, rgba(20, 45, 70, 0.045) 1px, transparent 1px);
    background-size: 52px 52px;
    mask-image: radial-gradient(
      1000px 640px at 50% 45%,
      #000 35%,
      transparent 90%
    );
    -webkit-mask-image: radial-gradient(
      1000px 640px at 50% 45%,
      #000 35%,
      transparent 90%
    );
  }
  .sb-pipe.transparent::before {
    display: none;
  }
  .sb-pipe * {
    box-sizing: border-box;
  }

  .rows {
    position: relative;
    display: flex;
    flex-direction: column;
  }
  .row {
    display: flex;
    align-items: stretch;
    width: 100%;
    position: relative;
  }
  .row.r1 {
    margin-bottom: var(--gap-rows);
  }
  .row.r2 {
    flex-direction: row-reverse;
  }

  /* ---------- node ---------- */
  .node {
    flex: 1 1 0;
    min-width: 0;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, var(--panel), var(--panel-2));
    border: 1.5px solid var(--line);
    border-radius: var(--r);
    padding: clamp(12px, 1.2vw, 18px);
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 10px 26px -16px var(--shadow);
  }
  .node::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 45%;
    left: -55%;
    pointer-events: none;
    background: linear-gradient(
      90deg,
      transparent,
      rgba(13, 148, 136, 0.09),
      transparent
    );
    animation: scan 3.6s ease-in-out infinite;
  }
  .r2 .node::after {
    background: linear-gradient(
      90deg,
      transparent,
      rgba(217, 119, 6, 0.1),
      transparent
    );
  }
  @keyframes scan {
    0% {
      left: -55%;
    }
    55% {
      left: 115%;
    }
    100% {
      left: 115%;
    }
  }

  .nhead {
    display: flex;
    align-items: flex-start;
    gap: 10px;
  }
  .ico {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    flex: none;
    border: 1.5px solid var(--line-hi);
    background: var(--panel-2);
    color: var(--signal);
  }
  .r2 .ico {
    color: var(--insight);
  }
  .r2 .node.data .ico {
    color: var(--signal);
  }
  .r2 .node.data::after {
    background: linear-gradient(
      90deg,
      transparent,
      rgba(13, 148, 136, 0.09),
      transparent
    );
  }
  .ico .num {
    position: absolute;
    left: -7px;
    top: -7px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: var(--ink);
    color: #fff;
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    display: grid;
    place-items: center;
    line-height: 1;
  }
  .sb-pipe.dark .ico .num {
    background: #eef3f8;
    color: #0b1119;
  }
  .ico {
    position: relative;
  }
  .ico svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .ttl {
    flex: 1;
    min-width: 0;
  }
  .ttl h3 {
    margin: 0;
    font-size: clamp(14px, 1.15vw, 17px);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.01em;
  }
  .ttl p {
    margin: 3px 0 0;
    font-size: 12px;
    color: var(--muted);
  }
  .where {
    flex: none;
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--muted);
    border: 1px solid var(--line-hi);
    border-radius: 20px;
    padding: 3px 8px;
    white-space: nowrap;
    background: var(--panel);
  }
  .where::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 6px;
    background: var(--signal);
    vertical-align: 1px;
  }
  .where.cloud::before {
    background: linear-gradient(135deg, var(--signal), var(--insight));
  }
  .where.team::before {
    background: var(--insight);
  }

  .chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .chips span {
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--muted);
    border: 1px solid var(--line-hi);
    border-radius: 6px;
    padding: 3px 8px;
    background: var(--panel);
  }
  .chips span.on {
    color: var(--signal);
    border-color: var(--signal);
    background: rgba(13, 148, 136, 0.06);
  }

  .kv {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 14px;
    font-family: var(--mono);
    font-size: 12.5px;
  }
  .kv div {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: var(--muted);
    border-bottom: 1px dotted var(--line-hi);
    padding-bottom: 4px;
    white-space: nowrap;
  }
  .kv b {
    color: var(--signal);
    font-weight: 600;
  }

  .line {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--muted);
    border-top: 1px dashed var(--line-hi);
    padding-top: 8px;
    margin-top: auto;
    min-height: 0;
  }
  .line .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--signal);
    flex: none;
    animation: beat 2.2s infinite;
  }
  .line .dot.warn {
    background: var(--insight);
  }
  .line b {
    color: var(--ink);
    font-weight: 600;
  }
  @keyframes beat {
    0% {
      box-shadow: 0 0 0 0 rgba(13, 148, 136, 0.45);
    }
    70% {
      box-shadow: 0 0 0 7px rgba(13, 148, 136, 0);
    }
    100% {
      box-shadow: 0 0 0 0 rgba(13, 148, 136, 0);
    }
  }

  /* canvases */
  .scope {
    position: relative;
    border: 1.5px solid var(--line-hi);
    border-radius: 10px;
    background: #0f1b2a;
    overflow: hidden;
  }
  .sb-pipe.dark .scope {
    background: #060a10;
    border-color: #22303f;
  }
  .scope canvas {
    display: block;
    width: 100%;
    height: 100%;
  }
  .scope .cap {
    position: absolute;
    left: 9px;
    top: 6px;
    font-family: var(--mono);
    font-size: 10.5px;
    color: #9fc7c2;
    letter-spacing: 0.03em;
  }
  .scope .axes {
    position: absolute;
    right: 9px;
    top: 6px;
    font-family: var(--mono);
    font-size: 10.5px;
    display: flex;
    gap: 7px;
  }
  .scope .axes i {
    font-style: normal;
  }
  .scope .axes .x {
    color: #16c4b2;
  }
  .scope .axes .y {
    color: #7fd6cd;
  }
  .scope .axes .z {
    color: #c4ebe7;
  }
  .wave {
    height: 86px;
  }
  .spec {
    height: 70px;
  }
  .scope .peaks {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 3px;
    font-family: var(--mono);
    font-size: 9.5px;
    color: #7f9aa8;
    display: flex;
    justify-content: space-around;
    padding: 0 6%;
  }

  .tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .tags em {
    font-style: normal;
    font-size: 12px;
    color: var(--muted);
    background: var(--panel-2);
    border: 1px solid var(--line-hi);
    border-radius: 20px;
    padding: 3px 10px;
  }

  /* ---------- hero (PIAI) ---------- */
  .node.hero {
    border-color: #ecc79a;
    background: linear-gradient(180deg, #fffaf2, #fff4e4);
    box-shadow:
      0 16px 40px -20px rgba(217, 119, 6, 0.45),
      0 0 0 1px rgba(217, 119, 6, 0.1);
  }
  .hero .ico {
    border-color: #ecc79a;
    background: #fff;
    position: relative;
  }
  .sb-pipe.dark .node.hero {
    border-color: #6b4a1e;
    background: linear-gradient(180deg, #1c1608, #171310);
    box-shadow:
      0 16px 40px -20px rgba(245, 165, 36, 0.35),
      0 0 0 1px rgba(245, 165, 36, 0.14);
  }
  .sb-pipe.dark .hero .ico {
    border-color: #6b4a1e;
    background: #171310;
  }
  .body {
    display: flex;
    gap: 12px;
    align-items: stretch;
    flex: 1;
    min-height: 0;
  }
  .core {
    flex: none;
    width: clamp(104px, 10vw, 136px);
    align-self: center;
    position: relative;
  }
  .core canvas {
    display: block;
    width: 100%;
    aspect-ratio: 1;
  }
  .core .cap {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -16px;
    text-align: center;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--faint);
    white-space: nowrap;
  }
  .steps {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 3px;
  }
  .step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    min-width: 0;
  }
  .step .k {
    width: 7px;
    height: 7px;
    border-radius: 2px;
    flex: none;
    background: linear-gradient(135deg, var(--signal), var(--insight));
  }
  .step b {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.15;
    white-space: nowrap;
  }
  .step small {
    display: block;
    font-size: 11px;
    color: var(--muted);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ---------- output ---------- */
  .node.out {
    border-color: #ecc79a;
  }
  .sb-pipe.dark .node.out {
    border-color: #6b4a1e;
  }
  .diag {
    border: 1.5px solid var(--line-hi);
    border-radius: 11px;
    padding: 11px 13px;
    background: var(--panel);
    display: flex;
    flex-direction: column;
    gap: 7px;
    transition: all 0.5s;
    flex: 1;
    min-height: 168px;
  }
  .diag .top {
    display: flex;
    align-items: center;
    gap: 9px;
  }
  .diag .sig {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--ok);
    flex: none;
    transition: background 0.5s;
  }
  .diag .state {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--ok);
    letter-spacing: 0.02em;
    transition: color 0.5s;
  }
  .diag .conf {
    margin-left: auto;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--faint);
    display: none;
  }
  .diag h4 {
    margin: 0;
    font-size: clamp(14px, 1.2vw, 17px);
    font-weight: 700;
    line-height: 1.15;
    color: var(--ink);
    letter-spacing: -0.01em;
  }
  .diag .rows2 {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 10px;
    font-size: 11.5px;
    line-height: 1.3;
  }
  .diag .lab {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--faint);
    padding-top: 2px;
  }
  .diag .val {
    color: var(--ink);
  }
  .diag .val b {
    font-weight: 600;
  }
  .diag .rows2,
  .diag .conf {
    display: none;
  }
  .diag .quiet {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
    margin-top: auto;
  }
  .diag.on {
    border-color: rgba(220, 38, 38, 0.5);
    background: #fff7f5;
  }
  .sb-pipe.dark .diag.on {
    border-color: rgba(255, 93, 93, 0.55);
    background: #241012;
  }
  .diag.on .sig {
    background: var(--alert);
    animation: beatr 1.2s infinite;
  }
  .diag.on .state {
    color: var(--alert);
  }
  .diag.on .rows2 {
    display: grid;
  }
  .diag.on .conf {
    display: block;
  }
  .diag.on .quiet {
    display: none;
  }
  @keyframes beatr {
    0% {
      box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5);
    }
    70% {
      box-shadow: 0 0 0 7px rgba(220, 38, 38, 0);
    }
    100% {
      box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
    }
  }

  .ind {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }
  .ind > div {
    background: var(--panel-2);
    border: 1px solid var(--line-hi);
    border-radius: 8px;
    padding: 6px 8px;
    min-width: 0;
  }
  .ind .k {
    font-size: 10px;
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
  }
  .ind .v {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--insight);
    margin-top: 2px;
    white-space: nowrap;
    transition: color 0.5s;
  }
  .ind .v small {
    font-size: 10px;
    color: var(--muted);
    font-weight: 500;
    margin-left: 2px;
  }
  .ind > div.warn {
    border-color: rgba(220, 38, 38, 0.45);
  }
  .ind > div.warn .v {
    color: var(--alert);
  }

  /* ---------- connectors ---------- */
  .conn {
    flex: 0 0 var(--conn-w);
    position: relative;
    align-self: center;
    height: 60px;
  }
  .conn .wire {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2.5px;
    transform: translateY(-50%);
    background: linear-gradient(
      90deg,
      transparent,
      var(--line-hi) 30%,
      var(--line-hi) 70%,
      transparent
    );
  }
  .conn .lbl {
    position: absolute;
    top: calc(50% - 24px);
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--faint);
    white-space: nowrap;
    letter-spacing: 0.03em;
  }
  .conn .p {
    position: absolute;
    top: 50%;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: flow 2.4s linear infinite;
  }
  @keyframes flow {
    0% {
      left: -8%;
      opacity: 0;
    }
    12% {
      opacity: 1;
    }
    88% {
      opacity: 1;
    }
    100% {
      left: 108%;
      opacity: 0;
    }
  }
  .conn.sig .p {
    background: var(--signal);
    box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.14);
  }
  .conn.ins .p {
    background: var(--insight);
    box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.16);
  }
  .r2 .conn .p {
    animation-direction: reverse;
  }

  .elbow {
    position: absolute;
    top: 100%;
    right: 13%;
    width: 14px;
    height: var(--gap-rows);
    z-index: 2;
  }
  .elbow .vwire {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2.5px;
    transform: translateX(-50%);
    background: linear-gradient(
      180deg,
      transparent,
      var(--line-hi) 25%,
      var(--line-hi) 75%,
      transparent
    );
  }
  .elbow .p {
    position: absolute;
    left: 50%;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: var(--signal);
    box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.14);
    animation: vflow 2.4s linear infinite;
  }
  @keyframes vflow {
    0% {
      top: -6%;
      opacity: 0;
    }
    14% {
      opacity: 1;
    }
    86% {
      opacity: 1;
    }
    100% {
      top: 106%;
      opacity: 0;
    }
  }
  .elbow .arrow {
    position: absolute;
    left: 50%;
    bottom: -2px;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid var(--signal);
  }

  /* ---------- legend ---------- */
  .legend {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 20px;
    margin-top: clamp(14px, 1.8vw, 24px);
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
  }
  .legend .l {
    display: inline-flex;
    align-items: center;
    gap: 7px;
  }
  .legend .l::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
  }
  .legend .sig::before {
    background: var(--signal);
  }
  .legend .ins::before {
    background: var(--insight);
  }
  .legend .alr::before {
    background: var(--alert);
  }
  .legend .flo::before {
    display: none;
  }
  .legend .flo i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--faint);
    margin-right: -3px;
    animation: lflow 1.2s ease-in-out infinite;
  }
  .legend .flo i:nth-child(2) {
    animation-delay: 0.2s;
  }
  .legend .flo i:nth-child(3) {
    animation-delay: 0.4s;
    margin-right: 4px;
  }
  @keyframes lflow {
    0%,
    100% {
      opacity: 0.35;
    }
    50% {
      opacity: 1;
    }
  }
  .legend .note {
    margin-left: auto;
    color: var(--faint);
  }
  @media (max-width: 860px) {
    .legend .note {
      margin-left: 0;
      flex-basis: 100%;
    }
  }

  /* ---------- narrow: stack vertically, flow top → bottom ---------- */
  @media (max-width: 860px) {
    .row,
    .row.r2 {
      flex-direction: column;
    }
    .row.r1 {
      margin-bottom: 0;
    }
    .node {
      flex: none;
    }
    .elbow {
      display: none;
    }
    .conn {
      flex: none;
      height: 44px;
      width: 100%;
      align-self: auto;
    }
    .conn .wire {
      left: 50%;
      right: auto;
      top: 0;
      bottom: 0;
      width: 2.5px;
      height: auto;
      transform: translateX(-50%);
      background: linear-gradient(
        180deg,
        transparent,
        var(--line-hi) 25%,
        var(--line-hi) 75%,
        transparent
      );
    }
    .conn .lbl {
      top: 50%;
      left: calc(50% + 12px);
      transform: translateY(-50%);
    }
    .conn .p {
      left: 50% !important;
      animation-name: vflow;
    }
    .r2 .conn .p {
      animation-direction: normal;
    }
    .steps {
      grid-template-columns: 1fr;
    }
  }
  @media (max-width: 480px) {
    .ind {
      grid-template-columns: 1fr 1fr;
    }
    .kv {
      grid-template-columns: 1fr;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .sb-pipe *,
    .sb-pipe *::after,
    .sb-pipe *::before {
      animation: none !important;
    }
    .conn .p,
    .elbow .p {
      opacity: 0.9;
    }
    .conn .p:nth-child(3) {
      left: 35%;
    }
    .conn .p:nth-child(4) {
      left: 65%;
    }
    .conn .p:nth-child(5) {
      left: 50%;
    }
  }