:root {
  color-scheme: light;
  --ink: #171717;
  --muted: #62615f;
  --line: #d8d4cc;
  --paper: #f7f3ea;
  --panel: #fffdfa;
  --green: #16735b;
  --blue: #2f5f9e;
  --red: #a33a32;
  --gold: #b7791f;
  --shadow: 0 16px 40px rgba(40, 35, 28, 0.11);
}

* {
  box-sizing: border-box;
}

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

button,
a {
  font: inherit;
}

.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 250, 0.82);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1,
.issue-copy h2,
.section-heading h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(28px, 4vw, 52px);
  line-height: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.language-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  background: var(--panel);
}

.language-switch button {
  min-width: 44px;
  min-height: 36px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.language-switch button:last-child {
  border-right: 0;
}

.language-switch button[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
}

.eyebrow,
.label {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.period {
  color: var(--muted);
  font-size: 14px;
  text-align: right;
  white-space: nowrap;
}

main {
  display: grid;
  gap: 0;
}

.issue-band,
.archive-band,
.topics-band,
.digest-band,
.source-band {
  padding: clamp(28px, 5vw, 64px) clamp(18px, 4vw, 56px);
}

.issue-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: clamp(24px, 5vw, 72px);
  align-items: end;
  background:
    linear-gradient(90deg, rgba(47, 95, 158, 0.09), transparent 36%),
    linear-gradient(180deg, #fffdfa, #f2eadc);
}

.issue-copy h2 {
  max-width: 920px;
  font-size: clamp(30px, 5vw, 72px);
  line-height: 0.98;
}

.issue-copy p:last-child {
  max-width: 780px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: clamp(16px, 2vw, 20px);
  line-height: 1.55;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--line);
  box-shadow: var(--shadow);
}

.metrics div {
  min-width: 0;
  padding: 22px 18px;
  background: var(--panel);
}

.metrics span {
  display: block;
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 800;
  line-height: 1;
}

.metrics p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topics-band {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #f9f7f0;
}

.archive-band {
  border-top: 1px solid var(--line);
  background: #fffdfa;
}

.issue-archive {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.issue-archive button {
  min-height: 42px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 9px 13px;
  cursor: pointer;
}

.issue-archive button[aria-pressed="true"] {
  border-color: var(--blue);
  box-shadow: inset 0 -3px 0 var(--blue);
}

.issue-archive small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

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

.section-heading h2 {
  font-size: clamp(22px, 3vw, 34px);
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
}

.topic-card,
.repo-card,
.repo-detail {
  border: 1px solid var(--line);
  background: var(--panel);
}

.topic-card {
  min-height: 260px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
  cursor: pointer;
}

.topic-card[aria-expanded="true"] {
  border-color: var(--blue);
  box-shadow: inset 0 -4px 0 var(--blue);
}

.topic-card h3 {
  margin: 0;
  font-size: 17px;
}

.topic-card p {
  margin: 10px 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.topic-score {
  display: grid;
  gap: 2px;
  margin-top: auto;
}

.topic-score span {
  color: var(--blue);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topic-score strong {
  font-size: 16px;
}

.bar {
  height: 8px;
  background: #ebe4d7;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.topic-detail-panel {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 20px;
}

.topic-detail-panel h3 {
  margin: 0 0 16px;
  font-size: 24px;
}

.topic-detail-panel strong {
  display: block;
  margin-top: 14px;
}

.topic-detail-panel p {
  max-width: 980px;
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.material-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.material-links a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  background: #f7f3ea;
}

.digest-band {
  background: var(--paper);
}

.section-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.section-tabs button {
  min-height: 42px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 9px 13px;
  cursor: pointer;
}

.section-tabs button[aria-selected="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.section-explainer {
  max-width: 980px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  background: #fffdfa;
  padding: 14px 16px;
}

.section-explainer strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

.section-explainer p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.repo-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 16px;
  align-items: start;
}

.repo-list {
  display: grid;
  gap: 10px;
}

.repo-card {
  width: 100%;
  min-height: 112px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 148px;
  gap: 16px;
  padding: 16px;
  text-align: left;
  cursor: pointer;
}

.repo-card[aria-pressed="true"] {
  border-color: var(--blue);
  box-shadow: inset 4px 0 0 var(--blue);
}

.repo-main {
  min-width: 0;
}

.repo-main h3 {
  margin: 0;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.repo-main p,
.detail-text {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.42;
}

.repo-main .repo-text,
.detail-text {
  color: var(--ink);
}

.badge-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  background: #ede8dc;
  color: #3e3b36;
  font-size: 12px;
  font-weight: 700;
}

.badge.new_spike {
  background: rgba(22, 115, 91, 0.13);
  color: var(--green);
}

.badge.reactivated {
  background: rgba(183, 121, 31, 0.16);
  color: #7b4f13;
}

.badge.steady_growth {
  background: rgba(47, 95, 158, 0.14);
  color: var(--blue);
}

.badge.insufficient_history {
  background: rgba(183, 121, 31, 0.16);
  color: #7b4f13;
}

.badge.noise {
  background: rgba(163, 58, 50, 0.13);
  color: var(--red);
}

.sparkline {
  width: 148px;
  height: 72px;
  align-self: center;
}

.sparkline path.area {
  fill: rgba(47, 95, 158, 0.12);
}

.sparkline path.line {
  fill: none;
  stroke: var(--blue);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.repo-detail {
  position: sticky;
  top: 112px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.repo-detail h3 {
  margin: 0;
  font-size: 24px;
  overflow-wrap: anywhere;
}

.score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.score strong {
  font-size: 42px;
  line-height: 1;
}

.repo-detail p {
  color: var(--muted);
  line-height: 1.55;
}

.repo-detail .detail-label {
  margin: 16px 0 0;
  color: var(--blue);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.repo-detail .detail-text {
  margin-top: 7px;
}

.repo-detail a {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  padding: 10px 14px;
  background: var(--ink);
  color: #fff;
  text-decoration: none;
}

.source-band {
  border-top: 1px solid var(--line);
  background: #fffdfa;
}

.source-band p:last-child {
  max-width: 920px;
  color: var(--muted);
  line-height: 1.6;
}

.coverage-note {
  max-width: 980px;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  background: #f7f3ea;
  padding: 16px;
}

.coverage-note strong {
  display: block;
  margin-bottom: 6px;
}

.coverage-note p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.coverage-ledger-link {
  display: inline-flex;
  margin-top: 12px;
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

@media (max-width: 980px) {
  .issue-band,
  .repo-layout {
    grid-template-columns: 1fr;
  }

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

  .repo-detail {
    position: static;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    align-items: flex-start;
    justify-content: space-between;
  }

  .period {
    text-align: left;
    white-space: normal;
  }

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

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

  .repo-card {
    grid-template-columns: 1fr;
  }

  .sparkline {
    width: 100%;
  }
}
