/* ============================================================
   智能捕捉 · Rose Luxe 设计系统
   配色：奶油白底 × 玫瑰金点缀 × 柔和奢华
   ============================================================ */

/* --------------------------------------------------
   CSS Variables - Design Tokens
   -------------------------------------------------- */
:root {
  /* 背景色系 — Coach 暖灰底 + 白卡片 */
  --bg-primary: #CCC2B4;
  --bg-secondary: #ffffff;
  --bg-tertiary: #E5DFD3;
  --bg-elevated: #D6CFC1;
  --bg-overlay: rgba(204, 194, 180, 0.95);

  /* 文字色系 — 深黑灰 */
  --text-primary: #1a1a1a;
  --text-secondary: #5a5a5a;
  --text-muted: #9a9a9a;
  --text-inverted: #ffffff;

  /* 主色调 — Tapestry 亮金黄 */
  --rose-50: #fffde8;
  --rose-100: #fff9cc;
  --rose-200: #fff299;
  --rose-300: #ffe866;
  --rose-400: #ffe033;
  --rose-500: #ffd700;
  --rose-600: #e6b800;

  /* 辅助金 — 金黄渐变 */
  --gold-300: #fff5e6;
  --gold-400: #ffe6b3;
  --gold-500: #ffd966;
  --gold-600: #ffcc33;

  /* 字体系统（Google Fonts 已注释，使用系统字体 fallback） */
  --font-display: Georgia, 'Noto Serif SC', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', sans-serif;
  --font-mono: 'SF Mono', 'Consolas', 'Courier New', monospace;

  /* 尺寸系统 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-8: 48px;

  /* 圆角系统 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
}

/* --------------------------------------------------
   Reset & Base
   -------------------------------------------------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* --------------------------------------------------
   背景纹理与氛围
   -------------------------------------------------- */
.bg-texture {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 215, 0, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(255, 204, 51, 0.02) 0%, transparent 40%);
}

.bg-noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.015;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 200px;
}

/* 动态光晕 */
.glow-orb {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.12;
  pointer-events: none;
  z-index: -1;
}

.glow-orb.orb-1 {
  background: var(--rose-300);
  top: -100px;
  right: -100px;
  animation: orbFloat 15s ease-in-out infinite;
}

.glow-orb.orb-2 {
  background: var(--gold-300);
  bottom: -100px;
  left: -100px;
  animation: orbFloat 18s ease-in-out infinite reverse;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(20px, -20px); }
}

/* --------------------------------------------------
   动画系统
   -------------------------------------------------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.animate-in {
  animation: fadeUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
}

/* 交错动画延迟 */
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }

/* --------------------------------------------------
   Header
   -------------------------------------------------- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  background: linear-gradient(180deg, rgba(204, 194, 180, 0.95) 0%, rgba(204, 194, 180, 0.85) 100%);
  border-bottom: 2px solid var(--rose-500);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 32px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.logo-img {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.logo-img[src=""] {
  display: none;
}

.logo {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
  white-space: nowrap;
  position: relative;
}

.logo::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--rose-500), var(--rose-300), var(--rose-500));
  background-size: 200% 100%;
  animation: shimmer 3s linear infinite;
  border-radius: 1px;
}

.search-bar {
  flex: 1;
  min-width: 200px;
  max-width: 420px;
  position: relative;
}

.search-bar input {
  width: 100%;
  padding: 12px 20px 12px 44px;
  background: var(--bg-tertiary);
  border: 1px solid rgba(26, 26, 26, 0.06);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: all 0.3s ease;
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

.search-bar input:focus {
  border-color: var(--rose-500);
  box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.15);
  background: var(--bg-secondary);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.3s ease;
}

.search-bar input:focus + .search-icon {
  color: var(--rose-400);
}

.stats {
  font-size: 13px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* --------------------------------------------------
   Main Content
   -------------------------------------------------- */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px;
}

