:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --ink: #16181d;
  --muted: #5d6470;
  --line: #e4e4e0;
  --soft: #f1f2ef;
  --blue: #1d4ed8;
  --blue-soft: #e8eefc;
  --orange: #d9620b;
  --orange-soft: #fdf0e4;
  --purple: #7c3aed;
  --purple-soft: #f1eafd;
  --green: #0f7a43;
  --green-soft: #e3f4ea;
  --red: #b42318;
  --red-soft: #fdecea;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #16191f;
    --ink: #eceef2;
    --muted: #9aa2ae;
    --line: #2a2f38;
    --soft: #1d2129;
    --blue: #6b93ff;
    --blue-soft: #1b2440;
    --orange: #f59e4c;
    --orange-soft: #33230f;
    --purple: #b08cff;
    --purple-soft: #2a1f45;
    --green: #4ccf8a;
    --green-soft: #12301f;
    --red: #ff7b6e;
    --red-soft: #3a1714;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); }
button { font: inherit; color: inherit; cursor: pointer; }

.app { display: grid; grid-template-columns: 400px 1fr; height: 100dvh; }
.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0; overflow-y: auto;
}
.mapwrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: var(--soft); }

.head { padding: 20px 20px 12px; }
h1 { font-size: 24px; line-height: 1.15; margin: 0; letter-spacing: -.01em; }
h1 span { display: block; font-size: 14px; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-top: 2px; }
.sub { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.sub strong { color: var(--ink); font-weight: 600; }

.modes {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  margin-top: 14px; padding: 4px; border-radius: 12px; background: var(--soft);
}
.modes button {
  border: 0; background: transparent; border-radius: 9px; padding: 8px 10px; text-align: left;
  display: flex; flex-direction: column; gap: 1px; color: var(--muted);
}
.modes button b { font-size: 15px; color: var(--ink); font-weight: 650; }
.modes button span { font-size: 12px; }
.modes button.on { background: var(--panel); box-shadow: var(--shadow); }
.modes button.on[data-mode="early"] b { color: var(--green); }
.modes button.on[data-mode="eday"] b { color: var(--blue); }
.modes button:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.modes[hidden] { display: none; }

.days { display: flex; gap: 6px; overflow-x: auto; margin: 0 -20px 10px; padding: 2px 20px; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.days:empty { display: none; }
.day {
  flex: none; border: 1px solid var(--line); background: var(--panel); border-radius: 10px;
  padding: 5px 11px; font-size: 13px; line-height: 1.2; text-align: center; color: var(--muted);
}
.day b { display: block; color: var(--ink); font-size: 14px; }
.day.on { background: var(--green); border-color: var(--green); color: #fff; }
.day.on b { color: #fff; }

.status {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px;
  background: var(--blue-soft); font-size: 14px;
}
.status b { display: block; font-size: 15px; }
.status.open, .status.early { background: var(--green-soft); }
.status.open b, .status.early b { color: var(--green); }
.status.closed { background: var(--soft); }

.controls {
  position: sticky; top: 0; z-index: 5;
  background: var(--panel);
  padding: 8px 20px 10px;
  border-bottom: 1px solid var(--line);
}
.search {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 0 4px 0 10px; background: var(--bg);
}
.search:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.search svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  padding: 11px 0; font: inherit; color: var(--ink);
}
.search .go {
  border: 0; background: var(--blue); color: #fff; border-radius: 7px;
  padding: 6px 12px; font-weight: 600; font-size: 14px;
}
.row { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel);
  border-radius: 999px; padding: 7px 13px; font-size: 14px; font-weight: 600;
}
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn:disabled { opacity: .6; cursor: progress; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: transparent; border-radius: 999px;
  padding: 6px 11px; font-size: 13px; color: var(--muted);
}
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--panel); }
.hint { margin: 8px 0 0; font-size: 13px; color: var(--muted); min-height: 1em; }
.hint:empty { display: none; }
.hint.err { color: var(--red); }

