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

:root {
  --primary: #8b1a1a;
  --primary-light: #c44e4e;
  --gold: #c5a055;
  --bg: #faf8f5;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #666;
  --border: #e0ddd8;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header {
  background: var(--primary);
  color: white;
  padding: 1rem 1.5rem;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.subtitle {
  font-size: 0.9rem;
  opacity: 0.8;
}

.user-area {
  margin-left: auto;
  font-size: 0.85rem;
}

.user-area a {
  color: var(--gold);
  text-decoration: none;
}

/* Filters */
.filters {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  flex-wrap: wrap;
}

.jurisdiction-chips {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.chip {
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.15s;
  user-select: none;
}

.chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

select {
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  background: var(--surface);
}

.distance-slider {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.distance-slider input[type="range"] {
  width: 100px;
  accent-color: var(--primary);
}

.view-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.view-btn {
  padding: 0.375rem 0.875rem;
  border: none;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s;
}

.view-btn.active {
  background: var(--primary);
  color: white;
}

/* Main */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
}

.view { display: none; }
.view.active { display: block; }

/* Events list */
.events-list {
  display: grid;
  gap: 0.75rem;
}

.event-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  gap: 1rem;
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.event-card:hover {
  box-shadow: var(--shadow);
}

.event-date-col {
  text-align: center;
  min-width: 48px;
  flex-shrink: 0;
}

.event-day {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--primary);
}

.event-month {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
}

.event-weekday {
  font-size: 0.7rem;
  color: var(--text-muted);
}

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

.event-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.event-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.event-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-liturgy { background: #fce4e4; color: #8b1a1a; }
.badge-vespers { background: #e8e4f8; color: #4a3a8a; }
.badge-feast { background: #fff3cd; color: #856404; }
.badge-festival { background: #d4edda; color: #155724; }
.badge-youth { background: #cce5ff; color: #004085; }
.badge-talk { background: #e2e3e5; color: #383d41; }
.badge-fundraiser { background: #f8d7da; color: #721c24; }
.badge-other { background: #f0f0f0; color: #555; }

.event-distance {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  align-self: center;
}

.event-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-end;
  align-self: center;
}

.directions-link {
  font-size: 0.75rem;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}

.directions-link:hover {
  text-decoration: underline;
}

/* Map */
#map {
  height: 500px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* Event detail panel */
.event-detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  max-width: 100vw;
  height: 100vh;
  background: var(--surface);
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  z-index: 1000;
  overflow-y: auto;
  padding: 1.5rem;
  transition: transform 0.25s ease;
}

.event-detail-panel.hidden {
  transform: translateX(100%);
}

.close-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
}

.detail-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  padding-right: 2rem;
}

.detail-meta {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.detail-description {
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 1rem;
}

.detail-actions {
  display: flex;
  gap: 0.75rem;
}

.btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state h3 {
  margin-bottom: 0.5rem;
}

/* Responsive */
@media (max-width: 640px) {
  .header-content { flex-direction: column; gap: 0.25rem; }
  .user-area { margin-left: 0; }
  .filters { flex-direction: column; align-items: stretch; }
  .filter-row { flex-direction: column; }
  .event-card { flex-direction: column; gap: 0.5rem; }
  .event-date-col { display: flex; gap: 0.5rem; align-items: baseline; }
  .event-detail-panel { width: 100vw; }
  #map { height: 350px; }
  .distance-slider input[type="range"] { width: 100%; }
}
