/* ═══ GRAPH TOOLBAR ═══ */
.graph-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
  min-height: 40px;
}
.graph-toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.glabel {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  font-family: var(--mono);
  letter-spacing: .4px;
  text-transform: uppercase;
  margin-right: auto;
}
.bg-picker-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--muted);
}
.bg-picker-wrap input[type="color"] {
  width: 18px; height: 18px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: transparent;
  cursor: pointer;
}
.layout-toggle { display: flex; gap: 3px; }
.layout-btn {
  font-size: 10px;
  font-family: var(--mono);
  padding: 4px 9px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s var(--ease);
}
.layout-btn.active, .layout-btn:hover {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(45,123,181,.3);
}

/* ═══ GRAPH CONTAINER ═══ */
#graph-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  background:
    radial-gradient(ellipse at 30% 40%, rgba(45,123,181,.04) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 70%, rgba(45,232,200,.03) 0%, transparent 60%),
    var(--bg);
}
svg#graph { width: 100%; height: 100%; }

/* ═══ LEGEND ═══ */
.legend {
  position: absolute;
  bottom: 12px; right: 12px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  font-family: var(--mono);
  box-shadow: var(--shadow-md);
  z-index: 10;
  max-height: 70vh;
  overflow-y: auto;
}
.legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.legend-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color .15s;
}
.legend-close:hover { color: var(--text); }
.legend-section {
  font-size: 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-top: 4px;
  opacity: .7;
}
.legend-toggle-btn {
  position: absolute;
  bottom: 12px; right: 12px;
  width: 30px; height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(16px);
  color: var(--muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  z-index: 10;
  box-shadow: var(--shadow-md);
  transition: all .15s var(--ease);
}
.legend-toggle-btn:hover { color: var(--text); border-color: var(--border-hover); }
.lt { font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-size: 9px; }
.li { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: 10px; }
.ll { width: 22px; height: 2px; border-radius: 1px; flex-shrink: 0; }
.ll.dash { background: repeating-linear-gradient(90deg, var(--accent) 0, var(--accent) 4px, transparent 4px, transparent 8px); }
.ll-hull { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; opacity: .5; }
.ln-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid;
  background: var(--surface);
  flex-shrink: 0;
  box-sizing: border-box;
}
.ln-dot.ln-entry { box-shadow: 0 0 0 2px transparent, 0 0 0 4px rgba(125,155,255,.3); }
.ln-dot.ln-term { border-width: 3px; box-shadow: 0 0 0 2px transparent, 0 0 0 4px rgba(52,211,153,.35); }
.ln-dot.ln-start { border: none; width: 10px; height: 10px; margin: 0 2px; }

