* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #000000;
  --text-secondary: #888888;
  --text-muted: #aaaaaa;
  --border: #d0d0d0;
  --border-light: #e8e8e8;
  --now-dot: #22c55e;
  --radius: 2px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* ── Jurisdiction banner ── */
.jurisdiction-banner {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.jurisdiction-banner::-webkit-scrollbar { display: none; }

.jurisdiction-chip {
  flex: none;
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.jurisdiction-chip:hover { color: var(--text-secondary); }
.jurisdiction-chip.active {
  color: var(--bg);
  border-bottom-color: transparent;
}

/* ── Map ── */
.map-container {
  position: relative;
  height: 120px;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  transition: height 0.3s ease;
}
.map-container.expanded { height: 50vh; }

#map { height: 100vh; width: 100%; }

.map-toggle {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 28px;
  background: linear-gradient(transparent, rgba(255,255,255,0.95));
  border: none;
  cursor: pointer;
  z-index: 401;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 8px;
}
.map-toggle::after {
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 6px solid var(--text-secondary);
  transition: transform 0.3s ease;
}
.map-container.expanded .map-toggle::after {
  transform: rotate(180deg);
}

/* ── Mode bar ── */
.mode-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
}

.icon-btn {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--text-secondary);
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-secondary); }
.icon-btn.active {
  color: var(--bg);
  background: var(--text);
  border-color: var(--text);
}
.icon-btn img {
  width: 18px;
  height: 18px;
  opacity: 0.5;
}
.icon-btn:hover img { opacity: 0.8; }
.icon-btn.active img { opacity: 1; filter: invert(1); }

