:root {
  --fg: #1a1a1a;
  --muted: #666;
  --accent: #2a6df4;
  --bg: #fafafa;
  --card: #fff;
  --border: #e6e6e6;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--fg);
  background: var(--bg);
}
main {
  max-width: 720px;
  margin: 12vh auto 4rem;
  padding: 0 1.25rem;
}
h1 {
  font-weight: 300;
  font-size: clamp(2.5rem, 6vw, 3.75rem);
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem;
}
h1 .dot { color: var(--accent); }
.tag {
  color: var(--muted);
  margin: 0 0 2rem;
}
form { display: grid; gap: 0.75rem; margin-bottom: 2rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
input, select, button {
  font: inherit;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--fg);
  min-width: 0;            /* allow flex items to shrink instead of overflowing the row */
}
/* row 1: location field grows; "use my location" hugs its text and
   wraps to its own line when the row gets tight. */
#location { flex: 1 1 12rem; }
#locate { flex: 0 1 auto; white-space: nowrap; }
/* row 2: dropdowns + find share the row with a comfortable basis —
   2-up on narrow phones, single line on desktop. */
.row > select { flex: 1 1 8rem; }
.row > button[type="submit"] { flex: 1 1 8rem; }
button {
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
button[type="button"] { background: var(--card); color: var(--fg); border-color: var(--border); }
button:hover { filter: brightness(0.97); }
/* blind-book shortcut: full-width secondary action under the form */
.lucky {
  width: 100%;
  background: var(--card);
  color: var(--accent);
  border: 1px dashed var(--accent);
  font-weight: 600;
}
.lucky:hover { background: rgba(42, 109, 244, 0.05); filter: none; }
#results { display: grid; gap: 0.5rem; }

/* shared day-badge styles */
.day-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  text-transform: uppercase;
}
.day-badge.today    { background: #dff5e0; color: #1c7430; }
.day-badge.tomorrow { background: #fff5d6; color: #8a5a00; }
.day-badge.near     { background: #eef0f3; color: #5b6470; }
.day-badge.far      { background: #eef0f3; color: #5b6470; }

/* clinic card */
.clinic-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
}
.clinic-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 1rem;
  align-items: center;
}
.clinic-soonest .when {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.clinic-soonest .when .duration {
  font-weight: 500;
  color: var(--accent);
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: rgba(42, 109, 244, 0.08);
  font-size: 0.85rem;
}
.clinic-soonest .where { color: var(--muted); font-size: 0.95rem; }
.clinic-soonest .meta { color: var(--muted); font-size: 0.85rem; }
.clinic-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
}
.clinic-actions .book {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  border: 1px solid var(--accent);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  text-align: center;
}
.clinic-actions .expand {
  background: var(--card);
  color: var(--accent);
  border: 1px dashed var(--border);
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
}
.clinic-actions .hide {
  background: var(--card);
  color: var(--muted);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
}

/* expanded slots list */
.clinic-slots {
  list-style: none;
  margin: 0.65rem 0 0;
  padding: 0.5rem 0 0;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 0.25rem;
}
.clinic-slots.hidden { display: none; }
.slot-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.25rem 0;
  font-size: 0.9rem;
}
.slot-row .time { font-weight: 600; min-width: 4.5rem; }
.slot-row .dur  { color: var(--muted); font-size: 0.85rem; }
.slot-row .who  { color: var(--fg); font-size: 0.9rem; flex: 1 1 auto; }
.slot-row .price { color: var(--muted); font-size: 0.85rem; }
.slot-row .slot-book {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.8rem;
  border: 1px solid var(--accent);
  padding: 0.15rem 0.6rem;
  border-radius: 7px;
  white-space: nowrap;
}
/* simultaneous-clinician group + its secondary unroll */
.slot-row.slot-group { display: block; }
.slot-group .slot-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.slot-group .who-expand {
  flex: 1 1 auto;
  text-align: left;
  background: var(--card);
  color: var(--accent);
  border: 1px dashed var(--border);
  font-size: 0.8rem;
  padding: 0.1rem 0.55rem;
  border-radius: 7px;
}
.slot-clinicians {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0.4rem 0 0 0.5rem;
  border-top: 1px dashed var(--border);
  display: grid;
  gap: 0.35rem;
}
.slot-clinicians.hidden { display: none; }
.clinician-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}
.clinician-row .who { flex: 1 1 auto; }
.clinician-row .price { color: var(--muted); font-size: 0.85rem; }