/* --------------------------------------------------
   Top Section
   -------------------------------------------------- */
.top-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}

/* --------------------------------------------------
   Filters
   -------------------------------------------------- */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 8px 20px;
  border: 1px solid rgba(26, 26, 26, 0.06);
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.filter-btn:hover {
  border-color: var(--rose-400);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.filter-btn.active {
  background: var(--text-primary);
  color: var(--text-inverted);
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(26, 26, 26, 0.08);
}

/* --------------------------------------------------
   Buttons
   -------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: none;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: var(--rose-500);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(255, 215, 0, 0.25);
}

.btn-primary:hover {
  background: var(--rose-600);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(255, 215, 0, 0.35);
}

.btn-ghost {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid rgba(26, 26, 26, 0.06);
}

.btn-ghost:hover {
  border-color: var(--rose-400);
  color: var(--text-primary);
  transform: translateY(-1px);
}

/* --------------------------------------------------
   Image Search Area
   -------------------------------------------------- */
.image-search {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.smart-capture-wrap {
  position: relative;
}

.smart-capture-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  border: 1px solid var(--bg-elevated);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(26, 26, 26, 0.12);
  padding: 6px;
  z-index: 50;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.smart-capture-menu.hidden {
  display: none;
}

.smart-capture-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.2s ease;
  text-align: left;
}

.smart-capture-option:hover {
  background: var(--bg-tertiary);
}

/* --------------------------------------------------
   Camera Preview Section
   -------------------------------------------------- */
.camera-preview-section {
  max-width: 1400px;
  margin: 16px auto 0;
  padding: 0 20px;
  text-align: center;
}

.preview-enhanced.hidden {
  display: none;
}

.enhance-loading-overlay.hidden {
  display: none;
}

.camera-preview-section.hidden {
  display: none;
}

.camera-toolbar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 0 auto 12px;
  max-width: 640px;
}

.camera-device-select {
  flex: 1;
  max-width: 320px;
  padding: 8px 16px;
  border: 1px solid rgba(26, 26, 26, 0.12);
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  outline: none;
  transition: all 0.3s ease;
}

.camera-device-select:focus {
  border-color: var(--rose-400);
}

.refresh-devices-btn {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(26, 26, 26, 0.08);
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.refresh-devices-btn:hover {
  border-color: var(--rose-400);
  color: var(--text-primary);
  transform: rotate(180deg);
}

.flip-camera-btn {
  display: none;
}

.camera-video-wrapper {
  width: 100%;
  max-width: 640px;
  aspect-ratio: 4 / 3;
  background: var(--text-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 0 auto 12px;
  box-shadow: 0 8px 32px rgba(26, 26, 26, 0.1);
}

.camera-video-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.capture-flash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #fff;
  pointer-events: none;
  animation: capture-flash 130ms ease-out forwards;
}

@keyframes capture-flash {
  0% { opacity: 0.85; }
  100% { opacity: 0; }
}

.capture-btn {
  padding: 10px 32px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--text-primary);
  color: var(--text-inverted);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
  margin-right: 8px;
}

.capture-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(26, 26, 26, 0.12);
}

.close-camera-btn {
  padding: 8px 20px;
  border: 1px solid rgba(26, 26, 26, 0.08);
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  transition: all 0.3s ease;
}

.close-camera-btn:hover {
  border-color: var(--rose-400);
  color: var(--text-primary);
}

/* --------------------------------------------------
   Upload Preview
   -------------------------------------------------- */
.upload-preview {
  max-width: 1400px;
  margin: 16px auto 0;
  padding: 0 20px;
}

.upload-preview.hidden {
  display: none;
}

.preview-content {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: 0 2px 8px rgba(26, 26, 26, 0.04);
  border: 1px solid rgba(26, 26, 26, 0.04);
}

.preview-content img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius-md);
}

.preview-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-info p {
  font-size: 14px;
  color: var(--text-secondary);
}

