/* TWmeme — Phase 1 front-end skeleton. Tokens from DESIGN.md. */

:root {
  /* Color (OKLCH based for premium playful-editorial paper theme) */
  --primary: oklch(64.5% 0.22 36);      /* 熱珊瑚 */
  --primary-ink: oklch(58.0% 0.21 36);  /* 熱珊瑚偏深 */
  --accent: oklch(82.0% 0.19 75);       /* 金盞花黃 */
  --bg: oklch(98.5% 0.006 45);          /* 奶油紙白 */
  --surface: oklch(99.5% 0.005 45);     /* 微暖白卡 */
  --ink: oklch(15.0% 0.008 45);         /* 深墨黑 */
  --muted: oklch(50.0% 0.015 45);       /* 暖灰 */
  --border: oklch(91.0% 0.008 45);      /* 紙質拼貼邊框灰 */
  
  --shadow-sm: 0 2px 8px rgba(26, 26, 26, 0.04);
  --shadow-md: 0 4px 16px rgba(26, 26, 26, 0.06);
  --shadow-lg: 0 12px 40px rgba(26, 26, 26, 0.1);

  /* Spacing (8-base) */
  --s-2xs: 2px; --s-xs: 4px; --s-sm: 8px; --s-md: 16px;
  --s-lg: 24px; --s-xl: 32px; --s-2xl: 48px; --s-3xl: 64px; --s-4xl: 96px;

  /* Radius */
  --r-sm: 6px; --r-md: 12px; --r-lg: 20px; --r-full: 9999px;

  /* Motion */
  --e-enter: cubic-bezier(0.16, 1, 0.3, 1);
  --d-short: 150ms;
  --d-medium: 250ms;
}

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

html { font-size: 16px; }

/* A11y: respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* A11y: screen-reader-only utility */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Universal hidden attribute override prevention */
[hidden] { display: none !important; }

/* A11y: Skip to content link for keyboard navigation */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 9999;
  padding: 12px 20px;
  background: var(--primary);
  color: oklch(99.5% 0.005 45);
  font-weight: 600;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
  transition: top 150ms ease-out;
}
.skip-link:focus {
  top: 16px;
}

/* A11y: keyboard focus ring — visible on all interactive elements */
:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
.btn-search:focus-visible,
.chip:focus-visible {
  outline-offset: 3px;
}
.searchbox:focus-within { outline: none; }

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.display {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

a { color: inherit; text-decoration: none; }

/* ===== Header ===== */
.site-header {
  height: 80px;
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1200px; margin: 0 auto;
  padding: 0 var(--s-xl);
}
.wordmark {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 24px; font-weight: 700;
  letter-spacing: -0.02em;
}
.wordmark em { color: var(--primary); font-style: normal; }
.nav-links { display: flex; gap: var(--s-xl); }
.nav-links a {
  font-size: 14px; color: var(--muted);
  transition: color var(--d-short) ease-out;
}
.nav-links a:hover { color: var(--ink); }

/* ===== Hero ===== */
.hero {
  max-width: 1200px; margin: 0 auto;
  padding: var(--s-3xl) var(--s-xl) var(--s-2xl);
  text-align: center;
}
.hero h1 {
  font-family: 'Space Grotesk', 'Noto Sans TC', sans-serif;
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-bottom: var(--s-md);
}
.hero .sub {
  font-size: 18px; color: var(--muted);
  margin-bottom: var(--s-xl);
}

/* ===== Search box ===== */
.searchbox {
  max-width: 640px; margin: 0 auto;
  display: flex; align-items: center;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r-full);
  padding: var(--s-sm) var(--s-sm) var(--s-sm) var(--s-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--d-short) ease-out, box-shadow var(--d-short) ease-out;
}
.searchbox:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(255, 91, 75, 0.12);
}
.searchbox svg { flex-shrink: 0; color: var(--muted); }
.searchbox input {
  flex: 1; border: none; outline: none; background: transparent;
  font: inherit; font-size: 16px;
  padding: 0 var(--s-md);
  color: var(--ink);
}
.searchbox input::placeholder { color: var(--muted); }
.btn-search {
  width: 48px; height: 48px;
  border: none; cursor: pointer;
  background: var(--primary); color: oklch(99.5% 0.005 45);
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--d-short) ease-out, transform var(--d-short) var(--e-enter);
}
.btn-search:hover { background: var(--primary-ink); transform: scale(1.05); }
.btn-search:active { transform: scale(0.97); }

