:root {
  --bg:        #0e131c;
  --bg-2:      #131927;
  --panel:     #182030;
  --panel-2:   #202a3e;
  --line:      #2a3552;
  --fg:        #e6ecff;
  --fg-mut:    #99a3c0;
  --accent:    #7b68ee;
  --accent-2:  #5dd6a8;
  --warn:      #e08a2a;
  --error:     #d04040;

  --kind-pure:        #3aa87a;
  --kind-imperative:  #e08a2a;
  --kind-event:       #d04040;

  --pin-exec:    #ffca6b;
  --pin-any:     #9aa1b2;
  --pin-number:  #74c0ff;
  --pin-string:  #e06bff;
  --pin-bool:    #ff7b7b;
  --pin-path:    #c8a268;
  --pin-uuid:    #a76bff;
  --pin-actor:   #5dd6a8;
  --pin-item:    #ffd94a;
  --pin-token:   #3ec8e0;
  --pin-array:   #d0d0d0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
  background:
    radial-gradient(circle at 12% -10%, rgba(123,104,238,.18), transparent 60%),
    radial-gradient(circle at 90% 110%, rgba(93,214,168,.10), transparent 60%),
    var(--bg);
  min-height: 100vh;
}

a { color: #b3a8ff; text-decoration: none; }
a:hover { color: #fff; text-decoration: underline; }
code, .mono { font-family: "JetBrains Mono", Consolas, monospace; font-size: .85em; }
kbd {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 11px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
}

.site-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: rgba(14, 19, 28, .85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header .brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 15px; letter-spacing: .3px;
  color: #fff;
}
.site-header .brand .logo {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #0e131c; font-weight: 900;
}
.site-header nav {
  display: flex; gap: 4px; flex: 1;
}
.site-header nav a {
  padding: 6px 12px; border-radius: 8px; color: var(--fg-mut);
  font-weight: 600; font-size: 13px;
}
.site-header nav a:hover { background: var(--panel); color: var(--fg); text-decoration: none; }
.site-header nav a.active { background: var(--panel); color: #fff; }
.lang-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 8px;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--fg); cursor: pointer; font-weight: 700; font-size: 12px;
}
.lang-toggle:hover { border-color: var(--accent); }

.page {
  max-width: 1280px; margin: 0 auto;
  padding: 32px 20px 80px;
}
.page h1 { font-size: 28px; margin: 0 0 8px; }
.page h2 { font-size: 22px; margin: 32px 0 12px; padding-top: 8px; border-top: 1px solid var(--line); }
.page h3 { font-size: 16px; margin: 18px 0 6px; color: var(--fg); }
.page p  { color: var(--fg); }
.page .lead { font-size: 16px; color: var(--fg-mut); max-width: 60ch; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin: 16px 0;
}
.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.card h3 { margin: 0 0 6px; font-size: 15px; }
.card p  { margin: 4px 0; color: var(--fg-mut); font-size: 13px; }
.card a.btn {
  display: inline-block; margin-top: 8px;
  padding: 6px 12px; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 12px;
}
.card a.btn:hover { background: #9485f6; text-decoration: none; }

.toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin: 12px 0 18px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.toolbar input[type="search"] {
  flex: 1; min-width: 180px;
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; font-size: 13px;
}
.toolbar select, .toolbar .chip {
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; font-size: 13px; cursor: pointer;
  font-weight: 600;
}
.toolbar .chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.toolbar .chip:hover { border-color: var(--accent); }

.pin-legend {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 16px;
}
.pin-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 11px; font-weight: 700; letter-spacing: .2px;
}
.pin-tag .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--c, var(--pin-any));
  box-shadow: 0 0 0 2px rgba(0,0,0,.3) inset, 0 0 6px var(--c, var(--pin-any));
}
.kind-badge {
  display: inline-block;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
  background: var(--c, var(--kind-pure));
  color: #fff;
}

.node {
  --accent: #555;
  position: relative;
  width: 320px;
  background: linear-gradient(180deg, #151a24, #101521);
  border: 1px solid #ffffff22;
  border-left: 3px solid var(--accent);
  border-radius: 16px;
  box-shadow: 0 18px 45px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.04) inset;
  overflow: hidden;
  font-size: 12px;
  color: #fff;
}
.node .nhdr {
  height: 38px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent-soft));
  font-weight: 800; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.node .nhdr small {
  margin-left: auto;
  font-size: 10px; font-weight: 600;
  color: rgba(255,255,255,.7);
  white-space: nowrap;
}
.node .nbody { padding: 6px 0; }
.node .nrow {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 30px; padding: 0 8px; gap: 8px;
}
.node .nrow .left,
.node .nrow .right {
  display: flex; align-items: center; gap: 6px; min-width: 0;
}
.node .nrow .left { flex: 1; }
.node .nrow .right { justify-content: flex-end; }

