:root {
  color-scheme: light;
  --bg-color: #ffffff;
  --panel-bg: #f6f8fa;
  --panel-border: #d0d7de;
  --text-color: #0f172a;
  --muted-text: #475569;
  --link-color: #1f6feb;
  --legend-bg: #ffffff;
  --node-outline: steelblue;
  --node-fill: #ffffff;
  --link-stroke: #030712;
}

[data-theme='dark'] {
  color-scheme: dark;
  --bg-color: #0f172a;
  --panel-bg: #1e293b;
  --panel-border: #334155;
  --text-color: #e2e8f0;
  --muted-text: #94a3b8;
  --link-color: #93c5fd;
  --legend-bg: #1e293b;
  --node-outline: #93c5fd;
  --node-fill: #0f172a;
  --link-stroke: #64748b;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg-color: #0f172a;
    --panel-bg: #1e293b;
    --panel-border: #334155;
    --text-color: #e2e8f0;
    --muted-text: #94a3b8;
    --link-color: #93c5fd;
    --legend-bg: #1e293b;
    --node-outline: #93c5fd;
    --node-fill: #0f172a;
    --link-stroke: #94a3b8;
  }
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-size: 14px;
  font-family: "Helvetica Neue", Helvetica;
  margin: 0;
  padding: 0 12px;
}

#body {
  margin: 0 auto;
  position: relative;
  max-width: 1280px;
}

#primary-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 20px auto 10px;
  max-width: 720px;
  align-items: center;
}

.nav-links {
  display: flex;
  gap: 12px;
  flex: 1;
}

.nav-link {
  flex: 1;
  text-align: center;
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-color);
  font-weight: 600;
  background: var(--panel-bg);
}

.nav-link.active {
  background: var(--link-color);
  color: #fff;
  border-color: var(--link-color);
}

.theme-toggle {
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  color: var(--text-color);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
}

#header {
  font-size: 40px;
  font-weight: bold;
  top: 20px;
  text-align: center;
}

.legend {
  position: absolute;
  top: 0px;
  right: 0;
  width: 330px;
  font-size: 11px;
  color: var(--text-color);
  background: var(--legend-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 8px;
}

.node {
  cursor: pointer;
}

.node circle {
  cursor: pointer;
  fill: var(--node-fill);
  stroke: var(--node-outline);
  stroke-width: 1.5px;
}

.node text {
  font-size: 12px;
  fill: var(--text-color);
}

path.link {
  fill: none;
  stroke: var(--link-stroke);
  stroke-width: 1px;
}

@media (max-width: 768px) {
  #header {
    font-size: 28px;
  }

  #primary-nav {
    flex-direction: column;
  }

  .nav-links {
    width: 100%;
  }

  .legend {
    position: relative;
    width: 100%;
    margin-top: 20px;
  }

  body {
    padding: 0 6px;
  }
}