.search-submit-btn {
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--text-primary);
  color: var(--text-inverted);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
  width: fit-content;
}

.search-submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(26, 26, 26, 0.12);
}

.search-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.clear-upload-btn {
  padding: 6px 16px;
  border: 1px solid rgba(26, 26, 26, 0.08);
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  transition: all 0.3s ease;
  width: fit-content;
}

.clear-upload-btn:hover {
  border-color: var(--rose-400);
  color: var(--text-primary);
}

/* --------------------------------------------------
   Search Results Panel
   -------------------------------------------------- */
.search-results {
  max-width: 1400px;
  margin: 32px auto 40px;
  padding: 0 20px;
}

.search-results.hidden {
  display: none;
}

.results-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.results-header h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.results-header span {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.product-info {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(26, 26, 26, 0.04);
  border: 1px solid rgba(26, 26, 26, 0.04);
}

.product-info.hidden {
  display: none;
}

.product-info h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
  font-family: var(--font-display);
}

.product-info .sku-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.product-info .sku-tag {
  display: inline-block;
  padding: 4px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* --------------------------------------------------
   Detection Badge
   -------------------------------------------------- */
.detection-badge {
  display: inline-block;
  padding: 4px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--bg-elevated);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.detection-badge.no-subject {
  background: var(--bg-elevated);
  border-color: var(--bg-elevated);
  color: var(--text-secondary);
}

/* --------------------------------------------------
   Masonry Grid
   -------------------------------------------------- */
.masonry-grid {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  clear: both;
  column-count: 2;
  column-gap: 20px;
}

@media (min-width: 768px) {
  .masonry-grid { column-count: 3; }
}

@media (min-width: 1024px) {
  .masonry-grid { column-count: 4; }
}

@media (min-width: 1400px) {
  .masonry-grid { column-count: 5; }
}

/* --------------------------------------------------
   Post Card
   -------------------------------------------------- */
.post-card {
  break-inside: avoid;
  margin-bottom: 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid rgba(26, 26, 26, 0.04);
  box-shadow: 0 2px 8px rgba(26, 26, 26, 0.04);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  position: relative;
  opacity: 0;
  animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* 卡片渐变边框光效 */
.post-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  padding: 1px;
  background: linear-gradient(135deg, transparent, rgba(255, 215, 0, 0.2), rgba(255, 204, 51, 0.15), transparent);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

@media (hover: hover) {
  .post-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 32px rgba(26, 26, 26, 0.08);
  }

  .post-card:hover::before {
    opacity: 1;
  }
}

.post-image-wrapper {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.post-image {
  width: 100%;
  display: block;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (hover: hover) {
  .post-card:hover .post-image {
    transform: scale(1.03);
  }
}

/* 图片叠加层 */
.post-image-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(26, 26, 26, 0.03) 100%);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

@media (hover: hover) {
  .post-card:hover .post-image-overlay {
    opacity: 1;
  }
}

.post-info {
  padding: 16px;
}

.post-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 10px;
}

.post-author {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.post-author-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--rose-300), var(--rose-500));
  color: var(--text-inverted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  position: relative;
}

.post-author-avatar::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: linear-gradient(135deg, var(--rose-300), var(--gold-400)) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.5;
}

.post-author-name {
  font-size: 12px;
  color: var(--text-secondary);
}

.post-stats {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--text-muted);
}

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

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.post-tag {
  display: inline-block;
  padding: 3px 10px;
  background: var(--bg-tertiary);
  border: 1px solid rgba(26, 26, 26, 0.08);
  border-radius: var(--radius-full);
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: all 0.3s ease;
}

.post-tag:hover {
  background: rgba(255, 215, 0, 0.12);
  border-color: var(--rose-400);
}

/* --------------------------------------------------
   Loading
   -------------------------------------------------- */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
  font-family: var(--font-body);
}

