:root {
  --bg: #FAF8F3;
  --card: #FFFFFF;
  --ink: #333333;
  --ink-heading: #1F3552;
  --muted: #5A708A;
  --line: #E8E2D8;
  --line-light: #F2EDE4;
  --brand: #1F3552;
  --brand-2: #2B4C7E;
  --brand-light: #EBF2FA;
  --gold: #997551;
  --gold-hover: #805E3B;
  --gold-light: #F7F3EC;
  --gold-border: #DFD5C6;
  --programs: #1F3552;
  --programs-bg: #EAF0F8;
  --programs-border: #C5D7EA;
  --worship: #997551;
  --worship-bg: #F7F2EB;
  --worship-border: #DFCFC0;
  --youth: #2A6F55;
  --youth-bg: #E9F4EE;
  --youth-border: #B9DCCB;
  --obs: #B05330;
  --obs-bg: #FDF1EB;
  --obs-border: #EACEC0;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 2px 6px rgba(31, 53, 82, 0.04);
  --shadow: 0 4px 16px rgba(31, 53, 82, 0.07);
  --shadow-hover: 0 10px 28px rgba(31, 53, 82, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: "Cormorant Garamond", Georgia, serif;
  color: var(--ink-heading);
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

.muted { color: var(--muted); }
.hidden { display: none !important; }

/* Top Navigation Bar */
.top-nav-bar {
  background: #FFFFFF;
  border-bottom: 1px solid var(--line);
  padding: 8px 24px;
  font-size: 12px;
  color: var(--muted);
}
.top-nav-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.synagogue-name {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gold);
}
.nav-return-link {
  color: var(--brand-2);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.15s;
}
.nav-return-link:hover {
  color: var(--gold);
  text-decoration: underline;
}

/* Hero Section */
.hero {
  background: #FFFFFF;
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 4px 20px rgba(31, 53, 82, 0.05);
  padding: 24px 24px 36px;
}
.hero-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  gap: 24px;
  align-items: center;
}
.logo-link {
  display: block;
  text-decoration: none;
  line-height: 0;
}
.kolami-logo {
  height: 64px;
  width: auto;
  object-fit: contain;
}
.brand-text h1 {
  font-size: 34px;
  line-height: 1.15;
  color: var(--brand);
}
.brand-text .tagline {
  margin: 4px 0 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-size: 18px;
  color: var(--gold);
}

/* Stat counters */
.stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.stat {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 10px 16px;
  border-radius: var(--radius);
  text-align: center;
  min-width: 96px;
  box-shadow: var(--shadow-sm);
}
.stat b {
  display: block;
  font-size: 24px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.1;
}
.stat span {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* Main Container */
.container {
  max-width: 1240px;
  margin: 30px auto 60px;
  padding: 0 24px;
}

/* Tabs */
.tabs {
  display: inline-flex;
  background: #FFFFFF;
  border-radius: 999px;
  padding: 5px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  gap: 6px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.tab {
  border: 0;
  background: transparent;
  padding: 10px 24px;
  border-radius: 999px;
  font-family: "Lato", sans-serif;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.tab:hover {
  color: var(--brand);
}
.tab.active {
  background: var(--brand);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(31, 53, 82, 0.25);
}

.panel { display: none; }
.panel.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards & Filters */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.filters {
  padding: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  background: #FFFFFF;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 140px;
}
.field.grow { flex: 1 1 280px; }
.field label {
  font-size: 11px;
  font-weight: 700;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
input[type=search], input[type=text], input[type=date], select {
  font-family: "Lato", sans-serif;
  font-size: 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #FAF8F3;
  color: var(--ink);
  outline: none;
  transition: all 0.15s ease;
  width: 100%;
}
input:focus, select:focus {
  border-color: var(--gold);
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(153, 117, 81, 0.18);
}

/* Category Chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  padding-top: 6px;
  border-top: 1px solid var(--line-light);
}
.chip {
  border: 1px solid var(--line);
  background: #FAF8F3;
  padding: 7px 16px;
  border-radius: 999px;
  font-family: "Lato", sans-serif;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s ease;
}
.chip:hover {
  border-color: var(--gold);
  color: var(--brand);
}
.chip.active {
  background: var(--brand);
  color: #FFFFFF;
  border-color: var(--brand);
}
.chip.c-programs.active {
  background: var(--brand-2);
  border-color: var(--brand-2);
  color: #FFFFFF;
}
.chip.c-worship.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #FFFFFF;
}
.chip.c-youth.active {
  background: var(--youth);
  border-color: var(--youth);
  color: #FFFFFF;
}
.chip.c-obs.active {
  background: var(--obs);
  border-color: var(--obs);
  color: #FFFFFF;
}

.check {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: center;
  cursor: pointer;
  font-weight: 500;
}
.check input { accent-color: var(--gold); }

/* Buttons */
.btn {
  border: 0;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-family: "Lato", sans-serif;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn.primary {
  background: var(--brand);
  color: #FFFFFF;
}
.btn.primary:hover {
  background: var(--brand-2);
  box-shadow: 0 4px 12px rgba(31, 53, 82, 0.25);
}
.btn.primary:disabled { opacity: 0.6; cursor: wait; }
.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}
.btn.ghost:hover {
  background: #FAF8F3;
  color: var(--brand);
  border-color: var(--gold);
}
.btn.small {
  padding: 6px 12px;
  font-size: 11px;
}

.result-bar {
  margin: 20px 4px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

/* Event Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}
.month-head {
  grid-column: 1 / -1;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 26px;
  font-weight: 700;
  margin: 22px 2px 4px;
  color: var(--brand);
  border-bottom: 2px solid var(--gold);
  padding-bottom: 6px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.event {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  display: flex;
  gap: 14px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}
.event:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: var(--gold);
}
.event.match {
  border: 2px solid var(--gold);
  background: linear-gradient(180deg, #FBF8F2 0%, #FFFFFF 100%);
}

/* Date Box */
.datebox {
  flex: 0 0 58px;
  height: 66px;
  border-radius: var(--radius);
  background: #FAF8F3;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s;
}
.event:hover .datebox {
  border-color: var(--gold);
}
.datebox .m {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--gold);
  letter-spacing: 0.08em;
}
.datebox .d {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 700;
  font-size: 24px;
  line-height: 1;
  color: var(--brand);
}
.datebox .w {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
}

.event-body {
  min-width: 0;
  flex: 1;
}
.event h3 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--brand);
  margin-bottom: 6px;
  transition: color 0.15s;
}
.event:hover h3 {
  color: var(--brand-2);
}
.meta {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}

/* Category Badges */
.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 6px;
  border: 1px solid transparent;
}
.badge.programs {
  background: var(--programs-bg);
  color: var(--programs);
  border-color: var(--programs-border);
}
.badge.worship {
  background: var(--worship-bg);
  color: var(--worship);
  border-color: var(--worship-border);
}
.badge.youth {
  background: var(--youth-bg);
  color: var(--youth);
  border-color: var(--youth-border);
}
.badge.obs {
  background: var(--obs-bg);
  color: var(--obs);
  border-color: var(--obs-border);
}

.reason {
  margin-top: 10px;
  font-size: 13px;
  background: var(--gold-light);
  border-left: 3px solid var(--gold);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 8px 12px;
  color: #4A3A28;
}
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
}
.empty h3 { font-size: 24px; color: var(--brand); margin-bottom: 8px; }
.more { grid-column: 1 / -1; text-align: center; margin: 20px 0; }

