/* ---------- tokens ---------- */
:root {
  --bg: #f6f4ef;
  --bg-elev: #ffffff;
  --bg-soft: #efece4;
  --fg: #1d1b16;
  --fg-muted: #6b665c;
  --line: #e4e0d6;
  --accent: #b5473a;
  --accent-soft: #f6dcd7;
  --accent-fg: #ffffff;
  --gold: #c7962b;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px -12px rgba(30,20,10,.25);
  --radius: 16px;
  --radius-sm: 10px;
  --header-h: 64px;
  --daybar-h: 56px;
  --font: "Heebo", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15140f; --bg-elev: #1f1d17; --bg-soft: #26231c; --fg: #ebe7dd; --fg-muted: #a39d90;
    --line: #35322a; --accent: #e06b5a; --accent-soft: #3d231f; --accent-fg: #fff; --gold: #d9ad46;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px -12px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15140f; --bg-elev: #1f1d17; --bg-soft: #26231c; --fg: #ebe7dd; --fg-muted: #a39d90;
  --line: #35322a; --accent: #e06b5a; --accent-soft: #3d231f; --accent-fg: #fff; --gold: #d9ad46;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px -12px rgba(0,0,0,.7);
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font);
  font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
img { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 50; height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 16px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { flex: 1 1 auto; min-width: 0; }
.brand h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.01em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .sub { margin: 0; font-size: 13px; color: var(--fg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
@media (max-width: 480px) {
  .brand h1 { font-size: 16px; white-space: normal; line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .brand .sub { display: none; }
}
.seg { display: inline-flex; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent;
  padding: 6px 14px; border-radius: 999px; color: var(--fg-muted); font-weight: 500; transition: .2s;
}
.seg button svg { width: 18px; height: 18px; }
.seg button.on { background: var(--bg-elev); color: var(--fg); box-shadow: var(--shadow); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg-soft);
  display: inline-grid; place-items: center; color: var(--fg-muted); transition: .2s;
}
.icon-btn:hover { color: var(--fg); }

/* ---------- day bar ---------- */
.daybar {
  position: sticky; top: var(--header-h); z-index: 40; height: var(--daybar-h);
  display: flex; gap: 8px; align-items: center; padding: 0 16px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.daybar::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; display: inline-flex; flex-direction: column; align-items: center; line-height: 1.1;
  border: 1px solid var(--line); background: var(--bg-elev); border-radius: 999px;
  padding: 6px 14px; color: var(--fg); transition: .2s; white-space: nowrap;
}
.chip small { font-size: 11px; color: var(--fg-muted); font-weight: 400; }
.chip b { font-size: 13px; font-weight: 600; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.chip.on small { color: color-mix(in srgb, var(--accent-fg) 80%, transparent); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 1fr; min-height: calc(100vh - var(--header-h) - var(--daybar-h)); }
.gallery { padding: 16px 16px 48px; min-width: 0; }
.mapwrap { position: relative; display: none; }
#map { width: 100%; height: 100%; background: var(--bg-soft); }
.map-legend {
  position: absolute; bottom: 12px; right: 12px; z-index: 500; font-size: 12px;
  background: color-mix(in srgb, var(--bg-elev) 90%, transparent); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px 10px; color: var(--fg-muted); backdrop-filter: blur(8px);
}
.map-legend:empty { display: none; }

@media (max-width: 959.98px) {
  .layout[data-view="map"] .gallery { display: none; }
  .layout[data-view="map"] .mapwrap { display: block; height: calc(100dvh - var(--header-h) - var(--daybar-h)); }
}
@media (min-width: 960px) {
  .seg { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr) clamp(360px, 42vw, 640px); }
  .gallery { padding: 24px 24px 64px; }
  .mapwrap {
    display: block; position: sticky; top: calc(var(--header-h) + var(--daybar-h));
    height: calc(100vh - var(--header-h) - var(--daybar-h)); border-inline-start: 1px solid var(--line);
  }
}

/* ---------- gallery ---------- */
.day {
  margin: 0 0 40px;
}
.day-head { display: flex; align-items: baseline; gap: 12px; margin: 8px 0 18px; }
.day-head h2 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.day-head .date { color: var(--fg-muted); font-size: 15px; }
.day-head .count { margin-inline-start: auto; font-size: 13px; color: var(--fg-muted); background: var(--bg-soft); padding: 2px 10px; border-radius: 999px; }

.place { margin: 0 0 28px; }
.place-head {
  display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; align-items: start;
  margin: 0 0 12px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--bg-elev); border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: border-color .2s, transform .2s;
}
.place-head.is-active { border-color: var(--accent); }
.place-pin {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; border: 0;
}
.place-pin.none { background: var(--bg-soft); color: var(--fg-muted); }
.place-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.place-title h3 { margin: 0; font-size: 17px; font-weight: 700; }
.place-title .time { font-size: 13px; color: var(--fg-muted); direction: ltr; unicode-bidi: isolate; }
.place-title .approx { font-size: 12px; color: var(--fg-muted); background: var(--bg-soft); padding: 0 8px; border-radius: 999px; }
.place-desc { grid-column: 2; margin: 0; font-size: 14px; color: var(--fg-muted); line-height: 1.55; }
.place-desc.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.place-more { grid-column: 2; justify-self: start; border: 0; background: none; padding: 0; color: var(--accent); font-size: 13px; font-weight: 500; }

.grid {
  display: grid; gap: 6px;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}
@media (min-width: 600px) { .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; } }
.tile {
  position: relative; aspect-ratio: 1; overflow: hidden; border-radius: var(--radius-sm);
  background: var(--bg-soft); border: 0; padding: 0; cursor: zoom-in; min-width: 0; min-height: 0; width: 100%;
}
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.tile:hover img { transform: scale(1.04); }
.tile.portrait { grid-row: span 1; }
.tile .badge {
  position: absolute; inset-inline-end: 6px; top: 6px; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; backdrop-filter: blur(4px);
}
.tile .badge svg { width: 14px; height: 14px; fill: #fff; stroke: none; }
.tile .t { position: absolute; bottom: 6px; inset-inline-start: 6px; font-size: 11px; color: #fff; background: rgba(0,0,0,.45); padding: 1px 7px; border-radius: 999px; direction: ltr; opacity: 0; transition: .2s; }
.tile:hover .t { opacity: 1; }

.empty { color: var(--fg-muted); text-align: center; padding: 60px 0; }

/* ---------- map markers ---------- */
.pin {
  width: 32px; height: 32px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--accent); border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35);
  display: grid; place-items: center; color: #fff; font: 700 12px/1 var(--font);
  transition: transform .15s;
}
.pin span { transform: rotate(45deg); }
.pin.dim { background: #9a958a; }
.pin.hot { transform: rotate(-45deg) scale(1.2); background: var(--gold); }
.leaflet-container { font-family: var(--font); }
.leaflet-popup-content-wrapper { border-radius: 14px; background: var(--bg-elev); color: var(--fg); box-shadow: var(--shadow); direction: rtl; }
.leaflet-popup-tip { background: var(--bg-elev); }
.leaflet-popup-content { margin: 10px 12px; min-width: 190px; }
.pp img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; margin-bottom: 8px; }
.pp h4 { margin: 0 0 2px; font-size: 15px; font-weight: 700; }
.pp .m { font-size: 12px; color: var(--fg-muted); margin-bottom: 8px; }
.pp p { margin: 0 0 8px; font-size: 13px; color: var(--fg-muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pp button { width: 100%; border: 0; border-radius: 999px; padding: 7px 12px; background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.leaflet-control-attribution { font-size: 10px; }
:root[data-theme="dark"] .leaflet-tile, :root:not([data-theme="light"]) .leaflet-tile { filter: var(--tile-filter, none); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --tile-filter: brightness(.8) contrast(1.05) saturate(.85); } }
:root[data-theme="dark"] { --tile-filter: brightness(.8) contrast(1.05) saturate(.85); }
:root[data-theme="light"] { --tile-filter: none; }

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 1000; background: rgba(8,7,5,.985); color: #f3efe6;
  display: grid; grid-template-rows: 1fr auto; animation: fade .18s ease;
}
.lightbox[hidden] { display: none; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.lb-stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 12px; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: calc(100vh - 150px); object-fit: contain; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.lb-close, .lb-nav {
  position: absolute; z-index: 2; border: 0; border-radius: 50%; width: 44px; height: 44px;
  background: rgba(255,255,255,.1); color: #fff; display: grid; place-items: center; backdrop-filter: blur(6px); transition: .2s;
}
.lb-close:hover, .lb-nav:hover { background: rgba(255,255,255,.22); }
.lb-close { top: 14px; inset-inline-end: 14px; }
.lb-nav { top: 50%; transform: translateY(-50%); }
.lb-prev { inset-inline-start: 12px; }
.lb-next { inset-inline-end: 12px; }
.lb-caption { padding: 12px 18px 18px; max-width: 900px; width: 100%; margin: 0 auto; }
.lb-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.lb-place { font-size: 18px; font-weight: 700; }
.lb-meta { font-size: 13px; color: #b9b3a6; }
.lb-desc { margin: 6px 0 0; font-size: 14px; color: #cfc9bc; line-height: 1.5; }
.lb-desc:empty { display: none; }
.lb-count { margin-top: 6px; font-size: 12px; color: #8f897c; direction: ltr; text-align: right; }
.btn-ghost {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; border: 1px solid rgba(255,255,255,.25);
  background: transparent; color: #fff; border-radius: 999px; padding: 6px 12px; font-size: 13px; transition: .2s;
}
.btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-ghost svg { width: 16px; height: 16px; }
@media (max-width: 600px) {
  .lb-nav { width: 38px; height: 38px; top: auto; bottom: 110px; transform: none; }
  .lb-stage img, .lb-stage video { max-height: calc(100vh - 190px); }
}
