:root {
  color-scheme: light;

  --bg: #f4f5f7;
  --bg-grad-top: #ebedf1;
  --surface: #ffffff;
  --surface-muted: #fafafb;

  --ink: #0f1626;
  --ink-hover: #1b2335;
  --text: #2a3140;
  --text-muted: #6a7382;
  --text-faint: #9aa2b1;

  --border: #e6e8ec;
  --border-strong: #d6dae1;

  --accent-warm: linear-gradient(135deg, #fba94c, #f97316);
  --accent-cool: linear-gradient(135deg, #38bdf8, #0ea5e9);
  --accent-pink: linear-gradient(135deg, #e879c9, #c026d3);
  --status-live: #16a34a;

  --radius-pill: 9999px;
  --radius-card: 20px;
  --radius-input: 14px;
  --radius-sm: 10px;

  --shadow-card: 0 1px 2px rgba(15, 22, 38, 0.04),
    0 8px 24px rgba(15, 22, 38, 0.05);
  --shadow-nav: 0 4px 20px rgba(15, 22, 38, 0.06);
  --shadow-btn: 0 1px 2px rgba(15, 22, 38, 0.08);

  --font-sans: "Avenir Next", "Helvetica Neue", "Hanken Grotesk", "General Sans", Arial, sans-serif;
  --font-serif: "New York", "Newsreader", Georgia, serif;
  --container: 1200px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    linear-gradient(180deg, var(--bg-grad-top), var(--bg) 30%),
    radial-gradient(circle, rgba(15, 22, 38, 0.05) 1px, transparent 1px);
  background-size: auto, 24px 24px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
}

a {
  color: inherit;
}

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

h1,
h2,
h3 {
  color: var(--ink);
  letter-spacing: -0.015em;
}

h1 {
  max-width: 780px;
  margin-bottom: 1.2rem;
  font-size: clamp(3rem, 7vw, 5.75rem);
  line-height: 0.96;
  font-weight: 760;
}

h1 em {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  letter-spacing: -0.025em;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 1;
  font-weight: 740;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--text-faint);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar {
  position: sticky;
  top: 22px;
  z-index: 20;
  width: min(var(--container), calc(100vw - 40px));
  min-height: 62px;
  margin: 22px auto 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 6px;
  border: 1px solid rgba(230, 232, 236, 0.82);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-nav);
  backdrop-filter: blur(22px);
}

.nav-brand {
  padding: 0 18px;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 720;
  text-decoration: none;
}

.nav-links,
.topbar-actions,
.control-row,
.result-tools,
.row-actions,
.chips {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-links {
  justify-content: center;
}

.nav-links a {
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 560;
  text-decoration: none;
  transition: color 220ms ease-out, background 220ms ease-out;
}

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

.nav-links a.active {
  background: var(--ink);
  color: #fff;
}

.topbar-actions {
  justify-content: flex-end;
}

.button,
button,
select,
input {
  min-height: 44px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 22px;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  font-weight: 680;
  text-decoration: none;
  box-shadow: none;
  cursor: pointer;
  transition: transform 220ms ease-out, box-shadow 220ms ease-out, background 220ms ease-out, border-color 220ms ease-out;
}

.button {
  border-color: transparent;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-btn);
}

.button:hover {
  background: var(--ink-hover);
  transform: translateY(-1px);
}

.button.secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--ink);
}

.button.secondary:hover,
button:hover {
  border-color: var(--ink);
  background: var(--surface-muted);
  transform: translateY(-1px);
}

select,
input {
  min-height: 48px;
  padding: 0 18px;
  border-radius: var(--radius-input);
  color: var(--text);
}

input::placeholder {
  color: var(--text-faint);
}

select:focus,
input:focus,
button:focus-visible,
a:focus-visible {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(15, 22, 38, 0.06);
}

input[type="search"] {
  width: min(440px, 100%);
}

main {
  width: min(var(--container), calc(100vw - 40px));
  margin: 0 auto;
  padding: clamp(4rem, 8vw, 7rem) 0 clamp(5rem, 10vw, 9rem);
}

.hero {
  min-height: 56vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3rem;
  align-content: center;
  padding: clamp(2rem, 6vw, 5rem) 0 clamp(5rem, 10vw, 8rem);
}

.hero-copy {
  max-width: 760px;
}

.lede {
  max-width: 700px;
  margin-bottom: 0;
  color: var(--text);
  font-size: clamp(1.0625rem, 2vw, 1.25rem);
  line-height: 1.55;
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1rem;
}

.metric {
  min-height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.metric-value {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--ink);
  font-size: clamp(1.5rem, 2.6vw, 2.1rem);
  line-height: 1;
  font-weight: 730;
  letter-spacing: -0.02em;
}

