:root {
  color-scheme: light;
  --ink: #171717;
  --muted: #676767;
  --faint: #939393;
  --line: #d9d9d6;
  --line-strong: #b9b9b4;
  --paper: #f4f4f1;
  --surface: #ffffff;
  --accent: #e5422b;
  --accent-soft: #fff0ed;
  --focus: #1b63d8;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input,
select { font: inherit; letter-spacing: 0; }

button,
select,
input { color: inherit; }

a { color: inherit; text-underline-offset: 3px; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 28%, transparent);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: end;
  gap: 2px;
  width: 20px;
  height: 18px;
}

.brand-mark i { display: block; width: 5px; background: var(--ink); }
.brand-mark i:nth-child(1) { height: 8px; }
.brand-mark i:nth-child(2) { height: 17px; background: var(--accent); }
.brand-mark i:nth-child(3) { height: 12px; }

.topnav { display: flex; gap: 22px; }
.topnav a { color: var(--muted); font-size: 13px; text-decoration: none; }
.topnav a:hover { color: var(--ink); }

main,
footer { width: min(1480px, calc(100% - 48px)); margin-inline: auto; }

.noscript-note { margin: 20px 0 0; padding: 14px 16px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.noscript-note a { margin-left: 4px; color: var(--ink); }

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 40px;
  min-height: 250px;
  padding: 54px 0 42px;
  border-bottom: 1px solid var(--line-strong);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  max-width: 760px;
  margin-bottom: 14px;
  font-size: 46px;
  line-height: 1.03;
  font-weight: 730;
}

.lede {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
}

.intro-stats {
  display: grid;
  grid-template-columns: repeat(3, 112px);
  gap: 1px;
  margin: 0;
  background: var(--line);
  border: 1px solid var(--line);
}

.intro-stats div { min-height: 92px; padding: 15px; background: var(--surface); }
.intro-stats dt { font-size: 29px; font-weight: 720; line-height: 1.15; }
.intro-stats dd { margin: 7px 0 0; color: var(--muted); font-size: 12px; }

.control-band {
  position: sticky;
  top: 62px;
  z-index: 15;
  padding: 16px 0 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 95%, transparent);
  backdrop-filter: blur(14px);
}

.controls {
  display: grid;
  grid-template-columns: minmax(240px, 1.6fr) repeat(3, minmax(150px, .8fr)) auto;
  gap: 10px;
  align-items: end;
}

.controls label,
.view-switch { display: grid; gap: 5px; min-width: 0; margin: 0; padding: 0; border: 0; }
.controls label > span,
.view-switch legend { color: var(--muted); font-size: 11px; font-weight: 650; }

input,
select,
.view-switch button,
.result-line button,
.dialog-actions button,
.dialog-actions a {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
}

