:root {
  --navy: #14213d;
  --navy-2: #1b2d50;
  --teal: #1f7a8c;
  --teal-light: #d9edf0;
  --gold: #e2a93b;
  --paper: #f6f3eb;
  --paper-2: #fffdf8;
  --ink: #17202a;
  --muted: #64748b;
  --line: #d8dde3;
  --white: #ffffff;
  --shadow: 0 18px 50px rgba(20, 33, 61, 0.1);
  --radius: 18px;
  --shell: min(1180px, calc(100% - 40px));
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.shell { width: var(--shell); margin-inline: auto; }

.skip-link {
  position: fixed;
  left: 16px;
  top: -80px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--gold);
  color: var(--navy);
  font-weight: 800;
  border-radius: 8px;
}
.skip-link:focus { top: 16px; }

.masthead {
  position: relative;
  overflow: hidden;
  min-height: 570px;
  color: var(--white);
  background:
    radial-gradient(circle at 84% 26%, rgba(31, 122, 140, 0.45), transparent 28%),
    linear-gradient(135deg, #101b34 0%, var(--navy) 55%, #193c51 100%);
}

.masthead::before,
.masthead::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 50%;
  pointer-events: none;
}
.masthead::before { width: 520px; height: 520px; right: -120px; top: 62px; }
.masthead::after { width: 360px; height: 360px; right: -40px; top: 142px; }

.masthead__ornament {
  position: absolute;
  width: 86px;
  height: 150px;
  right: max(9vw, 54px);
  top: 218px;
  border: 2px solid rgba(255, 255, 255, 0.32);
  border-radius: 46% 46% 38% 38% / 26% 26% 62% 62%;
  transform: rotate(8deg);
}
.masthead__ornament::before {
  content: "";
  position: absolute;
  width: 42px;
  height: 29px;
  left: 20px;
  top: -26px;
  border: 2px solid rgba(255, 255, 255, 0.32);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
}

.nav {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 26px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--white);
  text-decoration: none;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.wordmark__mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 20px;
}

.nav__links { display: flex; gap: 26px; font-size: 14px; }
.nav__links a { color: rgba(255, 255, 255, 0.8); text-decoration: none; }
.nav__links a:hover { color: var(--white); }

.hero { position: relative; z-index: 1; padding: 86px 0 96px; }
.hero h1,
.section-heading h2,
.downloads h2,
.about h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -0.045em;
}
.hero h1 {
  max-width: 810px;
  margin: 14px 0 24px;
  font-size: clamp(54px, 7vw, 92px);
  line-height: 0.96;
}

.eyebrow {
  color: #9bd1d9;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.16em;
}
.eyebrow--dark { color: var(--teal); }

.hero__lede {
  max-width: 680px;
  margin: 0;
  color: rgba(255, 255, 255, 0.75);
  font-size: clamp(18px, 2vw, 23px);
  line-height: 1.55;
}

.hero__status {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(530px, 100%);
  margin-top: 36px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
}
.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 5px rgba(226, 169, 59, 0.16);
}
.load-meter { height: 3px; flex: 1; overflow: hidden; border-radius: 4px; background: rgba(255, 255, 255, 0.14); }
.load-meter span { display: block; width: 0; height: 100%; background: var(--gold); transition: width 0.25s ease; }