/* ===== Category Explorations (index.html) ===== */
.search-categories {
  max-width: 640px;
  margin: var(--s-lg) auto 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: var(--s-sm);
}

.category-row {
  display: flex;
  align-items: center;
  gap: var(--s-md);
}

@media (max-width: 640px) {
  .category-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s-xs);
    margin-bottom: var(--s-xs);
  }
}

.category-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  width: 70px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-xs);
}

/* P1 fix: collapse categories on mobile to reduce cognitive overload */
.search-categories .category-row:nth-child(n+3) {
  display: none;
}
.search-categories.expanded .category-row:nth-child(n+3) {
  display: flex;
}
.chip-toggle {
  display: block;
  margin: var(--s-sm) auto 0;
  padding: 8px 20px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: color var(--d-short) ease-out, border-color var(--d-short) ease-out;
}
.chip-toggle:hover {
  color: var(--ink);
  border-color: var(--ink);
}
@media (min-width: 901px) {
  .search-categories .category-row:nth-child(n+3) { display: flex; }
  .chip-toggle { display: none; }
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 12px 16px;
  border-radius: var(--r-full);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: transform var(--d-short) var(--e-enter),
              background var(--d-short) ease-out,
              border-color var(--d-short) ease-out;
  border: 1px solid transparent;
  font-family: inherit;
}

.chip.emotion {
  background: oklch(93.0% 0.04 85); /* 奶油暖黃 */
  color: oklch(35.0% 0.06 85);
}

.chip.emotion:hover {
  background: var(--accent);
  color: var(--ink);
  transform: translateY(-2px);
}

.chip.role {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
}

.chip.role:hover {
  border-color: var(--ink);
  transform: translateY(-2px);
}

.chip.acg {
  background: oklch(94.0% 0.03 200); /* 柔水藍 */
  color: oklch(40.0% 0.05 200);
  border: 1px solid transparent;
}

.chip.acg:hover {
  background: oklch(88.0% 0.08 200);
  transform: translateY(-2px);
}

.chip.trend {
  background: oklch(94.0% 0.03 330); /* 柔粉紫 */
  color: oklch(40.0% 0.06 330);
  border: 1px solid transparent;
}

.chip.trend:hover {
  background: oklch(88.0% 0.11 330);
  transform: translateY(-2px);
}

.chip.scene {
  background: oklch(94.0% 0.04 140); /* 暖草綠 */
  color: oklch(35.0% 0.06 140);
  border: 1px solid transparent;
}

.chip.scene:hover {
  background: oklch(88.0% 0.08 140);
  transform: translateY(-2px);
}

.chip.format {
  background: oklch(93.0% 0.04 290); /* 薰衣草紫 */
  color: oklch(35.0% 0.06 290);
  border: 1px solid transparent;
}

.chip.format:hover {
  background: oklch(87.0% 0.09 290);
  transform: translateY(-2px);
}

/* ===== Weekly Hot Section ===== */
.weekly-hot {
  border-top: 2px solid oklch(90% 0.06 55);
  background: linear-gradient(180deg, oklch(98% 0.01 55) 0%, transparent 40%);
}
.weekly-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  color: oklch(45% 0.12 55);
  background: oklch(95% 0.04 55);
  padding: 3px 10px;
  border-radius: var(--r-full);
  white-space: nowrap;
}

