:root {
  --bg: #08080c;
  --bg-alt: #0b0b12;
  --surface: #0e0e16;
  --surface-2: #13131d;
  --border: #1c1c2e;
  --border-hi: #2a2a42;
  --border-control: #63637f;
  --text: #e4e4ef;
  --text-dim: #9090a8;
  --text-mute: #82829c;
  --accent: #f7931a;
  --white: #fff;
  --mono: 'JetBrains Mono', monospace;
  --display: 'Syne', system-ui, sans-serif;
  --nav-height: 64px;
  --max-width: 1120px;
  --gutter: clamp(20px, 5vw, 60px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  color-scheme: dark;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + 20px);
}

body {
  min-width: 320px;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

body::after {
  position: fixed;
  z-index: 9999;
  inset: 0;
  pointer-events: none;
  content: '';
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 0, 0, 0.015) 2px, rgba(0, 0, 0, 0.015) 4px);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

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

.skip-link {
  position: fixed;
  z-index: 10000;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  transform: translateY(-160%);
  border-radius: 4px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
}

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

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

.site-nav {
  position: fixed;
  z-index: 1000;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  height: var(--nav-height);
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--border);
  background: rgba(8, 8, 12, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.nav-logo,
.footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--white);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.nav-links {
  display: flex;
  gap: clamp(12px, 2vw, 28px);
  list-style: none;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.nav-links a {
  color: var(--text-dim);
  transition: color 0.2s;
}

.nav-links a:hover {
  color: var(--white);
}

.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  margin-right: -10px;
  cursor: pointer;
  border: 0;
  background: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 20px;
  line-height: 1;
}

main,
footer {
  width: 100%;
}

.hero,
.catalog-section {
  padding-right: var(--gutter);
  padding-left: var(--gutter);
}

.hero {
  position: relative;
  display: flex;
  min-height: 540px;
  align-items: center;
  padding-top: calc(var(--nav-height) + 72px);
  padding-bottom: 72px;
  background:
    radial-gradient(circle at 78% 42%, rgba(247, 147, 26, 0.08), transparent 28%),
    linear-gradient(180deg, var(--bg), var(--bg-alt));
}

.hero::after {
  position: absolute;
  right: var(--gutter);
  bottom: 0;
  left: var(--gutter);
  height: 1px;
  content: '';
  background: linear-gradient(90deg, var(--accent), rgba(247, 147, 26, 0.08));
}

.hero-grid,
.catalog-section {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, auto);
  gap: clamp(40px, 6vw, 80px);
  align-items: end;
}

.eyebrow {
  margin-bottom: 16px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4 {
  color: var(--white);
  font-family: var(--display);
  line-height: 1.18;
}

h1 {
  max-width: none;
  white-space: nowrap;
  font-size: clamp(42px, 3.7vw, 53px);
  font-weight: 700;
  letter-spacing: -0.04em;
}

h2 {
  font-size: clamp(26px, 4vw, 38px);
  letter-spacing: -0.02em;
}

.hero-sub {
  max-width: 680px;
  margin-top: 22px;
  color: var(--text-dim);
  font-size: clamp(14px, 1.6vw, 17px);
  line-height: 1.7;
}

.hero-source {
  max-width: 62ch;
  margin: 14px 0 0;
  color: var(--text-mute);
  font-size: 13px;
  line-height: 1.65;
}

.hero-source a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.library-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(14, 14, 22, 0.72);
}

.library-stats div {
  padding: 22px 18px;
}

.library-stats div + div {
  border-left: 1px solid var(--border);
}

.library-stats dt {
  margin-bottom: 8px;
  color: var(--text-mute);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.library-stats dd {
  white-space: nowrap;
  color: var(--white);
  font-family: var(--display);
  font-size: clamp(17px, 1.7vw, 23px);
  font-weight: 700;
}

.section-divider {
  position: relative;
}

.section-divider::before {
  position: absolute;
  top: 0;
  right: var(--gutter);
  left: var(--gutter);
  height: 1px;
  content: '';
  background: linear-gradient(90deg, var(--accent), rgba(247, 147, 26, 0.08));
}

.catalog-section {
  padding-top: 80px;
  padding-bottom: 90px;
}

.section-heading,
.viewer-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
}

.results-count {
  color: var(--text-mute);
  font-size: 12px;
}

.search-wrap {
  margin-top: 42px;
}

.search-wrap > label,
.filter-label {
  display: block;
  margin-bottom: 10px;
  color: var(--text-mute);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.search-control {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border: 1px solid var(--border-control);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-mute);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.search-control:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(247, 147, 26, 0.1);
}

.search-control input {
  min-width: 0;
  flex: 1;
  padding: 16px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.search-control input::placeholder {
  color: var(--text-mute);
}

kbd {
  padding: 2px 8px;
  border: 1px solid var(--border-hi);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-mute);
  font-size: 11px;
}

.filter-row {
  margin-top: 26px;
}

.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-button {
  min-height: 42px;
  padding: 9px 14px;
  cursor: pointer;
  border: 1px solid var(--border-control);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-dim);
  font-size: 11px;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.filter-button:hover,
