.tree-widget {
  --tree-bg: #ffffff;
  --tree-border: #e2e8f0;
  --tree-text: #1e293b;
  --tree-muted: #64748b;
  --tree-primary: #3b82f6;
  --tree-success: #16a34a;
  --tree-warning: #ea580c;
  --tree-danger: #dc2626;
  --tree-purple: #7c3aed;
}

.tree-presets-section {
  margin-bottom: 1.25rem;
}

.tree-section-label {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tree-muted);
  margin-bottom: 0.5rem;
}

.tree-presets-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.tree-preset-btn {
  appearance: none;
  border: 1px solid var(--tree-border);
  background: var(--tree-bg);
  color: var(--tree-text);
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.tree-preset-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.tree-preset-btn.active {
  background: #1e293b;
  color: #ffffff;
  border-color: #1e293b;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tree-preset-btn.qcm-btn {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.tree-preset-btn.qcm-btn:hover {
  background: #dbeafe;
}

.tree-preset-btn.qcm-btn.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

/* Tree diagram container */
.tree-diagram-container {
  background: #f8fafc;
  border: 1px solid var(--tree-border);
  border-radius: 8px;
  padding: 1.25rem;
  margin: 1rem 0;
  overflow-x: auto;
}

.tree-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  min-width: 680px;
}

.tree-level {
  display: flex;
  justify-content: center;
  gap: 1rem;
  width: 100%;
  position: relative;
}

.tree-node {
  background: #ffffff;
  border: 2px solid var(--tree-border);
  border-radius: 8px;
  padding: 0.75rem 0.95rem;
  text-align: center;
  transition: all 0.25s ease-in-out;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  position: relative;
  max-width: 260px;
  flex: 1;
}

.tree-node-title {
  font-weight: 750;
  font-size: 0.96rem;
  margin-bottom: 0.25rem;
  color: var(--tree-text);
}

.tree-node-desc {
  font-size: 0.82rem;
  color: var(--tree-muted);
  line-height: 1.35;
}

/* Node Highlight States */
.tree-node.dimmed {
  opacity: 0.22;
  filter: grayscale(80%);
}

.tree-node.highlight-root {
  border-color: #475569;
  background: #f8fafc;
}

.tree-node.highlight-non-sig {
  border-color: #64748b;
  background: #f1f5f9;
  box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.2);
}

.tree-node.highlight-sig {
  border-color: #3b82f6;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.tree-node.highlight-true-null {
  border-color: #16a34a;
  background: #f0fdf4;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.25);
}

.tree-node.highlight-beta {
  border-color: #ea580c;
  background: #fff7ed;
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.25);
}

.tree-node.highlight-alpha {
  border-color: #dc2626;
  background: #fef2f2;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.25);
}

.tree-node.highlight-true-stat {
  border-color: #8b5cf6;
  background: #f5f3ff;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.tree-node.highlight-confounding {
  border-color: #d97706;
  background: #fffbeb;
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.25);
}

.tree-node.highlight-causal {
  border-color: #059669;
  background: #ecfdf5;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.25);
}

/* Insight Box */
.tree-insight-panel {
  background: #ffffff;
  border: 1px solid var(--tree-border);
  border-left: 4px solid var(--tree-primary);
  border-radius: 6px;
  padding: 0.9rem 1.1rem;
  margin-top: 1rem;
}

.tree-insight-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tree-insight-title {
  font-weight: 800;
  font-size: 0.98rem;
  color: var(--tree-text);
}

.tree-insight-meta {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--tree-muted);
  background: #f1f5f9;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.tree-insight-body {
  font-size: 0.88rem;
  line-height: 1.45;
  color: #334155;
  margin: 0;
}