/* --------------------------------------------------
   Modal
   -------------------------------------------------- */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(26, 26, 26, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-content {
  position: relative;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  max-width: 900px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 201;
  box-shadow: 0 24px 48px rgba(26, 26, 26, 0.15);
  animation: scaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(26, 26, 26, 0.5);
  color: var(--text-inverted);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 202;
  transition: all 0.3s ease;
}

.modal-close:hover {
  background: rgba(26, 26, 26, 0.7);
  transform: rotate(90deg);
}

.modal-body {
  padding: 0;
}

.modal-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  padding: 20px;
}

.modal-images img {
  width: 100%;
  border-radius: var(--radius-md);
  object-fit: cover;
  aspect-ratio: 1;
}

.modal-info {
  padding: 24px;
  border-top: 1px solid rgba(26, 26, 26, 0.04);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-primary);
  line-height: 1.3;
}

.modal-text {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-secondary);
  margin-bottom: 20px;
  white-space: pre-wrap;
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.modal-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
}

.modal-link:hover {
  color: var(--rose-500);
}

/* --------------------------------------------------
   Preview Enhanced Inline
   -------------------------------------------------- */
.preview-enhanced {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.preview-enhanced .enhanced-image-wrapper {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: var(--radius-md);
  overflow: visible;
  cursor: pointer;
}

.preview-enhanced .enhanced-image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-md);
  display: block;
  border: 2px solid var(--rose-300);
}

.preview-enhanced .enhanced-image-wrapper .enhanced-hover-tooltip {
  display: none;
  position: absolute;
  top: 0;
  left: calc(100% + 12px);
  z-index: 10;
  width: 200px;
  padding: 8px;
  background: var(--bg-secondary);
  border: 1px solid rgba(26, 26, 26, 0.08);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(26, 26, 26, 0.1);
  pointer-events: none;
}

.preview-enhanced .enhanced-image-wrapper .enhanced-hover-tooltip::before {
  content: '';
  position: absolute;
  top: 20px;
  left: -6px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 6px solid var(--bg-secondary);
}

.preview-enhanced .enhanced-image-wrapper.tooltip-open .enhanced-hover-tooltip {
  display: block;
}

@media (hover: hover) {
  .preview-enhanced .enhanced-image-wrapper:hover .enhanced-hover-tooltip {
    display: block;
  }
}

.preview-enhanced .enhanced-image-wrapper .enhanced-hover-tooltip img {
  width: 100%;
  border-radius: var(--radius-sm);
  display: block;
  border: none;
}

.preview-enhanced .enhanced-image-wrapper .enhanced-hover-tooltip span {
  display: block;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  font-family: var(--font-body);
}

.preview-enhanced .enhanced-inline-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  font-family: var(--font-body);
}

/* --------------------------------------------------
   Enhance Loading Overlay
   -------------------------------------------------- */
.enhance-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: var(--radius-lg);
}

.enhance-loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px;
  animation: fadeUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.enhance-loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--rose-200);
  border-top-color: var(--rose-500);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.enhance-loading-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-display);
}

.enhance-loading-subtext {
  font-size: 14px;
  color: var(--text-secondary);
  font-family: var(--font-body);
}

/* --------------------------------------------------
   Enhance Confirm Panel
   -------------------------------------------------- */
/* --------------------------------------------------
   Enhance Confirm Panel (独立容器，放在原图预览下方)
   -------------------------------------------------- */
.enhance-confirm-panel {
  max-width: 1400px;
  margin: 0 auto 20px;
  padding: 0 20px;
}

.enhance-confirm-panel.hidden {
  display: none;
}

.enhance-confirm {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px 24px;
  gap: 12px;
}

.enhance-confirm-icon {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 4px;
}

.enhance-confirm-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.enhance-confirm-desc {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 400px;
  line-height: 1.6;
}

.enhance-confirm-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

/* --------------------------------------------------
   Enhanced Image Preview
   -------------------------------------------------- */