/* ===== Popular & Latest Sections ===== */
.popular-section {
  border-top: 1px solid oklch(92% 0.02 260);
  background: linear-gradient(180deg, oklch(98.5% 0.008 260) 0%, transparent 50%);
}
.popular-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  color: oklch(45% 0.12 260);
  background: oklch(95.5% 0.03 260);
  padding: 3px 10px;
  border-radius: var(--r-full);
  white-space: nowrap;
}

.latest-section {
  border-top: 1px solid oklch(92% 0.02 160);
  background: linear-gradient(180deg, oklch(98.5% 0.008 160) 0%, transparent 50%);
}
.latest-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  color: oklch(42% 0.12 160);
  background: oklch(95.5% 0.03 160);
  padding: 3px 10px;
  border-radius: var(--r-full);
  white-space: nowrap;
}

/* ===== Section Shared ===== */
.section {
  max-width: 1200px; margin: 0 auto;
  padding: var(--s-3xl) var(--s-xl);
}
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--s-xl);
  gap: var(--s-md);
}
.section-title-wrap {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
}
.section-head h2 {
  font-family: 'Space Grotesk', 'Noto Sans TC', sans-serif;
  font-size: 28px; font-weight: 600;
  letter-spacing: -0.01em;
}
.section-head .more {
  font-size: 14px; color: var(--muted);
}
.section-head .more:hover { color: var(--primary); }

/* Broken grid for trending (home only) — desktop */
.broken-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: 120px;
  gap: var(--s-md);
}
@media (min-width: 901px) {
  .broken-grid .card-wrap:nth-child(1) { grid-column: span 5; grid-row: span 3; }
  .broken-grid .card-wrap:nth-child(2) { grid-column: span 3; grid-row: span 2; }
  .broken-grid .card-wrap:nth-child(3) { grid-column: span 4; grid-row: span 2; }
  .broken-grid .card-wrap:nth-child(4) { grid-column: span 3; grid-row: span 2; }
  .broken-grid .card-wrap:nth-child(5) { grid-column: span 4; grid-row: span 3; }
  .broken-grid .card-wrap:nth-child(6) { grid-column: span 3; grid-row: span 2; }
  .broken-grid .card-wrap:nth-child(7) { grid-column: span 5; grid-row: span 2; }
  .broken-grid .card-wrap:nth-child(8) { grid-column: span 4; grid-row: span 2; }
  .broken-grid .card-wrap:nth-child(9) { grid-column: span 3; grid-row: span 2; }
}

@media (max-width: 900px) {
  .broken-grid { grid-template-columns: repeat(6, 1fr); }
  .broken-grid .card-wrap { grid-column: span 3; grid-row: span 2; }
}

/* Uniform masonry for results page */
.masonry {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  grid-auto-rows: 280px;
  gap: var(--s-md);
}
.masonry .card-wrap.tall { grid-row: span 2; }

/* ===== Meme Card ===== */
/* card-wrap = the grid item, wraps card link + copy button sibling.
   Structure: <article class="card-wrap"><a class="card">...</a><button class="copy-ghost">...</button></article> */
.card-wrap {
  position: relative;
  display: block;
}
.card {
  position: relative;
  background: var(--surface);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform var(--d-medium) var(--e-enter),
              box-shadow var(--d-medium) ease-out;
  display: flex; flex-direction: column;
  height: 100%;
  color: inherit;
  text-decoration: none;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}
/* Shimmer Skeleton Animation (single definition, used by card thumbs + skeleton cards) */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes shimmer-slide {
  100% { transform: translateX(100%); }
}

