:root {
  color-scheme: light dark;
  --font-body: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  --page: #ffffff;
  --ink: #111111;
  --muted: #3f3f3f;
  --faint: #525252;
  --line: #dddddd;
  --line-strong: #8c8c8c;
  --accent: #0b4f9c;
  --accent-soft: #f4f7fb;
  --paper: #ffffff;
  --node-0: #111111;
  --node-1: #444444;
  --node-2: #626262;
  --node-3: #2d2d2d;
  --node-4: #737373;
  --node-5: #505050;
  --node-6: #858585;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-resolved-theme="dark"] {
  --page: #101010;
  --ink: #f2f2f2;
  --muted: #d0d0d0;
  --faint: #b9b9b9;
  --line: #363636;
  --line-strong: #8d8d8d;
  --accent: #b8ccff;
  --accent-soft: #171717;
  --paper: #101010;
  --node-0: #f2f2f2;
  --node-1: #d6d6d6;
  --node-2: #bfbfbf;
  --node-3: #e7e7e7;
  --node-4: #a8a8a8;
  --node-5: #cccccc;
  --node-6: #999999;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16.5px;
  line-height: 1.68;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 10ch;
  margin-bottom: 1.2rem;
  color: var(--ink);
  font-size: clamp(2.25rem, 5.5vw, 3.8rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.03;
  text-wrap: balance;
}

h2 {
  margin-bottom: 0.75rem;
  font-size: clamp(1.45rem, 3.2vw, 2.05rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
  text-wrap: balance;
}

h3 {
  margin-bottom: 0.45rem;
  font-size: 1rem;
  line-height: 1.25;
}

.inspector h2,
.activity h2 {
  margin-bottom: 0.45rem;
  font-size: 1rem;
  line-height: 1.25;
}

p {
  max-width: 66ch;
  color: var(--muted);
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 20;
  padding: 0.35rem 0.5rem;
  background: var(--paper);
  color: var(--ink);
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site {
  min-height: 100vh;
}

.site-header,
main,
.site-footer {
  width: min(100% - 32px, 980px);
  margin: 0 auto;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.4rem;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.nav-links,
.site-footer nav,
.link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
}

.nav-links {
  flex: 1 1 auto;
  justify-content: flex-start;
}

.nav-links a,
.site-footer a,
.link-list a,
.text-button,
.cluster-chip,
.repo-actions a,
.repo-row a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

.theme-switcher {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  border: 0;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.theme-switcher legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.theme-switcher label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.theme-switcher input {
  accent-color: var(--accent);
}

.intro {
  max-width: 700px;
  padding: clamp(3.4rem, 9vw, 6.5rem) 0 clamp(3rem, 8vw, 4.6rem);
}

.small-note {
  color: var(--faint);
  font-size: 0.92rem;
}

.intro-kicker {
  color: var(--ink);
  font-weight: 650;
}

.link-list {
  list-style: none;
  margin: 1.75rem 0 0;
  padding: 0;
}

.section {
  padding: clamp(2.7rem, 7vw, 5rem) 0;
  border-top: 1px solid var(--line);
}

.section-head {
  margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
}

.split-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.35fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: end;
}

.plain-list {
  display: grid;
  gap: 0;
}

.plain-list article,
.repo-row {
  display: grid;
  grid-template-columns: minmax(140px, 210px) minmax(0, 1fr);
  gap: 0.75rem 2rem;
  padding: 1.05rem 0;
  border-top: 1px solid var(--line);
}

.plain-list article:last-child,
.repo-row:last-child {
  border-bottom: 1px solid var(--line);
}

.plain-list p,
.repo-row p {
  margin-bottom: 0;
}

.focus-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1rem, 3vw, 2rem);
}

.focus-list article {
  display: block;
  border-bottom: 1px solid var(--line);
}

.repo-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 290px);
  gap: clamp(1.4rem, 4vw, 2.5rem);
  align-items: start;
}

.graph-panel,
.repo-side,
.canvas-wrap,
.repo-list,
.repo-row,
.repo-row > * {
  min-width: 0;
}

.graph-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.graph-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.7rem 1rem;
  align-items: center;
}

.graph-help-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  align-items: center;
}

.graph-help {
  position: relative;
  display: inline-flex;
}

.graph-help-trigger {
  appearance: none;
  border: 0;
  border-bottom: 1px dotted currentColor;
  background: transparent;
  color: var(--faint);
  cursor: help;
  font: inherit;
  font-size: 0.92rem;
  padding: 0.08rem 0;
}

.graph-help-trigger:hover,
.graph-help-trigger:focus-visible {
  color: var(--ink);
}

.graph-help-trigger span {
  margin-left: 0.18rem;
  font-size: 0.78em;
}

.graph-tooltip {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  z-index: 10;
  width: min(285px, calc(100vw - 3rem));
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
  opacity: 0;
  padding: 0.55rem 0.65rem;
  pointer-events: none;
  transform: translateY(-2px);
  transition:
    opacity 120ms var(--ease),
    transform 120ms var(--ease),
    visibility 120ms var(--ease);
  visibility: hidden;
}

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

.graph-help:first-child .graph-tooltip {
  right: auto;
  left: 0;
}