.enhanced-preview {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  border: 1px solid rgba(26, 26, 26, 0.04);
}

.enhanced-image-wrapper {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: var(--radius-md);
  overflow: visible;
  cursor: pointer;
  flex-shrink: 0;
}

.enhanced-image-wrapper .enhanced-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-md);
  display: block;
}

.enhanced-hover-tooltip {
  display: none;
  position: absolute;
  top: 0;
  left: calc(100% + 12px);
  z-index: 10;
  width: 200px;
  padding: 8px;
  background: var(--bg-secondary);
  border: 1px solid rgba(26, 26, 26, 0.08);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(26, 26, 26, 0.1);
  pointer-events: none;
}

.enhanced-hover-tooltip::before {
  content: '';
  position: absolute;
  top: 20px;
  left: -6px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 6px solid var(--bg-secondary);
}

.enhanced-image-wrapper.tooltip-open .enhanced-hover-tooltip {
  display: block;
}

@media (hover: hover) {
  .enhanced-image-wrapper:hover .enhanced-hover-tooltip {
    display: block;
  }
}

.enhanced-hover-tooltip img {
  width: 100%;
  border-radius: var(--radius-sm);
  display: block;
}

.enhanced-hover-tooltip span {
  display: block;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  font-family: var(--font-body);
}

