:root {
  --bg: #ffffff;
  --panel: #f6f8fa;
  --ink: #1f2328;
  --muted: #59636e;
  --line: #d1d9e0;
  --accent: #0969da;
  --accent-soft: #ddf4ff;
  --hot: #bf3989;
  --code-bg: #eff2f5;
  --warn: #9a6700;
  --ok: #1a7f37;
  --radius: 6px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --panel: #151b23;
  --ink: #e6edf3;
  --muted: #9198a1;
  --line: #3d444d;
  --accent: #4493f8;
  --accent-soft: #11294a;
  --hot: #db61a2;
  --code-bg: #1f2630;
  --warn: #d29922;
  --ok: #3fb950;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px / 1.6 var(--sans);
}

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

a:hover {
  text-decoration: underline;
}

code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--code-bg);
  padding: 0.12em 0.36em;
  border-radius: 4px;
}

pre {
  background: var(--code-bg);
  padding: 12px 14px;
  border-radius: var(--radius);
  overflow: auto;
}

pre code {
  background: none;
  padding: 0;
}

button {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 10px;
  cursor: pointer;
}

button:hover {
  border-color: var(--muted);
}

/* ------------------------------------------------------------- frame */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 52px;
  padding: 0 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 600;
  color: var(--ink);
}

.snapshot {
  color: var(--muted);
  font-size: 13px;
}

.search {
  margin-left: auto;
  width: min(340px, 40vw);
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px 10px;
}

.search-results {
  position: absolute;
  top: 48px;
  right: 18px;
  width: min(560px, 92vw);
  max-height: 70vh;
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
}

.search-results a {
  display: block;
  padding: 8px 12px;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

.search-results a:hover,
.search-results a:focus {
  background: var(--accent-soft);
  text-decoration: none;
}

.search-results small {
  display: block;
  color: var(--muted);
}

.search-results mark {
  background: none;
  color: var(--accent);
  font-weight: 600;
}

.menu {
  display: none;
}

.layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 220px;
}

.sidebar,
.toc {
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
  overflow: auto;
  padding: 18px 12px 40px;
  font-size: 13.5px;
}

.sidebar {
  border-right: 1px solid var(--line);
}

.nav-group {
  margin-bottom: 18px;
}

.nav-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 8px 6px;
}

.sidebar a,
.toc a {
  display: block;
  padding: 3px 8px;
  border-radius: 4px;
  color: var(--ink);
}

.sidebar a:hover,
.toc a:hover {
  background: var(--panel);
  text-decoration: none;
}

.sidebar a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.toc a {
  color: var(--muted);
}

.toc a.toc-l3 {
  padding-left: 20px;
}

.toc a.active {
  color: var(--accent);
}

.toc-inline {
  display: none;
  max-width: 920px;
  margin: 0 0 18px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
}

.toc-inline summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
}

.toc-inline a {
  display: block;
  padding: 2px 0;
}

.toc-inline a.toc-l3 {
  padding-left: 16px;
}

.content {
  position: relative;
  padding: 28px 36px 80px;
  min-width: 0;
}

.source {
  position: absolute;
  top: 30px;
  right: 44px;
  font-size: 13px;
}

/* ------------------------------------------------------------- prose */

.prose {
  max-width: none;
}

.prose > :not(figure):not(.table-wrap) {
  max-width: 920px;
}

.prose h1 {
  font-size: 30px;
  line-height: 1.25;
  margin: 0 0 18px;
  padding-right: 110px;
}

.prose h2 {
  font-size: 22px;
  margin: 40px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.prose h3 {
  font-size: 17px;
  margin: 28px 0 8px;
}

.prose h4 {
  font-size: 15px;
  margin: 22px 0 6px;
}

.anchor {
  float: left;
  margin-left: -20px;
  width: 20px;
  color: var(--muted);
  opacity: 0;
}

h1:hover .anchor,
h2:hover .anchor,
h3:hover .anchor,
h4:hover .anchor {
  opacity: 1;
}

.prose img {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.table-wrap {
  overflow-x: auto;
  margin: 14px 0;
}

table {
  border-collapse: collapse;
  font-size: 14px;
  width: 100%;
}

th,
td {
  border: 1px solid var(--line);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--panel);
  font-weight: 600;
}

tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--panel) 45%, transparent);
}

