/* ===================== PROTO CARDS ===================== */
.proto-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}
.proto-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.proto-card-header {
  padding: 14px 18px; font-weight: 700; font-size: 15px;
  font-family: var(--font-mono);
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; user-select: none;
}
.proto-card-header .proto-file { color: var(--accent); }
.proto-card-header .proto-toggle { color: var(--text-muted); font-size: 18px; }
.proto-card-body {
  padding: 16px 18px;
  max-height: 0; overflow: hidden; transition: max-height .3s ease;
}
.proto-card.open .proto-card-body { max-height: 800px; }
.proto-card.open .proto-toggle { transform: rotate(180deg); }
pre.proto-code {
  font-family: var(--font-mono); font-size: 13px; line-height: 1.6;
  color: var(--text); white-space: pre-wrap; word-break: break-all;
}
.proto-kw { color: var(--accent); font-weight: 600; }
.proto-type { color: var(--accent2); }
.proto-comment { color: var(--text-muted); font-style: italic; }

/* ===================== DATAFLOW ===================== */
.dataflow-container {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
}
.dataflow-left, .dataflow-right {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.dataflow-left h3, .dataflow-right h3 {
  font-size: 16px; margin-bottom: 12px;
}
#topic-table-container { max-height: 480px; overflow-y: auto; }
.topic-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.topic-table th {
  text-align: left; padding: 8px 10px; font-weight: 600;
  border-bottom: 2px solid var(--border); color: var(--text-muted);
  position: sticky; top: 0; background: var(--bg-card);
}
.topic-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.topic-table td:first-child { font-family: var(--font-mono); color: var(--accent); }
.topic-dir { font-size: 11px; padding: 2px 6px; border-radius: 3px; font-weight: 600; }
.topic-dir.pub { background: rgba(52,211,153,0.12); color: var(--accent3); }
.topic-dir.sub { background: rgba(239,68,68,0.12); color: #f87171; }

#sankey-chart { height: 460px; width: 100%; }

/* ===================== PIPELINE ===================== */
.pipeline-container {
  display: flex; gap: 0; align-items: stretch;
  overflow-x: auto; padding: 20px 0;
}
.pipeline-stage {
  flex: 1; min-width: 140px; position: relative;
  display: flex; flex-direction: column; align-items: center;
}
.pipeline-node {
  width: 72px; height: 72px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; border: 3px solid;
  position: relative; z-index: 2; background: var(--bg);
  transition: all .3s;
}
.pipeline-node:hover { transform: scale(1.15); }
.pipeline-arrow {
  flex: 1; height: 3px; background: var(--border);
  position: absolute; top: 36px; left: calc(50% + 36px);
  right: calc(-50% + 36px); z-index: 1;
}
.pipeline-stage:last-child .pipeline-arrow { display: none; }
.pipeline-label {
  margin-top: 12px; text-align: center;
}
.pipeline-label strong { font-size: 14px; display: block; margin-bottom: 4px; }
.pipeline-label span { font-size: 12px; color: var(--text-muted); display: block; line-height: 1.4; }
.pipeline-stage:nth-child(1) .pipeline-node { border-color: var(--layer1); color: var(--layer1); }
.pipeline-stage:nth-child(2) .pipeline-node { border-color: var(--accent); color: var(--accent); }
.pipeline-stage:nth-child(3) .pipeline-node { border-color: var(--accent2); color: var(--accent2); }
.pipeline-stage:nth-child(4) .pipeline-node { border-color: var(--accent3); color: var(--accent3); }
.pipeline-stage:nth-child(5) .pipeline-node { border-color: var(--layer3); color: var(--layer3); }
.pipeline-stage:nth-child(6) .pipeline-node { border-color: var(--layer2); color: var(--layer2); }
.pipeline-stage:nth-child(7) .pipeline-node { border-color: var(--layer6); color: var(--layer6); }

@media (max-width: 900px) {
  .dataflow-container { grid-template-columns: 1fr; }
  .pipeline-container { flex-direction: column; align-items: center; }
  .pipeline-arrow { display: none !important; }
}
