.rule-graph-grid {
  --graph-content: #2c70ce;
  --graph-itemcf: #127868;
  --graph-lin: #a34c2e;
  --graph-sr: #5c4ab0;
  --graph-hybrid: #8c3b86;
  display: grid;
  grid-template-columns: clamp(196px, 16%, 226px) minmax(0, 1fr) clamp(252px, 22%, 324px);
  align-items: start;
  gap: 16px;
}
.rule-graph-grid [data-family='content'] { --rule-family: var(--graph-content); }
.rule-graph-grid [data-family='itemcf'] { --rule-family: var(--graph-itemcf); }
.rule-graph-grid [data-family='lin'] { --rule-family: var(--graph-lin); }
.rule-graph-grid [data-family='sr'] { --rule-family: var(--graph-sr); }
.rule-graph-grid [data-family='hybrid'] { --rule-family: var(--graph-hybrid); }
.rule-graph-grid > .panel { min-width: 0; }
.rule-graph-filters, .rule-graph-detail { padding: 18px; }
.rule-graph-filters summary, .rule-graph-detail h2 { font-size: 1.18rem; }
.rule-graph-filters summary { cursor: pointer; font-weight: 750; letter-spacing: -.035em; line-height: 1.15; }
.rule-graph-filters fieldset { margin: 16px 0 0; padding: 0; border: 0; min-inline-size: 0; }
.rule-graph-filters legend { margin-bottom: 6px; color: var(--muted); font-size: .86rem; font-weight: 700; }
.rule-graph-family { display: flex; gap: 8px; align-items: start; padding-block: 5px; cursor: pointer; }
.rule-graph-family input { flex: none; width: 16px; height: 16px; margin: 3px 0 0; accent-color: var(--rule-family); }
.rule-graph-family strong, .rule-graph-family small { display: block; }
.rule-graph-family strong { color: var(--rule-family); font-size: .9rem; line-height: 1.25; }
.rule-graph-family small { margin-top: 2px; color: var(--muted); font-size: .79rem; }
.rule-graph-sliders { display: grid; gap: 18px; margin-top: 14px; border-top: 1px solid var(--line); padding-top: 16px; }
.rule-graph-slider > div { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.rule-graph-slider label { color: var(--muted); font-size: .84rem; font-weight: 700; }
.rule-graph-slider output { padding: 1px 6px; border-radius: 5px; background: var(--accent-wash); color: var(--accent-dark); font-size: .8rem; font-variant-numeric: tabular-nums; }
.rule-graph-slider input { display: block; width: 100%; height: 26px; margin: 2px 0 0; accent-color: var(--accent); cursor: pointer; }
.rule-graph-range { color: var(--muted); font-size: .77rem; }
.rule-graph-reset { width: 100%; margin-top: 18px; }

.rule-graph-panel { padding: 13px; }
.rule-graph-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 10px 16px; margin-bottom: 12px; }
.rule-graph-search { flex: 1 1 44%; min-width: 0; max-width: 24rem; position: relative; }
.rule-graph-mode { text-align: end; min-width: 0; }
.rule-graph-mode strong { display: block; overflow-wrap: anywhere; }
.rule-graph-mode p { font-size: .83rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.rule-graph-stage { position: relative; }
.rule-graph-chart {
  position: relative;
  height: clamp(418px, calc(100svh - 292px), 740px);
  overflow: hidden;
  border: 1px solid #343b54;
  border-radius: 12px;
  background: radial-gradient(ellipse at 49% 52%, #242d4773, transparent 75%),
    radial-gradient(circle, #b0a9eb2c 1px, transparent 1.3px) center / 22px 22px, #111626;
  cursor: grab;
  touch-action: none;
}
.rule-graph-chart canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.rule-graph-chart[data-hover='node'], .rule-graph-chart[data-hover='edge'] { cursor: pointer; }
.rule-graph-chart.is-dragging { cursor: grabbing; }
.rule-graph-controls { position: absolute; inset-inline-end: 11px; bottom: 11px; display: flex; gap: 4px; }
.rule-graph-controls button {
  min-width: 39px;
  min-height: 39px;
  border: 1px solid #7d87a1;
  border-radius: 7px;
  padding-inline: 9px;
  background: #1d263d;
  color: #f4f6ff;
  font-size: .87rem;
  font-weight: 710;
}
.rule-graph-controls button:hover { background: #344260; }
.rule-graph-controls button:nth-child(-n+2) { font-size: 1.2rem; }
.rule-graph-empty { position: absolute; inset: 0; display: grid; place-content: center; padding: 15px; text-align: center; color: white; }
.rule-graph-empty span { color: #bfc9e4; font-size: .9rem; }
.rule-graph-order { margin: 4px 0 10px; }
.rule-graph-rule-list {
  max-height: min(67svh, 42rem);
  overflow: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  padding: 2px 6px 2px 2px;
  list-style: none;
  scrollbar-gutter: stable;
}
.rule-graph-rule-list li { border: 1px solid var(--line); border-radius: 8px; }
.rule-graph-rule-list li + li { margin-top: 6px; }
.rule-graph-rule-toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 9px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  background: white;
  color: var(--ink);
  text-align: start;
}
.rule-graph-rule-toggle:hover, .rule-graph-rule-toggle[aria-expanded='true'] {
  background: color-mix(in srgb, var(--rule-family) 9%, white);
}
.rule-graph-rule-toggle:focus-visible { outline-offset: -2px; }
.rule-graph-rule-toggle::after {
  content: '';
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  width: 7px;
  height: 7px;
  margin: 4px 2px 0;
  border-inline-end: 2px solid var(--rule-family);
  border-block-end: 2px solid var(--rule-family);
  transform: rotate(45deg);
}
.rule-graph-rule-toggle[aria-expanded='true']::after { margin-top: 7px; transform: rotate(225deg); }
.rule-graph-rule-name { font-size: .86rem; font-weight: 720; line-height: 1.3; overflow-wrap: anywhere; }
.rule-graph-rule-meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 8px; font-size: .76rem; }
.rule-graph-rule-meta span:first-child { color: var(--rule-family); font-weight: 700; }
.rule-graph-rule-meta span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.rule-graph-rule-evidence { padding: 0 11px 9px; border-top: 1px solid var(--line); }

.rule-graph-type {
  display: inline-block;
  margin-block: 13px;
  padding: 3px 8px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--rule-family) 11%, white);
  color: var(--rule-family);
  font-size: .82rem;
  font-weight: 700;
}
.rule-graph-relationship { display: grid; gap: 11px; border-inline-start: 3px solid var(--rule-family); padding-inline-start: 11px; }
.rule-graph-relationship dt, .rule-graph-metrics dt { color: var(--muted); font-size: .83rem; font-weight: 680; }
.rule-graph-relationship dd { display: flex; flex-wrap: wrap; gap: 4px; overflow-wrap: anywhere; }
.rule-graph-term { margin-top: 2px; padding: 2px 7px; border-radius: 5px; background: var(--wash); font-size: .88rem; font-weight: 650; }
.rule-graph-term:is([data-term='tag'], [data-term='genre']) { background: #eaf2fd; color: #25599c; }
.rule-graph-metrics { display: grid; grid-template-columns: 1fr 1fr; margin-block: 16px; border-block: 1px solid var(--line); }
.rule-graph-metrics div { padding-block: 10px; }
.rule-graph-metrics div + div { border-inline-start: 1px solid var(--line); padding-inline-start: 12px; }
.rule-graph-metrics dd { font-size: 1.35rem; font-weight: 780; font-variant-numeric: tabular-nums; }
.rule-graph-evidence h3 { font-size: 1rem; margin-bottom: 5px; }
.rule-graph-evidence p, .rule-graph-fitted { color: var(--muted); font-size: .89rem; }
.rule-graph-fitted { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.rule-graph-fitted button { margin-top: 4px; text-align: start; }

@media (max-width: 1120px) {
  .rule-graph-grid { grid-template-columns: minmax(180px, 22%) minmax(0, 1fr); gap: 12px; }
  .rule-graph-detail { grid-column: 2; }
  .rule-graph-chart { height: clamp(445px, 53vw, 570px); }
}

@media (max-width: 690px) {
  .rule-graph-grid { grid-template-columns: minmax(0, 1fr); }
  .rule-graph-detail { grid-column: auto; }
  .rule-graph-filters { padding: 13px; }
  .rule-graph-filters fieldset { margin-top: 9px; }
  .rule-graph-family { display: inline-flex; margin-inline-end: 8px; }
  .rule-graph-sliders { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; margin-top: 8px; padding-top: 8px; }
  .rule-graph-reset { margin-top: 9px; width: auto; }
  .rule-graph-panel { padding: 9px; }
  .rule-graph-chart { height: 438px; }
}

@media (max-width: 540px) {
  .rule-graph-toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
  .rule-graph-search { max-width: none; }
  .rule-graph-mode { display: flex; gap: 5px 12px; align-items: center; justify-content: space-between; text-align: start; }
}
