: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; }
/* Checkbox aligned with the first line, so longer labels wrap next to it */
.check { flex-direction: row; align-items: flex-start; gap: 0.6rem; font-weight: 400; font-size: 1rem; }
.check input { flex: none; width: 1.2rem; height: 1.2rem; margin: 0.15rem 0 0; }
.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; }
.row3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 0.6rem; }
@media (max-width: 480px) { .row3 { grid-template-columns: 1fr 1fr; } .row3 > :first-child { grid-column: 1 / -1; } }
.child-head { display: flex; justify-content: space-between; align-items: center; }
.child-head .link { font: inherit; font-size: 0.9rem; padding: 0.3rem 0; }
.danger-zone { margin-top: 2rem; }
.badge-ok { background: #16a34a; }
.badge-warn { background: #d97706; }
.badge-off { background: #6b7280; }
.row-actions { white-space: nowrap; }
.pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
h1 { overflow-wrap: anywhere; }
.row-actions form { display: inline; margin: 0 0.6rem 0 0; }
.row-actions .link { color: var(--primary); font: inherit; padding: 0; }
.nav .button { white-space: nowrap; }
.prose { max-width: 760px; margin: 0 auto; }
.prose h2 { margin-top: 1.6rem; }
.prose h3 { font-size: 1rem; margin: 1rem 0 0.4rem; }
.prose ul { padding-left: 1.2rem; }
.prose li { margin: 0.25rem 0; }

/* Public home page */
.hero { display: flex; flex-direction: column; gap: 0.8rem; padding: 1rem 0 1.5rem; }
.hero h1 { font-size: clamp(1.6rem, 5vw, 2.3rem); line-height: 1.15; margin: 0; }
.hero .lead { font-size: 1.1rem; margin: 0; max-width: 40rem; }
.hero p { margin: 0; }
.preview { padding: 0; overflow: hidden; margin: 0 0 1rem; }
.preview img { display: block; width: 100%; height: auto; }
.preview figcaption { padding: 0.8rem 1.1rem 1rem; gap: 0.5rem; }
.stats { text-align: center; margin: 0 0 1.2rem; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 1rem; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 2rem 1fr; gap: 0.1rem 0.8rem; }
.steps li::before { content: counter(step); grid-row: span 2; width: 2rem; height: 2rem; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.steps span { color: var(--muted); }
.checks { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.checks li { padding-left: 1.6rem; position: relative; }
.checks li::before { content: "✓"; position: absolute; left: 0; color: #16a34a; font-weight: 700; }

/* Services */
[hidden] { display: none !important; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.tag { border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600; line-height: 1.6; }
.tag-offer { background: #16a34a; color: #fff; }
.tag-request { background: #2563eb; color: #fff; }
.tag-category { background: #e0e7ff; color: #1e3a8a; }
.tag-plain { background: #f3f4f6; color: #374151; font-weight: 500; }
.services { list-style: none; margin: 0; padding: 0; }
.service-item { padding: 0.8rem 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.service-item:first-child { border-top: 0; padding-top: 0; }
.service-item.paused { opacity: 0.6; }
.service-title { font-weight: 700; font-size: 1.05rem; text-decoration: none; }
.service-title:hover { text-decoration: underline; }
.service-desc { margin: 0.3rem 0 0; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.service-item .row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.9rem; margin-top: 0.5rem; white-space: normal; }
.service-item .row-actions form { margin: 0; }
.result-meta { margin-top: 0.3rem; }
.result-meta .link { color: var(--primary); font: inherit; padding: 0; text-decoration: underline; }
.badge { color: #fff; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600; }
.checks-inline { display: flex; flex-wrap: wrap; gap: 0.5rem 1.2rem; }
.segmented { flex-direction: row; flex-wrap: wrap; gap: 0.5rem 1.5rem; }
.segmented legend { width: 100%; }

/* Map page: search toolbar, then map and results side by side (stacked on phones) */
.map-toolbar { display: grid; grid-template-columns: minmax(0, 1fr); }
.map-toolbar input, .map-toolbar select { padding: 0.55rem 0.7rem; }
@media (min-width: 760px) {
  .map-toolbar { grid-template-columns: minmax(12rem, 2fr) minmax(10rem, 1fr) auto; }
  .map-toolbar .legend { grid-column: 1 / -1; }
}
.map-layout { flex: 1; display: flex; flex-direction: column; }
.map-layout #map { flex: none; height: 55dvh; min-height: 320px; }
.results { padding: 0.8rem 1rem 2rem; background: var(--surface); }
.results > p { margin: 0 0 0.6rem; }
@media (min-width: 900px) {
  .wide:has(.map-layout) { height: calc(100dvh - 57px); min-height: 560px; }
  .map-layout { flex-direction: row-reverse; min-height: 0; }
  .map-layout #map { flex: 1; height: auto; }
  .results { width: 380px; flex: none; overflow-y: auto; border-right: 1px solid var(--border); }
  #map[hidden] + .results { width: auto; flex: 1; border-right: 0; }
}

/* Info window (Google renders it on a white background in every theme) */
.iw-person + .iw-person { border-top: 1px solid #e5e7eb; margin-top: 0.7rem; padding-top: 0.7rem; }
.iw-name { display: block; font-size: 15px; font-weight: 700; color: #111827; text-decoration: none; }
.iw-service { margin-top: 6px; }
.iw-title { color: #1d4ed8; font-weight: 600; }
.iw-link { display: block; margin-top: 4px; color: #1d4ed8; overflow-wrap: anywhere; }
