:root {
  --navy: #054F91;
  --navy-dark: #033a6b;
  --navy-soft: #e8f1f9;
  --gold: #B79A5C;
  --gold-dark: #9a7f45;
  --gold-soft: #f7f2e8;
  --text: #1a2332;
  --muted: #5a6577;
  --border: #e2e8f0;
  --bg: #f4f6f9;
  --card: #ffffff;
  --shadow: 0 4px 18px rgba(5, 79, 145, 0.08);
  --shadow-lg: 0 12px 40px rgba(5, 79, 145, 0.15);
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--navy); }
button { font-family: inherit; cursor: pointer; }


.app-header { position: relative; }
.header-back {
  position: absolute;
  top: 0.55rem;
  right: 1.15rem;
  z-index: 2;
  color: var(--gold);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border: 1px solid rgba(183, 154, 92, 0.55);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  white-space: nowrap;
}
.header-back:hover { background: rgba(183, 154, 92, 0.22); color: #fff; }
.header-back::before { content: "\2190\00a0"; }
@media (max-width: 720px) {
  .header-back { top: 0.4rem; right: 0.7rem; font-size: 0.75rem; padding: 0.28rem 0.55rem; }
  .app-header { padding-top: 2.2rem; }
}
.app-footer .footer-note {
  color: var(--muted);
  font-weight: 500;
}

.app-header {
  position: relative;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%);
  color: #fff;
  padding: 0.7rem 1.15rem 0.85rem;
  box-shadow: 0 4px 20px rgba(3, 58, 107, 0.35);
  border: 2px solid var(--gold);
  border-bottom-width: 3px;
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}
.header-logo {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #fff;
  padding: 3px;
  object-fit: contain;
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
  flex-shrink: 0;
  border: 2px solid var(--gold);
}
.header-text h1 {
  margin: 0;
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.25;
}
.header-text .subtitle {
  margin: 0.1rem 0 0;
  color: var(--gold);
  font-weight: 600;
  font-size: clamp(0.82rem, 1.8vw, 0.95rem);
}

.header-contact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  margin-top: 0.4rem;
  font-size: 0.74rem;
  color: rgba(255,255,255,0.88);
  line-height: 1.3;
  max-width: 40rem;
}
.header-contact-line {
  color: rgba(255,255,255,0.92);
  text-decoration: none;
}
a.header-contact-line:hover {
  color: var(--gold);
  text-decoration: underline;
}
.header-contact-sep {
  color: var(--gold);
  opacity: 0.85;
}
@media (max-width: 640px) {
  .header-contact-sep { display: none; }
  .header-contact { flex-direction: column; align-items: flex-start; gap: 0.2rem; }
}

