:root {
  --cream: #fff8e7;
  --cream-deep: #ffe8c2;
  --butter: #f5c842;
  --honey: #e8a838;
  --toast: #c47a2a;
  --pink: #ff6b8a;
  --pink-soft: #ffb6c8;
  --mint: #7ed4a6;
  --ink: #3d2c1e;
  --ink-soft: #7a6555;
  --card: #ffffff;
  --shadow: 0 8px 32px rgba(196, 122, 42, 0.12);
  --radius: 20px;
  --radius-sm: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  background: var(--cream);
  min-height: 100dvh;
  min-height: 100svh;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  touch-action: manipulation;
}

.app {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  min-height: 100dvh;
  min-height: 100svh;
  background: var(--cream);
  position: relative;
  overflow: hidden;
}

@media (min-width: 520px) {
  body {
    background: linear-gradient(165deg, #fff5e0 0%, #ffe4c8 45%, #ffd4e8 100%);
  }

  .app {
    max-width: 430px;
    min-height: 100dvh;
    box-shadow: 0 0 60px rgba(61, 44, 30, 0.08);
    border-radius: 0;
  }
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 248, 231, 0.92);
  backdrop-filter: blur(12px);
  padding: calc(12px + var(--safe-top)) 16px 10px;
  border-bottom: 1px solid rgba(245, 200, 66, 0.25);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--butter), var(--honey));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 12px rgba(232, 168, 56, 0.35);
}

.logo-text h1 {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: clamp(17px, 4.5vw, 20px);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

.logo-text span {
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 500;
}

.city-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--card);
  border: 2px solid var(--cream-deep);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
}

.city-pill:active { transform: scale(0.96); }

.slogan-bar {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 2px;
}

.slogan-bar::-webkit-scrollbar { display: none; }

.tag-chip {
  flex-shrink: 0;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #fff, var(--cream-deep));
  border: 1px solid rgba(245, 200, 66, 0.4);
  color: var(--toast);
  font-weight: 500;
  white-space: nowrap;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s;
}

.tag-chip:active { transform: scale(0.96); }

.tag-chip.hot {
  background: linear-gradient(90deg, var(--pink-soft), #fff);
  border-color: var(--pink);
  color: var(--pink);
}

    /* Panels */
.panel { display: none; }
.panel.active {
  display: block;
  animation: fadeUp 0.35s ease;
  padding-bottom: calc(64px + var(--safe-bottom));
}

#panel-map.active {
  display: flex;
  flex-direction: column;
  padding-bottom: calc(64px + var(--safe-bottom));
  height: calc(100svh - var(--safe-top) - var(--safe-bottom));
  min-height: 400px;
}

    #panel-map.active {
      display: flex;
      flex-direction: column;
      height: calc(100dvh - 56px - 64px - var(--safe-top) - var(--safe-bottom));
      min-height: 320px;
    }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Feed */
.feed-hero {
  margin: 14px 16px;
  padding: 18px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--butter) 0%, var(--honey) 55%, var(--pink-soft) 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
}

.feed-hero::after {
  content: "ðŸ¥";
  position: absolute;
  right: -8px;
  bottom: -12px;
  font-size: 72px;
  opacity: 0.35;
  transform: rotate(-15deg);
}

.feed-hero h2 {
  font-family: inherit;
  font-size: 22px;
  font-weight: 400;
  margin-bottom: 6px;
  text-shadow: 0 2px 8px rgba(61, 44, 30, 0.15);
}

.feed-hero p { font-size: 13px; opacity: 0.95; line-height: 1.5; }

.masonry {
  columns: 2;
  column-gap: 8px;
  padding: 0 10px 12px;
}

@media (max-width: 360px) {
  .masonry {
    column-gap: 6px;
    padding: 0 8px 10px;
  }

  .post-title { font-size: 12px; }
}

.post-card {
  break-inside: avoid;
  margin-bottom: 10px;
  background: var(--card);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s;
  animation: cardIn 0.4s ease both;
  animation-delay: calc(var(--i, 0) * 0.05s);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.post-card:active { transform: scale(0.98); }

.post-img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  display: block;
  background: var(--cream-deep);
  min-height: 120px;
}

.post-img[src=""],
.post-img:not([src]) {
  background: linear-gradient(135deg, var(--cream-deep), var(--pink-soft));
}

.post-img.short { aspect-ratio: 1; }

.post-body { padding: 10px 10px 12px; }

.post-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 11px;
  color: var(--ink-soft);
}

.post-user {
  display: flex;
  align-items: center;
  gap: 4px;
}

.avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink-soft), var(--butter));
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.likes { color: var(--pink); font-weight: 600; }