blockquote {
  margin: 14px 0;
  padding: 2px 14px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

/* ------------------------------------------------------------ diagrams */

.diagram {
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.mermaid-host {
  display: flex;
  justify-content: center;
  overflow-x: auto;
}

.mermaid-host.scrolls {
  justify-content: flex-start;
}

.mermaid-host svg {
  flex: none;
}

.diagram-tools {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.diagram-tools button {
  font-size: 12px;
}

.diagram-error {
  color: var(--hot);
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
}

.zoom-dialog {
  width: 96vw;
  height: 92vh;
  max-width: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
}

.zoom-dialog::backdrop {
  background: rgb(0 0 0 / 0.55);
}

.zoom-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.zoom-bar span {
  margin-right: auto;
}

.zoom-stage {
  width: 100%;
  height: calc(100% - 45px);
  overflow: hidden;
  cursor: grab;
}

.zoom-stage svg {
  transform-origin: 0 0;
  max-width: none !important;
}

/* ------------------------------------------------------------ explorers */

.explore h1 {
  font-size: 28px;
  margin: 0 0 6px;
}

.lede {
  color: var(--muted);
  max-width: 820px;
  margin: 0 0 20px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin: 18px 0 26px;
}

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

.card .value {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
}

.card .label {
  color: var(--muted);
  font-size: 13px;
}

.panel {
  margin: 0 0 28px;
}

.panel h2 {
  font-size: 18px;
  margin: 0 0 4px;
}

.panel p {
  color: var(--muted);
  margin: 0 0 10px;
  max-width: 820px;
}

.chart {
  width: 100%;
  overflow-x: auto;
}

.chart svg text {
  fill: var(--ink);
  font-size: 12px;
}

.chart .axis text {
  fill: var(--muted);
  font-size: 11px;
}

.chart .axis line,
.chart .axis path,
.chart .grid line {
  stroke: var(--line);
}

.tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  max-width: 360px;
  padding: 6px 9px;
  font-size: 12.5px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 4px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 0 0 12px;
}

.controls input[type="search"],
.controls select {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px 9px;
}

.controls label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 13.5px;
}

.count {
  color: var(--muted);
  font-size: 13px;
}

.pill {
  display: inline-block;
  padding: 0 7px;
  border-radius: 10px;
  font-size: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.pill.stream {
  border-color: var(--warn);
  color: var(--warn);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
}

.explore {
  max-width: 1500px;
}

.layout:has(.explore) {
  grid-template-columns: 250px minmax(0, 1fr);
}

.graph {
  height: min(760px, 78vh);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 14px;
  max-height: 640px;
  overflow: auto;
}

.details h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.details dl {
  margin: 0;
}

.details dt {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 10px;
}

.details dd {
  margin: 2px 0 0;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12.5px;
}

.api-table code {
  overflow-wrap: anywhere;
}

.api-table td:nth-child(4) {
  width: 48px;
}

.gallery {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  max-width: 1100px;
}

.gallery .diagram {
  margin: 0;
}

.gallery h3 {
  font-size: 14px;
  margin: 0 0 8px;
}

.gallery h3 small {
  display: block;
  color: var(--muted);
  font-weight: 400;
}

/* ------------------------------------------------------ direction picker */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.picker-top {
  display: grid;
  gap: 14px;
  margin: 0 0 18px;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.presets button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.weights {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 6px 18px;
  align-items: center;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.weights legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.weights label {
  display: grid;
  grid-template-columns: 1fr 96px 16px;
  gap: 8px;
  align-items: center;
  font-size: 13.5px;
}

.weights output {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.weights button {
  justify-self: start;
}

.picker-summary {
  position: sticky;
  top: 52px;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin: 0 0 20px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.verdict {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.verdict p {
  margin: 2px 0 0;
}

.verdict-score {
  display: grid;
  min-width: 150px;
}

.verdict-score .big {
  font-size: 30px;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.problems p,
.problems ul {
  margin: 0;
}

.issues {
  padding-left: 18px;
  color: var(--warn);
}

.issues button {
  margin-left: 6px;
  padding: 0 8px;
  font-size: 12.5px;
}

.ok {
  color: var(--ok);
}

.picker-charts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
}

.waves {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.wave h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.wave ol {
  margin: 0;
  padding-left: 18px;
}

.wave li {
  margin: 0 0 8px;
}

.area {
  margin: 0 0 34px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 150px;
}

.area header h2 {
  margin: 0;
  font-size: 20px;
}

.area header p {
  margin: 2px 0 10px;
}

.today {
  margin: 0 0 12px;
}

.today summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 14px;
}

.today ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.options {
  display: grid;
  gap: 6px;
  margin: 0 0 12px;
  padding: 0;
  border: 0;
}

.option {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 120px 44px;
  grid-template-areas:
    "radio head meter score"
    "radio summary summary summary";
  gap: 2px 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.option:hover {
  border-color: var(--muted);
}

.option.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option input {
  grid-area: radio;
  align-self: start;
  margin-top: 4px;
}

.option-head {
  grid-area: head;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.option-summary {
  grid-area: summary;
  color: var(--muted);
  font-size: 13.5px;
}

.meter {
  grid-area: meter;
  height: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  background: var(--muted);
}

.option.is-best .meter span {
  background: var(--accent);
}

.option-score {
  grid-area: score;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 13px;
}

.option.is-best .option-score {
  color: var(--ink);
  font-weight: 600;
}

.pill.rec {
  border-color: var(--accent);
  color: var(--accent);
}

.option-detail h4 {
  margin: 12px 0 4px;
  font-size: 14px;
}

.option-detail ul {
  margin: 0;
  padding-left: 20px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 20px;
}

.detail-grid aside dl,
.rec-block dl {
  margin: 8px 0 0;
  font-size: 13.5px;
}

.detail-grid aside dt,
.rec-block dt {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12.5px;
}

.detail-grid aside dd,
.rec-block dd {
  margin: 0;
}

.score-table {
  width: 100%;
  margin-top: 12px;
  border-collapse: collapse;
  font-size: 13px;
}

.score-table caption {
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.score-table th {
  text-align: left;
  font-weight: 400;
  color: var(--muted);
  padding: 1px 0;
}

.dots {
  letter-spacing: 2px;
  color: var(--accent);
}

.dots .off {
  color: var(--line);
}

.rec-block {
  margin-top: 14px;
  padding: 10px 14px;
  border-left: 3px solid var(--accent);
  background: var(--panel);
}

.rec-block h4 {
  margin: 0;
}

.record {
  max-height: 320px;
  white-space: pre-wrap;
  font-size: 12.5px;
}

@media (max-width: 1100px) {
  .picker-charts,
  .picker-summary,
  .detail-grid,
  .waves {
    grid-template-columns: minmax(0, 1fr);
  }

  .picker-summary {
    position: static;
  }
}

@media (max-width: 620px) {
  .option {
    grid-template-columns: 20px minmax(0, 1fr) 44px;
    grid-template-areas:
      "radio head score"
      "radio summary summary";
  }

  .meter {
    display: none;
  }
}

/* ------------------------------------------------------------ narrow */

@media (max-width: 1600px) {
  .layout {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .toc {
    display: none;
  }

  .toc-inline {
    display: block;
  }
}

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .menu {
    display: inline-block;
  }

  .snapshot {
    display: none;
  }

  .topbar {
    gap: 8px;
    padding: 0 10px;
  }

  .brand {
    white-space: nowrap;
    font-size: 14px;
  }

  .search {
    width: auto;
    min-width: 0;
    flex: 1;
  }

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

  .sidebar {
    position: fixed;
    z-index: 15;
    left: 0;
    width: 280px;
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform 0.15s;
  }

  .sidebar.open {
    transform: none;
  }

  .content {
    padding: 20px 18px 60px;
  }

  .source {
    position: static;
    display: block;
    margin-bottom: 8px;
  }

  .prose h1 {
    padding-right: 0;
  }

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