:root{
  --navy:#0a1a4f; --navy-2:#13245f; --sapphire:#3a63ff; --sapphire-2:#4f7cff;
  --ink:#10162e; --muted:#5b6478; --line:#e7e9f0; --bg:#f6f7fb; --card:#fff;
  --shadow:0 1px 3px rgba(16,22,46,.08),0 8px 24px rgba(16,22,46,.06);
  --safe-top:env(safe-area-inset-top,0px); --safe-bottom:env(safe-area-inset-bottom,0px);
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%}
body{
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  color:var(--ink);background:var(--bg);overflow:hidden;
}
#app{display:flex;flex-direction:column;height:100dvh}

/* ---------- Top bar ---------- */
#topbar{
  background:linear-gradient(135deg,var(--navy),var(--navy-2));
  color:#fff;padding:calc(7px + var(--safe-top)) 12px 7px;z-index:1200;
  box-shadow:0 2px 16px rgba(10,26,79,.25);flex:0 0 auto;
  display:flex;align-items:center;gap:10px;flex-wrap:wrap;
}
.brand{display:flex;align-items:center;gap:9px;flex:0 0 auto;min-width:0}
.logo{font-size:20px;color:var(--sapphire-2);line-height:1}
.brand h1{font-size:18px;margin:0;font-weight:700;letter-spacing:.2px;line-height:1.15;flex:0 0 auto;white-space:nowrap}
.tools{display:flex;align-items:center;gap:8px;flex:1 1 340px;min-width:0;position:relative}
.search-wrap{position:relative;flex:1 1 auto;display:flex;align-items:center;min-width:0}
.search-icon{position:absolute;left:11px;color:#8b97c4;pointer-events:none}
#search{
  width:100%;height:40px;padding:0 12px 0 36px;border:none;border-radius:11px;
  font-size:15px;background:rgba(255,255,255,.96);color:var(--ink);outline:none;
}
#search::placeholder{color:#9aa3bd}
.btn-locate{
  display:flex;align-items:center;gap:6px;border:none;border-radius:11px;cursor:pointer;height:40px;flex:0 0 auto;
  background:var(--sapphire);color:#fff;font-size:13.5px;font-weight:600;padding:0 14px;white-space:nowrap;
}
.btn-locate:active{background:var(--sapphire-2)}
.btn-locate svg{flex:0 0 auto}