.filter-button[aria-pressed='true'] {
  border-color: var(--accent);
  background: rgba(247, 147, 26, 0.1);
  color: var(--accent);
}

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

.catalog-status {
  margin-top: 24px;
  padding: 12px 16px;
  border: 1px solid rgba(255, 59, 48, 0.35);
  border-radius: 6px;
  background: rgba(255, 59, 48, 0.08);
  color: #ff8a84;
}

.chart-groups {
  margin-top: 48px;
}

.category-group + .category-group {
  margin-top: 68px;
}

.category-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border-hi);
}

.category-title {
  font-size: clamp(22px, 3vw, 30px);
}

.category-count {
  flex: 0 0 auto;
  color: var(--text-mute);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 22px;
}

.chart-card {
  display: flex;
  min-height: 300px;
  flex-direction: column;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.chart-card:hover,
.chart-card:focus-within {
  transform: translateY(-2px);
  border-color: rgba(247, 147, 26, 0.65);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
}

.featured-label {
  display: block;
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.chart-card h4 {
  font-size: 18px;
}

.card-description {
  margin-top: 12px;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.65;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
  list-style: none;
}

.tag-list li {
  padding: 4px 8px;
  border: 1px solid var(--border-hi);
  border-radius: 4px;
  color: var(--text-mute);
  font-size: 9px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 24px;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  cursor: pointer;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.button-primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--bg);
}

.button-primary:hover {
  border-color: var(--white);
  background: var(--white);
}

.button-secondary {
  border: 1px solid var(--border-control);
  background: transparent;
  color: var(--text-dim);
}

.button-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.no-results {
  grid-column: 1 / -1;
  padding: 58px 24px;
  border: 1px dashed var(--border-hi);
  border-radius: 8px;
  color: var(--text-mute);
  text-align: center;
}

.viewer-section {
  margin-top: 34px;
  padding: clamp(24px, 4vw, 40px);
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  background: var(--bg-alt);
}

.viewer-section[hidden] {
  display: none;
}

.viewer-copy {
  max-width: 720px;
}

.viewer-copy > p:last-child {
  margin-top: 12px;
  color: var(--text-dim);
}

.viewer-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
}

.viewer-scroll-hint {
  display: none;
  margin-top: 24px;
  color: var(--text-mute);
  font-size: 10px;
}

.chart-frame-wrap {
  position: relative;
  min-height: 520px;
  margin-top: 34px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--white);
}

.frame-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--text-mute);
}

.chart-frame-wrap.loaded .frame-loading {
  display: none;
}

#chartFrame {
  display: block;
  width: 100%;
  min-height: 520px;
  border: 0;
  background: var(--white);
}

footer {
  padding: 80px var(--gutter) 40px;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.footer-top {
  display: grid;
  grid-template-columns: minmax(240px, 1.5fr) repeat(3, minmax(130px, 1fr));
  gap: 40px;
  margin-bottom: 60px;
}

.footer-brand {
  color: var(--white);
}

.footer-tagline {
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.6;
}

.footer-col-title {
  margin-bottom: 16px;
  color: var(--text-mute);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
  list-style: none;
}

.footer-links a {
  color: var(--text-dim);
  font-size: 12px;
}

.footer-links a:hover {
  color: var(--white);
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  color: var(--text-mute);
  font-size: 11px;
}

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

  .library-stats {
    max-width: 520px;
  }

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

  .viewer-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 680px) {
  .site-nav {
    gap: 16px;
  }

  .nav-links {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    display: none;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
  }

  .nav-links.open {
    display: flex;
    flex-direction: column;
  }

  .nav-links li {
    padding: 12px var(--gutter);
  }

  .nav-links a {
    display: block;
    padding: 8px 0;
    font-size: 16px;
  }

  .nav-toggle {
    display: flex;
  }

  .hero {
    min-height: 520px;
    padding-top: calc(var(--nav-height) + 54px);
    padding-bottom: 54px;
  }

  h1 {
    white-space: normal;
    font-size: clamp(38px, 13vw, 58px);
  }

  .catalog-section {
    padding-top: 58px;
    padding-bottom: 64px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .search-wrap {
    margin-top: 32px;
  }

  .category-filters {
    flex-wrap: nowrap;
    margin-right: calc(var(--gutter) * -1);
    padding-right: var(--gutter);
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .filter-button {
    flex: 0 0 auto;
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .category-group + .category-group {
    margin-top: 54px;
  }

  .category-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .chart-card {
    min-height: 0;
  }

  .viewer-actions,
  .card-actions {
    width: 100%;
  }

  .viewer-actions {
    flex-direction: column;
  }

  .viewer-actions .button,
  .card-actions .button {
    flex: 1;
  }

  .chart-frame-wrap,
  #chartFrame {
    min-height: 620px;
  }

  .viewer-scroll-hint {
    display: block;
  }

  .chart-frame-wrap {
    margin-top: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
  }

  #chartFrame {
    width: 720px;
    max-width: none;
  }

  footer {
    padding: 48px var(--gutter) 32px;
  }

  .footer-top {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .footer-bottom {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