input,
select { width: 100%; padding: 8px 10px; }
input::placeholder { color: #9a9a96; }

.view-switch { grid-template-columns: 1fr 1fr; }
.view-switch legend { grid-column: 1 / -1; }
.view-switch button { min-width: 58px; padding: 7px 10px; cursor: pointer; }
.view-switch button.is-active { border-color: var(--ink); color: #fff; background: var(--ink); }

.result-line {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 29px;
  padding-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.result-line strong { color: var(--ink); }
.result-line span + span::before { content: "/"; margin-right: 12px; color: var(--line-strong); }
.result-line button { min-height: 28px; margin-left: auto; padding: 3px 9px; cursor: pointer; }

.catalog-section,
.coverage-section,
.sources-section { padding: 42px 0 58px; }

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.section-heading h2 { margin: 0; font-size: 24px; line-height: 1.15; }
.section-heading > p { max-width: 560px; margin: 0; color: var(--muted); font-size: 13px; text-align: right; }

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

.component-card {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  transition: border-color 140ms ease, transform 140ms ease;
}

.component-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }

.preview-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--chart-bg, #fff);
  cursor: zoom-in;
}

.chart-preview {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 226px;
  overflow: hidden;
}

.chart-preview svg { display: block; width: 100%; height: 100%; }

.card-body { display: grid; gap: 12px; padding: 15px 16px 14px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-index { color: var(--faint); font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.card-kicker { margin: 0 0 4px; color: var(--muted); font-family: var(--mono); font-size: 10px; text-transform: uppercase; }
.card-title { margin: 0; font-size: 15px; line-height: 1.3; font-weight: 700; }
.card-description { margin: 0; color: var(--muted); font-size: 12px; }
.card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: auto; }
.chip { padding: 2px 6px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); font-size: 10px; }
.source-name { margin-left: auto; color: var(--muted); font-size: 10px; }
.component-page-link { color: var(--ink); font-size: 10px; font-weight: 650; text-decoration: none; }
.component-page-link:hover { text-decoration: underline; }

.component-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.component-grid.compact .chart-preview { min-height: 170px; }
.component-grid.compact .card-description { display: none; }
.component-grid.compact .card-body { gap: 9px; padding: 12px; }

.empty-state {
  padding: 80px 24px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
}
.empty-state p { margin: 6px 0 0; color: var(--muted); }

.coverage-section { border-top: 1px solid var(--line-strong); }
.coverage-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, .8fr); gap: 28px; align-items: start; }
.coverage-table-wrap { overflow-x: auto; }
.coverage-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.coverage-table th,
.coverage-table td { padding: 10px 9px; border-bottom: 1px solid var(--line); text-align: left; }
.coverage-table th { color: var(--muted); font-weight: 600; }
.coverage-table td:last-child,
.coverage-table th:last-child { text-align: right; }
.coverage-bar { display: inline-block; width: min(160px, 18vw); height: 7px; margin-right: 8px; background: #dfdfdb; vertical-align: middle; }
.coverage-bar i { display: block; height: 100%; background: var(--ink); }

.coverage-rules { padding-left: 24px; border-left: 1px solid var(--line); }
.coverage-rules h3 { margin-bottom: 12px; font-size: 15px; }
.coverage-rules ol { margin: 0; padding-left: 19px; color: var(--muted); font-size: 13px; }
.coverage-rules li + li { margin-top: 8px; }

.sources-section { border-top: 1px solid var(--line-strong); }
.source-index { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.source-item { min-width: 0; padding: 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.source-item strong { display: block; margin-bottom: 4px; font-size: 12px; }
.source-item span { color: var(--muted); font-size: 11px; }
.source-item a { display: inline-block; max-width: 100%; margin-top: 8px; overflow: hidden; color: var(--muted); font-family: var(--mono); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 0 34px;
  border-top: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 11px;
}

.footer-links { display: flex; flex-wrap: wrap; gap: 18px; }
footer p { margin: 0; }

dialog {
  width: min(1180px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 24px 90px rgba(0, 0, 0, .24);
}

dialog::backdrop { background: rgba(20, 20, 20, .56); }
.dialog-shell { max-height: calc(100dvh - 34px); overflow-y: auto; }
.dialog-header { position: sticky; top: 0; z-index: 3; display: flex; justify-content: space-between; align-items: start; gap: 20px; padding: 18px 20px 15px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(12px); }
.dialog-header h2 { margin: 0; font-size: 22px; }
.icon-button { width: 36px; height: 36px; padding: 0; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface); font-size: 25px; line-height: 1; cursor: pointer; }
.dialog-body { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(280px, .75fr); gap: 20px; padding: 20px; }
.dialog-preview { display: grid; place-items: center; min-height: 460px; overflow: hidden; border: 1px solid var(--line); background: var(--chart-bg, #fff); }
.dialog-preview svg { width: 100%; height: auto; }
.dialog-meta { display: flex; flex-direction: column; min-width: 0; }
.fact-list { border-top: 1px solid var(--line); }
.fact { display: grid; grid-template-columns: 92px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 11px; }
.fact dt { color: var(--muted); }
.fact dd { margin: 0; font-weight: 650; }
.dialog-description { margin: 18px 0 0; color: var(--muted); font-size: 13px; }
.dialog-use { margin: 12px 0 0; padding-left: 12px; border-left: 3px solid var(--accent); font-size: 12px; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: auto; padding-top: 24px; }
.dialog-actions button,
.dialog-actions a { display: inline-flex; align-items: center; justify-content: center; padding: 8px 10px; text-decoration: none; cursor: pointer; }
.dialog-actions button:first-child { border-color: var(--ink); color: #fff; background: var(--ink); }
.dialog-actions a { grid-column: 1 / -1; }
.data-panel { margin: 0 20px 20px; border-top: 1px solid var(--line); }
.data-panel summary { padding: 14px 0; cursor: pointer; font-weight: 650; }
.data-panel pre { max-height: 340px; margin: 0; padding: 16px; overflow: auto; border: 1px solid var(--line); background: #1a1a1a; color: #f4f4ef; font: 11px/1.55 var(--mono); }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: min(360px, calc(100% - 40px));
  padding: 10px 13px;
  border: 1px solid #333;
  border-radius: 5px;
  background: #171717;
  color: #fff;
  font-size: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .24);
}

@media (max-width: 1120px) {
  .component-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .component-grid.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .controls { grid-template-columns: minmax(240px, 1.5fr) repeat(2, minmax(150px, 1fr)); }
  .controls label:nth-of-type(4), .view-switch { grid-row: 2; }
  .source-index { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 800px) {
  main,
  footer { width: min(100% - 28px, 1480px); }
  .topbar { padding: 0 14px; }
  .topnav { gap: 14px; }
  .intro { grid-template-columns: 1fr; min-height: 0; padding: 36px 0 30px; }
  h1 { font-size: 38px; }
  .intro-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .controls { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .controls label:nth-of-type(4), .view-switch { grid-row: auto; }
  .component-grid,
  .component-grid.compact { grid-template-columns: 1fr; }
  .component-grid.compact .chart-preview { min-height: 220px; }
  .coverage-layout { grid-template-columns: 1fr; }
  .coverage-rules { padding: 20px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .source-index { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dialog-body { grid-template-columns: 1fr; }
  .dialog-preview { min-height: 0; }
  .dialog-actions { margin-top: 6px; }
}

@media (max-width: 520px) {
  .topnav a:nth-child(2) { display: none; }
  .intro { gap: 24px; }
  h1 { font-size: 32px; }
  .lede { font-size: 15px; }
  .intro-stats div { min-height: 76px; padding: 11px; }
  .intro-stats dt { font-size: 24px; }
  .control-band { position: static; }
  .controls { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .section-heading { align-items: start; flex-direction: column; gap: 8px; }
  .section-heading > p { text-align: left; }
  .chart-preview { min-height: 200px; }
  .source-index { grid-template-columns: 1fr; }
  footer { flex-direction: column; gap: 8px; }
  dialog { width: calc(100% - 16px); max-height: calc(100dvh - 16px); }
  .dialog-shell { max-height: calc(100dvh - 18px); }
  .dialog-header,
  .dialog-body { padding: 14px; }
  .data-panel { margin: 0 14px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .component-card { transition: none; }
}