.services-btn {
  flex: none;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  background: none;
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.services-btn:hover { color: var(--text); border-color: var(--text-secondary); }
.services-btn.active {
  color: var(--bg);
  background: var(--text);
  border-color: var(--text);
}

.time-pills {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: flex-end;
}

.pill {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: 1px solid transparent;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.pill:hover { color: var(--text); }
.pill.active {
  color: var(--text);
  border-color: var(--border);
}

/* ── Parish filter pills ── */
.parish-filter-row {
  display: none;
  gap: 4px;
  padding: 4px 12px 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.parish-filter-row::-webkit-scrollbar { display: none; }
.parish-filter-row.visible { display: flex; }

.parish-pill {
  flex: none;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.parish-pill:hover { color: var(--text-secondary); border-color: var(--border); }
.parish-pill.active {
  color: var(--bg);
  border-color: transparent;
}

.location-pill {
  flex: none;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.location-pill:hover { color: var(--text-secondary); border-color: var(--border); }
.location-pill.active {
  color: #1565c0;
  border-color: #1565c0;
  background: #e3f2fd;
}
.location-pill img {
  width: 14px;
  height: 14px;
  opacity: 0.5;
}
.location-pill.active img { opacity: 1; }

/* ── Content views ── */
.content-view { display: none; }
.content-view.active { display: block; }

/* ── Section headers ── */
.section-header {
  padding: 12px 14px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.section-header .now-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--now-dot);
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

/* ── Services title (replaces time pills when in services mode) ── */
.services-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Centre the title within the time-pills flex container */
.time-pills:has(.services-title) {
  justify-content: center;
  flex: 1;
}

/* ── Event cards ── */
.event-card {
  display: flex;
  align-items: flex-start;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.1s;
}
.event-card:hover { background: #fafafa; }
.event-card:active { background: #f5f5f5; }

.event-content { flex: 1; min-width: 0; }

.event-title-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}
.event-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.event-time {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.event-parish-row {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.event-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 2px;
  margin-left: 4px;
  vertical-align: middle;
}
.badge-liturgy { background: #e8d5e8; color: #6b2d6b; }
.badge-prayer { background: #d5e0f0; color: #2d4a7a; }
.badge-youth { background: #d0e8f5; color: #2d5a8a; }
.badge-social { background: #d5ead5; color: #2d6a2d; }
.badge-talk { background: #f0e8d5; color: #7a5a20; }
.badge-feast { background: #f5ecd0; color: #7a6520; }
.badge-other { background: #f0f0f0; color: #555; }
/* Legacy types still in DB — mapped to display types at render time */
.badge-vespers { background: #d5e0f0; color: #2d4a7a; }
.badge-matins { background: #f0e0d0; color: #7a4a20; }
.badge-festival { background: #d5ead5; color: #2d6a2d; }
.badge-fundraiser { background: #e0f0e0; color: #3a6a3a; }

/* ── Parish acronym on event cards ── */
.event-parish-acronym {
  font-weight: 700;
  margin-right: 4px;
  opacity: 0.6;
}

/* ── Sunday cluster ── */
.sunday-cluster {
  border-left: 3px solid var(--border);
  background: #fafafa;
  margin: 4px 0;
  padding-left: 0;
  border-radius: 0 4px 4px 0;
}
.sunday-cluster .section-header {
  font-weight: 700;
}

/* ── Services view ── */
.parish-schedule {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.parish-schedule:hover { background: #fafafa; }
.parish-schedule:active { background: #f5f5f5; }
.parish-schedule-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.parish-schedule-jurisdiction {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 1px;
}
.schedule-day {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-top: 10px;
}
.schedule-item {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
  padding-left: 2px;
}
.schedule-item-time {
  color: var(--text-muted);
}

/* ── Detail panel ── */
.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 400px;
  background: var(--bg);
  border-left: 4px solid var(--border);
  z-index: 1000;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  padding: 20px;
}
.detail-panel:not(.hidden) { transform: translateX(0); }

.close-btn {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.detail-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-right: 30px;
}
.detail-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.detail-description {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}
.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.detail-actions a,
.detail-actions button {
  display: inline-block;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  border-radius: 4px;
  transition: opacity 0.15s;
  cursor: pointer;
}
.detail-actions a:hover,
.detail-actions button:hover { opacity: 0.8; }
.btn-primary {
  background: var(--text);
  color: var(--bg);
  border: none;
}
.btn-outline {
  background: none;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-danger {
  background: #dc3545;
  color: #fff;
  border: none;
}
.btn-save {
  background: #28a745;
  color: #fff;
  border: none;
}

/* ── Admin edit form in detail panel ── */
.detail-edit-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}
.detail-edit-form .edit-row {
  margin-bottom: 8px;
}
.detail-edit-form label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 2px;
}
.detail-edit-form input,
.detail-edit-form textarea,
.detail-edit-form select {
  width: 100%;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
}
.detail-edit-form textarea { resize: vertical; min-height: 60px; }

/* ── Location-active distance indicators ── */
.distance-blue { color: #2196f3; }
.distance-near { color: #1565c0; font-weight: 600; }
.distance-mid { color: #42a5f5; }
.distance-far { color: #90caf9; }

/* ── Nearby/Time sort toggle ── */
.sort-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  float: right;
}
.sort-toggle button {
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: none;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  color: var(--border);
  transition: all 0.15s;
}
.sort-toggle button.active {
  color: var(--text);
  font-weight: 700;
  background: #f0f0f0;
  border-color: var(--border);
}
.sort-toggle button:hover { color: var(--text-secondary); }
.sort-toggle .sort-sep {
  color: var(--border-light);
  font-size: 10px;
}
.sort-toggle .sort-icon {
  width: 12px;
  height: 12px;
  vertical-align: -2px;
  margin-right: 2px;
}

/* ── Empty state ── */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state h3 {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}
.empty-state p {
  font-size: 12px;
}

/* ── Admin float ── */
.admin-float {
  position: fixed;
  bottom: 12px;
  right: 12px;
  z-index: 500;
}
.admin-float a {
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
}
.admin-float a:hover { color: var(--text); border-color: var(--text-secondary); }

/* ── Backdrop for detail panel ── */
.detail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 999;
}

/* ── Map text labels ── */
.map-label {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  text-shadow: 1px 1px 2px rgba(255,255,255,0.9), -1px -1px 2px rgba(255,255,255,0.9),
               0 1px 2px rgba(255,255,255,0.9), 0 -1px 2px rgba(255,255,255,0.9);
  pointer-events: none;
}
.map-label-sub {
  font-size: 10px;
  font-weight: 400;
  opacity: 0.7;
}

/* ── Responsive ── */
@media (min-width: 640px) {
  .events-list, .services-list { max-width: 600px; margin: 0 auto; }
  .mode-bar { max-width: 600px; margin: 0 auto; padding: 10px 0; }
  .parish-filter-row { max-width: 600px; margin: 0 auto; }
}