/* Map */
#map {
  flex: 1;
  min-height: 200px;
  width: 100%;
  z-index: 1;
}

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 0;
  font-size: 12px;
  color: var(--ink-soft);
}

.map-count { font-weight: 600; color: var(--toast); }

.map-filters {
  display: flex;
  gap: 8px;
  padding: 8px 16px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--cream);
}

.map-filters::-webkit-scrollbar { display: none; }

.filter-btn {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 999px;
  border: 2px solid transparent;
  background: var(--card);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn.active {
  background: var(--butter);
  color: var(--ink);
  border-color: var(--honey);
  box-shadow: 0 4px 12px rgba(245, 200, 66, 0.4);
}

.leaflet-popup-content-wrapper {
  border-radius: 16px !important;
  box-shadow: var(--shadow) !important;
  padding: 0 !important;
  overflow: hidden;
}

.leaflet-popup-content { margin: 0 !important; width: 220px !important; }

.popup-card { padding: 12px; }

.popup-card h3 { font-size: 14px; margin-bottom: 4px; }

.popup-card p { font-size: 12px; color: var(--ink-soft); margin-bottom: 8px; }

.popup-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }

.popup-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--cream-deep);
  color: var(--toast);
}

.popup-detail {
  display: block;
  width: 100%;
  margin-bottom: 6px;
  text-align: center;
  background: var(--card);
  border: 2px solid var(--cream-deep);
  color: var(--ink);
  padding: 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.popup-nav {
  display: block;
  text-align: center;
  background: linear-gradient(90deg, var(--butter), var(--honey));
  color: var(--ink);
  text-decoration: none;
  padding: 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
}

.bread-pin {
  background: none !important;
  border: none !important;
}

.pin-dot {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--butter), var(--honey));
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(196, 122, 42, 0.35);
  border: 3px solid #fff;
}

.pin-dot span {
  transform: rotate(45deg);
  font-size: 16px;
}

/* Discover */
.section-title {
  padding: 16px 16px 10px;
  font-family: inherit;
  font-size: 18px;
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 6px;
}

.rank-list { padding: 0 16px 16px; }

.rank-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s;
}

.rank-item:active { transform: scale(0.98); }

.rank-num {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}