.card .thumb {
  flex: 1; position: relative;
  min-height: 180px;
  display: flex; align-items: center; justify-content: center;
  font-size: 72px;
  overflow: hidden;
  transition: transform var(--d-medium) ease-out, background var(--d-medium) ease-out;
  background: linear-gradient(90deg, oklch(96% 0.005 55) 0%, oklch(98.5% 0.01 55) 50%, oklch(96% 0.005 55) 100%);
  background-size: 200% 100%;
  animation: shimmer 3s infinite ease-in-out;
  padding: var(--s-sm); /* 卡片縮圖留白呼吸感 */
}
.card .thumb.loaded {
  animation: none;
  background: var(--surface);
}
.card:hover .thumb { transform: scale(1.02); }

/* Platform & Media Badge on Cards */
.card .platform-badge {
  display: none !important;
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--r-full);
  background: var(--surface);
  color: oklch(35% 0.05 45);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  pointer-events: none;
}
.card .platform-badge.ptt { color: oklch(40% 0.15 250); background: oklch(96% 0.02 250); }
.card .platform-badge.dcard { color: oklch(45% 0.15 220); background: oklch(96% 0.02 220); }
.card .platform-badge.baha { color: oklch(45% 0.15 150); background: oklch(96% 0.02 150); }

.card .caption {
  padding: var(--s-sm) var(--s-md);
  font-size: 14px; color: var(--muted); font-weight: 500;
  border-top: 1px solid var(--border);
}
.card .caption .name { color: var(--ink); display: block; }

/* Copy button: sibling of <a>, absolute-positioned in card-wrap bottom-right */
.copy-ghost {
  position: absolute;
  bottom: var(--s-sm);
  right: var(--s-sm);
  z-index: 2;
  opacity: 0;
  visibility: hidden;
  font-size: 12px; color: var(--primary); font-weight: 600;
  border: 1px solid var(--primary);
  padding: 4px 10px;
  border-radius: var(--r-sm);
  background: var(--surface);
  font-family: inherit;
  cursor: pointer;
  transition: opacity var(--d-short) ease-out,
              visibility var(--d-short) ease-out,
              background var(--d-short) ease-out,
              color var(--d-short) ease-out;
}
.card-wrap:hover .copy-ghost,
.card-wrap:focus-within .copy-ghost {
  opacity: 1;
  visibility: visible;
}
.copy-ghost:hover { background: var(--primary); color: oklch(99.5% 0.005 45); }

.quality-badge {
  position: absolute; top: var(--s-sm); right: var(--s-sm);
  background: var(--accent); color: var(--ink);
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  padding: 3px 8px; border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
}

/* Gradient placeholders for meme thumbs */
.t-coral { background: linear-gradient(135deg, oklch(90% 0.06 25), oklch(78% 0.12 25)); }
.t-mustard { background: linear-gradient(135deg, oklch(93% 0.06 85), oklch(83% 0.14 80)); }
.t-sage { background: linear-gradient(135deg, oklch(91% 0.05 145), oklch(78% 0.1 145)); }
.t-sky { background: linear-gradient(135deg, oklch(90% 0.04 240), oklch(78% 0.08 240)); }
.t-plum { background: linear-gradient(135deg, oklch(88% 0.04 330), oklch(76% 0.06 330)); }
.t-sand { background: linear-gradient(135deg, oklch(92% 0.03 70), oklch(82% 0.05 70)); }
.t-mint { background: linear-gradient(135deg, oklch(92% 0.05 165), oklch(82% 0.08 165)); }
.t-rose { background: linear-gradient(135deg, oklch(90% 0.04 15), oklch(76% 0.08 15)); }
.t-steel { background: linear-gradient(135deg, oklch(89% 0.01 260), oklch(72% 0.02 260)); }

/* ===== Footer ===== */
.site-footer {
  max-width: 1200px; margin: 0 auto;
  padding: var(--s-xl);
  text-align: center;
  font-size: 13px; color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: var(--s-2xl);
}

