:root {
  --bg: #f6f4f1;
  --surface: #ffffff;
  --surface-2: #f1eeea;
  --text: #1d1b19;
  --muted: #7a736c;
  --line: #e9e5df;
  --accent: #ff4d2e;
  --accent-ink: #ffffff;
  --accent-soft: #fff0ec;
  --price: #e42c1a;
  --gold: #ffb020;
  --shadow: 0 1px 2px rgba(30, 20, 10, .05), 0 6px 20px -8px rgba(30, 20, 10, .12);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131211;
    --surface: #1d1b19;
    --surface-2: #262321;
    --text: #f3f0ec;
    --muted: #a39b93;
    --line: #2f2b28;
    --accent: #ff6448;
    --accent-soft: #3a1f19;
    --price: #ff7461;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -10px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131211; --surface: #1d1b19; --surface-2: #262321; --text: #f3f0ec; --muted: #a39b93;
  --line: #2f2b28; --accent: #ff6448; --accent-soft: #3a1f19; --price: #ff7461;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -10px rgba(0,0,0,.6); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* header */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.top-inner { display: flex; align-items: center; gap: 16px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
}
.brand-mark svg { width: 24px; height: 24px; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: .02em; }
.search {
  flex: 1; max-width: 560px; margin-left: auto; display: flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 14px; border-radius: 999px; background: var(--surface-2);
  border: 1.5px solid transparent; transition: border-color .15s, background .15s;
}
.search:focus-within { border-color: var(--accent); background: var(--surface); }
.search svg { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 15px; }
.search input::-webkit-search-cancel-button { cursor: pointer; }

.announce {
  background: var(--accent); color: var(--accent-ink); text-align: center;
  font-size: 14px; font-weight: 600; padding: 8px 16px;
}

/* hero */
.hero { padding: 28px 0 8px; }
.hero-kicker {
  display: inline-block; margin: 0 0 8px; padding: 3px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 700;
}
.hero h1 { margin: 0; font-size: clamp(22px, 4vw, 32px); line-height: 1.3; font-weight: 800; text-wrap: balance; }

.sec-head h2 { font-size: 18px; margin: 24px 0 12px; }

/* featured rail */
.rail {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 300px); gap: 14px;
  overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px 16px 12px; margin: 0 -16px;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail .card { scroll-snap-align: start; }
.rail .card .thumb { aspect-ratio: 4 / 3; }

/* toolbar */
.toolbar {
  position: sticky; top: 64px; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 12px 0; margin-top: 12px; background: var(--bg);
}
.chips { display: flex; gap: 8px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; height: 36px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 600;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
#sort {
  flex-shrink: 0; height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-size: 14px; cursor: pointer;
}
.count { margin: 0 0 12px; color: var(--muted); font-size: 13px; }

/* grid */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 1160px) { .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

.card {
  display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line);
  transition: transform .18s ease, box-shadow .18s ease;
}
@media (hover: hover) {
  .card:hover { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(30,20,10,.06), 0 16px 32px -12px rgba(30,20,10,.22); }
  .card:hover .cta { background: var(--accent); color: var(--accent-ink); }
}
.thumb { position: relative; aspect-ratio: 1; background: #fff; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb .ph {
  width: 100%; height: 100%; display: grid; place-items: center; font-size: 42px; font-weight: 800;
  color: var(--accent); background: linear-gradient(135deg, var(--accent-soft), var(--surface-2));
}
.tag {
  position: absolute; top: 8px; left: 8px; padding: 3px 8px; border-radius: 6px;
  background: var(--price); color: #fff; font-size: 12px; font-weight: 800; letter-spacing: .02em;
}
.tag.alt { background: var(--gold); color: #3a2400; }
.tag.new { left: auto; right: 8px; background: var(--text); color: var(--bg); }
.body { display: flex; flex-direction: column; gap: 6px; padding: 12px; flex: 1; }
.body h3 {
  margin: 0; font-size: 14px; font-weight: 600; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.9em;
}
.note { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.price-row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.price { color: var(--price); font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.price small { font-size: 13px; margin-right: 1px; }
.price.ask { font-size: 15px; }
.price-row s { color: var(--muted); font-size: 12.5px; }
.cta {
  display: flex; align-items: center; justify-content: center; gap: 4px; height: 36px; margin-top: 6px;
  border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 700;
  transition: background .15s, color .15s;
}
.cta svg { width: 16px; height: 16px; }

.skeleton { aspect-ratio: 3 / 4.6; background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.empty { text-align: center; padding: 56px 0; color: var(--muted); }
.empty button {
  margin-top: 8px; height: 40px; padding: 0 20px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
}

.foot { margin-top: 48px; padding: 28px 0 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.foot p { margin: 0 0 6px; max-width: 720px; }

.totop {
  position: fixed; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom)); width: 44px; height: 44px;
  border-radius: 50%; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
  display: grid; place-items: center; cursor: pointer; z-index: 30;
}
.totop svg { width: 20px; height: 20px; }

@media (max-width: 560px) {
  .top-inner { gap: 10px; height: 58px; }
  .toolbar { top: 58px; }
  .brand-name { display: none; }
  .body { padding: 10px; }
  .price { font-size: 18px; }
  .hero { padding-top: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