.rank-num.gold { background: linear-gradient(135deg, #ffd700, #ffb800); color: #fff; }
.rank-num.silver { background: linear-gradient(135deg, #c0c0c0, #a0a0a0); color: #fff; }
.rank-num.bronze { background: linear-gradient(135deg, #cd7f32, #a0522d); color: #fff; }
.rank-num.normal { background: var(--cream-deep); color: var(--ink-soft); }

.rank-thumb {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
}

.rank-info { flex: 1; min-width: 0; }

.rank-info h3 { font-size: 14px; font-weight: 700; margin-bottom: 4px; }

.rank-info p { font-size: 11px; color: var(--ink-soft); }

.rank-score {
  font-size: 13px;
  font-weight: 700;
  color: var(--honey);
  flex-shrink: 0;
}

.shop-scroll {
  display: flex;
  gap: 12px;
  padding: 0 16px 20px;
  overflow-x: auto;
  scrollbar-width: none;
}

.shop-scroll::-webkit-scrollbar { display: none; }

.shop-card {
  flex-shrink: 0;
  width: 140px;
  background: var(--card);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.shop-card img {
  width: 100%;
  height: 100px;
  object-fit: cover;
}

.shop-card-body { padding: 10px; }

.shop-card-body h4 {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shop-card-body .price {
  font-size: 11px;
  color: var(--pink);
  font-weight: 600;
  margin-top: 4px;
}

/* Profile */
.profile-hero {
  text-align: center;
  padding: 28px 16px 20px;
  background: linear-gradient(180deg, var(--cream-deep) 0%, var(--cream) 100%);
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--pink-soft), var(--butter));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  border: 4px solid #fff;
  box-shadow: var(--shadow);
}

.profile-hero h2 {
  font-family: inherit;
  font-size: 20px;
  margin-bottom: 4px;
}

.profile-hero p { font-size: 13px; color: var(--ink-soft); }

.stats-row {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-top: 16px;
}

.stat { text-align: center; }

.stat strong { display: block; font-size: 18px; color: var(--toast); }

.stat span { font-size: 11px; color: var(--ink-soft); }

.badge-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 16px;
}

.badge {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}

.badge .emoji { font-size: 28px; display: block; margin-bottom: 6px; }

.badge span { font-size: 11px; font-weight: 600; color: var(--ink-soft); }

/* Publish FAB area */
.publish-panel {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - 180px);
  padding: 24px;
  text-align: center;
}

.publish-panel.active { display: flex; }

.publish-icon {
  width: 100px;
  height: 100px;
  border-radius: 30px;
  background: linear-gradient(135deg, var(--pink), var(--butter));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  margin-bottom: 20px;
  box-shadow: 0 12px 40px rgba(255, 107, 138, 0.35);
  animation: pulse 2s ease infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.publish-panel h2 {
  font-family: inherit;
  font-size: 22px;
  margin-bottom: 8px;
}

.publish-panel p {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.6;
  margin-bottom: 24px;
}

.btn-primary {
  background: linear-gradient(90deg, var(--butter), var(--honey));
  border: none;
  border-radius: 999px;
  padding: 14px 32px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(245, 200, 66, 0.45);
  transition: transform 0.2s;
}

.btn-primary:active { transform: scale(0.96); }

/* Bottom Tab */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  padding: 6px 4px calc(8px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(245, 200, 66, 0.2);
  z-index: 200;
}

@media (min-width: 520px) {
  .tabbar {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    max-width: 430px;
  }
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 600;
  transition: color 0.2s;
}

.tab-item .icon { font-size: 22px; line-height: 1; }

.tab-item.active { color: var(--toast); }

.tab-publish {
  flex: 0;
  margin-top: -28px;
}

.tab-publish .pub-btn {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--pink), #ff8fab);
  border: 4px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  box-shadow: 0 8px 24px rgba(255, 107, 138, 0.45);
  transition: transform 0.2s;
}

.tab-publish:active .pub-btn { transform: scale(0.92); }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(61, 44, 30, 0.45);
  z-index: 300;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 520px) {
  .modal-overlay {
    align-items: flex-end;
  }
}

.modal-overlay.open { display: flex; }

.modal-sheet {
  position: relative;
  width: 100%;
  max-width: 100%;
  max-height: 90dvh;
  max-height: 90svh;
  background: var(--cream);
  border-radius: 20px 20px 0 0;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
  padding-bottom: var(--safe-bottom);
}

@media (min-width: 520px) {
  .modal-sheet {
    max-width: 430px;
    border-radius: 24px 24px 0 0;
  }
}

.demo-banner {
  margin: 10px 16px 0;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px dashed rgba(196, 122, 42, 0.35);
  font-size: 11px;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.5;
}

.map-fallback {
  display: none;
  margin: 16px;
  padding: 20px;
  border-radius: var(--radius-sm);
  background: var(--card);
  text-align: center;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.6;
}

.map-fallback.show { display: block; }

.map-fallback[hidden] { display: none !important; }

.map-shop-list {
  padding: 0 12px 12px;
  display: none;
}

.map-shop-list.show {
  display: block;
}

.map-shop-list[hidden] { display: none !important; }

.map-shop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.map-shop-item img {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.map-shop-item-info { flex: 1; min-width: 0; }

.map-shop-item-info h4 {
  font-size: 14px;
  margin-bottom: 2px;
}

.map-shop-item-info p {
  font-size: 11px;
  color: var(--ink-soft);
}

.map-shop-item .go-nav {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--toast);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--cream-deep);
}

body.modal-open { overflow: hidden; }

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-cover {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.modal-content { padding: 20px 16px 32px; }

.modal-content h2 {
  font-family: inherit;
  font-size: 22px;
  margin-bottom: 8px;
}

.modal-rating {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.stars { color: var(--butter); font-size: 16px; }

.modal-rating span { font-size: 13px; color: var(--ink-soft); }

.modal-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }

.modal-desc {
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-soft);
  margin-bottom: 20px;
}

.modal-actions { display: flex; gap: 10px; }

.modal-actions a, .modal-actions button {
  flex: 1;
  text-align: center;
  padding: 12px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  border: none;
  cursor: pointer;
}

.btn-nav {
  background: linear-gradient(90deg, var(--butter), var(--honey));
  color: var(--ink);
}

.btn-collect {
  background: var(--card);
  border: 2px solid var(--pink-soft) !important;
  color: var(--pink);
}

.btn-collect.saved {
  background: var(--pink-soft);
  color: #fff;
}

.modal-address {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 12px;
  line-height: 1.5;
}

.btn-copy {
  flex-shrink: 0;
  background: var(--cream-deep);
  border: none;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--toast);
  cursor: pointer;
  font-family: inherit;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  border: none;
  font-size: 18px;
  cursor: pointer;
  z-index: 10;
}

.toast-msg {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(61, 44, 30, 0.88);
  color: #fff;
  padding: 14px 24px;
  border-radius: 14px;
  font-size: 14px;
  z-index: 400;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
}

.toast-msg.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

button:focus-visible,
a:focus-visible,
.tag-chip:focus-visible {
  outline: 2px solid var(--honey);
  outline-offset: 2px;
}

.scroll-hint {
  padding: 0 16px 8px;
  font-size: 11px;
  color: var(--ink-soft);
  opacity: 0.7;
}

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