/* ===== Top bar for sub-pages ===== */
.topbar {
  max-width: 1200px; margin: 0 auto;
  padding: var(--s-lg) var(--s-xl);
  display: flex; align-items: center; gap: var(--s-lg);
  border-bottom: 1px solid var(--border);
}
.topbar .back {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-full);
  color: var(--muted);
  transition: background var(--d-short) ease-out, color var(--d-short) ease-out;
}
.topbar .back:hover { background: var(--border); color: var(--ink); }
.topbar .searchbox { flex: 1; margin: 0; max-width: 560px; }
.topbar .result-meta {
  margin-left: auto;
  font-size: 13px; color: var(--muted);
}

/* ===== Detail page ===== */
.detail {
  max-width: 1200px; margin: 0 auto;
  padding: var(--s-2xl) var(--s-xl);
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: var(--s-2xl);
}
@media (max-width: 900px) {
  .detail { grid-template-columns: 1fr; }
}
.detail .image-pane {
  background: oklch(96.0% 0.006 45); /* 紙質襯底暖灰色 */
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 180px;
  position: relative;
  padding: var(--s-md); /* 詳情頁大圖留白 */
  border: 2px solid var(--border); /* 紙張邊框感 */
}
.detail .image-pane .quality-badge {
  top: var(--s-md); right: var(--s-md);
  font-size: 13px; padding: 6px 12px;
}
.detail aside h1 {
  font-family: 'Space Grotesk', 'Noto Sans TC', sans-serif;
  font-size: 28px; font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--s-md);
}
.detail aside .meta-row {
  display: flex; justify-content: space-between;
  font-size: 13px; color: var(--muted);
  padding-bottom: var(--s-md);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s-md);
}
.detail aside .tags {
  display: flex; flex-wrap: wrap; gap: var(--s-xs);
  margin-bottom: var(--s-xl);
}
.detail aside .tag-sm {
  font-size: 13px; color: var(--primary);
  background: rgba(255, 91, 75, 0.08);
  padding: 4px 10px; border-radius: var(--r-full);
}
.detail aside .actions { display: flex; flex-direction: column; gap: var(--s-sm); }
@media (max-width: 640px) {
  .detail aside .actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--s-sm);
  }
  .detail aside .actions .btn {
    padding: var(--s-sm) var(--s-md);
    font-size: 14px;
  }
}
.btn {
  padding: var(--s-md) var(--s-lg);
  border: none; cursor: pointer;
  font: inherit; font-size: 15px; font-weight: 600;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center; gap: var(--s-sm);
  transition: transform var(--d-short) var(--e-enter),
              background var(--d-short) ease-out,
              border-color var(--d-short) ease-out;
}
.btn-primary { background: var(--primary); color: oklch(99.5% 0.005 45); }
.btn-primary:hover { background: var(--primary-ink); transform: translateY(-2px); }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--ink); transform: translateY(-2px); }
.btn:active { transform: scale(0.97); }

/* AI upgrade teaser (Paper-Zine Editorial Ad styling) */
.ai-teaser {
  margin-top: var(--s-xl);
  padding: var(--s-md);
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  position: relative;
  overflow: hidden;
}
.ai-teaser::before {
  content: "";
  position: absolute;
  top: 0; right: 0;
  border-width: 0 16px 16px 0;
  border-style: solid;
  border-color: var(--bg) var(--bg) var(--border) var(--border);
  box-shadow: -1px 1px 2px rgba(0,0,0,0.05);
}
.ai-teaser strong { color: var(--ink); }
.ai-teaser .price { color: var(--primary); font-weight: 700; }

