:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-alt: #eef3f7;
  --text: #17202a;
  --muted: #5b6675;
  --border: #d7dde5;
  --blue: #2563eb;
  --green: #16805c;
  --amber: #b45309;
  --red: #b42318;
  --shadow: 0 18px 50px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select {
  font: inherit;
}

.site-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(20px, 4vw, 56px);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.35rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.site-header nav {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
}

.site-header nav a,
#focused-link,
#reset-view {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 11px;
  background: var(--surface);
  color: var(--text);
}

.site-header nav a:hover,
#focused-link:hover,
#reset-view:hover {
  border-color: var(--blue);
  text-decoration: none;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lede {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
}

main {
  padding: 16px clamp(16px, 4vw, 56px) 56px;
}

.toolbar,
.panel,
.graph-panel,
.stat-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.toolbar {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.graph-toolbar {
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
}

.search-label {
  font-size: 0.9rem;
  font-weight: 700;
}

#search,
.filter-row select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.7fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.filter-row label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

#reset-view {
  cursor: pointer;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.stat-card {
  padding: 16px;
}

.stat-card strong {
  display: block;
  font-size: 1.7rem;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.85rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.docs-grid,
.lower-layout {
  margin-top: 18px;
}

.docs-grid {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(260px, 320px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel,
.graph-panel {
  min-width: 0;
  overflow: hidden;
}

.panel-heading {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.panel-heading h2 {
  margin: 0;
  font-size: 1rem;
}

.panel-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.graph-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.card-list,
.chip-list,
.topic-list {
  padding: 14px;
}

.track-card {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.track-card + .track-card {
  margin-top: 10px;
}

.track-card[aria-pressed="true"],
.role-chip[aria-pressed="true"] {
  border-color: var(--blue);
  background: #eef4ff;
}

.track-card strong {
  display: block;
}

.track-card span,
.topic-meta,
.topic-summary {
  color: var(--muted);
  font-size: 0.88rem;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.role-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--surface);
  cursor: pointer;
}

.topic-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.topic-card + .topic-card {
  margin-top: 10px;
}

.topic-card h3 {
  margin: 0 0 5px;
  font-size: 1rem;
}

.topic-summary {
  margin: 8px 0 10px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-row a,
.tag-row span {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 7px;
  color: var(--muted);
  font-size: 0.78rem;
}

#graph {
  display: block;
  width: 100%;
  height: 560px;
  background:
    linear-gradient(#eef3f7 1px, transparent 1px),
    linear-gradient(90deg, #eef3f7 1px, transparent 1px);
  background-size: 32px 32px;
}

.graph-link {
  stroke: #aab4c1;
  stroke-width: 1.1;
}

.graph-link.related {
  stroke: var(--amber);
  stroke-dasharray: 5 5;
}

.graph-link.overlap {
  stroke: var(--green);
  stroke-opacity: 0.72;
}

.graph-node circle {
  stroke: var(--surface);
  stroke-width: 2;
}

.graph-node text {
  fill: var(--text);
  font-size: 12px;
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.graph-node {
  cursor: pointer;
}

.graph-node:focus-visible circle {
  outline: 3px solid var(--blue);
}

.node-root circle {
  fill: var(--text);
}

.node-domain circle {
  fill: var(--blue);
}

.node-group circle {
  fill: var(--green);
}

.node-topic circle {
  fill: var(--amber);
}

.node-role circle {
  fill: var(--red);
}

@media (max-width: 980px) {
  .site-header,
  .layout,
  .docs-grid,
  .filter-row {
    grid-template-columns: 1fr;
  }

  .site-header {
    display: grid;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #graph {
    height: 520px;
  }
}

@media (max-width: 560px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .graph-heading {
    display: grid;
  }
}