.node .pin {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: rgba(255,255,255,.85);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 240px;
}
.node .pin.right { flex-direction: row-reverse; }
.node .pin .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--pc, #9aa1b2);
  box-shadow: 0 0 0 2px rgba(0,0,0,.3) inset, 0 0 4px var(--pc, #9aa1b2);
  flex-shrink: 0;
}
.node .pin.exec .dot {
  border-radius: 2px; transform: rotate(45deg);
  background: var(--pin-exec);
  box-shadow: 0 0 4px var(--pin-exec);
}

.node .field {
  display: flex; align-items: center; gap: 6px;
  flex: 1; min-width: 0;
}
.node .field input,
.node .field select,
.node .field textarea {
  flex: 1; min-width: 0;
  background: rgba(255,255,255,.06);
  color: #fff;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 11px;
  font-family: inherit;
}
.node .field .lbl { color: rgba(255,255,255,.6); font-size: 11px; }

.node-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.node-detail {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin: 12px 0;
}
.node-detail header {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.node-detail header h3 {
  margin: 0;
  font-size: 17px; color: #fff;
}
.node-detail header .meta {
  margin-left: auto; display: flex; gap: 8px; align-items: center;
}
.node-detail .desc {
  color: var(--fg);
  margin: 0 0 12px;
}
.node-detail .grid2 {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 760px) {
  .node-detail .grid2 { grid-template-columns: 1fr; }
}
.node-detail .pinlist,
.node-detail .fieldlist {
  margin: 0; padding: 0; list-style: none;
}
.node-detail .pinlist li,
.node-detail .fieldlist li {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}
.node-detail .pinlist li:last-child,
.node-detail .fieldlist li:last-child { border-bottom: 0; }
.node-detail .pinlist li .name,
.node-detail .fieldlist li .name {
  font-weight: 700; min-width: 100px; color: #fff;
}
.node-detail .pinlist li .type {
  font-family: "JetBrains Mono", monospace; font-size: 11px;
  margin-left: auto;
}
.node-detail .pinlist li .desc {
  flex: 1; color: var(--fg-mut); margin: 0;
}
.node-detail .preview {
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,.04), transparent 50%),
    var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  display: flex; align-items: center; justify-content: center;
}

