:root {
  --bg-1: #f4efe2;
  --bg-2: #d8ebe5;
  --panel: #fffdf8;
  --text: #1f2a2e;
  --muted: #5f6c71;
  --accent: #0f766e;
  --accent-strong: #0b5f58;
  --accent-soft: #d9f0eb;
  --line: #d4dfdd;
  --chip: #f5f7f7;
  --chip-active: #0f766e;
  --chip-active-text: #f7fffd;
  --warning: #b45309;
  --shadow: 0 18px 40px rgba(19, 38, 40, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Public Sans", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1400px 700px at 10% -5%, rgba(248, 192, 130, 0.35), transparent 48%),
    radial-gradient(1200px 550px at 100% 15%, rgba(112, 194, 181, 0.24), transparent 52%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2));
}

.background-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(15, 118, 110, 0.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15, 118, 110, 0.06) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at 40% 20%, black 20%, transparent 76%);
}

.hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 1.25rem 1.6rem;
  position: relative;
  z-index: 1;
  animation: rise-in 360ms ease-out;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 700;
}

h1 {
  margin: 0.5rem 0 0.3rem;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  line-height: 1.05;
  font-size: clamp(2rem, 4.6vw, 3.5rem);
}

.lede {
  margin: 0;
  color: var(--muted);
  max-width: 70ch;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1.2rem;
}

.stat {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(15, 118, 110, 0.15);
  border-radius: 0.8rem;
  padding: 0.7rem 0.85rem;
  backdrop-filter: blur(2px);
}

.stat-value {
  display: block;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--accent-strong);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 1rem;
  position: relative;
  z-index: 1;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: var(--shadow);
}

.controls-panel {
  padding: 1.1rem;
  position: sticky;
  top: 1rem;
  height: calc(100dvh - 2rem);
  overflow-y: auto;
}

.controls-panel h2 {
  margin: 0 0 0.75rem;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.3rem;
}

.control-label {
  display: block;
  margin: 0.8rem 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

input[type="search"],
input[type="date"],
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  padding: 0.62rem 0.7rem;
  background: #fff;
  font: inherit;
  color: var(--text);
}

input[type="search"]:focus,
input[type="date"]:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(15, 118, 110, 0.22);
  border-color: var(--accent);
}

.checkbox-row {
  margin-top: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.clear-button {
  margin-top: 0.9rem;
  width: 100%;
  border: 1px solid var(--accent);
  border-radius: 0.65rem;
  padding: 0.62rem 0.7rem;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease;
}

.clear-button:hover {
  transform: translateY(-1px);
  background: #caebe3;
}

.facet-section {
  margin-top: 1rem;
}

.facet-section h3 {
  margin: 0 0 0.42rem;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.date-picker-section {
  margin-bottom: 0.15rem;
}

.date-input-group {
  margin-top: 0.2rem;
}

.date-input-group.is-hidden {
  display: none;
}

.date-helper {
  margin: 0.58rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.44rem;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 0.15rem;
}

.chip {
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--text);
  border-radius: 999px;
  padding: 0.3rem 0.62rem;
  font-size: 0.8rem;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.chip:hover {
  transform: translateY(-1px);
  border-color: #99b0ad;
}

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

.results-panel {
  padding: 1rem;
  min-height: 540px;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
  min-height: 1.2rem;
}

.active-pill {
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  background: #eaf5f3;
  border: 1px solid #c2dfd9;
  color: #245b55;
}

.results-meta {
  color: var(--muted);
  margin: 0.55rem 0 0.85rem;
}

.event-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}

.event-card {
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  padding: 0.84rem;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  animation: rise-in 260ms ease-out;
}

.event-topline {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
}

.event-date {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-strong);
}

.event-source {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
}

.event-source:hover {
  text-decoration: underline;
}

.event-source.is-disabled {
  pointer-events: none;
  text-decoration: none;
  opacity: 0.8;
}

.event-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.event-title-link {
  color: inherit;
  text-decoration: none;
}

.event-title-link:hover {
  text-decoration: underline;
}

.event-title-link.is-disabled {
  pointer-events: none;
  text-decoration: none;
}

.event-location {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.pill {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fafcfb;
  padding: 0.2rem 0.52rem;
  font-size: 0.72rem;
}

.pill.type {
  border-color: #8ebdb5;
  background: #e9f5f2;
  color: #0e635b;
}

.pill.tag {
  border-color: #f2d5ab;
  background: #fef6e9;
  color: #8a5a1d;
}

.event-actions {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.event-link,
.event-flag-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 700;
}

.event-link:hover,
.event-flag-link:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.event-link.is-disabled {
  pointer-events: none;
  text-decoration: none;
  opacity: 0.65;
}

.event-actions .event-flag-link {
  margin-left: auto;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 31, 35, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.modal-backdrop.is-hidden {
  display: none;
}

.modal-panel {
  width: min(560px, 100%);
  background: #fffefb;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  box-shadow: var(--shadow);
  padding: 0.95rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.modal-header h2 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.2rem;
}

.modal-close {
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  width: 2rem;
  height: 2rem;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.modal-context {
  margin: 0.55rem 0 0.25rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.flag-form {
  display: grid;
  gap: 0.3rem;
}

.flag-form-status {
  min-height: 1.1rem;
  margin: 0.45rem 0 0.1rem;
  font-size: 0.84rem;
  color: var(--muted);
}

.flag-form-status.is-error {
  color: #b42318;
}

.flag-form-status.is-success {
  color: #146c43;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 0.2rem;
}

.secondary-button {
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  padding: 0.62rem 0.7rem;
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.secondary-button:hover {
  border-color: #a6b8b5;
}

.primary-button {
  border: 1px solid var(--accent);
  border-radius: 0.65rem;
  padding: 0.62rem 0.8rem;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.primary-button:hover {
  background: #caebe3;
}

.empty-state {
  border: 1px dashed #c7d8d5;
  border-radius: 0.9rem;
  padding: 1.2rem;
  color: var(--muted);
  text-align: center;
}

.error {
  color: var(--warning);
  font-weight: 600;
}

@keyframes rise-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 940px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    position: relative;
    top: 0;
    height: auto;
    max-height: none;
  }

  .hero-stats {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 580px) {
  .hero {
    padding-top: 2rem;
  }

  .hero-stats {
    grid-template-columns: 1fr;
  }

  .event-grid {
    grid-template-columns: 1fr;
  }
}