.stats {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: -46px;
  background: var(--paper-2);
  border: 1px solid rgba(20, 33, 61, 0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat { padding: 28px 32px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat__value { display: block; color: var(--navy); font-family: Georgia, serif; font-size: clamp(30px, 3.4vw, 48px); line-height: 1; }
.stat__label { display: block; margin-top: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }

.explorer { padding: 104px 0 110px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 32px; margin-bottom: 34px; }
.section-heading h2, .downloads h2, .about h2 { margin: 8px 0 0; color: var(--navy); font-size: clamp(38px, 4vw, 58px); line-height: 1.05; }
.section-heading p { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
kbd { padding: 2px 7px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--white); font: 700 12px ui-monospace, monospace; }

.filters {
  padding: 25px;
  background: var(--paper-2);
  border: 1px solid rgba(20, 33, 61, 0.1);
  border-radius: var(--radius);
  box-shadow: 0 10px 35px rgba(20, 33, 61, 0.06);
}
.filters label { display: block; margin-bottom: 7px; color: var(--navy); font-size: 12px; font-weight: 800; letter-spacing: 0.02em; }
.search-field__input { position: relative; }
.search-field svg { position: absolute; left: 17px; top: 50%; width: 22px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-linecap: round; stroke-width: 1.7; }
.search-field input {
  width: 100%;
  height: 62px;
  padding: 0 55px 0 52px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid #cbd5df;
  border-radius: 12px;
  outline: none;
  font-size: 17px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-field input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(31, 122, 140, 0.13); }
.clear-search { position: absolute; right: 11px; top: 50%; width: 38px; height: 38px; transform: translateY(-50%); border: 0; border-radius: 50%; color: var(--muted); background: transparent; font-size: 24px; cursor: pointer; }
.clear-search:hover { background: var(--paper); color: var(--ink); }

.filter-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-top: 19px; align-items: end; }
.field select {
  width: 100%;
  height: 45px;
  padding: 0 32px 0 12px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid #cbd5df;
  border-radius: 9px;
  outline: none;
  font-size: 13px;
}

.toggle { display: flex !important; align-items: center; gap: 10px; min-height: 45px; margin: 0 !important; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle__track { position: relative; width: 42px; height: 24px; flex: 0 0 auto; border-radius: 30px; background: #cbd5df; transition: background 0.2s; }
.toggle__track span { position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: white; transition: transform 0.2s; box-shadow: 0 1px 4px rgba(0,0,0,0.2); }
.toggle input:checked + .toggle__track { background: var(--teal); }
.toggle input:checked + .toggle__track span { transform: translateX(18px); }
.toggle input:focus-visible + .toggle__track { outline: 3px solid rgba(31, 122, 140, 0.25); outline-offset: 2px; }

.filter-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 15px;
  border-radius: 8px;
  border: 1px solid transparent;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.button--quiet { color: var(--navy); background: var(--paper); border-color: var(--line); }
.button--quiet:hover { background: #ece9df; }
.button--outline { color: var(--teal); background: transparent; border-color: rgba(31, 122, 140, 0.38); }
.button--outline:hover { background: var(--teal-light); }
.button--dark { color: var(--white); background: var(--navy); }
.button--dark:hover { background: var(--navy-2); }
.button:disabled { opacity: 0.42; cursor: not-allowed; }

.results-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 35px 0 16px; }
.results-bar strong { color: var(--navy); font-size: 19px; }
.results-bar > div > span { margin-left: 7px; color: var(--muted); font-size: 13px; }
.active-filters { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.active-filter { padding: 5px 8px; color: var(--teal); background: var(--teal-light); border-radius: 5px; font-size: 11px; font-weight: 800; }

.results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.result-card {
  display: flex;
  min-height: 310px;
  flex-direction: column;
  padding: 24px;
  background: var(--paper-2);
  border: 1px solid rgba(20, 33, 61, 0.11);
  border-radius: 14px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.result-card:hover { transform: translateY(-2px); border-color: rgba(31, 122, 140, 0.35); box-shadow: 0 14px 34px rgba(20, 33, 61, 0.08); }
.result-card__meta { display: flex; align-items: center; gap: 9px; min-width: 0; color: var(--muted); font-size: 11px; }
.pill { flex: 0 0 auto; padding: 4px 8px; color: var(--teal); background: var(--teal-light); border-radius: 5px; font-weight: 850; }
.result-domain { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-label { margin: 17px 0 10px; color: var(--navy); font-family: Georgia, serif; font-size: 24px; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.result-context { display: -webkit-box; margin: 0; color: #475569; font-size: 14px; line-height: 1.55; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 4; }
.result-card__source { display: flex; flex-wrap: wrap; gap: 5px 10px; margin-top: auto; padding-top: 20px; color: var(--muted); font-size: 12px; }
.result-card__source a { color: var(--navy); font-weight: 800; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.result-section::before { content: "§ "; color: var(--gold); }
.result-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
.topic-tag { padding: 3px 7px; color: #5e5135; background: #fff0c9; border-radius: 4px; font-size: 10px; font-weight: 750; }
.result-card__actions { display: flex; gap: 8px; margin-top: 18px; }
.copy-link.copied { color: #22633b; background: #dff3e7; }

.empty-state, .loading-state { grid-column: 1 / -1; padding: 70px 24px; text-align: center; color: var(--muted); border: 1px dashed #b9c2cc; border-radius: 14px; }
.empty-state strong, .loading-state strong { display: block; margin-bottom: 8px; color: var(--navy); font-family: Georgia, serif; font-size: 26px; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 30px; }
.pagination span { min-width: 110px; text-align: center; color: var(--muted); font-size: 13px; font-weight: 700; }

.downloads { padding: 86px 0; color: white; background: var(--teal); }
.downloads__inner { display: grid; grid-template-columns: 0.85fr 1.15fr; gap: 80px; align-items: center; }
.downloads .eyebrow { color: #c6edf2; }
.downloads h2 { color: white; }
.downloads p { max-width: 430px; color: rgba(255,255,255,0.76); }
.download-cards { display: grid; gap: 12px; }
.download-card { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; padding: 18px 20px; color: var(--navy); background: rgba(255,255,255,0.94); border-radius: 12px; text-decoration: none; transition: background 0.15s, transform 0.15s; }
.download-card:hover { background: white; transform: translateX(3px); }
.download-card__type { display: grid; width: 48px; height: 48px; place-items: center; color: white; background: var(--navy); border-radius: 8px; font-size: 11px; font-weight: 900; }
.download-card strong, .download-card small { display: block; }
.download-card small { margin-top: 3px; color: var(--muted); }

.about { display: grid; grid-template-columns: 0.8fr 1.2fr; gap: 80px; padding: 100px 0; }
.about__copy { max-width: 700px; color: #475569; font-size: 17px; }
.about__copy p:first-child { margin-top: 0; }
.about__source { padding-top: 18px; border-top: 1px solid var(--line); font-size: 14px; }

footer { color: rgba(255,255,255,0.7); background: var(--navy); font-size: 12px; }
.footer__inner { display: flex; justify-content: space-between; gap: 20px; padding: 27px 0; }
.footer__inner a { color: white; }

@media (max-width: 980px) {
  .masthead__ornament { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .filter-grid { grid-template-columns: repeat(2, 1fr); }
  .downloads__inner, .about { grid-template-columns: 1fr; gap: 38px; }
}

@media (max-width: 720px) {
  :root { --shell: min(100% - 24px, 1180px); }
  .masthead { min-height: 540px; }
  .nav__links a:first-child { display: none; }
  .hero { padding: 70px 0 85px; }
  .hero h1 { font-size: clamp(48px, 15vw, 70px); }
  .stats { margin-top: -30px; }
  .stat { padding: 22px 20px; }
  .explorer { padding: 82px 0; }
  .section-heading { align-items: start; flex-direction: column; }
  .section-heading p { display: none; }
  .filters { padding: 17px; }
  .filter-grid { grid-template-columns: 1fr; }
  .filter-actions { justify-content: stretch; }
  .filter-actions .button { flex: 1; }
  .results-bar { align-items: start; flex-direction: column; }
  .active-filters { justify-content: start; }
  .results { grid-template-columns: 1fr; }
  .result-card { min-height: 280px; padding: 20px; }
  .downloads { padding: 70px 0; }
  .about { padding: 78px 0; }
  .footer__inner { flex-direction: column; }
}

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