.wgt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  margin: 16px 0;
}
.wgt-card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}
.wgt-card h3 {
  margin: 0 0 4px; font-size: 16px; display: flex; align-items: center; gap: 8px;
}
.wgt-card h3 .ic {
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--accent);
  display: grid; place-items: center; color: #fff;
}
.wgt-card .desc { color: var(--fg-mut); font-size: 12px; margin: 4px 0 10px; }
.wgt-card .frame {
  background: #1a1f2c;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  min-height: 80px;
  display: flex; align-items: center; justify-content: center;
}
.wgt-card .frame .wgt-shell {
  width: 100%;
}
.wgt-card details {
  margin-top: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
}
.wgt-card details > summary {
  cursor: pointer; font-weight: 600; color: var(--fg-mut);
  padding: 4px 0;
}
.wgt-card details ul {
  margin: 6px 0; padding-left: 20px;
}
.wgt-card details li { margin: 2px 0; }
.wgt-card details code { color: #9bd2ff; }

.example-block {
  margin: 28px 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}
.example-block h3 { margin: 0 0 6px; font-size: 17px; }
.example-block .ex-desc { color: var(--fg-mut); margin: 0 0 14px; }
.example-block .ex-stage {
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.02) 0 1px, transparent 1px 32px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.02) 0 1px, transparent 1px 32px),
    #0a0e16;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  overflow-x: auto;
  position: relative;
}
.example-block .ex-stage .ex-row {
  display: flex; gap: 36px; align-items: flex-start;
  flex-wrap: nowrap;
  min-width: max-content;
}
.example-block .ex-stage .ex-arrow {
  align-self: center;
  font-size: 20px;
  color: var(--accent);
  font-weight: 900;
  margin-top: 24px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.example-block .ex-stage .ex-arrow .lbl {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-mut);
  letter-spacing: 0.4px;
  text-transform: lowercase;
  white-space: nowrap;
}
.example-block .ex-stage .ex-arrow .arr { font-size: 24px; line-height: 1; }
.example-block .ex-stage .ex-arrow.exec  { color: #ffca6b; }
.example-block .ex-stage .ex-arrow.data  { color: #74c0ff; }

.example-block .ex-flowlist {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--fg-mut);
  display: flex; flex-direction: column; gap: 4px;
}
.example-block .ex-flowlist b { color: var(--fg); font-weight: 600; }

.ex-tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  margin-left: 8px;
  vertical-align: middle;
}
.ex-tag.basic    { background: rgba(58,168,122,.18);  color: #5dd6a8; border: 1px solid rgba(58,168,122,.4); }
.ex-tag.advanced { background: rgba(224,138,42,.16);  color: #ffb14a; border: 1px solid rgba(224,138,42,.4); }
.ex-tag.triggers { background: rgba(208,64,64,.18);   color: #ff9090; border: 1px solid rgba(208,64,64,.4); }

.example-block .ex-tip {
  margin-top: 12px;
  font-size: 13px;
  color: var(--fg-mut);
  border-left: 3px solid var(--accent-2);
  padding: 6px 12px;
  background: rgba(93,214,168,.06);
  border-radius: 6px;
}

.fakenode {
  width: 220px;
  background: #1a1f2e;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  font-size: 13px;
  flex-shrink: 0;
}
.fakenode .nhdr {
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #000));
  padding: 8px 10px;
  font-weight: 600;
}
.fakenode .nbody {
  padding: 10px 12px;
  color: var(--fg-mut);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
}

.toc {
  margin: 16px 0 24px;
  padding: 14px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
}
.toc strong { display: block; margin-bottom: 6px; color: var(--fg-mut); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.toc ul { margin: 0; padding-left: 18px; }
.toc a { color: var(--accent-2); text-decoration: none; }
.toc a:hover { text-decoration: underline; }

.callout {
  border-left: 4px solid var(--accent);
  background: rgba(123, 104, 238, .08);
  padding: 10px 14px;
  border-radius: 8px;
  margin: 12px 0;
}
.callout.warn { border-left-color: var(--warn); background: rgba(224, 138, 42, .08); }
.callout.tip  { border-left-color: var(--accent-2); background: rgba(93, 214, 168, .08); }
.callout.note h4 { margin: 0 0 4px; }

table.grid {
  border-collapse: collapse; width: 100%; margin: 8px 0;
  font-size: 13px;
}
table.grid th, table.grid td {
  border: 1px solid var(--line); padding: 6px 10px; text-align: left;
}
table.grid th { background: var(--panel-2); }
table.grid tr:nth-child(even) td { background: rgba(255,255,255,.02); }

footer.site {
  text-align: center;
  color: var(--fg-mut);
  font-size: 12px;
  padding: 32px 20px;
  border-top: 1px solid var(--line);
  margin-top: 32px;
}

@media print {
  .site-header, .toolbar { display: none; }
  body { background: #fff; color: #000; }
  .node, .wgt-card, .example-block { break-inside: avoid; }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.stat-card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.stat-card .num { font-size: 28px; font-weight: 900; color: #fff; line-height: 1; }
.stat-card .lbl { margin-top: 6px; color: var(--fg-mut); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}
.callout {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  background: rgba(123,104,238,.10);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 14px 0;
}
.callout.warn { border-left-color: var(--warn); background: rgba(224,138,42,.10); }
.callout.tip { border-left-color: var(--accent-2); background: rgba(93,214,168,.09); }
.toc {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  padding: 12px 16px;
  margin: 16px 0;
}
.toc ul { margin: 8px 0 0; columns: 2; }
@media (max-width: 720px) { .toc ul { columns: 1; } }
.table-wrap { overflow:auto; border:1px solid var(--line); border-radius:12px; margin:14px 0; }
table.doc-table { width:100%; border-collapse:collapse; min-width:720px; }
table.doc-table th, table.doc-table td { border-bottom:1px solid var(--line); padding:8px 10px; vertical-align:top; }
table.doc-table th { background:var(--panel); text-align:left; color:var(--fg-mut); font-size:12px; text-transform:uppercase; letter-spacing:.4px; }
table.doc-table tr:last-child td { border-bottom:0; }
.flow-steps { counter-reset: step; display:grid; gap:10px; margin:14px 0; }
.flow-steps li { list-style:none; position:relative; padding:10px 12px 10px 42px; border:1px solid var(--line); border-radius:10px; background:var(--panel); }
.flow-steps li::before { counter-increment: step; content: counter(step); position:absolute; left:12px; top:10px; width:20px; height:20px; border-radius:999px; background:var(--accent); display:grid; place-items:center; font-weight:800; font-size:12px; }
.cat-summary {
  border:1px solid var(--line); border-radius:12px; background:var(--panel); padding:12px; margin:12px 0 16px;
}
.cat-summary h3 { margin-top:0; }
.cat-summary .chips { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
.cat-summary .chips a { font-family:"JetBrains Mono",Consolas,monospace; font-size:11px; background:var(--bg); border:1px solid var(--line); border-radius:999px; padding:3px 8px; color:var(--fg-mut); }
.node-detail .runtime-note { color:var(--fg-mut); font-size:12px; margin:8px 0 0; }
.node-detail .doc-desc { color:var(--fg); font-size:13px; }