/* ===== Toast (Branded Paper Notification) ===== */
.toast {
  position: fixed; bottom: var(--s-2xl); left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--surface); color: var(--ink);
  border: 2px solid var(--primary);
  padding: var(--s-sm) var(--s-lg);
  border-radius: var(--r-full);
  font-size: 14px;
  font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity var(--d-short) ease-out, transform var(--d-short) var(--e-enter);
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== AI Interpretation / OCR Block & Tag Cloud ===== */
.ai-interpretation {
  margin: var(--s-md) 0 var(--s-xl);
  padding: var(--s-md);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.ai-interpretation blockquote {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.5;
  margin-bottom: var(--s-sm);
  position: relative;
  padding: var(--s-sm) var(--s-md);
  background: oklch(96.0% 0.006 45);
  border-radius: var(--r-sm);
}

.ai-interpretation blockquote::before {
  content: "“";
  font-family: Georgia, serif;
  font-size: 44px;
  color: var(--primary);
  position: absolute;
  left: 4px;
  top: -12px;
  opacity: 0.25;
  line-height: 1;
}

.ai-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: var(--s-md);
}

.ai-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-xs);
}

.chip-sm {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  min-height: 38px;
  background: oklch(95.0% 0.008 45);
  color: var(--muted);
  border-radius: var(--r-full);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  transition: transform var(--d-short) var(--e-enter), 
              background var(--d-short) ease-out,
              color var(--d-short) ease-out;
}

.chip-sm:hover {
  background: var(--accent);
  color: var(--ink);
  border-color: var(--accent);
  transform: translateY(-1.5px);
}

/* ===== Search keyword highlight ===== */
mark.highlight-term {
  background: oklch(92% 0.15 85);
  color: var(--ink);
  border-radius: 3px;
  padding: 0 3px;
}

/* ===== Image thumb (Supabase real meme) ===== */
/* Used by both card thumbs (results/index) and the detail page image pane.
   object-fit: contain ensures images are shown fully without cropping.
   The cards/panes themselves enforce aspect ratio and add padding. */
.thumb-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* ===== Detail page empty state ===== */
.detail-empty {
  max-width: 480px;
  margin: var(--s-3xl) auto;
  padding: var(--s-xl);
  text-align: center;
}
.detail-empty h2 {
  font-family: 'Space Grotesk', 'Noto Sans TC', sans-serif;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: var(--s-sm);
  color: var(--ink);
}
.detail-empty p {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: var(--s-lg);
}
.detail .image-pane .emoji-fallback {
  font-size: 180px;
}

/* ===== Zero-result fallback form (results.html) ===== */
.unmet-form {
  background: linear-gradient(135deg, rgba(255, 194, 51, 0.12), rgba(255, 91, 75, 0.06));
  border: 1px dashed var(--accent);
  border-radius: var(--r-md);
  padding: var(--s-lg);
  margin: 0 auto var(--s-xl);
  max-width: 640px;
  box-shadow: var(--shadow-sm);
}
.unmet-title {
  font-family: 'Space Grotesk', 'Noto Sans TC', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: var(--s-xs);
}
.unmet-title span {
  color: var(--primary);
  word-break: break-all;
}
.unmet-sub {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: var(--s-md);
}
.unmet-form textarea {
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-sm) var(--s-md);
  resize: vertical;
  min-height: 72px;
  margin-bottom: var(--s-sm);
  transition: border-color var(--d-short);
}
.unmet-form textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.unmet-submit {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  background: var(--primary);
  color: oklch(99.5% 0.005 45);
  border: none;
  border-radius: var(--r-full);
  padding: var(--s-sm) var(--s-xl);
  min-height: 40px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--d-short), transform var(--d-short);
}
.unmet-submit:hover {
  background: var(--primary-ink);
  transform: scale(1.03);
}
.unmet-submit:active { transform: scale(0.97); }

/* ===== FAQ Section (SEO/AEO) ===== */
.faq-section {
  padding-top: var(--s-2xl);
  padding-bottom: var(--s-4xl);
}
.faq-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-lg);
}
@media (max-width: 768px) {
  .faq-grid { grid-template-columns: 1fr; gap: var(--s-md); }
}
.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-lg) var(--s-xl);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--d-short) ease-out, transform var(--d-short) var(--e-enter);
}
.faq-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.faq-q {
  font-family: 'Space Grotesk', 'Noto Sans TC', sans-serif;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
  color: var(--ink);
  margin: 0 0 var(--s-sm) 0;
  position: relative;
  padding-left: var(--s-md);
}
.faq-q::before {
  content: 'Q';
  position: absolute;
  left: 0;
  top: 0;
  color: var(--primary);
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
}
.faq-a {
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink);
  margin: 0;
  max-width: 65ch;
}