.header-accent {
  width: min(100%, 22rem);
  max-width: 28rem;
  height: 3px;
  background: var(--gold);
  border-radius: 2px;
  margin-top: 0.4rem;
}
.header-actions {
  margin-left: auto;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: none;
  border-radius: 999px;
  padding: 0.38rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  transition: transform .15s, background .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn-gold {
  background: var(--gold);
  color: #fff;
  box-shadow: 0 2px 8px rgba(183, 154, 92, 0.4);
}
.btn-gold:hover { background: var(--gold-dark); color: #fff; }
.btn-ghost {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
}
.btn-ghost:hover { background: rgba(255,255,255,0.2); }

.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2.5rem;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .header-actions { margin-left: 0; width: 100%; }
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(5, 79, 145, 0.06);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
}
.month-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--navy);
  display: grid;
  place-items: center;
}
.nav-btn:hover { background: var(--navy-soft); border-color: #c5d8ec; }
.month-label {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--navy);
  min-width: 10.5rem;
  text-align: center;
}
.today-btn {
  border: 1px solid var(--gold);
  background: var(--gold-soft);
  color: var(--gold-dark);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-weight: 600;
  font-size: 0.85rem;
}
.today-btn:hover { background: var(--gold); color: #fff; }

.filters {
  padding: 0.85rem 1.15rem 1rem;
  border-bottom: 1px solid var(--border);
}

.filter-actions {
  display: flex;
  gap: 0.35rem;
  width: 100%;
  margin-bottom: 0.15rem;
}
.filter-action {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--navy);
  cursor: pointer;
}
.filter-action:hover { border-color: var(--navy); background: var(--gold-soft); }
.chip {
  cursor: pointer;
  user-select: none;
}
.chip input[type="checkbox"] {
  width: 0.95rem;
  height: 0.95rem;
  accent-color: var(--navy);
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
}
.chip-icon { display: inline-flex; }
.chip-icon svg { width: 14px; height: 14px; flex-shrink: 0; }
.event-chip.cat-invited { background: #6b4f9a; }


.filters-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  transition: all .15s;
}
.chip svg { width: 14px; height: 14px; flex-shrink: 0; }
.chip:hover { border-color: var(--navy); color: var(--navy); }
.chip.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.chip.active svg { stroke: #fff; }
.chip[data-cat="all"].active { background: var(--gold); border-color: var(--gold); }

.calendar-wrap { padding: 0.75rem 1rem 1.1rem; }
.dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}
.dow span {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 0.35rem 0;
}
.grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.day {
  min-height: 108px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbfd;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: background .15s;
}
.day.outside { opacity: 0.45; background: #f1f3f6; }
.day.today {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px var(--gold);
  background: #fffdf8;
}
.day-num {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--navy);
  padding: 0.1rem 0.25rem;
  align-self: flex-start;
}
.day.today .day-num {
  background: var(--gold);
  color: #fff;
  border-radius: 6px;
  min-width: 1.4rem;
  text-align: center;
}
.event-chip {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  border: none;
  border-radius: 6px;
  padding: 0.18rem 0.3rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-align: left;
  line-height: 1.2;
  color: #fff;
  background: var(--navy);
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.event-chip svg { width: 11px; height: 11px; flex-shrink: 0; stroke: #fff; }
.event-chip:hover { filter: brightness(1.08); box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.event-chip.cat-board { background: #054F91; }
.event-chip.cat-arb { background: #2f6fad; }
.event-chip.cat-infrastructure { background: #5a6a7a; }
.event-chip.cat-music { background: #7a4d9b; }
.event-chip.cat-entertainment { background: #9b3d6e; }
.event-chip.cat-food { background: #c46a2b; }
.event-chip.cat-safety { background: #b33a3a; }
.event-chip.cat-community { background: #2f8a5b; }
.event-chip.cat-education { background: #3d6ea8; }
.event-chip.cat-service { background: #8a6b3d; }
.event-chip.cat-recreation { background: #1f7a6c; }
.event-chip.cat-calendar { background: #B79A5C; }

/* Sold-Out overlay: red horizontal ribbon with a text label (do not rely on color alone).
   Category color remains visible above/below or beside the banner. */
.sold-out-ribbon {
  background: #c8102e;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.15;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.event-chip.sold-out {
  position: relative;
  min-height: 1.55rem;
}
.event-chip.sold-out .sold-out-ribbon {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  padding: 0.08rem 0.2rem;
  font-size: 0.58rem;
  z-index: 1;
}
.upcoming-item.sold-out .up-body {
  position: relative;
}
.upcoming-item.sold-out .sold-out-ribbon {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  padding: 0.16rem 0.35rem;
  font-size: 0.72rem;
  z-index: 1;
}
.modal-sold-out {
  display: block;
  margin: 0.4rem 0 0;
  padding: 0.28rem 0.5rem;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  border-radius: 4px;
}
.modal-sold-out[hidden] { display: none; }

.more-btn {
  border: none;
  background: transparent;
  color: var(--navy);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.25rem;
  text-align: left;
}
.more-btn:hover { text-decoration: underline; }

.sidebar { display: flex; flex-direction: column; gap: 1rem; }
.sidebar h2 {
  margin: 0;
  font-size: 1rem;
  color: var(--navy);
  padding: 1rem 1rem 0.35rem;
}
.upcoming-list {
  list-style: none;
  margin: 0;
  padding: 0.35rem 0.75rem 1rem;
  max-height: 420px;
  overflow-y: auto;
}
.upcoming-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  padding: 0.7rem 0.45rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-radius: 8px;
}
.upcoming-item:hover { background: var(--navy-soft); }
.upcoming-item:last-child { border-bottom: none; }
.up-date {
  width: 48px;
  text-align: center;
  background: var(--navy-soft);
  border-radius: 10px;
  padding: 0.35rem 0.2rem;
  color: var(--navy);
}
.up-date .mon {
  display: block;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.up-date .dom {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.1;
}
.up-body strong {
  display: block;
  font-size: 0.88rem;
  color: var(--text);
  margin-bottom: 0.15rem;
}
.up-meta {
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--navy);
  background: var(--gold-soft);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  width: fit-content;
  margin-top: 0.2rem;
}
.cat-pill svg { width: 12px; height: 12px; }

.legend {
  padding: 0.85rem 1rem 1rem;
}
.legend h2 { padding: 0 0 0.5rem; }
.legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}
.legend-swatch {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.legend-swatch svg { width: 13px; height: 13px; stroke: #fff; }

.empty-upcoming {
  padding: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.app-footer {
  max-width: 1280px;
  margin: 0 auto 2rem;
  padding: 0 1.25rem;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}
.app-footer .trial-note {
  background: var(--gold-soft);
  border: 1px solid #e6d7b5;
  color: #6b5630;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  font-weight: 500;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 30, 55, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
  backdrop-filter: blur(3px);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 16px;
  width: min(540px, 100%);
  max-height: min(90vh, 720px);
  overflow: auto;
  box-shadow: var(--shadow-lg);
  border-top: 4px solid var(--gold);
}
.modal-header {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 1.15rem 1.25rem 0.5rem;
}
.modal-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--navy);
}
.modal-icon svg { width: 22px; height: 22px; stroke: #fff; }
.modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--navy);
  line-height: 1.3;
}
.modal-close {
  margin-left: auto;
  border: none;
  background: var(--bg);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 1.2rem;
  color: var(--muted);
  line-height: 1;
}
.modal-close:hover { background: var(--navy-soft); color: var(--navy); }
.modal-body { padding: 0.5rem 1.25rem 1.35rem; }
.detail-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 0.55rem;
  align-items: start;
  margin: 0.65rem 0;
  font-size: 0.92rem;
}
.detail-row svg { width: 18px; height: 18px; stroke: var(--gold-dark); margin-top: 2px; }
.detail-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}
.detail-desc {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
}
.detail-desc p {
  margin: 0 0 0.75rem;
}
.detail-desc p:last-child {
  margin-bottom: 0;
}

@media (max-width: 720px) {
  .day { min-height: 78px; }
  .event-chip > span:not(.sold-out-ribbon) { display: none; }
  .event-chip { justify-content: center; padding: 0.25rem; }
  .event-chip.sold-out { min-height: 1.7rem; }
  .event-chip.sold-out .sold-out-ribbon { font-size: 0.5rem; }
  .event-chip svg { width: 14px; height: 14px; }
  .legend-grid { grid-template-columns: 1fr; }
  .header-logo { width: 56px; height: 56px; }
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  border: 0;
}

.subscribe-section {
  padding-top: 0;
  grid-template-columns: 1fr;
}
.help-panel {
  padding: 1.25rem 1.35rem 1.4rem;
}
.help-panel h2 {
  margin: 0 0 0.35rem;
  color: var(--navy);
  font-size: 1.15rem;
}
.help-lead {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}
.help-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 720px) {
  .help-grid { grid-template-columns: 1fr; }
}
.help-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.05rem;
}
.help-card h3 {
  margin: 0 0 0.5rem;
  color: var(--navy);
  font-size: 0.98rem;
}
.help-card ol {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--text);
  font-size: 0.88rem;
}
.help-card li { margin: 0.35rem 0; }
.help-tip {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--gold-soft);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
}
.help-url-row {
  margin: 1rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.help-url-row code, .help-tip code {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
  font-size: 0.78rem;
  word-break: break-all;
}
.btn-copy {
  border: 1px solid var(--navy);
  background: #fff;
  color: var(--navy);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 700;
}
.btn-copy:hover { background: var(--navy-soft); }
.btn-copy.copied { background: var(--navy); color: #fff; }