/* filter popover */
.filter-wrap{position:relative;flex:0 0 auto}
.btn-filter{
  display:flex;align-items:center;gap:6px;border:1px solid rgba(255,255,255,.4);border-radius:11px;cursor:pointer;height:40px;
  background:rgba(255,255,255,.12);color:#fff;font-size:13.5px;font-weight:600;padding:0 14px;white-space:nowrap;font-family:inherit;
}
.btn-filter:active,.btn-filter[aria-expanded="true"]{background:rgba(255,255,255,.24)}
.btn-filter svg{width:16px;height:16px;flex:0 0 auto}
.filter-badge{display:inline-flex;align-items:center;justify-content:center;min-width:18px;height:18px;padding:0 5px;border-radius:9px;background:var(--sapphire);color:#fff;font-size:11px;font-weight:700;line-height:1}
.filter-badge[hidden]{display:none}
.filter-pop{
  position:absolute;top:calc(100% + 9px);right:0;z-index:1400;width:262px;
  background:#fff;border-radius:14px;box-shadow:var(--shadow);padding:12px;
  display:flex;flex-direction:column;gap:9px;
}
.filter-pop[hidden]{display:none}
.filter-pop select{
  width:100%;padding:10px 12px;border-radius:10px;border:1px solid var(--line);font-size:14px;
  background:#fff;color:var(--ink);appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%235b6478' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right 12px center;padding-right:28px;
}
.pop-reset{border:1px solid var(--line);background:#fff;color:var(--muted);border-radius:10px;padding:9px 12px;font-size:13px;font-weight:600;cursor:pointer;font-family:inherit}
.pop-reset[hidden]{display:none}

/* ---------- Main split ---------- */
#main{flex:1;display:flex;min-height:0;position:relative;overflow:hidden}
#list-panel{
  width:392px;flex:0 0 392px;display:flex;flex-direction:column;background:var(--bg);
  border-right:1px solid var(--line);min-height:0;
}
#list-head{display:flex;align-items:center;justify-content:space-between;padding:10px 14px 6px;font-size:12.5px;color:var(--muted)}
#result-count{font-weight:600;color:var(--ink)}
#sort-note{color:var(--sapphire);font-weight:600}
#list{list-style:none;margin:0;padding:4px 10px 0;overflow-y:auto;flex:1;-webkit-overflow-scrolling:touch}

.card{
  background:var(--card);border:1px solid var(--line);border-radius:14px;padding:12px 13px;margin-bottom:9px;
  cursor:pointer;transition:border-color .15s,box-shadow .15s,transform .05s;
}
.card:hover{border-color:#cdd6f5}
.card.active{border-color:var(--sapphire);box-shadow:0 0 0 2px rgba(58,99,255,.15)}
.card:active{transform:scale(.997)}
.card-body{display:flex;gap:11px}
.card-main{flex:1;min-width:0}
.card-thumb{flex:0 0 76px;width:76px;height:76px;border-radius:10px;background:#e7e9f0 center/cover no-repeat;align-self:flex-start;object-fit:cover;display:block}
.badge-prem{display:inline-block;margin-left:6px;font-size:10px;font-weight:700;color:#8a6d00;background:#ffe9a8;border-radius:5px;padding:1px 5px;vertical-align:middle}
.card-top{display:flex;justify-content:space-between;align-items:baseline;gap:8px}
.card-name{font-weight:700;font-size:15px;line-height:1.25}
.card-dist{font-size:12px;font-weight:700;color:var(--sapphire);white-space:nowrap;flex:0 0 auto}
.card-cuis{font-size:12.5px;color:var(--muted);margin:3px 0 0}
.card-loc{font-size:12px;color:#8b93a7;margin:2px 0 0;display:flex;align-items:center;gap:4px}
.card-actions{display:flex;gap:7px;margin-top:10px}
.act{
  flex:1;display:flex;align-items:center;justify-content:center;gap:5px;text-decoration:none;
  font-size:12.5px;font-weight:600;padding:8px 6px;border-radius:9px;border:1px solid var(--line);color:var(--ink);background:#fbfcff;
}
.act svg{width:14px;height:14px}
.act.ot{background:var(--navy);color:#fff;border-color:var(--navy)}
.act.ot:active{background:var(--navy-2)}
.act.map{color:#1a73e8}
.act.web{color:var(--ink)}
.act.call{color:#1a8f4c}
.act:active{filter:brightness(.97)}

#list-footer{padding:8px 14px 12px;border-top:1px solid var(--line);background:var(--bg)}
.disclaimer{font-size:10.5px;color:#9aa3bd;line-height:1.45;margin:0;text-align:center}
.disclaimer a{color:var(--muted)}

/* ---------- Persistent ad / support footer (page shell, all views) ---------- */
#adbar{
  flex:0 0 auto;display:flex;align-items:center;justify-content:center;
  min-height:54px;max-height:104px;overflow:hidden;background:#fff;border-top:1px solid var(--line);
  padding:5px 12px calc(5px + var(--safe-bottom));z-index:1400;
}
#adbar .ad-slot:empty{display:none}
#adbar .ad-slot:not(:empty){width:100%;max-width:728px;min-height:50px;display:flex;align-items:center;justify-content:center;overflow:hidden}
#adbar .ad-slot:not(:empty) + .adbar-support{display:none}
.adbar-support{font-size:12.5px;font-weight:600;color:var(--navy);text-decoration:none;background:#fff3cf;border:1px solid #ffe49a;padding:7px 16px;border-radius:20px}
.adbar-support:active{filter:brightness(.97)}

/* ---------- Map ---------- */
#map-panel{flex:1;position:relative;min-width:0}
#map{position:absolute;inset:0;background:#dfe3ec}
.toggle-view{display:none}

/* Leaflet customisations */
.leaflet-popup-content-wrapper{border-radius:14px;box-shadow:var(--shadow);padding:2px}
.leaflet-popup-content{margin:12px 14px;font-family:inherit;width:230px!important}
.pop-photo{height:120px;margin:-2px -2px 8px;border-radius:12px 12px 0 0;background:#e7e9f0 center/cover no-repeat}
.pop-name{font-weight:700;font-size:15px;color:var(--ink);line-height:1.25}
.pop-cuis{font-size:12.5px;color:var(--muted);margin:3px 0 0}
.pop-loc{font-size:12px;color:#8b93a7;margin:3px 0 8px}
.pop-actions{display:grid;grid-template-columns:1fr 1fr;gap:6px}
.pop-actions .act{min-width:0}
.marker-pin{background:var(--sapphire);width:16px;height:16px;border-radius:50% 50% 50% 0;transform:rotate(-45deg);border:2px solid #fff;box-shadow:0 2px 5px rgba(0,0,0,.3)}
.cluster-ic{background:var(--navy);color:#fff;border-radius:50%;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:13px;border:3px solid rgba(79,124,255,.45);box-shadow:0 2px 8px rgba(10,26,79,.4)}
.me-dot{width:18px;height:18px;border-radius:50%;background:#1a73e8;border:3px solid #fff;box-shadow:0 0 0 4px rgba(26,115,232,.25)}

/* ---------- Mobile ---------- */
@media (max-width:760px){
  #main{display:block}
  #map-panel{position:absolute;inset:0}
  #list-panel{
    position:absolute;left:0;right:0;bottom:0;width:100%;flex:none;height:64%;z-index:1050;
    border-right:none;border-top-left-radius:18px;border-top-right-radius:18px;
    box-shadow:0 -6px 24px rgba(16,22,46,.18);
    transition:transform .3s cubic-bezier(.32,.72,0,1);transform:translateY(0);
    will-change:transform;
  }
  /* collapsed: only the handle + a peek of the list remain above the ad bar */
  body.map-mode #list-panel{transform:translateY(calc(100% - 104px))}

  /* the whole head is the grab handle — tap to open/close */
  #list-head{position:relative;padding:18px 14px 8px;cursor:pointer;user-select:none;-webkit-user-select:none}
  #list-head::before{content:"";position:absolute;top:7px;left:50%;transform:translateX(-50%);
    width:40px;height:5px;border-radius:3px;background:#cdd3e2;transition:background .15s}
  #list-head:active::before{background:#9aa3bd}

  .toggle-view{
    display:flex;align-items:center;position:absolute;top:12px;right:12px;z-index:1100;border:none;cursor:pointer;
    background:#fff;color:var(--navy);font-weight:700;font-size:13.5px;padding:10px 15px;border-radius:22px;box-shadow:var(--shadow);
  }
  .toggle-view:active{transform:scale(.96)}
  /* label shows the ACTION: collapsed→"List" (tap to open), open→"Map" (tap to dismiss) */
  .toggle-view .show-list{display:none}
  .toggle-view .show-map{display:inline}
  body.map-mode .toggle-view .show-map{display:none}
  body.map-mode .toggle-view .show-list{display:inline}
  #list-footer{display:none}  /* disclaimer lives in the list flow; ad bar is the pinned footer */
}
@media (max-width:760px){
  .brand{flex:1 1 100%}
  .tools{flex:1 1 100%}
  .btn-locate span,.btn-filter .bt-label{display:none}   /* icon-only buttons on phones */
  .btn-locate,.btn-filter{padding:0 12px}
  .filter-pop{width:min(290px,calc(100vw - 24px))}
}

/* ---------- About button, footer nav, consent, modal ---------- */
.about-btn{flex:0 0 auto;margin-left:auto;width:30px;height:30px;border:none;background:none;border-radius:8px;color:#9fb0e0;font-size:20px;cursor:pointer;line-height:1;display:flex;align-items:center;justify-content:center;padding:0}
.about-btn:hover{color:#fff}
.about-btn:active{color:#fff;background:rgba(255,255,255,.12)}

.foot-nav{display:flex;align-items:center;justify-content:center;gap:8px;font-size:12px;margin:0 0 7px;color:#b6bccc}
.foot-nav a,.link-btn{color:var(--muted);text-decoration:none;background:none;border:none;font-size:12px;cursor:pointer;padding:0;font-family:inherit}
.foot-nav a:active,.link-btn:active{color:var(--ink)}
.btn-donate{display:inline-block;text-decoration:none;font-size:13px;font-weight:600;color:var(--navy);background:#fff3cf;border:1px solid #ffe49a;padding:9px 16px;border-radius:20px}

.consent{position:fixed;left:0;right:0;bottom:0;z-index:1600;background:#0e1c52;color:#dfe6ff;
  display:flex;align-items:center;justify-content:center;gap:14px;flex-wrap:wrap;
  padding:12px 16px calc(12px + var(--safe-bottom));box-shadow:0 -4px 20px rgba(0,0,0,.3)}
.consent[hidden]{display:none}
.consent p{margin:0;font-size:13px;line-height:1.4}
.consent a{color:#9db4ff}
.consent-btns{display:flex;gap:8px;flex:0 0 auto}
.consent-yes,.consent-no{border:none;border-radius:9px;padding:9px 18px;font-size:13px;font-weight:700;cursor:pointer;font-family:inherit}
.consent-yes{background:var(--sapphire);color:#fff}
.consent-no{background:rgba(255,255,255,.14);color:#fff}

.modal{position:fixed;inset:0;z-index:1700;display:none;align-items:flex-end;justify-content:center;background:rgba(8,12,30,.55)}
.modal.open{display:flex}
.modal-card{background:#fff;width:100%;max-width:520px;border-radius:18px 18px 0 0;
  padding:24px 20px calc(24px + var(--safe-bottom));max-height:86vh;overflow-y:auto;position:relative;
  box-shadow:0 -10px 40px rgba(0,0,0,.3)}
.modal-close{position:absolute;top:12px;right:14px;border:none;background:#f0f2f8;width:30px;height:30px;border-radius:50%;font-size:18px;color:var(--muted);cursor:pointer;line-height:1}
.modal-card h2{margin:0 14px 12px 0;font-size:19px;color:var(--navy)}
.modal-card p{font-size:14px;line-height:1.55;color:var(--ink);margin:0 0 12px}
.modal-card p.muted{font-size:12px;color:#8b93a7}
.modal-card a{color:var(--sapphire)}
.about-actions{margin-top:4px}

@media (min-width:761px){
  .modal{align-items:center}
  .modal-card{border-radius:18px;max-height:82vh}
}

.list-empty{padding:28px 18px;color:#8b93a7;text-align:center;font-size:13.5px;line-height:1.6;list-style:none}

/* ---------- Card-program tabs (Chase | Amex·Resy) ---------- */
.tabs{display:flex;gap:3px;flex:0 1 auto;margin-left:6px;background:rgba(255,255,255,.10);border-radius:10px;padding:3px}
.tab{flex:0 0 auto;text-align:center;padding:7px 12px;border-radius:8px;font-size:13px;font-weight:700;color:#aebbe6;text-decoration:none;white-space:nowrap;transition:background .12s,color .12s}
.tab.active{background:#fff;color:var(--navy)}
.tab:not(.active):active{background:rgba(255,255,255,.10)}

/* ---------- Resy eligibility toggle (in the filter popover) ---------- */
.elig-toggle{display:inline-flex;align-items:center;justify-content:center;gap:6px;width:100%;border:1px solid var(--line);background:#f3f5fb;color:var(--ink);border-radius:10px;padding:10px 12px;font-size:13px;font-weight:600;cursor:pointer;font-family:inherit}
.elig-toggle.on{background:var(--sapphire);border-color:var(--sapphire);color:#fff}
.elig-note{margin:0;font-size:11.5px;line-height:1.45;color:var(--muted)}
.elig-note strong{color:var(--navy)}
.badge-no{display:inline-block;margin-left:6px;font-size:9.5px;font-weight:700;color:#9a3434;background:#fde2e2;border-radius:5px;padding:1px 5px;vertical-align:middle;white-space:nowrap}
@media (max-width:760px){ .brand h1{font-size:15px} .tabs{margin-left:4px;flex:1 1 auto;max-width:240px} .tab{flex:1 1 0;padding:6px 8px;font-size:12px} .brand{gap:6px} .logo{font-size:18px} }
@media (max-width:360px){ .brand h1{display:none} }
