:root {
  color-scheme: light;
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-alt: #f7f9fc;
  --text: #172033;
  --muted: #5c6880;
  --border: #d7dfeb;
  --accent: #0e7490;
  --accent-strong: #155e75;
  --accent-soft: #d9f0f7;
  --success: #15803d;
  --beta: #2563eb;
  --warning: #ca8a04;
  --research: #7c3aed;
  --community: #b91c1c;
  --shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Aptos", "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    sans-serif;
  background: linear-gradient(180deg, #f7fbff 0%, #eef3f8 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin: 0 auto 20px;
  max-width: 1500px;
}

.brand-block {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.brand-logo {
  width: 100%;
  max-width: 300px;
  height: auto;
  display: block;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1.05;
}

.intro {
  max-width: 720px;
  color: var(--muted);
  margin: 12px 0 0;
  line-height: 1.6;
}

.topbar-actions {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.refresh-card,
.action-button,
.map-section,
.sidebar section {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.refresh-card {
  display: grid;
  min-width: 210px;
  padding: 14px 16px;
}

.refresh-label,
#last-updated,
.field-label,
.stat-label,
.project-kicker,
.list-header span,
dt {
  color: var(--muted);
}

.action-button {
  border: 0;
  padding: 0 18px;
  color: white;
  background: linear-gradient(135deg, var(--accent) 0%, #2563eb 100%);
  font-weight: 700;
  cursor: pointer;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(340px, 0.9fr);
  grid-template-areas:
    "map sidebar"
    "radar sidebar";
  gap: 20px;
  max-width: 1500px;
  margin: 0 auto;
}

.map-section {
  grid-area: map;
  padding: 16px;
  position: relative;
}

.mobile-summary {
  display: none;
}

.map-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.85fr) minmax(0, 0.85fr) minmax(0, 1fr) minmax(92px, 0.5fr);
  gap: 12px;
  margin-bottom: 14px;
  position: relative;
  z-index: 20;
}

.search-group,
.filter-group {
  display: grid;
  gap: 8px;
}

.field-label {
  font-size: 0.92rem;
  font-weight: 700;
}

input,
select,
.ghost-button {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
}

.mobile-picker-button,
.mobile-picker-modal {
  display: none;
}

input::placeholder {
  color: #7b879c;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #64748b 50%),
    linear-gradient(135deg, #64748b 50%, transparent 50%);
  background-position:
    calc(100% - 20px) calc(50% - 3px),
    calc(100% - 14px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 38px;
}

.ghost-button {
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
  min-width: 0;
}

.map-frame {
  width: 100%;
  height: min(78vh, 820px);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
  z-index: 1;
}

.continent-label {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid rgba(148, 163, 184, 0.45);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  pointer-events: auto;
  cursor: pointer;
}

.region-filter-card {
  cursor: pointer;
}

.region-filter-card.is-selected {
  border-color: var(--accent);
  background: #eef4ff;
}

.leaflet-marker-pane .continent-label {
  position: relative;
  z-index: 200;
}

.legend-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding-top: 14px;
  font-size: 0.92rem;
}

.legend-dot {
  width: 11px;
  height: 11px;
  display: inline-block;
  margin-right: 8px;
  border-radius: 999px;
}

.legend-dot.active {
  background: var(--success);
}

.legend-dot.pilot {
  background: var(--warning);
}

.legend-dot.research {
  background: var(--research);
}

.legend-dot.beta {
  background: var(--beta);
}

.legend-dot.community {
  background: var(--community);
}

.sidebar {
  grid-area: sidebar;
  display: grid;
  gap: 20px;
}

.stats-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 12px;
}

.stat-card {
  padding: 14px;
  border-radius: 8px;
  background: var(--surface-alt);
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.6rem;
}

.details-panel,
.list-panel,
.radar-panel {
  padding: 18px;
}

.radar-panel {
  grid-area: radar;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.mobile-radar-panel {
  display: none;
}

.radar-blurb {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.radar-meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.radar-list {
  max-height: 360px;
}

.update-meta {
  font-size: 0.9rem;
}

.details-empty {
  padding: 12px 4px;
}

.details-empty h2,
.list-header h2,
#detail-name {
  margin: 0;
}

.details-empty p,
.project-summary,
dd {
  margin: 0;
  line-height: 1.6;
}

.project-card {
  display: grid;
  gap: 16px;
}

.project-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.status-pill {
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-active {
  color: #166534;
  background: #dcfce7;
}

.status-pilot {
  color: #854d0e;
  background: #fef3c7;
}

.status-research {
  color: #5b21b6;
  background: #efe4ff;
}

.status-beta {
  color: #1d4ed8;
  background: #dbeafe;
}

.status-community {
  color: #991b1b;
  background: #fee2e2;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas:
    "organization use-case"
    "project-type launch-date"
    "languages funding"
    "location location";
  gap: 16px 14px;
  margin: 0;
}

.detail-organization { grid-area: organization; }
.detail-use-case { grid-area: use-case; }
.detail-project-type { grid-area: project-type; }
.detail-launch-date { grid-area: launch-date; }
.detail-languages { grid-area: languages; }
.detail-location { grid-area: location; }
.detail-funding { grid-area: funding; }

dt {
  font-size: 0.82rem;
  margin-bottom: 4px;
}

dd {
  font-weight: 600;
}

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

.project-list {
  display: grid;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
}

.project-feed-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.project-feed-toggle {
  display: none;
}

.project-list-item {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-alt);
  text-align: left;
  cursor: pointer;
}

a.project-list-item {
  display: block;
  color: var(--text);
  text-decoration: none;
}

.project-list-item:hover,
.project-list-item.active {
  border-color: var(--accent);
  background: #eef8fb;
}

.project-list-item strong,
.project-list-item span {
  display: block;
}

.update-item strong {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.45;
}

.update-item,
.update-item span,
.update-item .update-meta {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.project-list-item span {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.5;
}

.project-cluster {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: #1d4ed8;
  box-shadow: 0 5px 15px rgba(15, 23, 42, 0.28);
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 700;
}

.soundwave-marker {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 3px solid white;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.24);
}

.soundwave-marker svg {
  width: 18px;
  height: 18px;
}

.soundwave-active {
  background: var(--success);
}

.soundwave-pilot {
  background: var(--warning);
}

.soundwave-research {
  background: var(--research);
}

.soundwave-beta {
  background: var(--beta);
}

.soundwave-community {
  background: var(--community);
}

.hidden {
  display: none !important;
}

.mobile-picker-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(15, 23, 42, 0.38);
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}

.mobile-picker-sheet {
  width: 100%;
  max-width: 520px;
  max-height: 78vh;
  overflow: hidden;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.22);
}

.mobile-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.mobile-picker-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.mobile-picker-close {
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.mobile-picker-options {
  display: grid;
  gap: 6px;
  max-height: calc(78vh - 64px);
  overflow: auto;
  padding: 10px 10px 14px;
}

.mobile-picker-option {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-alt);
  color: var(--text);
  text-align: left;
  padding: 13px 14px;
  font: inherit;
  cursor: pointer;
}

.mobile-picker-option.is-active {
  border-color: var(--accent);
  background: #eef8fb;
  color: var(--accent-strong);
  font-weight: 700;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "map"
      "sidebar"
      "radar";
  }

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

@media (max-width: 900px) {
  .sidebar {
    display: flex;
    flex-direction: column;
  }

  .details-panel { order: 1; }
  .list-panel { order: 2; }
  .mobile-radar-panel { display: block; order: 3; margin-top: 0; }
  .stats-summary-panel { display: none; }
  .stats-continent-panel { display: none; }
  .layout > .radar-panel { display: none; }

  .app-shell {
    padding: 12px;
  }

  .topbar,
  .topbar-actions,
  .brand-block {
    grid-template-columns: 1fr;
    display: grid;
  }

  .brand-logo {
    max-width: 280px;
  }

  .eyebrow {
    font-size: 0.9rem;
  }

  h1 {
    font-size: 2.2rem;
    line-height: 1.08;
  }

  .intro {
    font-size: 1rem;
    line-height: 1.65;
  }

  .refresh-card {
    min-width: 0;
    gap: 4px;
  }

  .refresh-label,
  #last-updated,
  .field-label,
  .stat-label,
  .project-kicker,
  .list-header span,
  dt,
  .update-meta {
    font-size: 0.95rem;
  }

  .map-toolbar {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "organization"
      "use-case"
      "project-type"
      "launch-date"
      "languages"
      "funding"
      "location";
  }

  .map-toolbar {
    gap: 10px;
    margin-bottom: 12px;
  }

  .search-group,
  .filter-group {
    gap: 6px;
  }

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

  .stats-summary-panel .stat-card:last-child {
    grid-column: 1 / -1;
  }

  input,
  select,
  .ghost-button,
  .action-button {
    min-height: 52px;
    font-size: 1rem;
    padding-left: 14px;
    padding-right: 14px;
  }

  .map-frame {
    height: min(50vh, 420px);
  }

  .details-panel {
    order: 1;
  }

  .list-panel {
    order: 2;
  }

  .stats-summary-panel {
    order: 3;
  }

  .stats-continent-panel {
    order: 4;
  }

  .radar-panel {
    margin-top: 0;
  }

  .topbar-actions {
    width: 100%;
  }

  .refresh-card {
    padding: 12px 14px;
  }

  .map-section,
  .details-panel,
  .list-panel,
  .radar-panel {
    padding: 14px;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-card strong {
    font-size: 1.8rem;
  }

  .details-empty p,
  .project-summary,
  dd,
  .project-list-item,
  .project-list-item span {
    font-size: 1rem;
  }

  .project-list-item strong,
  #detail-name,
  .details-empty h2,
  .list-header h2 {
    font-size: 1.2rem;
  }

  .project-card-header,
  .list-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .mobile-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
  }

  .mobile-summary .stat-card {
    min-width: 0;
    padding: 12px 10px;
  }

  .mobile-summary .stat-label {
    font-size: 0.78rem;
    line-height: 1.25;
  }

  .mobile-summary .stat-card strong {
    margin-top: 5px;
    font-size: 1.25rem;
  }

  .project-feed-toggle {
    display: flex;
    width: 100%;
    min-height: 46px;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-alt);
    color: var(--accent-strong);
    padding: 0 12px;
    font: inherit;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
  }

  .list-panel .list-header > h2,
  .project-feed-controls > #visible-count {
    display: none;
  }

  .project-feed-controls {
    display: block;
    width: 100%;
  }

  .project-feed-toggle::after {
    content: "+";
    font-size: 1.3rem;
    line-height: 1;
  }

  .project-feed-toggle[aria-expanded="true"]::after {
    content: "-";
  }

  .list-panel.is-collapsed #project-list {
    display: none;
  }

  .app-shell {
    padding: 10px;
  }

  .topbar {
    gap: 12px;
    margin-bottom: 14px;
  }

  .topbar-actions {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .refresh-card {
    display: none;
  }

  h1 {
    font-size: 1.8rem;
  }

  .brand-logo {
    max-width: 260px;
  }

  .intro {
    font-size: 0.96rem;
  }

  .field-label {
    font-size: 0.92rem;
    color: #334155;
  }

  .legend-strip {
    gap: 10px;
    font-size: 0.86rem;
  }

  .map-frame {
    height: min(42vh, 320px);
  }

  .map-toolbar {
    gap: 8px;
  }

  .project-list {
    max-height: none;
  }

  .mobile-radar-panel .radar-list {
    max-height: 360px;
    overflow: auto;
  }

  .stats-panel {
    grid-template-columns: 1fr;
  }

  .stats-summary-panel .stat-card:last-child {
    grid-column: auto;
  }

  input,
  .ghost-button,
  .action-button {
    min-height: 48px;
    font-size: 0.92rem;
    border-color: #c6d2e3;
    background: #f8fbff;
  }

  input::placeholder {
    font-size: 0.88rem;
    color: #6b7280;
  }

  select {
    display: none;
  }

  .ghost-button {
    font-weight: 700;
  }

  .mobile-picker-button {
    display: block;
    width: 100%;
    min-height: 48px;
    border: 1px solid #c6d2e3;
    border-radius: 8px;
    background: #f8fbff;
    color: var(--text);
    text-align: left;
    padding: 0 14px;
    font: inherit;
    cursor: pointer;
  }

  .mobile-picker-modal.is-open {
    display: flex;
  }

  .stat-card {
    padding: 12px 14px;
  }

  .stat-card strong {
    font-size: 1.2rem;
  }

  .project-list-item {
    padding: 12px;
  }

  .details-panel,
  .list-panel,
  .radar-panel,
  .map-section {
    padding: 12px;
  }

  .details-empty p,
  .project-summary,
  dd,
  .project-list-item,
  .project-list-item span {
    font-size: 0.92rem;
  }

  .project-list-item strong,
  #detail-name,
  .details-empty h2,
  .list-header h2 {
    font-size: 1.05rem;
  }
}

.tracker-popup .leaflet-popup-content {
  margin: 12px 14px;
  max-width: 180px;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.45;
}

.tracker-popup .leaflet-popup-content a,
.tracker-popup .popup-url {
  display: block;
  max-width: 180px;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
  font-size: 0.8rem;
}

.tracker-popup .leaflet-popup-content-wrapper {
  border-radius: 8px;
}

.detail-note {
  margin-top: 0.35rem;
  font-size: 0.82em;
  font-weight: 400;
  line-height: 1.35;
}
