:root {
  --blue: #2563eb;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: #f3f4f6;
}

#map { position: fixed; inset: 0; z-index: 1; }

.top {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
}
.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #f9fafb;
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.tabs button.on {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
}
.sub {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.base { display: flex; gap: 4px; flex: 0 0 auto; }
.base button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  color: #374151;
  cursor: pointer;
}
.base button.on {
  background: #111827;
  color: #fff;
  border-color: #111827;
}

.pin-wrap { background: none; border: none; }
.pin {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.pin.on { background: #dc2626; transform: scale(1.15); }
.pin.pink { background: #ec4899; box-shadow: 0 0 0 5px rgba(236, 72, 153, .35), 0 1px 4px rgba(0, 0, 0, .35); }
.pin.pink.on { background: #dc2626; }
.pin.green { background: #16a34a; }
.pin.green.on { background: #dc2626; }
.pin.opt { background: #9ca3af; }
.pin.dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--blue);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
.pin.dot.pink {
  background: #ec4899;
  width: 18px; height: 18px;
  margin: -2px 0 0 -2px;
  box-shadow: 0 0 0 5px rgba(236, 72, 153, .32), 0 1px 3px rgba(0, 0, 0, .3);
}
.pin.dot.green {
  background: #16a34a;
  width: 16px; height: 16px;
  margin: -1px 0 0 -1px;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, .28), 0 1px 3px rgba(0, 0, 0, .3);
}

.legend {
  display: flex;
  gap: 12px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}
.legend .lg { display: flex; align-items: center; gap: 4px; }
.legend .sw {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.legend .sw.pink { background: #ec4899; }
.legend .sw.green { background: #16a34a; }
.legend .sw.blue { background: #2563eb; }

.panel {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1500;
  background: #fff;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, .18);
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(110%);
  transition: transform .25s ease;
  max-height: 72vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.panel.show { transform: translateY(0); }
.close {
  position: absolute;
  top: 10px; right: 12px;
  border: none;
  background: #f3f4f6;
  color: #374151;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}
.kicker {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: .02em;
}
#p-name { margin: 0 0 8px; font-size: 20px; line-height: 1.3; padding-right: 60px; }
.note {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.6;
  color: #374151;
  white-space: pre-wrap;
}
.amapbtn {
  display: inline-block;
  margin: 0 8px 8px 0;
  border: none;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.photos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}
.photos figure { margin: 0; }
.photos img {
  width: 100%;
  border-radius: 10px;
  display: block;
  cursor: zoom-in;
}
.photos img.big { grid-column: 1 / -1; cursor: zoom-out; }
.photos figcaption {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

@media (min-width: 700px) {
  .panel {
    left: auto; right: 20px; bottom: 20px;
    width: 420px;
    border-radius: 16px;
    transform: translateY(0);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    max-height: 76vh;
  }
  .panel.show { opacity: 1; pointer-events: auto; }
}

.legend { flex-wrap: wrap; row-gap: 2px; }
.legend .sw.cave, .pin.cave { background: #7c3aed; }
.legend .sw.fall, .pin.fall { background: #0891b2; }
.legend .sw.other, .pin.other { background: #f59e0b; }
.legend .sw.stay, .pin.stay { background: #475569; }
.pin.cave.on, .pin.fall.on, .pin.other.on, .pin.stay.on { background: #dc2626; }

.page {
  position: fixed; left: 0; right: 0; bottom: 0; top: 96px;
  z-index: 1200; background: #f8fafc; overflow-y: auto;
  -webkit-overflow-scrolling: touch; display: none;
  padding: 14px 14px calc(30px + env(safe-area-inset-bottom));
  font-size: 14px; line-height: 1.55;
}
.page.show { display: block; }
body.paged .legend, body.paged .base { display: none; }
.page .wrap { max-width: 820px; margin: 0 auto; }
.page h2 { font-size: 18px; margin: 18px 0 6px; }
.page h3 { font-size: 15px; margin: 14px 0 4px; }
.page .card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.page table { border-collapse: collapse; width: 100%; font-size: 13px; background: #fff; }
.page th, .page td { border: 1px solid var(--line); padding: 5px 6px; text-align: left; vertical-align: top; }
.page th { background: #f1f5f9; }
.page .tl { list-style: none; padding: 0; margin: 0; }
.page .tl li { padding: 4px 0 4px 62px; position: relative; border-bottom: 1px dashed var(--line); }
.page .tl li b.t { position: absolute; left: 0; width: 56px; color: var(--blue); }
.page .warn { color: #b45309; }
.page .tag { display: inline-block; font-size: 11px; background: #fef3c7; color: #92400e; border-radius: 6px; padding: 0 5px; margin-left: 4px; }
.page textarea { width: 100%; font: 13px/1.5 ui-monospace, Menlo, monospace; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.page code { background: #eef2ff; padding: 1px 4px; border-radius: 4px; }
.page button.copy { border: none; background: var(--blue); color: #fff; border-radius: 8px; padding: 6px 12px; font-size: 12px; cursor: pointer; margin: 4px 0; }
.page a { color: var(--blue); }
.page .thumbs { display: flex; gap: 6px; overflow-x: auto; margin: 6px 0; }
.page .thumbs img { height: 110px; border-radius: 8px; }
.legend .sw.blue, .pin.blue { background: #2563eb; }

.legend .sw.hist, .pin.hist { background: #b45309; }
.legend .sw.street, .pin.street { background: #ea580c; }
.legend .sw.night, .pin.night { background: #4338ca; }
.legend .sw.food, .pin.food { background: #e11d48; }
.legend .sw.other, .pin.other { background: #f59e0b; }
.pin.hist.on, .pin.street.on, .pin.night.on, .pin.food.on { background: #dc2626; }
.page details { margin: 10px 0; }
