:root {
  --navy: #172c46;
  --navy-2: #244262;
  --gold: #b38a42;
  --gold-light: #eadcb9;
  --cream: #f7f4ed;
  --paper: #fff;
  --ink: #1f2933;
  --muted: #66727f;
  --line: #dfe4e8;
  --shadow: 0 18px 50px rgba(23, 44, 70, .12);
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body { margin: 0; background: var(--cream); color: var(--ink); font-family: Arial, Helvetica, sans-serif; line-height: 1.55; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.app-shell { max-width: 1380px; margin: 0 auto; padding: clamp(22px, 4vw, 58px); }
.intro { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr); gap: 48px; align-items: end; padding: 15px 0 38px; }
.eyebrow { margin: 0 0 8px; color: var(--gold); font-size: .78rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1 { margin: 0; color: var(--navy); font-family: Georgia, 'Times New Roman', serif; font-size: clamp(2.7rem, 6vw, 5.5rem); font-weight: 500; letter-spacing: -.045em; line-height: .98; }
.lede { max-width: 680px; margin: 20px 0 0; color: var(--muted); font-size: clamp(1rem, 2vw, 1.2rem); }
.scripture { border-left: 3px solid var(--gold); padding-left: 22px; color: var(--navy-2); font-family: Georgia, 'Times New Roman', serif; font-size: 1.04rem; font-style: italic; }
.scripture strong { display: block; margin-top: 8px; color: var(--muted); font-family: Arial, sans-serif; font-size: .76rem; font-style: normal; letter-spacing: .1em; text-transform: uppercase; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--navy); color: white; border-radius: 12px 12px 0 0; overflow: hidden; }
.stats div { min-height: 118px; display: flex; flex-direction: column; justify-content: center; padding: 20px 26px; border-right: 1px solid rgba(255,255,255,.16); }
.stats div:last-child { border-right: 0; }
.stats strong { font-family: Georgia, serif; font-size: 2.2rem; font-weight: 500; line-height: 1; }
.stats span { margin-top: 8px; color: #d8e0e8; font-size: .76rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }

.workspace { background: var(--paper); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 12px 12px; box-shadow: var(--shadow); overflow: hidden; }
.view-bar { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 24px; border-bottom: 1px solid var(--line); }
.view-bar p { margin: 0; color: var(--muted); font-size: .9rem; }
.segmented { display: inline-flex; padding: 4px; background: #eef1f4; border-radius: 9px; }
.view-button { min-width: 112px; padding: 10px 18px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-weight: 700; }
.view-button.active { background: white; color: var(--navy); box-shadow: 0 2px 8px rgba(23,44,70,.12); }
.controls { display: grid; grid-template-columns: minmax(280px, 1fr) 230px 210px; gap: 12px; padding: 18px 24px; background: #fafbfc; border-bottom: 1px solid var(--line); }
input, select { width: 100%; min-height: 48px; border: 1px solid #cbd3da; border-radius: 7px; background: white; color: var(--ink); padding: 0 14px; }
input:focus, select:focus, button:focus-visible { outline: 3px solid rgba(179,138,66,.35); outline-offset: 2px; border-color: var(--gold); }
.search-field { position: relative; }
.search-field svg { position: absolute; left: 15px; top: 14px; width: 20px; fill: none; stroke: var(--muted); stroke-width: 2; }
.search-field input { padding-left: 45px; }
.panel { display: none; }
.panel.active { display: block; }
#map { height: min(64vh, 650px); min-height: 440px; background: #dce7ec; }
.map-note { padding: 10px 24px; background: var(--navy); color: #dbe4ec; font-size: .78rem; text-align: center; }
.custom-marker { width: 24px !important; height: 24px !important; margin: -12px 0 0 -12px !important; border: 3px solid white; border-radius: 50% 50% 50% 0; background: var(--gold); box-shadow: 0 3px 9px rgba(23,44,70,.35); transform: rotate(-45deg); }
.leaflet-popup-content-wrapper { border-radius: 8px; box-shadow: var(--shadow); }
.map-popup { min-width: 190px; padding: 4px; }
.map-popup img { width: calc(100% + 8px); height: 105px; margin: -4px -4px 10px; border-radius: 6px 6px 0 0; object-fit: cover; object-position: 50% 38%; }
.map-popup img.organization-photo { padding: 10px; background: #f4f6f8; object-fit: contain; object-position: center; }
.map-popup small { color: var(--gold); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.map-popup h3 { margin: 5px 0 2px; color: var(--navy); font-family: Georgia, serif; font-size: 1.16rem; }
.map-popup p { margin: 0 0 12px; color: var(--muted); }
.map-popup button { width: 100%; padding: 8px; border: 0; border-radius: 5px; background: var(--navy); color: white; font-weight: 700; }

.directory-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 24px; }
.missionary-card { position: relative; display: flex; min-height: 152px; flex-direction: column; align-items: flex-start; padding: 22px; border: 1px solid var(--line); border-radius: 8px; background: white; text-align: left; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.missionary-card:has(.card-photo) { padding-top: 0; overflow: hidden; }
.card-photo { width: calc(100% + 44px); height: 145px; margin: 0 -22px 20px; object-fit: cover; object-position: 50% 38%; }
.card-photo.organization-photo { padding: 18px; background: #f4f6f8; object-fit: contain; object-position: center; }
.missionary-card:hover { transform: translateY(-3px); border-color: var(--gold-light); box-shadow: 0 12px 28px rgba(23,44,70,.1); }
.missionary-card .category { color: var(--gold); font-size: .69rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.missionary-card h2 { margin: 10px 0 3px; color: var(--navy); font-family: Georgia, serif; font-size: 1.25rem; font-weight: 600; line-height: 1.2; }
.missionary-card .location { color: var(--muted); font-size: .92rem; }
.missionary-card .arrow { margin-top: auto; padding-top: 12px; color: var(--navy); font-size: .8rem; font-weight: 800; }
.location-heading { grid-column: 1 / -1; margin: 18px 0 0; padding-bottom: 7px; border-bottom: 2px solid var(--gold-light); color: var(--navy); font-size: .85rem; letter-spacing: .12em; text-transform: uppercase; }
.empty-state { padding: 70px 24px; text-align: center; }
.empty-state h2 { color: var(--navy); font-family: Georgia, serif; }
.empty-state button { padding: 10px 18px; border: 0; border-radius: 6px; background: var(--navy); color: white; }

footer { padding: 26px 4px; color: var(--muted); font-size: .82rem; }
dialog { width: min(680px, calc(100% - 28px)); max-height: calc(100vh - 28px); padding: 0; border: 0; border-radius: 12px; box-shadow: 0 30px 90px rgba(10,24,40,.32); overflow: auto; }
dialog::backdrop { background: rgba(15,29,45,.72); backdrop-filter: blur(3px); }
.dialog-close { position: absolute; z-index: 2; top: 12px; right: 14px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(255,255,255,.92); color: var(--navy); font-size: 1.6rem; line-height: 1; }
.profile-hero { padding: 54px 44px 34px; background: var(--navy); color: white; }
.profile-hero.with-photo { display: grid; grid-template-columns: 220px 1fr; gap: 28px; align-items: center; padding: 34px 44px 34px 34px; }
.profile-photo { width: 220px; aspect-ratio: 4 / 3; border: 4px solid rgba(255,255,255,.9); border-radius: 8px; object-fit: cover; object-position: 50% 38%; box-shadow: 0 12px 30px rgba(0,0,0,.24); }
.photo-right { object-position: right center !important; }
.profile-photo.organization-photo { padding: 14px; background: white; object-fit: contain; object-position: center; }
.profile-hero .profile-category { color: var(--gold-light); font-size: .74rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.profile-hero h2 { margin: 10px 0 4px; font-family: Georgia, serif; font-size: clamp(2rem, 6vw, 3.1rem); font-weight: 500; line-height: 1.05; }
.profile-hero p { margin: 0; color: #dce4ec; font-size: 1.05rem; }
.view-on-map { margin-top: 18px; padding: 10px 16px; border: 1px solid rgba(255,255,255,.55); border-radius: 6px; background: white; color: var(--navy); font-weight: 800; }
.view-on-map:hover { background: var(--gold-light); border-color: var(--gold-light); }
.profile-body { padding: 34px 44px 44px; }
.profile-body h3 { margin: 0 0 8px; color: var(--navy); font-family: Georgia, serif; font-size: 1.35rem; }
.profile-body p { margin: 0 0 26px; color: var(--muted); }
.sensitive-notice { display: grid; gap: 3px; margin: 0 0 28px; padding: 16px 18px; border-left: 4px solid var(--gold); border-radius: 0 6px 6px 0; background: var(--cream); }
.sensitive-notice strong { color: var(--navy); }
.sensitive-notice span { color: var(--muted); font-size: .9rem; }
.prayer-list { margin: 0 0 30px; padding-left: 22px; color: var(--muted); }
.prayer-list li { margin-bottom: 8px; }
.letter-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; padding: 18px 20px; border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 7px; background: #fafbfc; }
.letter-card strong, .letter-card span { display: block; }
.letter-card strong { color: var(--navy); }
.letter-card span { color: var(--muted); font-size: .82rem; }
.letter-card a { flex: 0 0 auto; padding: 10px 15px; border-radius: 6px; background: var(--navy); color: white; font-size: .88rem; font-weight: 700; text-decoration: none; }
.ministry-website { display: inline-block; margin-bottom: 12px; padding: 11px 17px; border: 1px solid var(--navy); border-radius: 6px; color: var(--navy); font-weight: 800; text-decoration: none; }
.ministry-website:hover { background: var(--navy); color: white; }
.placeholder-notice { padding: 16px; border-left: 3px solid var(--gold); background: var(--cream); font-size: .9rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 850px) {
  .intro { grid-template-columns: 1fr; gap: 24px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats div:nth-child(2) { border-right: 0; }
  .stats div:nth-child(-n+2) { border-bottom: 1px solid rgba(255,255,255,.16); }
  .controls { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .directory-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .app-shell { padding: 16px; }
  .intro { padding-top: 12px; }
  .scripture { display: none; }
  .stats div { min-height: 96px; padding: 16px; }
  .stats strong { font-size: 1.8rem; }
  .stats span { font-size: .65rem; }
  .view-bar { align-items: stretch; flex-direction: column; }
  .segmented { width: 100%; }
  .view-button { flex: 1; min-width: 0; }
  .controls { grid-template-columns: 1fr; padding: 14px; }
  .search-field { grid-column: auto; }
  #map { min-height: 480px; }
  .directory-grid { grid-template-columns: 1fr; padding: 14px; }
  .profile-hero { padding: 52px 24px 28px; }
  .profile-hero.with-photo { grid-template-columns: 1fr; padding: 24px; }
  .profile-photo { width: 100%; }
  .profile-body { padding: 28px 24px 34px; }
  .letter-card { align-items: stretch; flex-direction: column; }
  .letter-card a { text-align: center; }
}