.enhanced-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.enhanced-meta-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.enhanced-badge {
  display: inline-block;
  padding: 4px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--bg-elevated);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.enhanced-count {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* --------------------------------------------------
   Scrollbar
   -------------------------------------------------- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --------------------------------------------------
   Responsive
   -------------------------------------------------- */
@media (max-width: 768px) {
  .header-inner {
    padding: 16px 20px;
  }

  .logo {
    font-size: 22px;
  }

  .main {
    padding: 20px;
  }

  .modal-content {
    width: 95%;
    border-radius: var(--radius-lg);
  }

  .modal-info {
    padding: 16px;
  }

  .modal-title {
    font-size: 20px;
  }
}

/* --------------------------------------------------
   Social Card Button
   -------------------------------------------------- */
.btn-generate-card {
  display: none;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 8px 16px;
  background: linear-gradient(135deg, var(--rose-500), var(--rose-600));
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(196, 114, 102, 0.3);
}

.btn-generate-card:hover {
  background: linear-gradient(135deg, var(--rose-600), var(--rose-700));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(196, 114, 102, 0.4);
}

.btn-generate-card:active {
  transform: translateY(0);
}

.btn-generate-card::before {
  content: '📱';
  font-size: 14px;
}

body {
  min-height: 100dvh;
}

@media (max-width: 768px) {
  .header {
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .header-inner {
    padding: 12px 16px;
    gap: 10px 12px;
  }

  .logo {
    font-size: 20px;
  }

  .search-bar {
    flex: 1 1 100%;
    order: 2;
    max-width: none;
  }

  .search-bar input {
    padding: 11px 18px 11px 40px;
    font-size: 16px;
  }

  .stats {
    display: none;
  }

  .main {
    padding: 0;
  }

  .top-section {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 20px;
  }

  .filters,
  .image-search {
    justify-content: center;
  }

  .filter-btn,
  .btn,
  .capture-btn,
  .close-camera-btn,
  .search-submit-btn,
  .clear-upload-btn,
  .refresh-devices-btn {
    min-height: 44px;
  }

  .filter-btn {
    padding: 10px 18px;
  }

  .btn {
    padding: 12px 18px;
  }

  .camera-preview-section,
  .upload-preview,
  .search-results,
  .enhance-confirm-panel,
  .masonry-grid {
    padding-left: 6px;
    padding-right: 6px;
  }

  .camera-toolbar,
  .camera-video-wrapper {
    max-width: 100%;
  }

  /* Smart Capture: 手机端底部悬浮，滚动时常驻 */
  .top-section {
    margin-top: 0;
    margin-bottom: 0;
  }

  .smart-capture-wrap {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom) + 14px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 90;
  }

  .smart-capture-menu {
    top: auto;
    bottom: calc(100% + 8px);
  }

  .main {
    padding-bottom: 88px;
  }

  /* 摄像头工具栏：手机端只显翻转按钮 */
  .camera-device-select,
  .refresh-devices-btn {
    display: none;
  }

  .flip-camera-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(26, 26, 26, 0.08);
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    transition: transform 0.3s ease;
  }

  .flip-camera-btn:active {
    transform: rotate(180deg);
  }

  /* 摄像头打开时：滚入可视区留出 sticky header 高度，并隐藏底部 FAB 避免重叠 */
  .camera-preview-section {
    scroll-margin-top: 96px;
  }

  body.camera-active .smart-capture-wrap {
    display: none;
  }

  /* 确认后预览面板滚入可视区时避让 sticky header */
  .upload-preview {
    scroll-margin-top: 96px;
  }

  .preview-content {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
  }

  .preview-content > img {
    width: 140px;
    height: 140px;
  }

  .preview-info {
    align-items: center;
  }

  .enhanced-preview {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .enhanced-image-wrapper {
    width: 140px;
    height: 140px;
  }

  .preview-enhanced .enhanced-image-wrapper .enhanced-hover-tooltip,
  .enhanced-image-wrapper .enhanced-hover-tooltip {
    top: auto;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%);
    width: 180px;
  }

  .preview-enhanced .enhanced-image-wrapper .enhanced-hover-tooltip::before,
  .enhanced-hover-tooltip::before {
    top: auto;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-top: 6px solid var(--bg-secondary);
    border-bottom: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
  }

  .masonry-grid {
    column-gap: 6px;
  }

  .post-card {
    margin-bottom: 6px;
    border-radius: 8px;
    border: none;
    box-shadow: 0 1px 4px rgba(26, 26, 26, 0.03);
  }

  .post-image-wrapper {
    border-radius: 8px 8px 0 0;
  }

  .post-image {
    aspect-ratio: 4/5;
    object-fit: cover;
  }

  .post-info {
    padding: 12px;
  }

  .btn-generate-card {
    width: 100%;
    justify-content: center;
  }

  .product-info {
    padding: 16px;
  }

  .modal-content {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .modal-close {
    top: calc(12px + env(safe-area-inset-top));
    right: 12px;
    width: 40px;
    height: 40px;
    font-size: 22px;
  }

  .modal-images {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    padding: 16px;
    gap: 8px;
  }

  .modal-info {
    padding: 16px;
  }

  .modal-title {
    font-size: 20px;
  }

  .modal-meta {
    gap: 10px 16px;
  }

  .enhance-loading-content {
    padding: 24px;
  }

  .enhance-loading-text {
    font-size: 16px;
  }
}

@media (max-width: 380px) {
  .masonry-grid {
    column-gap: 10px;
  }

  .post-info {
    padding: 10px;
  }

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

  .modal-images {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (hover: none) {
  .post-card {
    transition: transform 0.15s ease;
  }

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

  .btn:active,
  .filter-btn:active,
  .capture-btn:active {
    transform: scale(0.97);
  }
}

.card-preview {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: #1a1a1a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  gap: 20px;
}

.card-preview.hidden {
  display: none;
}

.card-canvas {
  position: relative;
  aspect-ratio: 3 / 4;
  width: min(92vw, 69vh);
  max-height: 78vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.card-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}

.card-photo {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8%;
}

.card-photo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.card-actions {
  display: flex;
  gap: 16px;
}

.card-actions button {
  min-height: 44px;
  padding: 12px 28px;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font-body);
}

#cardRetake {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

#cardConfirm {
  background: var(--text-primary);
  color: var(--text-inverted);
}

#cardConfirm.loading {
  opacity: 0.7;
  pointer-events: none;
}

#cardConfirm.loading::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  vertical-align: -2px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
