:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #1d4ed8;
  --primary-dark: #1e3a8a;
  --danger: #b91c1c;
  --ok-bg: #dcfce7;
  --ok-text: #166534;
  --error-bg: #fee2e2;
  --error-text: #991b1b;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111a2e;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --border: #1f2a44;
    --primary: #3b82f6;
    --primary-dark: #93c5fd;
    --danger: #f87171;
    --ok-bg: #052e16;
    --ok-text: #86efac;
    --error-bg: #450a0a;
    --error-text: #fca5a5;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: 0 0 0.75rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 0.4rem; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.brand-mark { background: var(--primary); color: #fff; border-radius: 8px; padding: 0.1rem 0.4rem; font-size: 0.85rem; }
.nav { display: flex; align-items: center; gap: 0.5rem; }

.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; font-size: 1.4rem; padding: 0.2rem 0.5rem; user-select: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute;
  right: 0;
  top: 2.6rem;
  min-width: 13rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.15);
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
}
.menu-panel a, .menu-panel .link { padding: 0.7rem 0.8rem; border-radius: 10px; color: var(--text); text-decoration: none; text-align: left; font: inherit; }
.menu-panel a:hover, .menu-panel .link:hover { background: var(--bg); }
.menu-panel form { margin: 0; display: flex; }
.menu-panel .link { flex: 1; }

.container { max-width: 960px; margin: 0 auto; padding: 1rem; }
.footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 2rem 1rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1rem; }
.narrow { max-width: 440px; margin: 1.5rem auto; }
.stack { display: flex; flex-direction: column; gap: 0.9rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; font-size: 0.9rem; }
input, select, textarea {
  font: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
  font-weight: 400;
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
input[type="checkbox"] { width: auto; }
input[type="file"] { padding: 0.5rem; }
.code-input { font-family: ui-monospace, Menlo, monospace; letter-spacing: 0.15em; text-transform: uppercase; font-size: 1.25rem; text-align: center; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 0.8rem; }
legend { font-weight: 600; font-size: 0.9rem; padding: 0 0.3rem; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.75rem 1.1rem;
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  min-height: 44px;
}
.button:hover { filter: brightness(1.08); }
.button-small { padding: 0.4rem 0.8rem; min-height: 36px; font-size: 0.9rem; }
.button-secondary { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.button-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.link { background: none; border: 0; cursor: pointer; }

.alert { padding: 0.75rem 1rem; border-radius: 10px; margin: 0 0 1rem; }
.alert-ok { background: var(--ok-bg); color: var(--ok-text); }
.alert-error { background: var(--error-bg); color: var(--error-text); }

.filters { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; margin-bottom: 1rem; }
.alert-info { background: #dbeafe; color: #1e3a8a; }
@media (prefers-color-scheme: dark) { .alert-info { background: #172554; color: #bfdbfe; } }
.danger { color: var(--danger); }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 0.85em; background: var(--bg); padding: 0.1rem 0.3rem; border-radius: 6px; overflow-wrap: anywhere; }
.check { flex-direction: row; align-items: center; gap: 0.6rem; font-weight: 400; font-size: 1rem; }
.check input { flex: none; width: 1.2rem; height: 1.2rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.child { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.6rem 0; }
.child + .child { border-top: 1px solid var(--border); }
fieldset { display: flex; flex-direction: column; gap: 0.7rem; margin: 0; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.6rem 0; border-top: 1px solid var(--border); }
.list li > div { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }

/* Map page: the map fills the screen below the header */
.wide { display: flex; flex-direction: column; min-height: calc(100dvh - 57px); }
.wide > .container { width: 100%; padding-bottom: 0; }
.map-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; padding: 0.6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.chips { display: flex; gap: 0.4rem; }
.chip { font: inherit; font-size: 0.9rem; padding: 0.4rem 0.9rem; min-height: 36px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; list-style: none; margin: 0; padding: 0; font-size: 0.85rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 0.35rem; }
.swatch { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
#map { flex: 1; min-height: 420px; width: 100%; background: var(--border); }
.map-status { margin: 0; padding: 0.8rem 1rem; text-align: center; color: var(--muted); }

/* Info window (Google renders it on a white background in every theme) */
.iw { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #111827; font-size: 14px; line-height: 1.4; max-width: 280px; }
.iw-family + .iw-family { border-top: 1px solid #e5e7eb; margin-top: 0.7rem; padding-top: 0.7rem; }
.iw-name { display: block; font-size: 15px; }
.iw-tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.iw-tag { color: #fff; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600; }
.iw-offering { background: #16a34a; }
.iw-seeking { background: #2563eb; }
.iw-none { background: #6b7280; }
.iw-child { color: #374151; }
.iw-about { margin: 6px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.iw-mail, .iw-edit { display: block; margin-top: 4px; color: #1d4ed8; overflow-wrap: anywhere; }
.iw-empty { margin: 0 0 4px; color: #6b7280; }

.week { display: grid; grid-template-columns: 2.2rem 1fr auto 1fr; align-items: center; gap: 0.4rem 0.5rem; }
.week-day { font-weight: 600; }
.iw-child { margin-top: 4px; }
