:root {
  color-scheme: light dark;
  --bg: #f4f6f8;
  --card-bg: #fff;
  --text: #1a1a1a;
  --muted: #666;
  --accent: #2b6cb0;
  --accent-bg: #e6effa;
  --border: #ddd;
  --warning-bg: #fff4e5;
  --warning-border: #f0b429;
  --warning-text: #8a5a00;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181c;
    --card-bg: #1f2429;
    --text: #eee;
    --muted: #aaa;
    --accent: #6fa8dc;
    --accent-bg: #23303d;
    --border: #333;
    --warning-bg: #3a2f10;
    --warning-border: #a97c1a;
    --warning-text: #e8c477;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.page-header {
  padding: 16px 16px 4px;
  text-align: center;
}
.banner {
  width: 100%;
  max-width: 280px;
  height: auto;
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}
.subtitle { margin: 10px 0 0; color: var(--muted); font-size: 13px; }

.warning {
  margin: 12px 16px;
  padding: 12px 14px;
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: 8px;
  color: var(--warning-text);
  font-size: 13px;
}
.warning strong { display: block; margin-bottom: 4px; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  padding: 16px;
  max-width: 900px;
  margin: 0 auto;
}
.field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 160px; min-width: 140px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field select {
  height: 44px;
  box-sizing: border-box;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 14px;
}
/* Safari renders <select> with its own native chrome, shorter than
   <input type="date"> even with identical padding/font-size — force a
   consistent box and draw a plain CSS arrow in place of the native one. */
.field select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 30px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 13px) calc(50% - 3px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.search-button {
  min-height: 44px;
  padding: 0 24px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.search-button:disabled { opacity: 0.6; cursor: default; }

.result-count { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.empty-state { text-align: center; color: var(--muted); padding: 40px 16px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 0 16px 32px;
  max-width: 1200px;
  margin: 0 auto;
}

.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.card .date { font-size: 12px; color: var(--muted); }
.card .badge {
  align-self: flex-start;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
}
.card .title { font-size: 16px; font-weight: 700; margin: 2px 0; }
.card .location { font-size: 13px; color: var(--muted); }
.card .description {
  font-size: 13px;
  color: var(--text);
  opacity: 0.85;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .actions { display: flex; gap: 8px; margin-top: 8px; }
.card .actions button, .card .actions a {
  flex: 1;
  min-height: 44px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
}
.card .actions .primary { background: var(--accent); color: #fff; }
.card .actions .secondary { background: var(--accent-bg); color: var(--accent); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 10;
}
.modal-backdrop[hidden] { display: none; }
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
}
.modal-sheet {
  background: var(--card-bg);
  color: var(--text);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding: 24px;
  position: relative;
}
@media (min-width: 640px) {
  .modal-sheet { border-radius: 16px; }
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}
#modal-content .participant { font-size: 13px; margin: 2px 0; }
#modal-content .source { font-size: 12px; color: var(--muted); margin-top: 12px; }
#modal-content .official-link {
  display: inline-block;
  margin-top: 16px;
  padding: 10px 20px;
  min-height: 44px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}
