:root {
  --paper: #f5f7f4;
  --surface: #ffffff;
  --ink: #162024;
  --muted: #607276;
  --line: #d9e1de;
  --teal: #0f766e;
  --blue: #2563eb;
  --amber: #d97706;
  --red: #dc2626;
  --green: #15803d;
  --shadow: 0 18px 45px rgba(22, 32, 36, 0.12);
}

* {
  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;
}

img {
  display: block;
  max-width: 100%;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 14px clamp(18px, 4vw, 56px);
  background: rgba(245, 247, 244, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand,
.site-nav,
.quick-stats,
.toolbar,
.compare-controls {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #ffffff;
  background: var(--teal);
  border-radius: 8px;
}

.site-nav {
  gap: clamp(12px, 3vw, 28px);
  color: var(--muted);
  font-weight: 700;
}

.site-nav a {
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--teal);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.intro-section {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(300px, 0.8fr);
  gap: clamp(24px, 5vw, 54px);
  align-items: center;
  padding: clamp(34px, 7vw, 82px) 0 34px;
}

.eyebrow,
.label,
.result-count,
.card-meta,
.modal-topbar p {
  margin: 0;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  max-width: 750px;
  margin-bottom: 18px;
  font-size: clamp(2.8rem, 7vw, 5.6rem);
  line-height: 0.98;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.05;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.05rem;
  line-height: 1.25;
}

.project-subtitle {
  max-width: 720px;
  margin-bottom: 28px;
  color: var(--muted);
  font-size: clamp(1.1rem, 2vw, 1.42rem);
}

.quick-stats {
  flex-wrap: wrap;
  gap: 10px;
}

.quick-stats div {
  min-width: 142px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.quick-stats strong,
.quick-stats span {
  display: block;
}

.quick-stats strong {
  font-size: 1.05rem;
}

.quick-stats span {
  color: var(--muted);
  font-size: 0.88rem;
}

.intro-figure {
  margin: 0;
}

.intro-figure img {
  width: 100%;
  max-height: 720px;
  object-fit: contain;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.intro-figure figcaption {
  margin-top: 12px;
  color: var(--muted);
  font-weight: 700;
}

.insight-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin: 0 0 clamp(46px, 8vw, 84px);
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.insight-band div {
  min-height: 122px;
  padding: 24px;
  background: var(--surface);
}

.insight-band strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1rem, 2vw, 1.26rem);
  line-height: 1.3;
}

.figures-section,
.compare-section {
  padding-bottom: clamp(56px, 8vw, 96px);
}

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

.result-count {
  color: var(--ink);
  padding: 8px 12px;
  background: #e9f5f1;
  border: 1px solid #b9ddd3;
  border-radius: 999px;
  white-space: nowrap;
}

.toolbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-box {
  display: grid;
  width: min(420px, 100%);
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.search-box input,
.compare-controls select {
  width: 100%;
  min-height: 44px;
  color: var(--ink);
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.search-box input {
  padding: 0 14px;
}

.search-box input:focus,
.compare-controls select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.filter-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.filter-button,
.secondary-button,
.icon-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
}

.filter-button {
  padding: 0 13px;
}

.filter-button[aria-pressed="true"] {
  color: #ffffff;
  background: var(--ink);
  border-color: var(--ink);
}

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

.figure-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.figure-card-image {
  display: grid;
  width: 100%;
  aspect-ratio: 4 / 3;
  place-items: center;
  padding: 12px;
  background: #f9faf8;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.figure-card-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.figure-card-body {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.card-meta {
  color: var(--muted);
}

.figure-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--ink);
  background: #eef2f1;
  font-size: 0.78rem;
  font-weight: 800;
}

.tag.aqi {
  background: #fff1bd;
}

.tag.pollutants {
  background: #dbeafe;
}

.tag.meteorology {
  background: #d9f99d;
}

.tag.correlation {
  background: #ffe4e6;
}

.tag.map {
  background: #e0f2fe;
}

.compare-controls {
  justify-content: center;
  gap: 14px;
  margin-bottom: 18px;
}

.compare-controls label {
  display: grid;
  flex: 1 1 280px;
  gap: 6px;
  max-width: 440px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.compare-controls select {
  padding: 0 12px;
}

.secondary-button {
  padding: 0 14px;
}

.secondary-button:hover,
.icon-button:hover,
.filter-button:hover {
  border-color: var(--teal);
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.compare-panel {
  display: grid;
  gap: 12px;
  min-height: 100%;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.compare-panel img {
  width: 100%;
  height: min(58vh, 560px);
  object-fit: contain;
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.compare-panel p {
  margin-bottom: 0;
  color: var(--muted);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 32px clamp(18px, 4vw, 56px);
  color: #ffffff;
  background: var(--ink);
}

.site-footer div {
  display: grid;
  gap: 5px;
}

.site-footer a {
  color: #b7f0e7;
  font-weight: 800;
  text-decoration: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  padding: 18px;
}

.modal.is-open {
  display: grid;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 21, 24, 0.74);
}

.modal-dialog {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: min(1120px, 100%);
  max-height: calc(100vh - 36px);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
}

.modal-topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.modal-topbar h2 {
  overflow: hidden;
  margin: 0;
  font-size: clamp(1.1rem, 3vw, 1.8rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: grid;
  width: 42px;
  padding: 0;
  place-items: center;
  font-size: 1.1rem;
}

.zoom-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.zoom-controls input {
  width: min(360px, 50vw);
}

.modal-image-wrap {
  overflow: auto;
  padding: 18px;
  background: #f3f5f3;
}

.modal-image-wrap img {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  object-fit: contain;
  transform-origin: top center;
}

#modal-caption {
  margin: 0;
  padding: 14px 18px 18px;
  color: var(--muted);
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 980px) {
  .intro-section,
  .insight-band,
  .compare-grid {
    grid-template-columns: 1fr;
  }

  .intro-section {
    padding-top: 34px;
  }

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

  .toolbar,
  .compare-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-buttons {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .site-header,
  .site-footer,
  .section-heading,
  .modal-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-header {
    position: static;
  }

  .site-nav {
    width: 100%;
    justify-content: space-between;
  }

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

  .modal {
    padding: 0;
  }

  .modal-dialog {
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .modal-topbar {
    display: flex;
    gap: 10px;
  }

  .modal-topbar h2 {
    white-space: normal;
  }

  .icon-button {
    width: 40px;
    height: 40px;
  }
}