/* ===== Static meme detail page (Phase 2 SSG) ===== */
.meme-context {
  margin-top: var(--s-xl);
  padding-top: var(--s-lg);
  border-top: 1px solid var(--border);
}
.meme-context p {
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink);
  margin: 0;
}
.caption .meta-sm {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* ===== Article / Guide pages (Phase 3) ===== */
.article {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--s-3xl) var(--s-xl) var(--s-4xl);
}
.article h1 {
  font-family: 'Space Grotesk', 'Noto Sans TC', sans-serif;
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: var(--s-md) 0;
}
.article h2 {
  font-family: 'Space Grotesk', 'Noto Sans TC', sans-serif;
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin: var(--s-2xl) 0 var(--s-md);
}
.article h3 {
  font-family: 'Space Grotesk', 'Noto Sans TC', sans-serif;
  font-size: 19px;
  font-weight: 600;
  margin: var(--s-xl) 0 var(--s-sm);
}
.article p,
.article li {
  font-size: 16px;
  line-height: 1.75;
  color: var(--ink);
  margin: 0 0 var(--s-md);
}
.article ul,
.article ol {
  padding-left: var(--s-xl);
  margin: 0 0 var(--s-md);
}
.article li { margin-bottom: var(--s-xs); }
.article :where(a:not(.btn)) {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.article :where(a:not(.btn)):hover { color: var(--primary-ink); }
.article code {
  font-family: 'DM Sans', monospace;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 2px 6px;
  font-size: 14px;
}
.article-breadcrumb {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 var(--s-md);
}
.article-breadcrumb a { color: var(--muted); text-decoration: none; }
.article-breadcrumb a:hover { color: var(--ink); }
.article-byline {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 var(--s-xl);
}
.tldr {
  background: oklch(97% 0.03 75);
  border: 1px solid oklch(90% 0.06 75);
  border-radius: var(--r-sm);
  padding: var(--s-md) var(--s-lg);
  margin: var(--s-xl) 0 var(--s-2xl);
  font-size: 15px;
  line-height: 1.7;
  max-width: 65ch;
}
.tldr strong { color: #6B4A00; }
.article-cta {
  margin-top: var(--s-3xl);
  padding-top: var(--s-xl);
  border-top: 1px solid var(--border);
  text-align: center;
}
.article-cta h3 { margin-bottom: var(--s-md); }
.article-cta .btn,
.article a.btn {
  display: inline-flex;
  margin: var(--s-xs);
  text-decoration: none !important;
}
.article a.btn-primary,
.article-cta .btn-primary {
  background: var(--primary);
  color: #FFFFFF;
}
.article a.btn-primary:hover,
.article-cta .btn-primary:hover {
  background: var(--primary-ink);
  color: #FFFFFF;
}
.article a.btn-secondary,
.article-cta .btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
}
.article a.btn-secondary:hover,
.article-cta .btn-secondary:hover {
  border-color: var(--ink);
  color: var(--ink);
}
.article table {
  font-size: 14px;
  line-height: 1.5;
}

/* Guide index list */
.guide-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-md);
  margin-top: var(--s-2xl);
}
.guide-item {
  display: block;
  padding: var(--s-lg) var(--s-xl);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  text-decoration: none !important;
  color: var(--ink) !important;
  transition: box-shadow var(--d-short) ease-out, transform var(--d-short) var(--e-enter);
}
.guide-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.guide-item h2 {
  font-size: 19px !important;
  margin: 0 0 var(--s-sm) !important;
  color: var(--ink);
}
.guide-item p {
  font-size: 15px !important;
  color: var(--muted);
  margin: 0 0 var(--s-sm) !important;
}
.guide-meta {
  font-size: 13px;
  color: var(--primary);
  font-weight: 500;
}

