:root {
  --bg: #f7f7f3;
  --panel: #ffffff;
  --text: #202124;
  --muted: #666b73;
  --border: #d8d9d5;
  --shadow: 0 8px 24px rgba(0,0,0,.08);
  --chip: #eef0f3;
  --accent: #263238;
  --footer-space: 28px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
}
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.4rem 1.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 20;
}
h1 { margin: 0; font-size: 1.45rem; }
.tagline { margin: .35rem 0 0; max-width: 820px; color: var(--muted); }
.meta { color: var(--muted); font-size: .9rem; text-align: right; min-width: 220px; }
.layout { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 1rem; padding: 1rem; height: calc(100vh - 112px - var(--footer-space)); overflow: hidden; }
.filters { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 1rem; height: 100%; overflow: auto; position: static; }
.filters section { margin-bottom: 1.15rem; }
.content { display: flex; flex-direction: column; gap: 1rem; align-content: start; min-width: 0; min-height: 0; }
.label { font-weight: 650; display: block; margin-bottom: .45rem; }
.search, input[type="number"] { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: .7rem .75rem; font: inherit; background: #fff; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.facet { display: flex; flex-direction: column; gap: .25rem; max-height: 220px; overflow: auto; padding-right: .2rem; }
.facet label { display: flex; gap: .45rem; align-items: baseline; font-size: .92rem; line-height: 1.25rem; }
.facet small { color: var(--muted); }
.button { border: 0; border-radius: 8px; padding: .65rem .8rem; margin-right: .4rem; margin-bottom: .4rem; background: var(--accent); color: #fff; font: inherit; cursor: pointer; }
.button.secondary { background: #e4e7e9; color: var(--text); }
.graph-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .8rem;
  overflow: hidden;
  position: sticky;
  top: .85rem;
  z-index: 3;
  box-shadow: 0 4px 14px rgba(0,0,0,.06);
  margin-top: -1.5rem;
}
.graph-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .75rem;
  margin-bottom: .4rem;
}
.graph-header h2 {
  margin: 0;
  font-size: 1rem;
}
.graph-status {
  margin: 0;
  color: var(--muted);
  font-size: .86rem;
  text-align: right;
}
.graph {
  width: 100%;
  height: 420px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background:
    radial-gradient(circle at 20% 10%, rgba(38, 50, 56, 0.08), rgba(255, 255, 255, 0) 55%),
    linear-gradient(120deg, #fbfcff 0%, #f4f6f9 100%);
}
.graph svg { width: 100%; height: 100%; display: block; }
.graph-link { stroke: #7f8fa1; stroke-opacity: .35; stroke-width: 1.2; }
.graph-link.hidden-neighbor { stroke-opacity: .65; stroke-dasharray: 4 3; }
.graph-link.focus-link { stroke: #0b57d0; stroke-opacity: .9; stroke-width: 2; }
.graph-node { stroke: #fff; stroke-width: 1.2; cursor: pointer; }
.graph-node.hidden-node { opacity: .45; }
.graph-node.center-node { stroke: #0b57d0; stroke-width: 2.6; }
.graph-label {
  fill: #28323a;
  font-size: .72rem;
  pointer-events: auto;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, .95);
  stroke-width: 3;
  stroke-linejoin: round;
}
.summary { margin: .25rem 0 .35rem; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: .85rem; overflow: auto; min-height: 0; flex: 1; padding-right: .25rem; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 1rem; box-shadow: 0 1px 0 rgba(0,0,0,.02); }
.card {
  transition: border-color 160ms ease;
}
.card:hover,
.card.hover-card,
.card:focus-within {
  border-color: #084fc7;
  border-width: 2px;
}
.card.active-card { border: 3px solid #0b57d0; box-shadow: none; }
.card h2 { margin: 0 0 .35rem; font-size: 1.05rem; }
.card h2 button { all: unset; cursor: pointer; color: #0b57d0; }
.desc { color: var(--muted); margin: .25rem 0 .7rem; min-height: 2.5em; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; margin: .45rem 0; }
.chip { background: var(--chip); border-radius: 999px; padding: .18rem .5rem; font-size: .8rem; color: #384047; }
.qid { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); font-size: .82rem; }
.dialog { width: min(940px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); border: 1px solid var(--border); border-radius: 14px; padding: 1.2rem; box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(0,0,0,.35); }
.close { position: absolute; right: .75rem; top: .5rem; font-size: 1.6rem; border: 0; background: transparent; cursor: pointer; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.detail-section { border-top: 1px solid var(--border); padding-top: .75rem; margin-top: .75rem; }
.rel { border: 1px solid var(--border); border-radius: 8px; padding: .55rem; margin: .4rem 0; background: #fbfbfa; }
a { color: #0b57d0; }
@media (max-width: 800px) {
  body { height: auto; overflow: auto; }
  .topbar { position: static; }
  .topbar { flex-direction: column; }
  .layout { grid-template-columns: 1fr; height: auto; overflow: visible; }
  .filters { position: static; height: auto; overflow: visible; }
  .content { min-height: auto; }
  .graph { height: 320px; }
  .graph-header { flex-direction: column; align-items: flex-start; }
  .graph-status { text-align: left; }
  .cards { overflow: visible; }
  .detail-grid { grid-template-columns: 1fr; }
}
