:root {
  --cream: #fafaf6;
  --paper: #ffffff;
  --forest: #214e3b;
  --forest-deep: #17382b;
  --papaya: #ff7043;
  --papaya-soft: #fff0eb;
  --sage: #8fa58a;
  --sage-soft: #e8f0e6;
  --mustard: #e8b647;
  --mustard-soft: #fdf5e0;
  --rose: #ffd9c0;
  --rose-soft: #fff4ec;
  --line: #e2e5dc;
  --ink: #25372d;
  --muted: #6b7c70;
  --ghost: #f3f5f0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(33,78,59,.08);
  --shadow-md: 0 4px 16px rgba(33,78,59,.1);
  --shadow-lg: 0 8px 32px rgba(33,78,59,.14);
  --transition: .2s ease;
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }

body {
  background: var(--cream);
  color: var(--ink);
  font-family: Nunito, Inter, system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: Montserrat, Nunito, system-ui, sans-serif;
  letter-spacing: -.01em;
  line-height: 1.15;
}

button, input, select { font: inherit; }

/* ── Header ────────────────────────────────────── */

.header {
  align-items: center;
  background: var(--forest);
  display: flex;
  gap: 16px;
  padding: 12px clamp(12px, 3vw, 32px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  gap: 10px;
}

.logo { flex-shrink: 0; }

.header-title {
  color: #fff;
  display: block;
  font-family: Montserrat, sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: .01em;
  line-height: 1.1;
}

.header-sub {
  color: var(--sage);
  display: block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.header-search {
  align-items: center;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 999px;
  display: flex;
  flex: 1;
  gap: 8px;
  max-width: 480px;
  padding: 0 14px;
  transition: background var(--transition), border-color var(--transition);
}

.header-search:focus-within {
  background: rgba(255,255,255,.2);
  border-color: var(--papaya);
}

.search-icon { color: var(--sage); flex-shrink: 0; }

.header-search input {
  background: none;
  border: 0;
  color: #fff;
  min-height: 40px;
  outline: none;
  width: 100%;
}

.header-search input::placeholder { color: rgba(255,255,255,.5); }

.header-actions { display: flex; gap: 6px; }

.header-btn {
  align-items: center;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%;
  color: var(--sage);
  cursor: pointer;
  display: inline-flex;
  height: 38px;
  justify-content: center;
  text-decoration: none;
  transition: background var(--transition);
  width: 38px;
}

.header-btn:hover { background: rgba(255,255,255,.18); }

/* ── Tabs ──────────────────────────────────────── */

.tabs {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 0 clamp(12px, 3vw, 32px);
}

.tab {
  align-items: center;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  font-size: .82rem;
  font-weight: 800;
  gap: 6px;
  min-height: 46px;
  padding: 0 14px;
  text-transform: uppercase;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.tab:hover { color: var(--forest); }
.tab.active { border-bottom-color: var(--papaya); color: var(--forest); }
.tab.active svg { stroke: var(--papaya); }

/* ── Filters ───────────────────────────────────── */

.filters {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 0 clamp(12px, 3vw, 32px);
}

.filter-toggle {
  align-items: center;
  background: none;
  border: none;
  color: var(--forest);
  cursor: pointer;
  display: flex;
  font-size: .82rem;
  font-weight: 800;
  gap: 8px;
  min-height: 44px;
  padding: 0;
  width: 100%;
}

.filter-toggle .chevron { margin-left: auto; transition: transform var(--transition); }
.filter-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.filter-count {
  align-items: center;
  background: var(--papaya);
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-size: .7rem;
  font-weight: 900;
  height: 20px;
  justify-content: center;
  min-width: 20px;
  padding: 0 6px;
}

.filter-panel {
  padding: 0 0 14px;
}

.filter-panel[hidden] { display: none; }

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-item {
  display: grid;
  flex: 1;
  gap: 4px;
  min-width: 140px;
}

.filter-item span {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.filter-item select {
  background: var(--ghost);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  min-height: 38px;
  padding: 0 10px;
  transition: border-color var(--transition);
}

.filter-item select:focus { border-color: var(--forest); outline: none; }

.filter-actions {
  align-items: center;
  display: flex;
  gap: 16px;
  margin-top: 12px;
}

.verified-toggle {
  align-items: center;
  cursor: pointer;
  display: flex;
  font-size: .84rem;
  font-weight: 700;
  gap: 8px;
}

.verified-toggle input {
  accent-color: var(--forest);
  height: 18px;
  width: 18px;
}

.text-btn {
  background: none;
  border: none;
  color: var(--papaya);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 800;
  padding: 4px 0;
}

.text-btn:hover { text-decoration: underline; }

/* ── Stats bar ─────────────────────────────────── */

.stats-bar {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding: 12px clamp(12px, 3vw, 32px);
}

.stat {
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  display: flex;
  flex: 1;
  gap: 6px;
  min-width: 90px;
  padding: 10px 14px;
}

.stat:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.stat:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.stat + .stat { border-left: none; }

.stat strong {
  color: var(--forest);
  font-family: Montserrat, sans-serif;
  font-size: 1.15rem;
  font-weight: 900;
}

.stat span {
  color: var(--muted);
  font-size: .74rem;
  font-weight: 700;
  text-transform: uppercase;
}

/* ── Notice ────────────────────────────────────── */

.notice {
  align-items: flex-start;
  background: var(--rose-soft);
  border: 1px solid var(--rose);
  border-radius: var(--radius-sm);
  display: flex;
  gap: 10px;
  margin: 0 clamp(12px, 3vw, 32px);
  padding: 12px 14px;
}

.notice svg { color: var(--papaya); flex-shrink: 0; margin-top: 2px; }
.notice p { font-size: .86rem; line-height: 1.45; }
.notice strong { color: var(--forest); }

/* ── Content layout ────────────────────────────── */

.app {
  min-height: calc(100vh - 120px);
}

.content {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(300px, .6fr) minmax(0, 1fr);
  padding: 0 clamp(12px, 3vw, 32px) 32px;
}

.map-col { position: sticky; top: 72px; align-self: start; }

.map-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.map-toolbar {
  align-items: center;
  display: flex;
  gap: 6px;
  padding: 8px 10px;
}

.map-btn {
  align-items: center;
  background: var(--ghost);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--forest);
  cursor: pointer;
  display: inline-flex;
  font-size: .78rem;
  font-weight: 800;
  gap: 4px;
  min-height: 32px;
  padding: 0 10px;
  transition: background var(--transition);
}

.map-btn:hover { background: var(--sage-soft); }
.map-btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.map-btn.ghost:hover { color: var(--papaya); }

.map {
  aspect-ratio: 4 / 3;
  min-height: 300px;
}

.plot {
  aspect-ratio: 4 / 3;
  background:
    linear-gradient(90deg, rgba(33,78,59,.06) 1px, transparent 1px),
    linear-gradient(rgba(33,78,59,.06) 1px, transparent 1px),
    var(--ghost);
  background-size: 20% 20%, 20% 20%, auto;
  min-height: 300px;
  overflow: hidden;
  position: relative;
}

.plot[hidden], .map[hidden] { display: none; }

.pin {
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(33,78,59,.3);
  height: 10px;
  position: absolute;
  transform: translate(-50%, -50%);
  width: 10px;
}

.pin.htgf_verified_pipeline { background: var(--forest); }
.pin.osm_odbl_seed { background: var(--mustard); }
.pin.flagged { background: var(--papaya); }

.attribution {
  color: var(--muted);
  font-size: .7rem;
  margin-top: 6px;
  padding: 0 4px;
}

/* ── Map markers ───────────────────────────────── */

.atlas-marker {
  align-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(33,78,59,.3);
  color: #fff;
  display: flex;
  font-size: 10px;
  font-weight: 900;
  height: 26px;
  justify-content: center;
  transition: transform .15s ease;
  width: 26px;
}

.atlas-marker:hover { transform: scale(1.2); }
.atlas-marker.exact { background: var(--forest); }
.atlas-marker.osm { background: var(--mustard); color: var(--forest-deep); }
.atlas-marker.approx { background: #fff; border-color: var(--forest); color: var(--forest); }
.atlas-marker.flagged { background: var(--papaya); }

/* ── List ──────────────────────────────────────── */

.list-col { min-width: 0; }

.list-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-top: 4px;
}

.result-count {
  color: var(--forest);
  font-size: 1rem;
  font-weight: 800;
}

.results {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* ── Cards ─────────────────────────────────────── */

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: grid;
  gap: 8px;
  padding: 14px 14px 14px 16px;
  text-align: left;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.card.tier-d { border-left-color: var(--forest); }
.card.tier-p { border-left-color: var(--sage); }
.card.tier-o { border-left-color: var(--mustard); }
.card.tier-u { border-left-color: var(--line); }
.card.tier-x { border-left-color: var(--papaya); }
.card.community-card { border-left-color: var(--sage); }

.card-top {
  align-items: center;
  display: flex;
  gap: 6px;
}

.tier-badge {
  border-radius: 4px;
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .03em;
  padding: 3px 7px;
  text-transform: uppercase;
}

.tier-d .tier-badge { background: var(--sage-soft); color: var(--forest); }
.tier-p .tier-badge { background: var(--sage-soft); color: var(--forest); }
.tier-o .tier-badge { background: var(--mustard-soft); color: #7a5f12; }
.tier-u .tier-badge { background: var(--ghost); color: var(--muted); }
.tier-x .tier-badge { background: var(--papaya-soft); color: #b8401e; }
.community-card .tier-badge { background: var(--sage-soft); color: var(--forest); }

.source-tag {
  background: var(--ghost);
  border-radius: 4px;
  color: var(--muted);
  font-size: .66rem;
  font-weight: 800;
  margin-left: auto;
  padding: 3px 6px;
  text-transform: uppercase;
}

.card h3 {
  color: var(--forest-deep);
  font-family: Nunito, sans-serif;
  font-size: .95rem;
  font-weight: 800;
  line-height: 1.25;
}

.card-meta {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
}

.card-desc {
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--muted);
  display: -webkit-box;
  font-size: .82rem;
  line-height: 1.45;
  overflow: hidden;
}

.review-line {
  background: var(--papaya-soft);
  border-radius: 4px;
  color: #9d3518;
  font-size: .72rem;
  font-weight: 800;
  line-height: 1.3;
  padding: 5px 7px;
}

.category-pill {
  background: var(--ghost);
  border-radius: 999px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 800;
  padding: 2px 8px;
}

/* ── Skeleton ──────────────────────────────────── */

.skeleton-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.skeleton-card {
  animation: pulse 1.5s ease-in-out infinite;
  background: var(--ghost);
  border-radius: var(--radius-sm);
  height: 140px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

/* ── Load more ─────────────────────────────────── */

.load-more-btn {
  background: var(--forest);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  cursor: pointer;
  display: block;
  font-size: .88rem;
  font-weight: 800;
  margin: 18px auto 0;
  min-height: 44px;
  min-width: 200px;
  padding: 0 24px;
  transition: background var(--transition), transform var(--transition);
}

.load-more-btn:hover { background: var(--forest-deep); }
.load-more-btn:active { transform: scale(.97); }
.load-more-btn:disabled { cursor: wait; opacity: .6; }
.load-more-btn[hidden] { display: none; }

/* ── Matchday ──────────────────────────────────── */

.matchday-section {
  padding: 0 clamp(12px, 3vw, 32px) 32px;
}

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

.matchday-hero {
  background: linear-gradient(135deg, var(--forest) 0%, var(--forest-deep) 100%);
  border-radius: var(--radius);
  color: #fff;
  margin-bottom: 20px;
  padding: 28px 24px;
}

.matchday-hero h2 {
  font-size: 1.6rem;
  margin-bottom: 8px;
}

.matchday-hero p {
  color: var(--sage);
  font-size: .92rem;
  max-width: 600px;
}

.matchday-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.matchday-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}

.matchday-card h3 {
  color: var(--forest);
  font-size: 1rem;
  margin-bottom: 8px;
}

.matchday-card p {
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.5;
}

.matchday-card ul {
  color: var(--ink);
  font-size: .86rem;
  line-height: 1.6;
  padding-left: 18px;
}

.checklist-item { margin-bottom: 4px; }

/* ── Dialog ────────────────────────────────────── */

dialog {
  background: var(--paper);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: min(680px, calc(100vh - 40px));
  max-width: min(560px, calc(100vw - 24px));
  overflow-y: auto;
  padding: 0;
  width: 100%;
}

dialog::backdrop { background: rgba(23,56,43,.5); }

dialog[open] {
  animation: dialog-in .25s ease;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.dialog-header {
  position: sticky;
  top: 0;
  background: var(--paper);
  display: flex;
  justify-content: flex-end;
  padding: 12px 12px 0;
  z-index: 1;
}

.dialog-close {
  align-items: center;
  background: var(--ghost);
  border: none;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  height: 36px;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
  width: 36px;
}

.dialog-close:hover { background: var(--line); color: var(--ink); }

.dialog-body { padding: 4px 24px 24px; }

.detail-tier {
  border-radius: 6px;
  display: inline-block;
  font-size: .78rem;
  font-weight: 900;
  margin-bottom: 12px;
  padding: 5px 10px;
  text-transform: uppercase;
}

.detail-tier.d { background: var(--sage-soft); color: var(--forest); }
.detail-tier.p { background: var(--sage-soft); color: var(--forest); }
.detail-tier.o { background: var(--mustard-soft); color: #7a5f12; }
.detail-tier.u { background: var(--ghost); color: var(--muted); }
.detail-tier.x { background: var(--papaya-soft); color: #b8401e; }

.detail-name {
  color: var(--forest);
  font-size: 1.35rem;
  margin-bottom: 6px;
}

.detail-location {
  color: var(--muted);
  font-size: .88rem;
  margin-bottom: 16px;
}

.detail-section {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
}

.detail-section h4 {
  color: var(--forest);
  font-family: Nunito, sans-serif;
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .04em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.detail-section p {
  color: var(--ink);
  font-size: .88rem;
  line-height: 1.55;
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.detail-badge {
  background: var(--ghost);
  border-radius: 999px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
  padding: 4px 10px;
}

.detail-badge.verified { background: var(--sage-soft); color: var(--forest); }
.detail-badge.warning { background: var(--papaya-soft); color: #b8401e; }

.detail-link {
  background: var(--forest);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-size: .84rem;
  font-weight: 800;
  margin-top: 16px;
  min-height: 40px;
  padding: 0 18px;
  text-decoration: none;
  align-items: center;
  gap: 6px;
  transition: background var(--transition);
}

.detail-link:hover { background: var(--forest-deep); }

/* ── Responsive ────────────────────────────────── */

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

  .map-col {
    position: static;
    order: -1;
  }

  .map { aspect-ratio: 16 / 9; min-height: 220px; }

  .stats-bar { gap: 0; }

  .filter-row { flex-direction: column; }
  .filter-item { min-width: 0; }

  .results { grid-template-columns: 1fr; }
  .skeleton-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .header { gap: 10px; flex-wrap: wrap; }

  .header-search {
    flex: 1 1 100%;
    max-width: none;
    order: 3;
  }

  .header-sub { display: none; }

  .stat { flex-direction: column; gap: 2px; padding: 8px 10px; }
  .stat strong { font-size: 1rem; }

  .tabs { gap: 0; }
  .tab { flex: 1; font-size: .72rem; justify-content: center; padding: 0 8px; }

  .matchday-hero { padding: 20px 16px; }
  .matchday-hero h2 { font-size: 1.3rem; }
}

/* ── v5 brand overrides (Atlas app) ─────────────────────────────── */
h1, h2, h3, h4,
.header-title, .result-count, .detail-name {
  font-family: "Fraunces", Georgia, serif;
  letter-spacing: -.01em;
}
.header-title { font-weight: 600; }

/* ★ Dedicated (tier D) gets the warm gold v5 chip so it reads as the top tier */
.tier-d .tier-badge, .detail-tier.d {
  background: #FCEFC9; color: #8a6300;
}
.card.tier-d { border-left-color: var(--mustard); }

/* Language toggle (header) */
.lang-toggle {
  display: flex; gap: 2px;
  background: rgba(255,255,255,.12);
  border-radius: 999px; padding: 3px;
}
.lang-toggle button {
  background: none; border: none; cursor: pointer;
  font-family: Nunito, sans-serif; font-weight: 800; font-size: .74rem;
  color: #CFE0D5; padding: 5px 10px; border-radius: 999px;
  transition: background var(--transition), color var(--transition);
}
.lang-toggle button.on { background: var(--mustard); color: var(--forest-deep); }
.lang-toggle button:hover:not(.on) { color: #fff; }

/* Evidence/date line on cards */
.review-line { font-weight: 700; font-size: .76rem; margin-top: 8px; }
.review-line.verified { color: var(--forest); }
.review-line.listed { color: var(--muted); font-weight: 600; }
