
  /* ============================================================
     DESIGN TOKENS
     Near-monochrome dark shell, one restrained accent.
     The diagram is the only thing that earns saturation.
     ============================================================ */
  :root {
    --bg:           #0c0d10;
    --bg-panel:     #131419;
    --bg-node:      #1b1d24;
    --bg-node-hi:   #21242d;
    --ink:          #e8e9ed;
    --ink-dim:      #9a9ca6;
    --ink-faint:    #61636e;
    --line:         #2a2c35;
    --line-soft:    #20222a;

    /* one accent — cool slate-cyan, used sparingly */
    --accent:       #5fb4c4;
    --accent-dim:   #3c7682;

    /* semantic store-role colors, low-saturation so they read as
       structure not decoration */
    --canonical:    #c9a14a;   /* warm gold — source of truth */
    --artifact:     #7d8fb3;   /* cool steel — built artifact */
    --ephemeral:    #6b6e7a;   /* grey — runtime/ephemeral */

    /* flow-nature hues */
    --flow-realtime:  #5fb4c4;
    --flow-triggered: #c98a5f;
    --flow-scheduled: #8b7fc4;
    --flow-manual:    #6b6e7a;
    --flow-deploy:    #5f9ec4;

    --claude:       #d97757;   /* Claude marker accent */

    --r: 10px;
    --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  }

  * { box-sizing: border-box; }

  body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
  }

  /* harness chrome — exists only to demo the component;
     the main site won't include this. */
  .harness {
    max-width: 1080px;
    margin: 0 auto;
    padding: 40px 28px 80px;
  }
  .harness-head { margin-bottom: 28px; }
  .harness-head .eyebrow {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin: 0 0 8px;
  }
  .harness-head h1 {
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 6px;
    letter-spacing: -.01em;
  }
  .harness-head p {
    color: var(--ink-dim);
    font-size: 14px;
    max-width: 64ch;
    margin: 0;
  }

  .switcher {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    margin: 24px 0 8px;
  }
  .switcher button {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--ink-dim);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .18s ease, color .18s ease;
  }
  .switcher button:hover { color: var(--ink); }
  .switcher button[aria-pressed="true"] {
    background: var(--bg-node-hi);
    color: var(--ink);
  }
  .switcher button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  /* ============================================================
     THE COMPONENT
     Everything below .dfd is the reusable diagram.
     ============================================================ */
  .dfd {
    position: relative;
    background:
      radial-gradient(120% 120% at 50% 0%, #101218 0%, var(--bg-panel) 60%);
    border: 1px solid var(--line);
    border-radius: var(--r);
    overflow: hidden;
  }

  .dfd-stage {
    position: relative;
    width: 100%;
  }
  .dfd svg { display: block; width: 100%; height: auto; }

  /* nodes are HTML overlaid on the SVG flow layer, positioned
     by the layout engine. lets us use real text wrapping +
     crisp hover states the SVG would fight us on. */
  .dfd-nodes {
    position: absolute;
    inset: 0;
    pointer-events: none;
  }
  .node {
    position: absolute;
    transform: translate(-50%, -50%);
    width: var(--node-w, 150px);
    pointer-events: auto;
    background: var(--bg-node);
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 11px 12px 12px;
    cursor: default;
    transition: transform .22s cubic-bezier(.2,.7,.3,1),
                border-color .2s ease, background .2s ease,
                box-shadow .22s ease;
    will-change: transform;
  }
  .node:hover, .node.is-active {
    background: var(--bg-node-hi);
    border-color: var(--line);
    transform: translate(-50%, -50%) translateY(-3px);
    box-shadow: 0 12px 30px -12px rgba(0,0,0,.7);
    z-index: 5;
  }
  .node:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
  }

  .node-kind {
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
  }
  .node-title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -.005em;
    line-height: 1.25;
  }
  .node-sub {
    font-size: 11px;
    color: var(--ink-dim);
    margin-top: 3px;
    line-height: 1.3;
  }

  /* store-role treatments — the canonical/artifact/ephemeral
     distinction the brief requires */
  .node[data-role="canonical"] {
    border-color: var(--canonical);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--canonical) 35%, transparent),
                inset 0 0 24px -16px var(--canonical);
  }
  .node[data-role="artifact"] {
    border-style: dashed;
    border-color: var(--artifact);
  }
  .node[data-role="ephemeral"] {
    border-color: var(--line);
    background:
      repeating-linear-gradient(
        -45deg,
        var(--bg-node) 0 7px,
        #16171d 7px 14px);
  }

  .role-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--mono);
    font-size: 8.5px;
    letter-spacing: .1em;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 999px;
    margin-top: 8px;
    border: 1px solid transparent;
  }
  .role-badge[data-role="canonical"] {
    color: var(--canonical);
    border-color: color-mix(in srgb, var(--canonical) 45%, transparent);
    background: color-mix(in srgb, var(--canonical) 10%, transparent);
  }
  .role-badge[data-role="artifact"] {
    color: var(--artifact);
    border-color: color-mix(in srgb, var(--artifact) 40%, transparent);
  }
  .role-badge[data-role="ephemeral"] {
    color: var(--ephemeral);
    border-color: color-mix(in srgb, var(--ephemeral) 40%, transparent);
  }

  /* Claude marker — the signature touch */
  .claude-dot {
    width: 13px !important; height: 13px !important;
    flex: 0 0 auto;
    display: inline-block;
    vertical-align: middle;
    filter: drop-shadow(0 0 5px color-mix(in srgb, var(--claude) 60%, transparent));
  }
  .role-badge .claude-dot,
  .node-kind .claude-dot { width: 11px !important; height: 11px !important; }
  .legend-item .claude-dot { width: 13px !important; height: 13px !important; }
  .readout-icon .claude-dot { width: 17px !important; height: 17px !important; }
  .node.is-claude {
    border-color: color-mix(in srgb, var(--claude) 55%, transparent);
  }
  .node.is-claude::after {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: 9px;
    pointer-events: none;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--claude) 30%, transparent);
    opacity: 0;
    transition: opacity .3s ease;
  }
  .dfd.claude-lit .node.is-claude::after { opacity: 1; }

  /* edge labels (flow nature), shown on hover of node or flow */
  .edge-label {
    position: absolute;
    transform: translate(-50%, -50%);
    font-family: var(--mono);
    font-size: 9.5px;
    letter-spacing: .04em;
    color: var(--ink-dim);
    background: var(--bg);
    border: 1px solid var(--line);
    padding: 2px 7px;
    border-radius: 999px;
    pointer-events: none;
    white-space: nowrap;
    opacity: 0;
    transition: opacity .18s ease;
    z-index: 4;
  }
  .edge-label.show { opacity: 1; }
  .edge-label .nature-dot {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
  }

  /* detail readout — fills on hover, the "thinks in systems" payoff */
  .dfd-readout {
    border-top: 1px solid var(--line);
    padding: 16px 20px;
    min-height: 76px;
    display: flex;
    gap: 18px;
    align-items: flex-start;
    background: var(--bg-panel);
  }
  .readout-icon {
    flex: 0 0 auto;
    width: 34px; height: 34px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    background: var(--bg-node);
    margin-top: 1px;
  }
  .readout-body { flex: 1; min-width: 0; }
  .readout-kicker {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin-bottom: 3px;
  }
  .readout-title { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
  .readout-desc { font-size: 13px; color: var(--ink-dim); }
  .readout-idle { color: var(--ink-faint); font-size: 13px; align-self: center; }

  /* legend */
  .dfd-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    padding: 13px 20px;
    border-top: 1px solid var(--line);
    background: var(--bg);
  }
  .legend-group {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
  }
  .legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--ink-dim);
    font-family: var(--mono);
    letter-spacing: .02em;
  }
  .legend-swatch { width: 22px; height: 0; border-top-width: 2px; border-top-style: solid; }
  .legend-chip {
    width: 12px; height: 12px; border-radius: 3px;
    border: 1px solid var(--line);
  }
  .legend-sep { width: 1px; align-self: stretch; background: var(--line); }

  /* SVG flow styling */
  .flow-path { fill: none; stroke-linecap: round; }
  .flow-hit  { fill: none; stroke: transparent; stroke-width: 18px; cursor: pointer; }
  .flow-path.dim, .flow-arrow.dim { opacity: .18; transition: opacity .2s; }
  .flow-path.lit { opacity: 1; }
  .flow-arrow { transition: opacity .2s; }

  /* animated directional pulse on live flows only */
  .pulse {
    r: 3;
    opacity: 0;
  }
  @media (prefers-reduced-motion: no-preference) {
    .pulse.run { animation: travel var(--dur, 2.4s) linear infinite; }
  }
  @keyframes travel {
    0%   { opacity: 0; }
    8%   { opacity: 1; }
    92%  { opacity: 1; }
    100% { opacity: 0; }
  }

  .node.dim { opacity: .3; transition: opacity .2s; }

  @media (max-width: 720px) {
    .dfd-legend { font-size: 10px; gap: 6px 12px; }
    .harness { padding: 24px 16px 60px; }
  }

  /* floating tooltip — follows the cursor, gives the tight one-liner */
  .dfd-tip {
    position: fixed;
    z-index: 50;
    max-width: 240px;
    background: #0a0b0e;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 11px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity .14s ease, transform .14s ease;
    box-shadow: 0 14px 34px -14px rgba(0,0,0,.85);
  }
  .dfd-tip.show { opacity: 1; transform: translateY(0); }
  .dfd-tip .tip-head {
    display: flex; align-items: center; gap: 6px;
    font-family: var(--mono);
    font-size: 9px; letter-spacing: .12em; text-transform: uppercase;
    color: var(--ink-faint);
    margin-bottom: 4px;
  }
  .dfd-tip .tip-title { font-size: 12.5px; font-weight: 600; margin-bottom: 3px; line-height: 1.25; }
  .dfd-tip .tip-body { font-size: 12px; color: var(--ink-dim); line-height: 1.35; }
  .dfd-tip .tip-nature { display:inline-block; width:6px; height:6px; border-radius:50%; }
  @media (prefers-reduced-motion: reduce) { .dfd-tip { transition: opacity .14s ease; transform:none; } }

  /* readout meta chip-line */
  .readout-meta {
    margin-top: 6px;
    font-family: var(--mono);
    font-size: 10.5px;
    letter-spacing: .02em;
    color: var(--ink-faint);
  }
  .readout-meta .dot { color: var(--line); margin: 0 6px; }

  /* connection-graph signature motif — the knowledge-graph payoff,
     drawn as a living constellation tied to the artifact node. Uses the
     artifact hue (not accent cyan) so it never reads as a flow line. */
  .motif-edge { stroke: var(--artifact); fill: none; }
  .motif-node { fill: var(--artifact); }
  .motif-node.lit { fill: #c7d4ec; }
  @media (prefers-reduced-motion: no-preference) {
    .motif-edge { animation: motif-edge-in .9s ease both; }
    .motif-node { animation: motif-node-pulse 3.2s ease-in-out infinite; }
    .motif-ring { animation: motif-ring 4s linear infinite; transform-origin: center; }
  }
  @keyframes motif-edge-in {
    from { stroke-dashoffset: var(--len, 60); opacity: 0; }
    to   { stroke-dashoffset: 0; opacity: .5; }
  }
  @keyframes motif-node-pulse {
    0%,100% { opacity: .55; }
    50%     { opacity: 1; }
  }
  @keyframes motif-ring {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
  }
  .motif-cap {
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: .12em;
    text-transform: uppercase;
    fill: var(--ink-faint);
  }
