:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #241c2b;
  --muted: #675f6d;
  --line: #e8e1d6;
  --brand: #c8102e;
  --brand-dark: #a00d24;
  --brand-ink: #ffffff;
  --brand-soft: #fdecee;
  --gold: #c08a2e;
  --gold-soft: #f8eedb;
  --classical: #6a2c5b;
  --classical-soft: #f3e8f0;
  --grey-pin: #8a8590;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(36, 28, 43, .06), 0 4px 16px rgba(36, 28, 43, .05);
  --header-h: 64px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 Inter, system-ui, -apple-system, Segoe UI, sans-serif; }
h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 650; line-height: 1.15; margin: 0; }
a { color: var(--brand); }
button, input, select { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }

/* Header */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); height: var(--header-h); display: flex; align-items: center; position: sticky; top: 0; z-index: 1000; }
.site-header .wrap { width: 100%; }
.brand { display: inline-flex; gap: 12px; align-items: center; text-decoration: none; color: var(--ink); font-family: Fraunces, Georgia, serif; font-weight: 650; font-size: 1.3rem; }
.brand img { height: 44px; width: auto; display: block; }

/* Hero */
.hero { padding: 28px 0 18px; position: relative; overflow: hidden; isolation: isolate; background: #f6dfe2; }
/* Faint, pinky-red photo of the Royal Crescent behind the heading
   (photo: "Bath, Royal Crescent" by snelson951, Wikimedia Commons, CC0) */
.hero::before { content: ""; position: absolute; inset: 0; z-index: -2; background: url(/royal-crescent.jpg) center 55% / cover no-repeat; filter: sepia(1) hue-rotate(-28deg) saturate(2.4) brightness(1.05); opacity: .38; }
/* Soft wash so the text stays easy to read, fading into the page below */
.hero::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(253, 236, 238, .5) 0%, rgba(253, 236, 238, .62) 55%, rgba(250, 247, 242, .92) 88%, var(--bg) 100%); }
.hero-inner { display: flex; align-items: center; gap: 28px; margin-bottom: 18px; }
.hero-text { flex: 1; min-width: 0; }
.hero-logo { flex: none; width: 180px; height: auto; background: #fff; border-radius: 16px; padding: 10px; box-shadow: var(--shadow); }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin-bottom: 10px; }
.lede { color: var(--ink); margin: 0 0 10px; max-width: 64ch; font-size: 1.08rem; }
.lede.small { color: var(--muted); font-size: .95rem; margin-bottom: 0; }
.searchbar { display: flex; gap: 10px; flex-wrap: wrap; }
.field { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 6px 6px 16px; box-shadow: var(--shadow); min-height: 50px; }
.field:focus-within { border-color: var(--brand); outline: 2px solid var(--brand-soft); }
.field svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.field input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; padding: 6px 0; }
.field.grow { flex: 1 1 380px; }
.field.near { flex: 0 1 360px; }
.near-msg { min-height: 1.4em; margin: 8px 4px 0; font-size: .92rem; color: var(--muted); }
.near-msg.error { color: #a12a2a; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); border-radius: 999px; padding: 9px 16px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.small { padding: 7px 14px; font-size: .92rem; }
.btn.ghost { background: var(--card); color: var(--brand); }
.btn.ghost:hover { background: var(--brand-soft); }
.icon-btn { border: 0; background: transparent; padding: 6px; border-radius: 999px; cursor: pointer; display: inline-flex; }
.icon-btn:hover { background: var(--brand-soft); }
.icon-btn svg { stroke: var(--brand); }
.link-btn { border: 0; background: none; color: var(--brand); cursor: pointer; padding: 4px 0; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.badge { background: var(--brand); color: #fff; border-radius: 999px; font-size: .75rem; padding: 1px 7px; font-weight: 600; }

/* Toolbar with the two "envelope" tabs */
.main { padding-top: 18px; padding-bottom: 40px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar-left, .toolbar-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tab-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow); transition: border-color .15s, background .15s; }
.tab-btn:hover { border-color: var(--brand); }
.tab-btn[aria-expanded="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.tab-btn[aria-expanded="true"] .badge { background: #fff; color: var(--brand); }
.tab-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab-btn .chev { transition: transform .25s; }
.tab-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.count { margin: 0; font-weight: 600; }
.sort { display: inline-flex; gap: 6px; align-items: center; font-size: .9rem; color: var(--muted); }
.sort select { border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; background: var(--card); color: var(--ink); }

/* Map envelope: folds open at the top of the list */
.map-panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .35s ease; }
.map-panel.open { grid-template-rows: 1fr; }
.map-panel-inner { overflow: hidden; min-height: 0; }
.map-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; margin-bottom: 16px; visibility: hidden; transition: visibility 0s .35s; }
.map-panel.open .map-card { visibility: visible; transition: visibility 0s; }
#map { height: 440px; border-radius: 10px; background: #e9e4dc; }
.map-foot { display: flex; justify-content: space-between; align-items: center; padding: 6px 4px 0; }
.legend { display: flex; gap: 14px; font-size: .82rem; color: var(--muted); flex-wrap: wrap; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.dot.community { background: var(--gold); }
.dot.classical { background: var(--classical); }
.dot.other { background: var(--grey-pin); }
.no-map #map-toggle, .no-map .map-panel { display: none !important; }

.pin { background: none; border: 0; }
.pin span { display: block; width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); background: var(--grey-pin); }
.pin.community span { background: var(--gold); }
.pin.classical span { background: var(--classical); }
.you-pin span { display: block; width: 16px; height: 16px; border-radius: 50%; background: #2563eb; border: 3px solid #fff; box-shadow: 0 0 0 4px rgba(37,99,235,.25); }
.marker-cluster div { background: var(--brand) !important; color: #fff; font-weight: 600; font-family: Inter, sans-serif; }
.marker-cluster { background: rgba(200, 16, 46, .25) !important; }
.leaflet-popup-content { font-family: Inter, sans-serif; margin: 12px 14px; }
.popup h4 { font-family: Fraunces, Georgia, serif; font-size: 1.05rem; margin: 0 0 2px; }
.popup p { margin: 0 0 6px; color: var(--muted); font-size: .88rem; }
.popup a { font-weight: 600; }

/* Filters envelope: slides out from the left */
.scrim { position: fixed; inset: 0; background: rgba(20, 14, 24, .45); z-index: 2000; opacity: 0; transition: opacity .25s; }
.scrim.show { opacity: 1; }
.scrim[hidden] { display: none; }
.filters-panel { position: fixed; top: 0; bottom: 0; left: 0; width: min(380px, 100%); background: var(--bg); z-index: 2001; display: flex; flex-direction: column; box-shadow: 8px 0 30px rgba(0,0,0,.18); transform: translateX(-105%); visibility: hidden; transition: transform .3s ease, visibility 0s .3s; }
body.filters-open .filters-panel { transform: none; visibility: visible; transition: transform .3s ease; }
body.filters-open { overflow: hidden; }
.filters-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); background: var(--card); }
.filters-head h2 { font-size: 1.35rem; }
.icon-close { border: 0; background: var(--bg); width: 40px; height: 40px; border-radius: 50%; font-size: 1.7rem; line-height: 1; cursor: pointer; color: var(--ink); }
.icon-close:hover { background: var(--brand-soft); color: var(--brand); }
.filters-body { flex: 1; overflow: auto; padding: 4px 18px 12px; }
.filters-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--line); background: var(--card); }
.filters-foot .btn { flex: 1; max-width: 230px; }
.filter-group { border-bottom: 1px solid var(--line); padding: 14px 0; }
.filter-group:last-child { border-bottom: 0; }
.filter-group h3 { font-family: Inter, sans-serif; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 12px; font-size: .9rem; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.chip:hover { border-color: var(--brand); }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .n { font-size: .75rem; color: var(--muted); }
.chip[aria-pressed="true"] .n { color: #ffd6dc; }
.chip:disabled { opacity: .4; cursor: default; }
.chip:disabled:hover { border-color: var(--line); }

.active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.active-filters:empty { display: none; }
.pill { display: inline-flex; align-items: center; gap: 4px; background: var(--brand-soft); color: var(--brand); border: 0; border-radius: 999px; padding: 4px 10px; font-size: .85rem; cursor: pointer; }
.pill::after { content: "×"; font-size: 1rem; line-height: 1; }

/* Choir cards */
.results { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: grid; grid-template-columns: 190px minmax(0, 1fr); overflow: hidden; scroll-margin-top: calc(var(--header-h) + 16px); transition: box-shadow .2s, border-color .2s; }
.card.flash { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft), var(--shadow); }
.card-media { background: #f3eee7; position: relative; min-height: 150px; }
.media-btn { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; padding: 8px; margin: 0; background: #f3eee7; cursor: zoom-in; display: block; }
.media-btn.broken { cursor: default; }
.media-btn:focus-visible { outline: 3px solid var(--brand); outline-offset: -3px; }
.media-btn img { position: relative; width: 100%; height: 100%; object-fit: contain; display: block; }
.media-btn:has(img) .monogram { display: none; }
.zoom-hint { position: absolute; right: 8px; bottom: 8px; background: rgba(36, 28, 43, .72); color: #fff; font-size: .72rem; font-weight: 600; padding: 3px 8px; border-radius: 999px; opacity: 0; transition: opacity .15s; pointer-events: none; }
.media-btn:hover .zoom-hint, .media-btn:focus-visible .zoom-hint { opacity: 1; }
.media-btn.broken .zoom-hint { display: none; }
.monogram { position: absolute; inset: 0; display: grid; place-items: center; font-family: Fraunces, Georgia, serif; font-size: 2rem; color: var(--brand); background: var(--brand-soft); pointer-events: none; }
.card-body { padding: 14px 16px 16px; min-width: 0; }
.card-top { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.card h3 { font-size: 1.18rem; }
.style-tag { flex: none; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; border-radius: 6px; padding: 3px 7px; }
.style-tag.community { background: var(--gold-soft); color: #7d5615; }
.style-tag.classical { background: var(--classical-soft); color: var(--classical); }
.when { margin: 4px 0 8px; color: var(--muted); font-size: .93rem; }
.when strong { color: var(--ink); font-weight: 600; }
.dist { color: var(--brand); font-weight: 600; }
.tags { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { font-size: .8rem; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; }
.details { margin: 0; font-size: .95rem; overflow-wrap: anywhere; white-space: pre-line; }
.details.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.empty { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); grid-column: 1 / -1; }

/* Photo lightbox */
.lightbox { position: fixed; inset: 0; z-index: 5000; background: rgba(20, 14, 24, .88); display: flex; align-items: center; justify-content: center; padding: 56px 16px 24px; cursor: zoom-out; }
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.lightbox img { max-width: min(1100px, 100%); max-height: calc(100vh - 120px); object-fit: contain; border-radius: 8px; background: #fff; box-shadow: 0 10px 40px rgba(0,0,0,.4); cursor: default; }
.lightbox figcaption { color: #fff; font-family: Fraunces, Georgia, serif; font-size: 1.1rem; text-align: center; }
.lb-close { position: absolute; top: 12px; right: 14px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.15); color: #fff; font-size: 2rem; line-height: 1; cursor: pointer; }
.lb-close:hover { background: rgba(255,255,255,.28); }
body.lb-open { overflow: hidden; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: 24px 0 40px; color: var(--ink); font-size: .92rem; }
.site-footer p { margin: 0 0 6px; }
.signup { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; background: var(--brand-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px; scroll-margin-top: calc(var(--header-h) + 16px); }
.signup h2 { font-size: 1.3rem; margin-bottom: 4px; }
.signup p { margin: 0; color: var(--muted); }

@media (max-width: 720px) {
  :root { --header-h: 56px; }
  .brand img { height: 38px; }
  .hero { padding: 20px 0 12px; }
  .hero-inner { flex-direction: column-reverse; align-items: flex-start; gap: 14px; }
  .hero-logo { width: 120px; padding: 6px; }
  .field.near, .field.grow { flex: 1 1 100%; }
  .toolbar-left { width: 100%; }
  .toolbar-left .tab-btn { flex: 1; justify-content: center; }
  .toolbar-right { width: 100%; justify-content: space-between; }
  .sort span { display: none; }
  #map { height: 60vh; min-height: 320px; }
  .card { grid-template-columns: 1fr; }
  .card-media { min-height: 0; height: 200px; }
  .zoom-hint { opacity: 1; }
}