.cdk-graph-page {
  max-width: 100%;
  padding: 1rem 1.5rem 0;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 80px);
  min-height: 600px;
  font-family: system-ui, -apple-system, sans-serif;
}

.cdk-graph-header h1 {
  margin: 0 0 0.25rem 0;
  font-size: 1.5rem;
  color: #2c3e50;
}

.cdk-graph-subtitle {
  margin: 0 0 1rem 0;
  color: #5a6c7d;
  font-size: 0.95rem;
  max-width: 60rem;
}

.cdk-graph-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e2e8ef;
}

.cdk-graph-controls label { font-weight: 600; color: #34495e; }
.cdk-graph-controls select,
.cdk-graph-controls button {
  padding: 0.45rem 0.8rem;
  border: 1px solid #c5d1dc;
  border-radius: 6px;
  background: #fff;
  font-size: 0.9rem;
  cursor: pointer;
}
.cdk-graph-controls select { min-width: 18rem; }
.cdk-graph-controls button:hover { border-color: #4a9bb8; background: #f0f7fa; }

.cdk-graph-stats {
  margin-left: auto;
  color: #5a6c7d;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

/* ── Layout: graph + side panel side by side ─────────────────────────────── */
.cdk-graph-body {
  flex: 1;
  display: flex;
  gap: 1rem;
  margin-top: 0.75rem;
  min-height: 0;  /* allows canvas to shrink */
}

.cdk-graph-canvas {
  flex: 1;
  border: 1px solid #d8dfe6;
  border-radius: 8px;
  background: #fafbfc;
  position: relative;
  overflow: hidden;
}

.cdk-graph-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7a8a99;
  font-size: 1rem;
}

/* ── Side panel: appears when a domain is selected ───────────────────────── */
.cdk-graph-panel {
  width: 340px;
  flex-shrink: 0;
  border: 1px solid #d8dfe6;
  border-radius: 8px;
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cdk-graph-panel-in 0.25s ease-out;
}

.cdk-graph-panel[hidden] { display: none; }

@keyframes cdk-graph-panel-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.cdk-graph-panel__header {
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid #e2e8ef;
  background: #fdf2f0;  /* very light red tint */
  position: relative;
}

.cdk-graph-panel__close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #5a6c7d;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.cdk-graph-panel__close:hover {
  border-color: #c5d1dc;
  background: #fff;
  color: #c0392b;
}

.cdk-graph-panel__title {
  margin: 0 0 0.25rem 0;
  padding-right: 2rem;
  font-size: 1.15rem;
  color: #c0392b;
  line-height: 1.3;
}

.cdk-graph-panel__meta {
  margin: 0;
  font-size: 0.85rem;
  color: #5a6c7d;
}

.cdk-graph-panel__list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

/* Uniform-sized subtopic buttons — fixed height, ellipsis on overflow */
.cdk-graph-subtopic-btn {
  width: 100%;
  height: 44px;
  padding: 0 0.85rem;
  border: 1px solid #d8dfe6;
  border-radius: 6px;
  background: #ffffff;
  color: #34495e;
  font-size: 0.9rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.cdk-graph-subtopic-btn:hover {
  border-color: #c0392b;
  background: #fdf2f0;
  color: #c0392b;
}

.cdk-graph-subtopic-btn[data-active="true"] {
  border-color: #c0392b;
  background: #c0392b;
  color: #ffffff;
  font-weight: 600;
}

.cdk-graph-subtopic-btn .count {
  float: right;
  font-size: 0.8rem;
  color: #95a5a6;
}
.cdk-graph-subtopic-btn[data-active="true"] .count { color: rgba(255,255,255,0.85); }

/* ── Legend ─────────────────────────────────────────────────────────────── */
.cdk-graph-legend {
  padding: 0.5rem 0;
  font-size: 0.85rem;
  color: #5a6c7d;
}
.cdk-graph-legend .legend-item {
  font-size: 1.4rem;
  vertical-align: middle;
  margin: 0 0.15rem 0 0.6rem;
}
.cdk-graph-legend .legend-topic { color: #c0392b; }
.cdk-graph-legend .legend-sub   { color: #e57373; }