/* ═══ EMPTY STATE ═══ */
.gempty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(45,123,181,.04) 0%, transparent 70%);
}
.gempty-icon {
  font-size: 56px;
  opacity: .15;
  line-height: 1;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ═══ TOOLTIP ═══ */
.tooltip {
  position: fixed;
  background: var(--glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 11px;
  font-family: var(--mono);
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s var(--ease);
  z-index: 100;
  max-width: 320px;
  line-height: 1.7;
  box-shadow: var(--shadow-lg);
}
.tip-desc { color: var(--accent2); font-style: italic; margin-top: 3px; font-size: 11px; }

/* ═══ GRAPH FILTERS ═══ */
.graph-filters { display: flex; gap: 3px; margin-left: 4px; }
.gf-toggle {
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s var(--ease);
}
.gf-toggle.active {
  background: var(--accent-dim);
  border-color: rgba(45,123,181,.35);
  color: var(--accent);
}

/* ═══ GRAPH INFO ═══ */
.graph-info {
  font-size: 11px;
  font-family: var(--mono);
  padding: 6px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.graph-info::-webkit-scrollbar { display: none; }
.graph-info strong { color: var(--text); }
.graph-info-pill {
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.03);
}

/* ═══ TOOLBAR BUTTONS ═══ */
.tb-icon-btn {
  width: 28px; height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 14px;
  transition: all .15s var(--ease);
  flex-shrink: 0;
}
.tb-icon-btn:hover { color: var(--text); border-color: var(--border-hover); background: rgba(255,255,255,.04); }
.tb-icon-btn.active { color: var(--accent); border-color: rgba(45,123,181,.35); background: var(--accent-dim); }

.tb-sep { width: 1px; height: 20px; background: var(--border); flex-shrink: 0; margin: 0 2px; }

/* ═══ ZOOM GROUP ═══ */
.zoom-group {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  overflow: hidden;
}
.zoom-group .tb-icon-btn { border: none; border-radius: 0; width: 26px; height: 26px; font-size: 13px; }
.zoom-group .tb-icon-btn:hover { background: rgba(255,255,255,.06); }
.zoom-pct {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-secondary);
  min-width: 36px;
  text-align: center;
  padding: 0 2px;
  user-select: none;
  cursor: default;
}

/* ═══ DIFF GRAPH HIGHLIGHTS ═══ */
.diff-node-added circle { stroke: var(--success) !important; stroke-width: 3px !important; filter: drop-shadow(0 0 8px rgba(52,211,153,.6)); }
.diff-node-removed circle { stroke: var(--danger) !important; stroke-width: 3px !important; stroke-dasharray: 4 2; filter: drop-shadow(0 0 8px rgba(248,113,113,.6)); }
.diff-node-changed circle { stroke: var(--warn) !important; stroke-width: 3px !important; filter: drop-shadow(0 0 8px rgba(251,191,36,.6)); }
.diff-edge-added { stroke: var(--success) !important; stroke-width: 2.5px !important; }
.diff-edge-removed { stroke: var(--danger) !important; stroke-width: 2.5px !important; stroke-dasharray: 6 3 !important; }
.diff-edge-changed { stroke: var(--warn) !important; stroke-width: 2.5px !important; }

/* ═══ ANIMATIONS ═══ */
@keyframes riskPulse {
  0% { stroke-opacity: 1; stroke-width: 3px; }
  50% { stroke-opacity: .4; stroke-width: 5px; }
  100% { stroke-opacity: 1; stroke-width: 3px; }
}
@keyframes nodeFlash {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(2) drop-shadow(0 0 10px #f87171); }
}
@keyframes labelPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; }
}
.risk-edge { animation: riskPulse 1.2s ease-in-out infinite; }
.risk-node circle { animation: nodeFlash 1.2s ease-in-out infinite; }

@keyframes playDash { from { stroke-dashoffset: 16; } to { stroke-dashoffset: 0; } }
.play-edge {
  stroke: var(--accent) !important;
  stroke-width: 3px !important;
  stroke-dasharray: 8 4 !important;
  animation: playDash .6s linear infinite;
}
.play-node circle { filter: brightness(1.6) drop-shadow(0 0 12px rgba(45,123,181,.8)); }

/* ═══ NODE & EDGE STYLES ═══ */
.node-start circle {
  stroke: var(--accent2) !important;
  stroke-width: 3px !important;
  filter: drop-shadow(0 0 12px rgba(45,232,200,.7));
}
.node-end circle {
  stroke: #34d399 !important;
  stroke-width: 3px !important;
  filter: drop-shadow(0 0 12px rgba(52,211,153,.8));
}
.node circle {
  stroke-width: 2px;
  transition: filter .2s var(--ease);
  cursor: pointer;
}
.node:hover circle { filter: brightness(1.3) drop-shadow(0 0 6px rgba(109,140,255,.3)); }
.node text { pointer-events: none; font-family: var(--sans); font-weight: 600; }
.node-badge {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  pointer-events: none;
}
.badge-entry { fill: #7d9bff; opacity: .6; }
.badge-term { fill: #34d399; opacity: .6; }
.link {
  fill: none;
  stroke-width: 2px;
  stroke-linecap: round;
}
.linklabel {
  font-family: var(--mono);
  font-size: 10px;
  fill: var(--text-secondary, #b0b0b0);
  paint-order: stroke;
  stroke: var(--bg, #0d0f14);
  stroke-width: 4px;
  stroke-linejoin: round;
}
.edge-marker { font-size: 11px; pointer-events: none; }
.phase-hull { fill-opacity: .03; stroke-width: 1.5; stroke-dasharray: 4,3; rx: 12; }
.phase-label { font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; opacity: .4; }