/* ===== Advanced Search & Filter Bar ===== */
.topbar-main {
  display: flex;
  align-items: center;
  gap: var(--s-md);
  width: 100%;
}
.topbar-main .back {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color var(--d-short) ease-out, transform var(--d-short) var(--e-enter);
}
.topbar-main .back:hover {
  border-color: var(--ink);
  transform: scale(1.05);
}
.topbar-main .searchbox {
  flex: 1;
  max-width: none;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-md);
  margin-top: var(--s-md);
  width: 100%;
}

.filter-group {
  display: flex;
  align-items: center;
}

.filter-select {
  padding: var(--s-sm) var(--s-lg) var(--s-sm) var(--s-md);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-full);
  cursor: pointer;
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--d-short) ease-out, box-shadow var(--d-short) ease-out;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23707070' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 14px;
}

.filter-select:hover {
  border-color: var(--muted);
}

.filter-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 91, 75, 0.12);
}

@media (max-width: 600px) {
  .filter-bar {
    gap: var(--s-sm);
  }
  .filter-select {
    font-size: 13px;
    padding: 6px 28px 6px 12px;
    background-position: right 10px center;
  }
}

/* Quick Tag Bar in search results */
.quick-tags {
  display: flex;
  align-items: center;
  gap: var(--s-xs);
  overflow-x: auto;
  padding: var(--s-xs) 0;
  margin-top: var(--s-xs);
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}
.quick-tags::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}
.quick-tags .chip {
  flex-shrink: 0;
  font-size: 13px;
  padding: 4px 12px;
}

/* ===== Skeleton Loading (Premium Shimmer) ===== */
.skeleton-card {
  position: relative;
  background: oklch(95.0% 0.003 45);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.skeleton-card::after {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    oklch(99.5% 0.005 45 / 0) 0%,
    oklch(99.5% 0.005 45 / 0.6) 20%,
    oklch(99.5% 0.005 45 / 0.8) 60%,
    oklch(99.5% 0.005 45 / 0) 100%
  );
  animation: shimmer-slide 1.5s infinite;
}

/* ===== Sponsor & Support Styles (Playful Paper Craft) ===== */
.sponsor-float-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 990;
  display: inline-flex;
  align-items: center;
  gap: var(--s-xs);
  padding: 10px 18px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  transition: transform var(--d-short) var(--e-enter), box-shadow var(--d-short) ease-out, background var(--d-short) ease-out;
}
.sponsor-float-btn:hover {
  transform: translateY(-2px) scale(1.03);
  background: var(--accent);
  box-shadow: var(--shadow-lg);
  color: var(--ink);
}

.btn-sponsor {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-xs);
  padding: 12px 20px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform var(--d-short) var(--e-enter), background var(--d-short) ease-out, border-color var(--d-short) ease-out;
}
.btn-sponsor:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.sponsor-grid, .support-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--s-lg);
  margin: var(--s-xl) 0;
}

.sponsor-card, .support-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-xl);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: transform var(--d-short) var(--e-enter), box-shadow var(--d-short) ease-out;
}
.sponsor-card:hover, .support-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.sponsor-icon, .support-icon {
  font-size: 2.4rem;
  margin-bottom: var(--s-sm);
}

.sponsor-title, .support-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: var(--s-xs);
  color: var(--ink);
}

.sponsor-desc, .support-desc {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: var(--s-lg);
}

.qr-box {
  width: 180px;
  height: 180px;
  background: oklch(96.0% 0.005 45);
  border: 2px dashed var(--border);
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--s-md);
  color: var(--muted);
  font-size: 0.85rem;
  padding: var(--s-sm);
}
.qr-box img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--r-sm);
}


