:root {
  --bg: #0b0c10;
  --surface: #16181f;
  --surface-2: #1f222b;
  --surface-3: #2a2e39;
  --text: #f4f1ea;
  --muted: #9a9cab;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .22);
  --like: #3ddc97;
  --nope: #ff5d73;
  --super: #5aa9ff;
  --accent: #ffb86b;
  --radius: 28px;
  --spring: cubic-bezier(.2, 1.3, .35, 1);
  --ease: cubic-bezier(.3, .9, .3, 1);
  --display: "Fraunces", Georgia, serif;
  --sans: "DM Sans", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(900px 600px at 15% 10%, #2a1d3a 0%, transparent 60%),
    radial-gradient(800px 600px at 90% 90%, #13303a 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  display: grid;
  place-items: center;
  overflow: hidden;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
svg { display: block; }
h1, h2, h3, h4, p { margin: 0; }

/* ---------- App shell ---------- */
.app {
  position: relative;
  width: 100vw;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  user-select: none;
  -webkit-user-select: none;
}
@media (min-width: 560px) {
  .app {
    width: 410px;
    height: min(880px, 94dvh);
    border-radius: 44px;
    box-shadow: 0 0 0 10px #050507, 0 0 0 11px #2b2d35, 0 50px 120px -30px rgba(0, 0, 0, .8);
  }
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: max(22px, env(safe-area-inset-top)) 24px 12px;
}
.greeting { font-family: var(--display); font-style: italic; color: var(--accent); font-size: 15px; margin-bottom: 4px; }
.remote-i { color: var(--accent); font-size: 13px; font-variant-numeric: tabular-nums; margin-bottom: 4px; opacity: .85; }
.eyebrow { color: var(--muted); font-size: 13px; letter-spacing: .02em; }
h1 { font-family: var(--display); font-weight: 700; font-size: 32px; letter-spacing: -.02em; }
.counter {
  font-size: 13px; color: var(--muted);
  padding: 6px 12px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.viewport { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.views { display: flex; height: 100%; transition: transform .55s var(--ease); }
.view { flex: 0 0 100%; height: 100%; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

/* ---------- Deck ---------- */
.deck { position: relative; flex: 1; margin: 6px 20px 0; min-height: 0; }
.card {
  position: absolute; inset: 0 0 30px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: 0 24px 50px -24px rgba(0, 0, 0, .8), 0 0 0 1px var(--line);
  transition: transform .55s var(--spring), opacity .35s ease;
  touch-action: none;
  will-change: transform;
}
.card.is-top { cursor: grab; }
.card.dragging { cursor: grabbing; }
.card-art, .card-art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.card-tint { position: absolute; inset: 0; pointer-events: none; }
.card-tint i { position: absolute; inset: 0; }
.card-tint .t-like { background: linear-gradient(90deg, transparent 30%, rgba(61, 220, 151, .5)); opacity: var(--s-like, 0); }
.card-tint .t-nope { background: linear-gradient(270deg, transparent 30%, rgba(255, 93, 115, .5)); opacity: var(--s-nope, 0); }
.card-tint .t-super { background: linear-gradient(0deg, transparent 40%, rgba(90, 169, 255, .5)); opacity: var(--s-super, 0); }

.card-info {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 80px 22px 22px;
  background: linear-gradient(transparent, rgba(5, 6, 10, .82));
}
.card-info h2 { font-family: var(--display); font-size: 34px; font-weight: 700; letter-spacing: -.02em; line-height: 1.05; }
.card-meta { color: rgba(255, 255, 255, .78); font-size: 14px; margin-top: 6px; display: flex; gap: 8px; align-items: center; }
.card-meta .rating { color: var(--accent); font-weight: 700; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag {
  font-size: 12px; padding: 5px 10px; border-radius: 99px;
  background: rgba(255, 255, 255, .14); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, .14);
}

.stamp {
  position: absolute; top: 34px;
  font-family: var(--display); font-weight: 700; font-size: 34px; letter-spacing: .06em;
  padding: 4px 14px; border: 4px solid currentColor; border-radius: 12px;
  pointer-events: none;
}
.stamp-like  { left: 24px;  color: var(--like);  transform: rotate(-14deg) scale(calc(1.5 - var(--s-like, 0) * .5));  opacity: var(--s-like, 0); }
.stamp-nope  { right: 24px; color: var(--nope);  transform: rotate(14deg)  scale(calc(1.5 - var(--s-nope, 0) * .5));  opacity: var(--s-nope, 0); }
.stamp-super { left: 50%; top: auto; bottom: 170px; color: var(--super); transform: translateX(-50%) rotate(-6deg) scale(calc(1.5 - var(--s-super, 0) * .5)); opacity: var(--s-super, 0); }

.deck-empty {
  position: absolute; inset: 0 0 30px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  text-align: center; padding: 30px;
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
}
.deck-empty-title { font-family: var(--display); font-size: 24px; }
.deck-empty-sub { color: var(--muted); font-size: 14px; max-width: 260px; margin-bottom: 8px; }

.controls { display: flex; justify-content: center; align-items: center; gap: 18px; padding: 6px 0 4px; }
.ctl {
  display: grid; place-items: center; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, .8);
  transform: scale(calc(1 + var(--p, 0) * .18));
  transition: transform .3s var(--spring), background .2s, opacity .2s;
}
.ctl svg { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ctl-lg { width: 66px; height: 66px; }
.ctl-lg svg { width: 30px; height: 30px; }
.ctl-sm { width: 50px; height: 50px; color: var(--accent); }
.ctl-sm svg { width: 22px; height: 22px; }
.ctl-nope { color: var(--nope); }
.ctl-like { color: var(--like); }
.ctl-like svg, .ctl-super svg { fill: currentColor; stroke-width: 1.6; }
.ctl-super { color: var(--super); }
.ctl:hover { background: var(--surface-2); }
.ctl:active { transform: scale(.88); }
.ctl:disabled { opacity: .35; cursor: default; }
.hint { text-align: center; color: var(--muted); font-size: 11.5px; padding: 8px 16px 10px; }

/* ---------- Gallery carousel ---------- */
.carousel {
  position: relative; flex: 0 0 auto; height: min(62%, 470px);
  margin-top: 6px; overflow: hidden; perspective: 1100px;
  touch-action: pan-y; cursor: grab;
}
.track { display: flex; gap: 16px; height: 100%; transform-style: preserve-3d; will-change: transform; }
.slide {
  position: relative; flex: 0 0 auto; height: 100%;
  border-radius: var(--radius); overflow: hidden;
  background: var(--surface-2);
  box-shadow: 0 30px 50px -28px rgba(0, 0, 0, .9), 0 0 0 1px var(--line);
}
.slide-art { position: absolute; inset: -6% -20%; }
.slide-art svg { width: 100%; height: 100%; }
.slide-meta { position: absolute; left: 0; right: 0; bottom: 0; padding: 60px 20px 20px; background: linear-gradient(transparent, rgba(5, 6, 10, .78)); }
.slide-meta h3 { font-family: var(--display); font-size: 28px; letter-spacing: -.02em; }
.slide-meta p { color: rgba(255, 255, 255, .75); font-size: 13px; margin-top: 4px; }
.slide-num { position: absolute; top: 16px; left: 18px; font-size: 12px; font-weight: 700; letter-spacing: .1em; color: rgba(255, 255, 255, .85); }

.dots { display: flex; justify-content: center; gap: 6px; padding: 18px 0 14px; }
.dot { width: 7px; height: 7px; padding: 0; border-radius: 99px; background: var(--line-strong); transition: width .35s var(--spring), background .3s; }
.dot.on { width: 24px; background: var(--text); }
.gallery-caption { padding: 0 26px; transition: opacity .25s, transform .25s; }
.gallery-caption.fade { opacity: 0; transform: translateY(6px); }
.gallery-caption h3 { font-family: var(--display); font-size: 22px; }
.gallery-caption p { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 6px 0 14px; }

/* ---------- Map ---------- */
.view-map { position: relative; }
.map { position: absolute; inset: 0 12px 0; border-radius: var(--radius); overflow: hidden; background: #1a1c22; }
.leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.6); }
.leaflet-container { font-family: var(--sans); background: #1a1c22; }
.leaflet-control-attribution { background: rgba(11, 12, 16, .7) !important; color: var(--muted) !important; font-size: 10px; }
.leaflet-control-attribution a { color: #c8cad6 !important; }
.leaflet-bar a { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--line) !important; }
.leaflet-bar { border: 1px solid var(--line) !important; box-shadow: none !important; }
.pin {
  width: 34px; height: 34px; border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  display: grid; place-items: center;
  background: var(--surface-3); border: 2px solid #fff;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .5);
  transition: transform .35s var(--spring), background .2s;
}
.pin span { transform: rotate(45deg); font-size: 11px; font-weight: 700; }
.pin.saved { background: var(--like); color: #062b1b; }
.pin.dream { background: var(--super); color: #04223f; }
.pin.active { transform: rotate(-45deg) scale(1.3); border-color: var(--accent); }
/* Long-press pin drop */
.map { -webkit-touch-callout: none; }
.press-ring {
  position: absolute; z-index: 650; width: 70px; height: 70px; margin: -35px 0 0 -35px;
  border-radius: 50%; pointer-events: none; opacity: 0;
  border: 3px solid var(--accent); background: radial-gradient(rgba(255, 184, 107, .35), transparent 70%);
}
.press-ring.on { animation: pressGrow .55s linear forwards; }
@keyframes pressGrow { 0% { opacity: 0; transform: scale(.25); } 25% { opacity: 1; } 100% { opacity: 1; transform: scale(1); } }
.pin-drop { background: var(--accent); animation: pinDrop .5s var(--spring); }
.pin-drop span { width: 9px; height: 9px; border-radius: 50%; background: #3a2200; }
@keyframes pinDrop { from { opacity: 0; transform: translateY(-46px) rotate(-45deg); } }
.map-hint {
  position: absolute; top: 12px; left: 50%; z-index: 500; transform: translateX(-50%);
  padding: 7px 13px; border-radius: 99px; white-space: nowrap; pointer-events: none;
  background: rgba(22, 24, 31, .88); border: 1px solid var(--line); color: var(--text); font-size: 12px;
  transition: opacity .4s;
}
.map-hint.gone { opacity: 0; }
.map-pop-img.loading { background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%) 0 0 / 300% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -150% 0; } }
.dots i { font-style: normal; animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: .2; } }
.map-pop-foot .btn-ghost { color: var(--text); }
.map-pop-body h3 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.map-pop-desc { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.wander-popup .map-pop-img { height: 130px; }

/* Map popup */
.wander-popup .leaflet-popup-content-wrapper {
  padding: 0; border-radius: 22px; overflow: hidden;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); box-shadow: 0 24px 50px -16px rgba(0, 0, 0, .8);
}
.wander-popup .leaflet-popup-content { margin: 0; width: 260px !important; line-height: 1.4; }
.wander-popup .leaflet-popup-tip { background: var(--surface); border: 1px solid var(--line); }
.wander-popup a.leaflet-popup-close-button {
  top: 10px; right: 10px; z-index: 2; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font: 18px/1 var(--sans);
  background: rgba(11, 12, 16, .55); color: #fff; backdrop-filter: blur(6px);
}
.map-pop { animation: popIn .35s var(--spring); transform-origin: 50% 100%; }
@keyframes popIn { from { opacity: 0; transform: scale(.85) translateY(10px); } }
.map-pop-img { position: relative; height: 150px; overflow: hidden; background: var(--surface-2); isolation: isolate; }
.wander-popup .map-pop-img svg { z-index: 0; } /* Leaflet gives map svgs z-index 200 */
.wander-popup .map-pop-img img { z-index: 1; }
.map-pop-img svg, .map-pop-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.map-pop-img img { opacity: 0; transform: scale(1.06); transition: opacity .5s ease, transform .8s var(--ease); }
.map-pop-img img.loaded { opacity: 1; transform: none; }
.map-pop-body { padding: 14px 16px 16px; }
.map-pop-body h3 { font-family: var(--display); font-size: 22px; letter-spacing: -.01em; }
.map-pop-meta { color: var(--muted); font-size: 12px; margin-top: 2px !important; }
.map-pop-desc { font-size: 13.5px; color: #d6d4cf; margin: 10px 0 14px !important; }
.map-pop-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.map-pop-foot .btn { padding: 9px 16px; font-size: 13px; }
.map-pop-credit { font-size: 11px; color: var(--muted) !important; text-decoration: none; }
.map-pop-credit:hover { color: var(--text) !important; }

.map-strip {
  position: absolute; left: 12px; right: 12px; bottom: 14px; z-index: 500;
  display: flex; gap: 10px; padding: 0 16px;
  overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.map-strip::-webkit-scrollbar { display: none; }
.map-chip {
  flex: 0 0 78%; scroll-snap-align: center;
  display: flex; gap: 12px; align-items: center; text-align: left;
  padding: 10px; border-radius: 20px;
  background: rgba(22, 24, 31, .88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  transition: border-color .2s, transform .3s var(--spring);
}
.map-chip.active { border-color: var(--accent); }
.map-chip .thumb { width: 52px; height: 52px; }
.map-chip h3 { font-size: 16px; }
.map-chip p { color: var(--muted); font-size: 12px; margin-top: 2px; }
.map-strip::before, .map-strip::after { content: ""; flex: 0 0 6%; }

/* ---------- Saved list ---------- */
.view-saved { overflow-y: auto; padding: 0 16px 24px; overscroll-behavior: contain; }
.list-hint { color: var(--muted); font-size: 12.5px; padding: 4px 6px 12px; }
.list { list-style: none; margin: 0; padding: 0; }
.row {
  position: relative; border-radius: 22px; overflow: hidden; margin-bottom: 10px;
  transition: height .28s var(--ease), margin .28s var(--ease), opacity .28s;
}
.row.collapsing { margin-bottom: 0; opacity: 0; }
.row-bg {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: space-between; padding: 0 26px;
  background: var(--surface-2);
}
.row[data-side="visit"] .row-bg { background: color-mix(in srgb, var(--like) calc(var(--reveal, 0) * 100%), var(--surface-2)); }
.row[data-side="del"] .row-bg { background: color-mix(in srgb, var(--nope) calc(var(--reveal, 0) * 100%), var(--surface-2)); }
.act { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; color: #0b0c10; opacity: 0; transform: scale(.7); transition: transform .3s var(--spring); }
.act svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.row[data-side="visit"] .act-visit, .row[data-side="del"] .act-del { opacity: 1; transform: scale(calc(.7 + var(--reveal, 0) * .3)); }
.row.armed[data-side="visit"] .act-visit, .row.armed[data-side="del"] .act-del { transform: scale(1.15); }
.row-fg {
  position: relative; display: flex; align-items: center; gap: 14px;
  padding: 12px; border-radius: 22px;
  background: var(--surface); border: 1px solid var(--line);
  touch-action: pan-y; cursor: grab;
  transition: transform .5s var(--spring);
}
.thumb { position: relative; flex: 0 0 auto; width: 64px; height: 64px; border-radius: 15px; overflow: hidden; }
.thumb svg { width: 100%; height: 100%; }
.row-text { flex: 1; min-width: 0; }
.row-text h3 { font-size: 17px; font-weight: 700; }
.row-text p { color: var(--muted); font-size: 13px; margin-top: 3px; }
.chip { font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 99px; white-space: nowrap; }
.chip-dream { background: rgba(90, 169, 255, .16); color: var(--super); }
.chip-visited { background: rgba(61, 220, 151, .16); color: var(--like); }
.row.visited .row-text h3 { text-decoration: line-through; text-decoration-color: rgba(255, 255, 255, .35); }
.row.visited .thumb { filter: saturate(.4); }
.list-empty { text-align: center; padding: 60px 30px; display: grid; gap: 8px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: relative; display: grid; grid-template-columns: repeat(4, 1fr);
  margin: 6px 14px max(14px, env(safe-area-inset-bottom));
  padding: 6px; border-radius: 24px;
  background: var(--surface); border: 1px solid var(--line);
}
.tab-pill {
  position: absolute; top: 6px; bottom: 6px; left: 6px; width: calc((100% - 12px) / 4);
  border-radius: 18px; background: var(--surface-3);
  transition: transform .5s var(--spring);
}
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 0; font-size: 11px; color: var(--muted); transition: color .2s;
}
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tab.is-active { color: var(--text); }
.badge {
  position: absolute; top: 4px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  background: var(--like); color: #062b1b; font-size: 11px; line-height: 18px; text-align: center;
}
.badge:empty { display: none; }
.badge.bump { animation: bump .45s var(--spring); }
@keyframes bump { 40% { transform: scale(1.45); } }

/* ---------- Bottom sheet ---------- */
.backdrop {
  position: absolute; inset: 0; z-index: 900;
  background: rgba(0, 0, 0, .6);
  opacity: 0; pointer-events: none;
}
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1000;
  height: 92%;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: 30px 30px 0 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, .6);
  transform: translateY(110%);
  will-change: transform;
}
.sheet-grab { position: relative; touch-action: none; cursor: grab; flex: 0 0 auto; }
.handle { position: absolute; top: 10px; left: 50%; z-index: 2; width: 42px; height: 5px; margin-left: -21px; border-radius: 99px; background: rgba(255, 255, 255, .7); }
.sheet-hero { position: relative; height: 210px; border-radius: 30px 30px 0 0; overflow: hidden; }
.sheet-hero svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sheet-hero .hero-text { position: absolute; left: 0; right: 0; bottom: 0; padding: 50px 22px 16px; background: linear-gradient(transparent, rgba(22, 24, 31, 1)); }
.sheet-hero h2 { font-family: var(--display); font-size: 32px; letter-spacing: -.02em; }
.sheet-hero p { color: rgba(255, 255, 255, .75); font-size: 14px; margin-top: 2px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 6px 22px 40px; overscroll-behavior: contain; user-select: text; -webkit-user-select: text; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { padding: 12px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); }
.stat span { display: block; color: var(--muted); font-size: 11px; }
.stat b { display: block; margin-top: 4px; font-size: 15px; }
.sheet-desc { color: #d6d4cf; font-size: 15px; line-height: 1.6; margin: 18px 0 6px; }
.sheet-body h4 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; }
.sheet-body .tag { background: var(--surface-2); }
.highlights { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.highlights li { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); font-size: 14px; }
.highlights li::before { content: ""; flex: 0 0 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; margin-top: 24px; }

.btn { padding: 13px 16px; border-radius: 16px; font-weight: 700; font-size: 14px; transition: transform .2s var(--spring), opacity .2s; }
.btn:active { transform: scale(.95); }
.btn-primary { background: var(--text); color: var(--bg); }
.btn-ghost { background: var(--surface-2); border: 1px solid var(--line); }

/* ---------- Toast ---------- */
.toast {
  position: absolute; left: 16px; right: 16px; bottom: 100px; z-index: 1100;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 12px 12px 18px; border-radius: 18px;
  background: #f4f1ea; color: #111;
  font-size: 14px; font-weight: 500;
  box-shadow: 0 16px 40px -10px rgba(0, 0, 0, .7);
  transform: translateY(160%); opacity: 0;
  transition: transform .45s var(--spring), opacity .3s;
  touch-action: pan-y; pointer-events: none;
}
.toast.show { transform: none; opacity: 1; pointer-events: auto; }
.toast button { font-weight: 700; padding: 6px 12px; border-radius: 10px; background: #111; color: #f4f1ea; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