.graph-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

.graph-mode {
  display: inline-flex;
  gap: 0.45rem;
  align-items: baseline;
  color: var(--muted);
  font-size: 0.92rem;
}

.graph-mode button {
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0.08rem 0;
}

.graph-mode button[aria-pressed="true"] {
  border-color: currentColor;
  color: var(--ink);
  font-weight: 650;
}

.search-field {
  display: grid;
  min-width: min(100%, 420px);
  gap: 0.35rem;
  color: var(--muted);
}

.search-field span {
  font-size: 0.92rem;
}

.search-field input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  padding: 0.35rem 0;
  background: transparent;
  color: var(--ink);
  outline: none;
}

.search-field input::placeholder {
  color: var(--faint);
}

.search-field input:focus {
  border-color: var(--accent);
}

.text-button,
.cluster-chip {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0.1rem 0;
}

.inline-button {
  display: inline;
  margin-left: 0.35rem;
  font-size: inherit;
}

.refresh-status:empty {
  display: none;
}

.cluster-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.85rem;
  margin-bottom: 1rem;
}

.cluster-chip {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.cluster-swatch {
  width: 0.58rem;
  height: 0.58rem;
  border: 1px solid var(--ink);
  background: var(--cluster-color, var(--ink));
  opacity: 0.74;
}

.cluster-chip[aria-pressed="true"] {
  color: var(--ink);
  font-weight: 650;
  text-decoration-thickness: 2px;
  text-decoration-color: currentColor;
}

.filter-summary {
  margin: -0.35rem 0 1rem;
  color: var(--faint);
  font-size: 0.92rem;
}

.canvas-wrap {
  position: relative;
  min-height: clamp(390px, 48vw, 560px);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper);
}

#repo-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: inherit;
  cursor: grab;
  touch-action: none;
}

#repo-canvas.is-dragging {
  cursor: grabbing;
}

.graph-hint {
  position: absolute;
  left: 0.85rem;
  bottom: 0.75rem;
  max-width: calc(100% - 1.5rem);
  margin: 0;
  color: var(--faint);
  font-size: 0.92rem;
  pointer-events: none;
}

.repo-side {
  display: grid;
  gap: 1.75rem;
}

.inspector,
.activity {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.inspector:focus {
  outline: none;
}

.inspector dl {
  display: grid;
  gap: 0.45rem;
  margin: 1rem 0 0;
}

.inspector dl > div {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 0.75rem;
}

.inspector dt {
  color: var(--faint);
}

.inspector dd {
  margin: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.repo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-top: 1rem;
}

.activity-bars {
  display: grid;
  grid-template-columns: repeat(12, minmax(6px, 1fr));
  gap: 0.35rem;
  min-height: 76px;
  align-items: end;
  margin: 1rem 0 0.75rem;
}

.activity-bar {
  min-height: 18px;
  border: 0;
  border-bottom: 1px solid var(--ink);
  background: var(--ink);
  cursor: help;
  opacity: 0.72;
  padding: 0;
}

.activity-bar:hover,
.activity-bar:focus-visible {
  opacity: 1;
}

.activity-detail {
  min-height: 1.5em;
}

.repo-list {
  display: grid;
}

.list-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  align-items: baseline;
  justify-content: flex-end;
}

.limit-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.sort-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.6rem;
}

.limit-button,
.sort-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

.limit-button[aria-pressed="true"],
.sort-button[aria-pressed="true"] {
  color: var(--ink);
  font-weight: 650;
  text-decoration-thickness: 2px;
}

.repo-row {
  grid-template-columns: minmax(0, 200px) minmax(0, 1fr) minmax(84px, 120px) minmax(92px, 128px);
}

.repo-row a {
  text-align: left;
  overflow-wrap: anywhere;
  word-break: normal;
}

.repo-row p {
  overflow-wrap: anywhere;
}

.repo-row small {
  color: var(--faint);
}

.repo-updated {
  color: var(--faint);
  font-size: 0.92rem;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--line);
}

.site-footer p {
  margin: 0;
  color: var(--ink);
  font-weight: 650;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (max-width: 860px) {
  .split-head,
  .repo-layout,
  .focus-list,
  .plain-list article,
  .repo-row,
  .site-footer {
    grid-template-columns: 1fr;
  }

  .repo-row {
    gap: 0.4rem;
  }

  .list-tools {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 16px;
  }

  .site-header,
  main,
  .site-footer {
    width: min(100% - 24px, 980px);
  }

  .intro {
    padding-top: 3.5rem;
  }

  .canvas-wrap {
    min-height: 390px;
  }

  .theme-switcher,
  .nav-links {
    gap: 0.5rem 0.75rem;
  }

  .graph-controls {
    align-items: stretch;
  }

  .graph-actions {
    width: 100%;
    align-items: flex-start;
  }

  .graph-help-list {
    position: relative;
    width: 100%;
  }

  .graph-help {
    position: static;
  }

  .graph-tooltip {
    top: calc(100% + 0.45rem);
    right: auto;
    left: 0;
    width: min(100%, calc(100vw - 24px));
  }

  .search-field {
    min-width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