/* map (search center + radius) */
.map-wrap { margin-bottom: 1.25rem; }
.map-wrap.hidden { display: none; }
.map {
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 180px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;       /* clip tiles to the rounded corners */
  background: #e9eef3;    /* placeholder while tiles load */
}
.map-caption {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.4rem;
  padding-left: 0.15rem;
}
/* keep Leaflet's font consistent + corners rounded */
.leaflet-container { border-radius: 12px; font: inherit; }

/* watch bar */
.watch-bar {
  background: rgba(42, 109, 244, 0.04);
  border: 1px solid rgba(42, 109, 244, 0.2);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.watch-bar.hidden { display: none; }
.watch-bar label { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.watch-status { color: var(--muted); font-size: 0.85rem; }

/* hidden-clinics bar */
.hidden-clinics {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: rgba(0,0,0,0.025);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.hidden-clinics.hidden { display: none; }
.hidden-clinics .muted { color: var(--muted); }
.hidden-clinics .chip {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 0.8rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}
.empty, .err { color: var(--muted); text-align: center; padding: 1rem; }
.err { color: #c0392b; }

.geo-tooltip {
  background: #fff7e6;
  border: 1px solid #f0d28b;
  color: #6b4d00;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-top: -0.4rem;
}
.geo-tooltip.hidden { display: none; }
.pagination { text-align: center; padding: 0.5rem 0; }
.pagination .more {
  background: var(--card);
  color: var(--accent);
  border: 1px dashed var(--accent);
  font-weight: 500;
}
.footer-summary {
  text-align: center; color: var(--muted); font-size: 0.8rem; padding: 0.75rem 0;
}
footer { margin-top: 3rem; color: var(--muted); font-size: 0.85rem; text-align: center; }
footer a { color: inherit; }

/* prose pages (privacy, etc.) */
.prose { max-width: 640px; }
.prose .back { margin: 0 0 1.5rem; }
.prose .back a { color: var(--muted); text-decoration: none; }
.prose h1 { font-weight: 600; font-size: clamp(1.8rem, 5vw, 2.4rem); }
.prose h2 { font-weight: 600; font-size: 1.1rem; margin: 2rem 0 0.5rem; }
.prose p, .prose li { color: #2a2a2a; }
.prose ul { padding-left: 1.2rem; display: grid; gap: 0.4rem; }
.prose a { color: var(--accent); }
.prose code { background: #eef0f3; padding: 0.05rem 0.3rem; border-radius: 4px; font-size: 0.85em; }
.prose .muted { color: var(--muted); font-size: 0.9rem; }
.prose footer { text-align: left; margin-top: 2.5rem; }

/* self-update toast */
.update-toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  background: var(--fg);
  color: #fff;
  border-radius: 999px;
  padding: 0.5rem 0.5rem 0.5rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
  z-index: 1000;
  font-size: 0.9rem;
  max-width: calc(100vw - 2rem);
}
.update-toast button {
  background: #fff;
  color: var(--fg);
  border: none;
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-weight: 600;
}

/* Tighten spacing + scale the hero down on small screens so the form
   sits higher and nothing crowds the edges. Everything above already
   wraps/shrinks; this is purely breathing room. */
@media (max-width: 640px) {
  main { margin: 6vh auto 3rem; }
  h1 { font-size: clamp(2rem, 9vw, 2.6rem); }
  .tag { margin-bottom: 1.5rem; }
}
