:root {
  --bg: #f7f3ec;
  --bg-alt: #efe8dc;
  --card: #fffdf9;
  --ink: #1f2a24;
  --muted: #6b716b;
  --line: #e2d9c9;
  --accent: #2f5d4a;
  --accent-soft: #e3ece6;
  --gold: #a9834a;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(31, 42, 36, .04), 0 8px 24px rgba(31, 42, 36, .06);
  --serif: "Noto Serif TC", "Songti TC", serif;
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
img, video, iframe { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.35; margin: 0; }

.wrap { width: min(1160px, 100% - 32px); margin-inline: auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .5em;
  padding: .8em 1.5em; border-radius: 999px; border: 1px solid transparent;
  font: 500 15px/1 var(--sans); text-decoration: none; cursor: pointer;
  transition: transform .2s, background .2s, box-shadow .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { box-shadow: 0 6px 18px rgba(47, 93, 74, .25); }
.btn-ghost { border-color: var(--ink); color: var(--ink); background: transparent; }
.btn-sm { padding: .55em 1.1em; font-size: 14px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(247, 243, 236, .86);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { font: 700 20px var(--serif); text-decoration: none; letter-spacing: .04em; }
.brand span { color: var(--gold); }
.nav { display: flex; align-items: center; gap: 24px; font-size: 15px; }
.nav > a:not(.btn) { text-decoration: none; color: var(--muted); }
.nav > a:not(.btn):hover { color: var(--ink); }

/* ---------- Hero ---------- */
.hero {
  padding: 96px 0 80px;
  background:
    radial-gradient(900px 420px at 85% 0%, rgba(169, 131, 74, .14), transparent 70%),
    radial-gradient(700px 400px at 0% 100%, rgba(47, 93, 74, .10), transparent 70%);
}
.eyebrow { color: var(--gold); letter-spacing: .2em; font-size: 14px; font-weight: 500; margin: 0 0 18px; }
.hero h1 { font-size: clamp(34px, 5.4vw, 60px); white-space: pre-line; letter-spacing: .02em; }
.hero-text { max-width: 560px; color: var(--muted); font-size: 17px; margin: 24px 0 32px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.stats { display: flex; gap: 48px; margin: 56px 0 0; padding-top: 28px; border-top: 1px solid var(--line); max-width: 560px; }
.stats div { display: flex; flex-direction: column-reverse; }
.stats dt { color: var(--muted); font-size: 14px; }
.stats dd { margin: 0; font: 700 34px var(--serif); color: var(--accent); }
.hero-inner { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 56px; align-items: center; }
.hero-media { margin: 0; }
.hero-media img {
  display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: var(--radius); box-shadow: var(--shadow);
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
@media (max-width: 960px) {
  .hero-inner { grid-template-columns: 1fr; gap: 40px; }
  .hero-media img { aspect-ratio: 16 / 9; }
}

/* ---------- Sections ---------- */
.section { padding: 88px 0; }
.section-alt { background: var(--bg-alt); }
.section-head { margin-bottom: 32px; }
.section-head h2 { font-size: clamp(26px, 3.4vw, 36px); }
.section-head h2::after { content: ""; display: block; width: 40px; height: 2px; background: var(--gold); margin-top: 14px; }
.section-head p { color: var(--muted); margin: 12px 0 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: .45em 1.1em; border-radius: 999px; font: 14px var(--sans); cursor: pointer;
  transition: all .2s;
}
.chip:hover { border-color: var(--accent); }
.chip.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Products ---------- */
.product-tools { margin-bottom: 16px; }
#productSearch {
  width: min(460px, 100%); padding: .8em 1.2em .8em 2.8em; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card) no-repeat 1.1em center / 1.1em;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b716b' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  font: 15px var(--sans); color: var(--ink); outline: none;
}
#productSearch:focus { border-color: var(--accent); }
.chip small { opacity: .55; margin-left: 2px; font-size: 12px; }
.more-wrap { text-align: center; margin-top: 32px; }
.more-wrap .btn[hidden] { display: none; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 20px; }
.product {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; cursor: pointer; text-align: left; border: 1px solid transparent;
  font: inherit; color: inherit; display: flex; flex-direction: column;
  transition: transform .25s, border-color .25s;
}
.product:hover { transform: translateY(-4px); border-color: var(--line); }
.product.is-active { border-color: var(--accent); }
.product-img { aspect-ratio: 1; border-radius: 12px; background: #fff; overflow: hidden; display: grid; place-items: center; }
.product-img img { width: 100%; height: 100%; object-fit: contain; transition: transform .4s; }
.product:hover .product-img img { transform: scale(1.04); }
.product-img .ph { font: 700 28px var(--serif); color: var(--gold); }
.product-brand { font-size: 12px; color: var(--gold); letter-spacing: .06em; margin-top: 14px; }
.product-name { font-size: 15px; font-weight: 500; line-height: 1.5; margin: 4px 0 10px; flex: 1; }
.product-count { font-size: 13px; color: var(--accent); }
.product-count.zero { color: var(--muted); }

/* ---------- Stories ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.filters .chips { margin-bottom: 20px; }
.active-product {
  display: inline-flex; align-items: center; gap: 10px; margin-bottom: 20px;
  background: var(--accent-soft); color: var(--accent); padding: .4em .6em .4em 1em; border-radius: 999px; font-size: 14px;
}
.active-product[hidden] { display: none; }
.active-product button { border: 0; background: var(--accent); color: #fff; border-radius: 999px; width: 22px; height: 22px; cursor: pointer; line-height: 1; }

.masonry { columns: 3 320px; column-gap: 20px; }
.story {
  break-inside: avoid; margin-bottom: 20px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; animation: rise .5s both;
}
.story.featured { outline: 1px solid var(--gold); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.story-media { position: relative; background: #000; }
.story-media img { width: 100%; cursor: zoom-in; }
.story-media .video { aspect-ratio: 16/9; width: 100%; }
.story-media video { width: 100%; }
.story-photos { display: grid; gap: 2px; grid-template-columns: repeat(2, 1fr); background: var(--card); }
.story-photos img { aspect-ratio: 1; object-fit: cover; width: 100%; height: 100%; cursor: zoom-in; }
.story-photos.single { grid-template-columns: 1fr; }
.story-photos.single img { aspect-ratio: auto; }
.story-photos .more { position: relative; }
.story-photos .more img { height: 100%; }
.story-photos .more::after {
  content: attr(data-more); position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(0, 0, 0, .45); color: #fff; font-size: 22px; pointer-events: none;
}
.story-body { padding: 22px 24px 24px; }
.story-tag { display: inline-block; font-size: 12px; color: var(--gold); letter-spacing: .08em; margin-bottom: 8px; }
.story h3 { font-size: 19px; margin-bottom: 10px; }
.story-text { white-space: pre-line; color: #3a433d; font-size: 15px; margin: 0; }
.story-text.clamp { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.read-more { border: 0; background: none; color: var(--accent); padding: 4px 0 0; cursor: pointer; font: 500 14px var(--sans); }
.story-foot { display: flex; align-items: center; gap: 12px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font: 700 16px var(--serif); flex: none; }
.who { font-size: 14px; line-height: 1.4; }
.who small { display: block; color: var(--muted); font-size: 12px; }
.product-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.product-links button { border: 0; background: var(--bg); color: var(--muted); font: 12px var(--sans); padding: 4px 10px; border-radius: 999px; cursor: pointer; }
.product-links button:hover { color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- Footer ---------- */
.footer { padding: 40px 0 48px; font-size: 13px; color: var(--muted); }
.disclaimer { max-width: 760px; margin: 0 0 12px; }
.copy { margin: 0; }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(15, 18, 16, .92); display: grid; place-items: center; }
.lightbox[hidden] { display: none; }
.lb-stage { max-width: min(1000px, 92vw); max-height: 86vh; }
.lb-stage img { max-height: 86vh; width: auto; margin: auto; border-radius: 8px; }
.lightbox button { position: absolute; border: 0; background: rgba(255,255,255,.12); color: #fff; width: 48px; height: 48px; border-radius: 50%; font-size: 28px; cursor: pointer; line-height: 1; }
.lightbox button:hover { background: rgba(255,255,255,.24); }
.lb-close { top: 20px; right: 20px; }
.lb-prev { left: 20px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 20px; top: 50%; transform: translateY(-50%); }

.toast { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 22px; border-radius: 999px; font-size: 14px; z-index: 120; }

/* ---------- Share banner ---------- */
.share-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  margin-top: 40px; padding: 28px 32px; border-radius: var(--radius);
  background: var(--card); border: 1px dashed var(--gold);
}
.share-banner h3 { font-size: 20px; }
.share-banner p { margin: 6px 0 0; color: var(--muted); font-size: 15px; }

/* ---------- Upload dialog ---------- */
.upload {
  width: min(600px, 100% - 24px); max-height: calc(100dvh - 24px); padding: 0;
  border: 0; border-radius: 22px; background: var(--card); color: var(--ink);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .25);
}
.upload::backdrop { background: rgba(20, 24, 22, .55); backdrop-filter: blur(3px); }
.upload form[hidden] { display: none; }
.upload form { display: flex; flex-direction: column; max-height: calc(100dvh - 24px); }
.upload-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px 10px; }
.upload-head h2 { font-size: 22px; }
.upload-x { border: 0; background: var(--bg); width: 36px; height: 36px; border-radius: 50%; font-size: 22px; cursor: pointer; color: var(--muted); }
.upload-body { padding: 8px 24px 8px; overflow-y: auto; }
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  padding: 26px 16px; border: 1.5px dashed var(--line); border-radius: 16px; cursor: pointer;
  background: var(--bg); transition: border-color .2s, background .2s;
}
.drop:hover, .drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { color: var(--accent); }
.drop span { font-size: 13px; color: var(--muted); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-top: 12px; }
.thumbs:empty { display: none; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--bg); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border: 0; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; line-height: 1; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; font-size: 14px; font-weight: 500; }
.field small { font-weight: 400; color: var(--muted); }
.field input, .field textarea {
  font: 15px var(--sans); color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 12px; padding: .7em .9em; outline: none; resize: vertical;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.consent { display: flex; gap: 10px; align-items: flex-start; margin-top: 18px; font-size: 13px; color: #3a433d; cursor: pointer; }
.consent input { margin-top: 4px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.upload-note { font-size: 12px; color: var(--muted); margin: 10px 0 0; }
.upload-error { background: #fbe9e7; color: #a33a2b; padding: 10px 14px; border-radius: 10px; font-size: 14px; margin: 12px 0 0; }
.upload-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px 22px; border-top: 1px solid var(--line); margin-top: 16px; }
.upload-foot .btn[disabled] { opacity: .6; cursor: wait; transform: none; }
.upload-done { padding: 48px 32px; text-align: center; }
.upload-done p { color: var(--muted); margin: 10px 0 24px; }
.done-mark { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 30px; }

/* ---------- Login gate ---------- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card { width: min(380px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px 28px; box-shadow: var(--shadow); }
.gate-card .brand { display: block; text-align: center; font-size: 24px; margin-bottom: 8px; }
.gate-card p { text-align: center; color: var(--muted); font-size: 14px; margin: 0 0 8px; }
.gate-card .btn { width: 100%; justify-content: center; margin-top: 18px; }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .nav > a:not(.btn):not(.nav-logout) { display: none; }
  .nav { gap: 14px; }
  .hero { padding: 64px 0 56px; }
  .stats { gap: 28px; }
  .stats dd { font-size: 28px; }
  .section { padding: 64px 0; }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .product { padding: 10px; }
  .product-name { font-size: 14px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin-inline: -16px; padding-inline: 16px; scrollbar-width: none; }
  .chip { flex: none; }
  .lb-prev, .lb-next { top: auto; bottom: 24px; transform: none; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .share-banner { padding: 22px; }
}