/* AI Search Box */
.ai-box {
  padding: 30px;
  background: #FFFFFF;
  border-top: 3px solid var(--gold);
}
.ai-box h2 {
  font-size: 28px;
  color: var(--brand);
}
.ai-box p {
  margin: 6px 0 18px;
  font-size: 15px;
  color: var(--muted);
}
.ai-form {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.ai-form input {
  flex: 1;
  font-size: 16px;
  padding: 14px 18px;
}
.ai-summary {
  padding: 22px 24px;
  margin: 24px 0 18px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  border-left: 4px solid var(--gold);
  background: #FAF8F3;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
}
.ai-summary .icon { font-size: 28px; line-height: 1; }
.ai-summary .text { flex: 1; }
.ai-summary h3 {
  font-size: 22px;
  margin-bottom: 6px;
  color: var(--brand);
}
.ai-summary p { margin: 0 0 10px; color: #4A3A28; line-height: 1.6; }

/* Loading Spinner */
.loading {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  padding: 50px;
  color: var(--muted);
  grid-column: 1 / -1;
  font-weight: 500;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner.sm {
  width: 14px;
  height: 14px;
  border-width: 2px;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Audio (TTS) Button */
.speak {
  border: 1px solid var(--gold-border);
  background: #FFFFFF;
  border-radius: 999px;
  padding: 7px 14px;
  font-family: "Lato", sans-serif;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--gold);
  transition: all 0.15s ease;
}
.speak:hover {
  background: var(--gold-light);
  border-color: var(--gold);
  color: var(--gold-hover);
}
.speak.playing {
  background: var(--gold);
  color: #FFFFFF;
  border-color: var(--gold);
}

/* Modal Popup */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(31, 53, 82, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  animation: fadeIn 0.15s ease;
}
.modal-card {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  border-top: 4px solid var(--gold);
  max-width: 600px;
  width: 100%;
  max-height: 88vh;
  overflow: auto;
  padding: 30px;
  position: relative;
  box-shadow: 0 25px 70px rgba(31, 53, 82, 0.3);
}
.modal-card h2 {
  font-size: 28px;
  color: var(--brand);
  margin: 6px 0 10px;
  padding-right: 36px;
}
.modal-card .row {
  display: flex;
  gap: 12px;
  font-size: 14px;
  margin: 8px 0;
}
.modal-card .row b {
  min-width: 90px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  padding-top: 2px;
}
.modal-card .desc {
  margin: 18px 0;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: #333333;
  padding: 14px;
  background: #FAF8F3;
  border-radius: var(--radius);
  border: 1px solid var(--line-light);
}
.modal-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.modal-actions a {
  text-decoration: none;
}
.close {
  position: absolute;
  top: 18px;
  right: 18px;
  border: 1px solid var(--line);
  background: #FAF8F3;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.15s ease;
}
.close:hover {
  background: var(--gold-light);
  color: var(--gold);
  border-color: var(--gold);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--brand);
  color: #FFFFFF;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(31, 53, 82, 0.25);
  border: 1px solid var(--gold);
  z-index: 60;
}

@media (max-width: 768px) {
  .hero { padding: 18px 16px 26px; }
  .brand { flex-direction: column; align-items: flex-start; gap: 12px; }
  .brand-text h1 { font-size: 26px; }
  .kolami-logo { height: 48px; }
  .stats { width: 100%; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { min-width: 0; padding: 8px; }
  .container { padding: 0 16px; margin-top: 20px; }
  .field { min-width: calc(50% - 7px); flex: 1 1 calc(50% - 7px); }
  .field.grow { flex-basis: 100%; }
  .ai-form { flex-direction: column; }
  .grid { grid-template-columns: 1fr; }
  .tabs { display: flex; width: 100%; }
  .tab { flex: 1; text-align: center; padding: 10px 12px; font-size: 11px; }
}