.metric-label {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.category-wrap,
.insight-layout,
.detail-section {
  scroll-margin-top: 120px;
}

.category-wrap {
  padding: clamp(4rem, 8vw, 7rem) 0 0;
}

.section-head {
  max-width: 720px;
  margin-bottom: 2rem;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.1rem;
}

.category-card {
  --dot: var(--accent-cool);
  position: relative;
  width: 100%;
  min-height: 210px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  text-align: left;
  overflow: hidden;
}

.category-card::after {
  content: "";
  position: absolute;
  top: 1.45rem;
  right: 1.45rem;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
  background: var(--dot);
}

.category-card:hover,
.category-card.active {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.category-card.active {
  box-shadow: 0 1px 2px rgba(15, 22, 38, 0.05),
    0 12px 32px rgba(15, 22, 38, 0.08);
}

.tone-green { --dot: var(--status-live); }
.tone-blue { --dot: var(--accent-cool); }
.tone-amber { --dot: var(--accent-warm); }
.tone-red { --dot: #d1433d; }
.tone-purple { --dot: var(--accent-pink); }
.tone-indigo { --dot: #6470d7; }
.tone-gray { --dot: #9aa2b1; }

.category-topline {
  display: grid;
  gap: 1rem;
}

.category-title {
  max-width: 86%;
  color: var(--ink);
  font-size: 1.45rem;
  line-height: 1.08;
  font-weight: 720;
}

.category-count {
  color: var(--ink);
  font-size: clamp(2.1rem, 4vw, 3.35rem);
  line-height: 0.95;
  font-weight: 760;
  letter-spacing: -0.035em;
}

.category-copy {
  display: block;
  margin: 1.2rem 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.94rem;
  line-height: 1.55;
}

.category-size {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.insight-layout {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr;
  gap: 1.1rem;
  padding: clamp(4rem, 8vw, 7rem) 0 0;
}

.insight-panel,
.detail-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.insight-panel {
  padding: 2rem;
}

.panel-title {
  margin-bottom: 1.4rem;
  color: var(--ink);
  font-size: 1.08rem;
  line-height: 1.2;
  font-weight: 700;
}

.bar-row {
  display: grid;
  grid-template-columns: 78px minmax(70px, 1fr) 74px;
  gap: 0.8rem;
  align-items: center;
  margin: 0.85rem 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.bar-track {
  height: 7px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--ink);
}

.detail-section {
  min-height: 560px;
  margin-top: clamp(4rem, 8vw, 7rem);
  padding: clamp(1.5rem, 4vw, 2.5rem);
}

.detail-head {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(360px, 1.2fr);
  gap: 2rem;
  align-items: start;
  margin-bottom: 2rem;
}

.detail-head h2 {
  margin-bottom: 0.75rem;
}

.detail-copy {
  margin-bottom: 0;
  color: var(--text-muted);
}

.control-row {
  justify-content: flex-end;
}

.result-tools {
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 0 1.2rem;
  border-top: 1px solid var(--border);
}

.result-count {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.result-list {
  overflow-x: auto;
}

.file-row {
  min-width: 100%;
  display: grid;
  grid-template-columns: minmax(260px, 1.55fr) 72px 88px 112px minmax(140px, 0.72fr) minmax(220px, 1fr) minmax(88px, auto);
  gap: 0.9rem;
  align-items: center;
  min-height: 76px;
  padding: 1rem 0.4rem 1rem 0;
  border-top: 1px solid var(--border);
}

.file-row.header {
  min-height: 42px;
  padding: 0.7rem 0;
  color: var(--text-faint);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.file-name {
  color: var(--ink);
  overflow-wrap: anywhere;
  font-weight: 650;
  line-height: 1.35;
}

.file-path,
.reason-text,
.muted {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.score,
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 26px;
  padding: 0 0.75rem;
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.score {
  min-width: 48px;
  color: var(--ink);
}

.score::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  margin-right: 0.45rem;
  border-radius: 999px;
  background: var(--score-color, var(--text-faint));
}

.chips {
  margin-top: 0.5rem;
}

.link-out {
  display: inline-flex;
  min-width: 52px;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
}

.link-out:hover {
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.empty-state {
  min-width: 100%;
  padding: 5rem 1rem;
  color: var(--text-muted);
  text-align: center;
}

.load-more {
  width: 100%;
  margin-top: 1.5rem;
}

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

@media (max-width: 1040px) {
  .topbar {
    grid-template-columns: 1fr;
    border-radius: 28px;
  }

  .nav-links,
  .topbar-actions {
    justify-content: flex-start;
    padding: 0 8px 6px;
  }

  .summary-band,
  .category-grid,
  .insight-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-head {
    grid-template-columns: 1fr;
  }

  .control-row {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .topbar {
    position: static;
    width: min(100% - 24px, var(--container));
    margin-top: 12px;
  }

  .nav-links a {
    padding-inline: 14px;
  }

  main {
    width: min(100% - 28px, var(--container));
    padding-top: 2rem;
  }

  .hero {
    min-height: auto;
    padding-top: 2rem;
  }

  .summary-band,
  .category-grid,
  .insight-layout {
    grid-template-columns: 1fr;
  }

  .metric,
  .category-card,
  .insight-panel,
  .detail-section {
    padding: 1.5rem;
  }

  .category-card {
    min-height: 180px;
  }

  .result-tools {
    display: block;
  }

  .result-tools .muted {
    display: block;
    margin-top: 0.35rem;
  }

  select,
  input,
  .button,
  button {
    width: 100%;
  }

  .topbar-actions .button,
  .topbar-actions button {
    width: auto;
  }
}
