:root {
  --bg: #0b0e13;
  --panel: #11151c;
  --raised: #171c26;
  --line: #1f2733;
  --text: #e8eaf0;
  --muted: #8d97a8;
  --faint: #5d6778;
  --accent: #f5b04c;
  --accent-ink: #1b1307;
  --ok: #6fcf97;
  --warn: #f2c94c;
  --bad: #eb6b6b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif; }
a { color: inherit; }
button { font: inherit; color: inherit; }

#app { display: grid; grid-template-columns: 400px minmax(0, 1fr); height: 100vh; }
#panel { min-width: 0; display: flex; flex-direction: column; min-height: 0; background: var(--panel);
  border-right: 1px solid var(--line); z-index: 2; }
#map { background: var(--bg); min-height: 0; }

/* header */
header { padding: 20px 22px 6px; }
h1 { margin: 0; font: 600 23px/1.15 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  letter-spacing: .01em; color: #f6f0e4; }
.sub { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; }

#tilenote { margin: 10px 22px 0; padding: 8px 10px; border-radius: 8px; font-size: 12.5px;
  background: rgba(235,107,107,.10); border: 1px solid rgba(235,107,107,.4); color: #f0b8b8; }
#banner { margin: 10px 22px 0; padding: 8px 10px; border-radius: 8px; font-size: 12.5px;
  background: rgba(245,176,76,.10); border: 1px solid rgba(245,176,76,.35); color: #f3d9a8; }

/* controls */
.controls { padding: 14px 22px 10px; border-bottom: 1px solid var(--line); }
.datebar { display: flex; gap: 6px; align-items: stretch; }
.datebar button, .datebar input[type=date] {
  background: var(--raised); border: 1px solid var(--line); border-radius: 8px; height: 36px; padding: 0 10px; }
.datebar button { cursor: pointer; min-width: 36px; font-size: 18px; line-height: 1; }
.datebar button#today { font-size: 12.5px; margin-left: auto; }
.datebar button:hover:not(:disabled) { border-color: #354156; }
.datebar button:disabled { opacity: .35; cursor: default; }
.datebar input[type=date] { flex: 1; min-width: 0; font-size: 14px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#strip { display: flex; gap: 6px; margin: 12px -22px 0; padding: 2px 22px 8px; overflow-x: auto; scrollbar-width: thin;
  scrollbar-color: #2a3342 transparent; }
.day { flex: 0 0 auto; width: 46px; padding: 6px 0 7px; border-radius: 10px; cursor: pointer; text-align: center;
  background: transparent; border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 1px; }
.day .mon { font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); height: 11px; }
.day .dow { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.day .num { font-size: 17px; font-weight: 600; }
.day .cnt { margin-top: 2px; font-size: 10.5px; min-width: 18px; border-radius: 9px; padding: 0 5px; background: #222a37; color: var(--muted); }
.day.empty .num { color: var(--faint); }
.day.empty .cnt { background: transparent; color: var(--faint); }
.day:hover { border-color: #354156; }
.day.today .num::after { content: ""; display: block; height: 2px; margin: 1px auto 0; width: 12px; border-radius: 2px; background: var(--accent); }
.day.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.day.active .dow, .day.active .mon { color: rgba(27,19,7,.7); }
.day.active .cnt { background: rgba(27,19,7,.16); color: var(--accent-ink); }

.toggle { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 15px; height: 15px; }

/* organizations filter */
#orgs { border-bottom: 1px solid var(--line); }
#orgs summary { display: flex; justify-content: space-between; align-items: center; padding: 9px 22px; cursor: pointer;
  color: var(--muted); list-style: none; font-size: 12.5px; }
#orgs summary::-webkit-details-marker { display: none; }
#orgs summary > span:first-child::before { content: "\25B8  "; }
#orgs[open] summary > span:first-child::before { content: "\25BE  "; }
#orgs-sum { color: var(--faint); }
.orgs-body { padding: 0 22px 10px; }
.orgs-actions { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.orgs-actions button { background: var(--raised); border: 1px solid var(--line); border-radius: 7px; padding: 2px 10px; font-size: 12px; cursor: pointer; }
.orgs-actions button:hover { border-color: #354156; }
.orgs-actions .hint { margin-left: auto; color: var(--faint); font-size: 11px; }
#org-chips { display: flex; flex-wrap: wrap; gap: 5px; max-height: 24vh; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #2a3342 transparent; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 7px; border-radius: 14px; cursor: pointer;
  background: var(--raised); border: 1px solid var(--line); font-size: 12px; line-height: 1.3; user-select: none; }
.chip:hover { border-color: #354156; }
.chip .sw { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--oc); box-shadow: 0 0 6px var(--oc); }
.chip .n { color: var(--faint); font-variant-numeric: tabular-nums; font-size: 11px; }
.chip[aria-pressed="false"] { background: transparent; color: var(--faint); border-style: dashed; }
.chip[aria-pressed="false"] .sw { background: transparent; box-shadow: none; border: 1px solid var(--faint); }
.chip.none:not([aria-pressed="false"]) { color: var(--muted); }
.chip.none .n { opacity: .6; }
.sw-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 0; background: var(--oc); }

/* list */
.listhead { display: flex; align-items: baseline; justify-content: space-between; padding: 14px 22px 6px; }
h2 { margin: 0; font-size: 15px; font-weight: 600; }
#count { color: var(--muted); font-size: 12.5px; }
#listwrap { flex: 1; min-height: 0; overflow-y: auto; padding: 0 12px 12px; scrollbar-width: thin; scrollbar-color: #2a3342 transparent; }
ol { list-style: none; margin: 0; padding: 0; }
.sub-heading { margin: 16px 10px 6px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 600; }

.ev { display: grid; grid-template-columns: 62px 1fr; gap: 10px; padding: 10px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent; border-left: 3px solid var(--oc, transparent); }
.ev:hover { background: var(--raised); }
.ev.active { background: var(--raised); border-color: rgba(245,176,76,.55); border-left-color: var(--oc, rgba(245,176,76,.55)); }
.ev .t { color: var(--accent); font-weight: 600; font-size: 12.5px; padding-top: 1px; font-variant-numeric: tabular-nums; }
.ev .t.dim { color: var(--muted); font-weight: 500; }
.ev .title { font-weight: 600; font-size: 14px; line-height: 1.3; }
.ev .title a { text-decoration: none; }
.ev .title a:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.ev .title a::after { content: " \2197"; color: var(--faint); font-weight: 400; font-size: 12px; }
.ev .where { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.ev .org { color: var(--oc, var(--muted)); }
.ev .meta { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 5px; }
.tag { font-size: 10.5px; padding: 1px 7px; border-radius: 8px; border: 1px solid var(--line); color: var(--muted); }
.tag.warn { color: #e8c682; border-color: rgba(245,176,76,.35); }

#empty { margin: 18px 12px; color: var(--muted); }

/* sources */
#sources { border-top: 1px solid var(--line); background: #0e1218; font-size: 12.5px; }
#sources summary { display: flex; justify-content: space-between; padding: 10px 22px; cursor: pointer; color: var(--muted); list-style: none; }
#sources summary::-webkit-details-marker { display: none; }
#sources summary span:first-child::before { content: "\25B8  "; }
#sources[open] summary span:first-child::before { content: "\25BE  "; }
#source-list { list-style: none; margin: 0; padding: 0 22px 12px; max-height: 38vh; overflow-y: auto; }
#source-list li { display: grid; grid-template-columns: 10px 1fr auto; gap: 4px 8px; padding: 5px 0; align-items: baseline; }
#source-list .dot { width: 8px; height: 8px; border-radius: 50%; align-self: center; background: var(--ok); }
#source-list .dot.warn { background: var(--warn); }
#source-list .dot.bad { background: var(--bad); }
#source-list a { text-decoration: none; }
#source-list .sw-dot { margin-right: 7px; }
#source-list a:hover { text-decoration: underline; }
#source-list .n { color: var(--muted); font-variant-numeric: tabular-nums; }
#source-list .note { grid-column: 2 / 4; color: var(--faint); font-size: 11.5px; }

/* map pins */
.pin-wrap { background: none; border: none; }
.pin { --c: var(--accent); --g: rgba(245,176,76,.20); display: grid; place-items: center; border-radius: 50%; background: var(--c); color: var(--accent-ink);
  border: 2px solid var(--bg); font-weight: 700; font-size: 12.5px;
  box-shadow: 0 0 0 4px var(--g), 0 0 18px var(--c); transition: transform .12s; }
.pin.one { width: 16px; height: 16px; }
.pin.many { width: 28px; height: 28px; }
.pin.ring { background: rgba(11,14,19,.85); color: var(--c); border-color: var(--c); box-shadow: 0 0 12px var(--c); }
.pin.approx { background: transparent; color: var(--c); border: 2px dashed var(--c); box-shadow: 0 0 12px var(--c); }
.pin.mix > span { display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: var(--bg); color: var(--text); font-size: 11px; }
.pin.on { transform: scale(1.35); z-index: 1000; }

/* OpenStreetMap tiles are light; this turns them into a muted dark basemap (markers live in other panes, untouched) */
.dark-tiles .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.88) saturate(.55); }

/* leaflet skin */
.leaflet-container { background: var(--bg); font: inherit; }
.leaflet-popup-content-wrapper { background: #151a23; color: var(--text); border: 1px solid #2a3342; border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.5); }
.leaflet-popup-tip { background: #151a23; border: 1px solid #2a3342; }
.leaflet-popup-content { margin: 12px 14px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-control-attribution { background: rgba(11,14,19,.75) !important; color: var(--faint) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-bar a { background: var(--raised); color: var(--text); border-color: var(--line); }
.leaflet-bar a:hover { background: #222a37; color: var(--text); }
.leaflet-container .pop a { color: var(--text); }
.pop h4 { margin: 0; font-size: 14px; }
.pop .addr { color: var(--muted); font-size: 12px; margin: 1px 0 8px; }
.pop ul { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.pop li { padding: 5px 0; border-top: 1px solid var(--line); font-size: 13px; }
.pop li .pt { color: var(--accent); font-weight: 600; font-size: 12px; margin-right: 6px; }
.pop li a { font-weight: 600; text-decoration: none; }
.pop li a:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.pop li .sub2 { display: block; color: var(--muted); font-size: 12px; }
.pop li .sw-dot { margin-right: 5px; }

@media (max-width: 820px) {
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: 44vh minmax(0, 1fr); }
  #map { order: -1; }
  #panel { border-right: none; border-top: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) { .pin { transition: none; } }
