:root {
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #1b1e23;
  --muted: #6b7280;
  --accent: #2563eb;
  --border: #e5e7eb;
  --today-bg: #fff7e6;
  --today-border: #f5a623;
  --chip-bg: #eef1f5;
  --chip-active-bg: #2563eb;
  --chip-active-text: #ffffff;
  --danger: #dc2626;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card-bg: #1e2126;
    --text: #f0f1f3;
    --muted: #9aa0aa;
    --accent: #5b8dee;
    --border: #2c3038;
    --today-bg: #3a2f14;
    --today-border: #f5a623;
    --chip-bg: #262a31;
    --chip-active-bg: #5b8dee;
    --chip-active-text: #10131a;
    --danger: #f87171;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.login-card h1 { font-size: 1.4rem; margin: 0 0 4px; }
.subtitle { color: var(--muted); margin: 0 0 20px; font-size: 0.9rem; }
.error { color: var(--danger); font-size: 0.85rem; margin-bottom: 12px; }

.pin-input {
  width: 100%;
  font-size: 1.4rem;
  letter-spacing: 0.2em;
  text-align: center;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  margin-bottom: 14px;
}

.login-card button {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.topbar h1 { font-size: 1.15rem; margin: 0; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

#refreshBtn, #historyBtn {
  background: var(--chip-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.85rem;
  cursor: pointer;
}

#historyBtn.active {
  background: var(--chip-active-bg);
  color: var(--chip-active-text);
  border-color: transparent;
}

.logout-link { color: var(--muted); font-size: 0.8rem; text-decoration: none; }

.filters {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
}

.filter-chip {
  flex: none;
  background: var(--chip-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.filter-chip .grade { color: var(--muted); font-size: 0.75rem; }

.filter-chip.active {
  background: var(--chip-active-bg);
  color: var(--chip-active-text);
  border-color: transparent;
}

.status-line {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  margin: 0 0 8px;
}

.event-list {
  padding: 0 16px 24px;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.day-heading {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 18px 0 2px;
}

.day-heading:first-child { margin-top: 4px; }

.event-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.event-card.today {
  background: var(--today-bg);
  border-color: var(--today-border);
}

.event-card.past {
  opacity: 0.55;
}

.event-icon { font-size: 1.4rem; line-height: 1; margin-top: 2px; }

.event-main { flex: 1; min-width: 0; }

.event-title { font-weight: 600; margin: 0 0 2px; }

.event-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.map-link {
  color: var(--accent);
  text-decoration: none;
  /* A full street address is far wider than a phone card. As a flex item it would
     otherwise refuse to shrink below its longest line and overflow, so let it wrap
     and break. The pin is held to the first word by a non-breaking space in the
     markup instead, which keeps them together without pinning the whole address. */
  min-width: 0;
  overflow-wrap: break-word;
}

.map-link:hover,
.map-link:focus-visible {
  text-decoration: underline;
}

/* Comfortable thumb target on a phone without disturbing the meta row's spacing. */
@media (pointer: coarse) {
  .map-link {
    padding: 2px 0;
  }
}

.event-kid-badge {
  display: inline-block;
  background: var(--chip-bg);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 4px;
}

.event-notes {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 6px;
}

.dismiss-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 16px;
}
