:root {
  color: #191917;
  background: #f7f4ee;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: #f7f4ee; }
button, a { font: inherit; }

.page {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 12px 56px;
}

.header {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0 -12px;
  padding: 16px 12px 14px;
  background: rgba(247, 244, 238, 0.96);
  backdrop-filter: blur(8px);
}

h1 {
  margin: 0;
  font-size: clamp(24px, 5vw, 36px);
  line-height: 1.1;
}

.header p {
  margin: 8px 0 0;
  color: #817b70;
  font-size: 14px;
}

.categories {
  display: flex;
  gap: 8px;
  margin: 14px 0 18px;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}

.category {
  flex: 0 0 auto;
  border: 1px solid #ddd6c9;
  border-radius: 999px;
  padding: 7px 14px;
  background: transparent;
  color: #6f685d;
  cursor: pointer;
  font-size: 13px;
}

.category.active {
  border-color: #1d1b18;
  background: #1d1b18;
  color: #fffaf0;
}

/* ============ 固定两列瀑布流 ============ */
.waterfall {
  display: flex;
  gap: 10px;
  width: 100%;
}

.waterfall-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ============ 卡片 ============ */
.card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: box-shadow 0.2s, transform 0.15s;
  break-inside: avoid;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}

.card-img-wrap {
  position: relative;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

.card-img-wrap img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  background: #e4ded2;
}

.card-img-wrap::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: url('/static/pixel.gif') repeat;
  z-index: 1;
  pointer-events: none;
}

.card-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  border-radius: 16px;
  background: rgba(0,0,0,0.4);
  color: #fff;
  font-size: 10px;
  backdrop-filter: blur(4px);
  z-index: 2;
}

.card-views {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 10px;
  background: rgba(0,0,0,0.35);
  color: #fff;
  font-size: 10px;
  z-index: 2;
}

.card-views svg {
  width: 12px;
  height: 12px;
  fill: #fff;
  opacity: 0.85;
}

/* 点赞按钮 */
.card-like {
  position: absolute;
  bottom: 8px;
  left: 8px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 10px;
  border: none;
  background: rgba(255,255,255,0.7);
  color: #666;
  font-size: 10px;
  cursor: pointer;
  z-index: 2;
  transition: background 0.3s, color 0.3s;
  backdrop-filter: blur(4px);
}
.card-like:hover { background: rgba(255,255,255,0.9); }
.card-like svg {
  width: 12px;
  height: 12px;
  fill: #999;
  transition: fill 0.3s;
}
.card-like.liked {
  background: rgba(255,59,48,0.8);
  color: #fff;
}
.card-like.liked svg {
  fill: #fff;
}
.card-like.pop {
  animation: likePop 0.35s ease;
}
@keyframes likePop {
  0% { transform: scale(1); }
  15% { transform: scale(1.8); }
  40% { transform: scale(0.7); }
  60% { transform: scale(1.3); }
  80% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

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

.card-body h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  color: #999;
  font-size: 11px;
}

.card-meta .location {
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: 58%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty {
  display: grid;
  gap: 10px;
  padding: 80px 20px;
  color: #817b70;
  text-align: center;
}

.empty strong {
  color: #24221f;
  font-size: 20px;
}

/* ============ 详情弹窗 ============ */
.detail-dialog-wrap {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.detail-dialog-wrap[hidden] {
  display: none;
}

.detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 18, 15, 0.62);
}

.detail-dialog {
  position: relative;
  width: min(920px, 100%);
  max-height: calc(100vh - 28px);
  border: 0;
  border-radius: 16px;
  background: #fffaf0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 1;
}

.close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(25, 25, 23, 0.6);
  color: #fff;
  font-size: 26px;
  line-height: 34px;
  cursor: pointer;
}

.detail-media {
  position: relative;
  width: 100%;
  height: 60vh;
  background: #e4ded2;
  -webkit-user-select: none;
  user-select: none;
}

.detail-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #e4ded2;
}

.detail-media::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: url('/static/pixel.gif') repeat;
  z-index: 1;
  pointer-events: none;
}

.slide-control {
  position: absolute;
  top: 50%;
  width: 40px;
  height: 52px;
  border: 0;
  border-radius: 999px;
  background: rgba(25, 25, 23, 0.45);
  color: #fff;
  font-size: 36px;
  transform: translateY(-50%);
  cursor: pointer;
  z-index: 3;
}

.prev { left: 14px; }
.next { right: 14px; }

.pager {
  position: absolute;
  right: 16px;
  bottom: 16px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(25, 25, 23, 0.55);
  color: #fff;
  font-size: 13px;
  z-index: 3;
}

.detail-content {
  padding: 24px;
}

.detail-content h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.3;
}

.detail-content p {
  color: #5c554b;
  line-height: 1.6;
}

.detail-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.primary, .secondary {
  min-height: 46px;
  border-radius: 8px;
  padding: 0 18px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.primary {
  flex: 1;
  border: 0;
  background: #1d1b18;
  color: #fffaf0;
}

.secondary {
  border: 1px solid #cfc7b8;
  background: transparent;
  color: #1d1b18;
}

.qr-box {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid #e4ded2;
  border-radius: 10px;
  text-align: center;
}

.qr-box img {
  width: 200px;
  max-width: 100%;
}

@media (max-width: 640px) {
  .detail-media {
    height: 50vh;
  }
  .detail-actions {
    flex-direction: column;
  }
}

/* 平板优化 */
@media (min-width: 641px) and (max-width: 1024px) {
  .detail-media {
    height: 65vh;
  }
}

/* PC 端放大 */
@media (min-width: 768px) {
  .page {
    max-width: 800px;
    padding: 32px 20px 64px;
  }
  .waterfall {
    gap: 16px;
  }
  .waterfall-col {
    gap: 16px;
  }
  h1 {
    font-size: 42px;
  }
  .card-body h2 {
    font-size: 15px;
  }
  .card-tag, .card-views {
    font-size: 11px;
  }
}

@media (min-width: 1024px) {
  .page {
    max-width: 960px;
  }
}
