:root {
  --today: #d7263d;
  --tomorrow: #f49d37;
  --later: #3f88c5;
  --bg: #ffffff;
  --fg: #1d2330;
  --muted: #6b7280;
  --border: #d9dde3;
  --hl: #fff4d6;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--fg); background: var(--bg); }
#map { position: absolute; inset: 0; }
/* Mute the basemap so the sweeping colors stand out */
.basemap { filter: grayscale(1) contrast(.9) brightness(1.08); }

#panel {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  width: min(520px, calc(100% - 24px)); z-index: 1000;
}
#search-form {
  display: flex; background: var(--bg); border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,.2); overflow: hidden;
}
#search { flex: 1; border: 0; padding: 12px 14px; font-size: 16px; outline: none; min-width: 0; background: transparent; color: var(--fg); }
#locate { border: 0; border-left: 1px solid var(--border); background: var(--bg); color: var(--later); padding: 0 14px; cursor: pointer; }
#locate:hover { background: #f2f6fb; }
#locate.busy { color: var(--muted); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .4; } }

#suggestions {
  list-style: none; margin: 6px 0 0; padding: 4px 0; background: var(--bg);
  border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,.2); max-height: 50vh; overflow-y: auto;
}
#suggestions li { padding: 9px 14px; cursor: pointer; }
#suggestions li small { color: var(--muted); margin-left: 6px; }
#suggestions li.active, #suggestions li:hover { background: #eef3fa; }
#status { margin-top: 6px; padding: 8px 12px; background: var(--bg); border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,.15); color: var(--muted); }

#today-chip {
  margin-top: 8px; display: inline-flex; align-items: center; gap: 6px; border: 0; cursor: pointer;
  background: var(--bg); color: var(--fg); padding: 6px 12px; border-radius: 999px; font: inherit; font-size: 13px;
  box-shadow: 0 1px 6px rgba(0,0,0,.2); max-width: 100%;
}
#today-chip .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--later); }
#today-chip .dot.hol { background: #8e44ad; }
#today-chip .dot.wkd { background: var(--tomorrow); }
#today-chip .caret { color: var(--muted); font-size: 10px; }
#today-card {
  margin-top: 6px; background: var(--bg); border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,.2);
  padding: 12px 14px; max-height: 60vh; overflow-y: auto;
}
#today-card h2 { margin: 0; font-size: 17px; }
#today-card .sub { color: var(--muted); margin-bottom: 8px; }
#today-card .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
#today-card .tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eef3fa; color: #24507a; }
#today-card .tag.warn { background: #fff1e0; color: #8a4b00; }
#today-card .tag.hol { background: #f3e8fa; color: #6a2c8a; }
#today-card .tag.ok { background: #e8f6ec; color: #1e6b3a; }
#today-card dl { margin: 0; }
#today-card dt { font-weight: 600; margin-top: 10px; }
#today-card dd { margin: 2px 0 0; }
#today-card .weeks { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 6px; text-align: center; font-size: 12px; }
#today-card .weeks span { padding: 4px 0; border-radius: 6px; background: #f2f4f7; color: var(--muted); }
#today-card .weeks span.on { background: var(--later); color: #fff; font-weight: 600; }
#today-card .weeks span.none { opacity: .4; text-decoration: line-through; }
#today-card .fine { color: var(--muted); font-size: 12px; margin-top: 6px; }

#legend {
  position: absolute; bottom: 24px; left: 12px; z-index: 1000; background: var(--bg);
  padding: 8px 10px; border-radius: 8px; box-shadow: 0 1px 6px rgba(0,0,0,.2); font-size: 12px;
}
.swatch { display: inline-block; width: 18px; height: 4px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

#loading {
  position: absolute; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.85); font-size: 16px; color: var(--muted);
}
#loading.hidden { display: none; }

/* Popup */
.leaflet-popup-content { margin: 12px 14px; min-width: 240px; }
.pop h3 { margin: 0 0 2px; font-size: 16px; }
.pop .limits { color: var(--muted); margin-bottom: 8px; }
.pop .side { border-top: 1px solid var(--border); padding: 8px 0 4px; }
.pop .side.mine { background: var(--hl); margin: 0 -14px; padding: 8px 14px 4px; }
.pop .side h4 { margin: 0 0 4px; font-size: 13px; }
.pop .side h4 .tag { font-weight: 600; font-size: 11px; color: #8a5a00; margin-left: 6px; }
.pop ul { margin: 0; padding: 0 0 0 16px; }
.pop .next { margin-top: 4px; font-weight: 600; }
.pop .next.today { color: var(--today); }
.pop .next.tomorrow { color: #b86400; }
.pop .next.ok { color: #1e6b3a; font-weight: 500; }
.pop .heading { color: var(--muted); font-size: 12px; margin: -2px 0 4px; }
.pop .heading b { color: var(--fg); }

/* Side labels drawn beside the selected block */
.leaflet-tooltip.side-label {
  background: #1d2330; color: #fff; border: 0; border-radius: 6px; padding: 2px 7px;
  font-size: 12px; font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.3); text-align: center; line-height: 1.25;
}
.leaflet-tooltip.side-label::before { display: none; }
.leaflet-tooltip.side-label.unswept { background: #e8f6ec; color: #1e6b3a; }
.leaflet-tooltip.side-label small { font-weight: 400; font-size: 10px; }
.pop .where { color: var(--muted); font-size: 12px; margin-bottom: 6px; }

@media (max-width: 600px) {
  #legend { bottom: 16px; }
}