.list { list-style: none; margin: 0; padding: 6px 12px 12px; flex: 1; }
.item {
  display: grid; grid-template-columns: 34px 1fr; gap: 10px;
  padding: 12px 8px; border-bottom: 1px solid var(--line);
  border-radius: 10px; scroll-margin-top: 140px;
}
.item:last-child { border-bottom: 0; }
.item.sel { background: var(--blue-soft); border-color: transparent; }
.num {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--blue); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.num.tent { background: var(--orange); }
.num.drop { background: var(--purple); border-radius: 8px; }
.num.ev { background: var(--green); font-size: 11px; letter-spacing: .02em; }
.num.ev.tent { background: var(--orange); }
.num svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.name { font-weight: 650; font-size: 15px; line-height: 1.3; margin: 3px 0 2px; }
.name button { all: unset; cursor: pointer; }
.name button:hover { text-decoration: underline; }
.name button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 3px; }
.addr { color: var(--muted); font-size: 14px; }
.meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; align-items: center; }
.tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.tag.tent { background: var(--orange-soft); color: var(--orange); }
.tag.drop { background: var(--purple-soft); color: var(--purple); }
.tag.dist { background: var(--soft); color: var(--ink); font-variant-numeric: tabular-nums; }
.tag.hours { background: var(--green-soft); color: var(--green); }
.tag.now { background: var(--green); color: #fff; }
.tag.later { background: var(--soft); color: var(--ink); }
.tag.shut { background: var(--red-soft); color: var(--red); }
.note { color: var(--muted); font-size: 13px; font-style: italic; }
.more { margin-top: 6px; font-size: 13px; }
.more summary { cursor: pointer; color: var(--blue); font-weight: 600; width: fit-content; }
.more .sched { margin-top: 4px; }
.sched tr.today td { font-weight: 700; color: var(--green); }
.sched td.x { color: var(--muted); font-weight: 400; }
.actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.actions a, .actions button {
  font-size: 13px; font-weight: 600; text-decoration: none;
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px;
  background: var(--panel); color: var(--ink);
}
.actions a.dir { background: var(--blue); border-color: var(--blue); color: #fff; }
.sched { margin: 8px 0 0; font-size: 13px; border-collapse: collapse; width: 100%; }
.sched td { padding: 3px 0; vertical-align: top; border-top: 1px dashed var(--line); }
.sched td:last-child { text-align: right; white-space: nowrap; padding-left: 10px; font-weight: 600; }
.empty { padding: 30px 12px; color: var(--muted); text-align: center; }

.foot { padding: 16px 20px 90px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.foot p { margin: 8px 0; }
.foot .fine { font-size: 12px; }
.foot details { margin-bottom: 10px; }
.foot summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.foot ul { margin: 6px 0; padding-left: 18px; }

.legend {
  position: absolute; z-index: 500; left: 12px; bottom: 22px;
  background: var(--panel); border-radius: 10px; box-shadow: var(--shadow);
  padding: 8px 12px; display: flex; gap: 12px; font-size: 12px; font-weight: 600;
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.dot.vc { background: var(--blue); }
.dot.tent { background: var(--orange); }
.dot.drop { background: var(--purple); border-radius: 3px; }
.dot.ev { background: var(--green); }

/* map markers */
.pin {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--blue); border: 2.5px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
  transition: transform .15s;
}
.pin.tent { background: var(--orange); }
.pin.drop { background: var(--purple); border-radius: 5px; }
.pin.ev { background: var(--green); }
.pin.ev.tent { background: var(--orange); }
.pin.ev.dim { background: #8a929e; opacity: .85; }
.pin.sel { transform: scale(1.45); }
.me {
  width: 16px; height: 16px; border-radius: 50%;
  background: #2563eb; border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(37,99,235,.25);
}
.leaflet-popup-content-wrapper {
  background: var(--panel); color: var(--ink); border-radius: 12px; box-shadow: var(--shadow);
}
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { margin: 12px 14px; font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-width: 220px; }
.leaflet-popup-content .name { margin-top: 0; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-container .leaflet-control-attribution { background: color-mix(in srgb, var(--panel) 85%, transparent); color: var(--muted); }
.leaflet-control-attribution a { color: var(--muted); }
.leaflet-bar a { background: var(--panel); color: var(--ink); border-color: var(--line); }

.toggle { display: none; }

@media (max-width: 760px) {
  .app { display: block; height: auto; }
  .panel { border-right: 0; overflow: visible; min-height: 100dvh; }
  .head { padding: 18px 16px 10px; }
  .controls { padding: 8px 16px 10px; }
  .days { margin: 0 -16px 10px; padding: 2px 16px; }
  .list { padding: 4px 6px 12px; }
  .foot { padding: 16px 16px 96px; }
  .mapwrap { position: fixed; inset: 0; z-index: 10; visibility: hidden; }
  .app[data-view="map"] .mapwrap { visibility: visible; }
  .app[data-view="map"] .panel { height: 100dvh; overflow: hidden; }
  .legend { bottom: 84px; left: 10px; }
  .toggle {
    display: flex; position: fixed; z-index: 1000;
    left: 50%; transform: translateX(-50%);
    bottom: calc(16px + env(safe-area-inset-bottom));
    background: var(--ink); border-radius: 999px; padding: 4px; box-shadow: var(--shadow);
  }
  .toggle button {
    border: 0; background: transparent; color: var(--panel);
    padding: 9px 22px; border-radius: 999px; font-weight: 650; font-size: 15px;
  }
  .toggle button.on { background: var(--panel); color: var(--ink); }
}
