:root {
  --bg: #fff6fa;
  --surface: #ffffff;
  --surface-2: #ffe3f1;
  --line: #f8cfe3;
  --text: #3a1328;
  --muted: #8f6a7d;
  --accent: #e6007e; /* สีชมพูของโลโก้ร้าน */
  --accent-ink: #ffffff;
  --line-green: #06c755;
  --fb-blue: #1877f2;
  --tabbar-h: 78px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Sukhumvit Set", "Noto Sans Thai", "Thonburi", "Segoe UI", sans-serif;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
img { max-width: 100%; display: block; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

/* โครงหน้า */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.brand img { width: 40px; height: 40px; border-radius: 10px; display: block; }
.admin-brand img { width: 32px; height: 32px; }
.topbar-actions { display: flex; gap: 8px; }
.langbtn { display: flex; gap: 8px; padding: 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.flag { display: block; width: 38px; height: 38px; border-radius: 50%; overflow: hidden; opacity: .45; border: 3px solid transparent; }
.flag svg { display: block; width: 100%; height: 100%; }
.flag.on { opacity: 1; border-color: var(--accent); }
.pill {
  min-height: 36px; padding: 0 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text); font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
}
#view {
  max-width: 720px; margin: 0 auto;
  padding: 0 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
  min-height: calc(100dvh - var(--topbar-h));
}
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  margin: 6px 4px; border-radius: 16px;
  font-size: 17px; font-weight: 600; color: var(--text);
}
.tabbar a.active { color: var(--accent); background: var(--surface-2); }
.ico { display: inline-flex; width: 32px; height: 32px; }
.ico svg { width: 100%; height: 100%; }
.badge {
  position: absolute; top: 2px; left: calc(50% + 8px);
  min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 14px; font-weight: 700; line-height: 24px; text-align: center;
}

/* ปุ่ม */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 48px; padding: 0 18px; border-radius: 14px;
  background: var(--surface); color: var(--text); font-weight: 600; text-align: center;
  border: 1px solid var(--line);
}
.btn-line, .btn-fb, .btn-accent { border-color: transparent; }
.btn-line { background: var(--line-green); color: #fff; }
.btn-fb { background: var(--fb-blue); color: #fff; }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: none; border: 1px solid var(--line); font-weight: 500; }
.stack { display: grid; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.section-title { font-size: 15px; font-weight: 600; margin: 28px 0 12px; }
.page-title { font-size: 22px; font-weight: 600; margin: 8px 0 16px; }
.empty { text-align: center; padding: 56px 0; display: grid; gap: 16px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 14px;
  display: inline-flex; align-items: center; white-space: nowrap; flex: none;
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip[data-shortcut] { background: var(--surface-2); border-color: var(--surface-2); color: var(--accent); font-weight: 600; }
.tag { display: inline-flex; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); font-size: 13px; }

/* โชว์รูม */
.search {
  width: 100%; height: 46px; padding: 0 18px; border-radius: 23px;
  border: 1px solid var(--line); background: var(--surface); outline: 0;
}
/* แนะนำปุ่มหัวใจ: ภาพเคลื่อนไหวสั้นๆ แทนข้อความอธิบาย */
.how { margin: 4px -16px 0; padding: 20px 16px 22px; background: linear-gradient(180deg, #ffd3ea 0%, var(--bg) 100%); text-align: center; }
.how h1 { font-size: 28px; font-weight: 600; line-height: 1.35; margin-top: 14px; }
.how p { margin-top: 4px; color: var(--text); font-size: 20px; }
.demo { display: flex; align-items: center; justify-content: center; gap: 14px; }
.demo-card { position: relative; width: 84px; padding: 6px; border-radius: 14px; background: var(--surface); box-shadow: 0 6px 18px #e6007e26; }
.demo-card i { display: block; height: 6px; border-radius: 3px; background: var(--surface-2); margin-top: 6px; }
.demo-card i + i { width: 55%; }
.demo-img { height: 56px; border-radius: 9px; background: linear-gradient(135deg, #ffc2e2, #ffe9f4); }
.demo-heart, .demo-pill { display: grid; place-items: center; }
.demo-heart { position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; border-radius: 50%; background: #fff; color: var(--accent); box-shadow: 0 1px 4px #3a132833; animation: demo-tap 3.2s infinite; }
.demo-heart svg { width: 15px; height: 15px; }
.demo-arrow { color: var(--accent); font-size: 22px; animation: demo-fade 3.2s infinite; }
.demo-pill { grid-auto-flow: column; gap: 6px; padding: 8px 14px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 14px; font-weight: 600; box-shadow: 0 6px 16px #e6007e59; animation: demo-pop 3.2s infinite; }
.demo-pill svg { width: 16px; height: 16px; fill: currentColor; }
@keyframes demo-tap { 0%, 30% { background: #fff; color: var(--accent); transform: scale(1); } 40% { transform: scale(.8); } 50%, 90% { background: var(--accent); color: #fff; transform: scale(1.12); } 100% { background: #fff; color: var(--accent); transform: scale(1); } }
@keyframes demo-fade { 0%, 45% { opacity: 0; } 60%, 90% { opacity: 1; } 100% { opacity: 0; } }
@keyframes demo-pop { 0%, 48% { opacity: 0; transform: scale(.6); } 60% { opacity: 1; transform: scale(1.08); } 66%, 90% { opacity: 1; transform: scale(1); } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .demo-heart, .demo-arrow, .demo-pill { animation: none; } .demo-heart { background: var(--accent); color: #fff; } }
.cats { margin-top: 14px; }
.cats { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 4px 16px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cat-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 8px; }
.cat-tile { display: grid; justify-items: center; gap: 8px; font-size: 13px; text-align: center; color: var(--text); }
.cat-tile .circle {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--surface-2); color: var(--accent);
  display: grid; place-items: center; transition: background .15s, color .15s;
}
.cat-tile .circle svg { width: 44px; height: 44px; } /* ไอคอนใหญ่ขึ้น วงกลมยังขนาดเดิม 64px */
.cat-tile.on .circle { background: var(--accent); color: var(--accent-ink); }
.cat-tile.on { color: var(--accent); font-weight: 600; }
#products { scroll-margin-top: var(--topbar-h); min-height: 100dvh; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 12px 0; }
.toolbar select { height: 36px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.thumb { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); font-size: 22px; font-weight: 600; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.soldout .thumb img, .soldout .thumb { opacity: .55; }
.sold-badge { position: absolute; left: 8px; top: 8px; z-index: 1; padding: 2px 9px; border-radius: 999px; background: #000c; color: #fff; font-size: 12px; }
.card .name { margin-top: 8px; font-size: 14px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.price { font-weight: 600; }
.heart {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 38px; height: 38px; border-radius: 50%; background: #fffffff2; color: var(--accent);
  box-shadow: 0 1px 6px #3a132833; font-size: 14px; font-weight: 600;
}
.heart svg { width: 20px; height: 20px; flex: none; }
.heart.on { background: var(--accent); color: var(--accent-ink); }
.heart.on svg { fill: currentColor; }
.heart span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.card .heart { position: absolute; top: 8px; right: 8px; }
.heart[data-long] { width: 100%; height: 48px; border-radius: 14px; border: 1.5px solid var(--accent); box-shadow: none; background: var(--surface); font-size: 16px; }
.heart[data-long].on { background: var(--accent); }
.heart[data-long] span { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
.card { position: relative; display: flex; flex-direction: column; }
.card > a { position: relative; display: block; flex: 1; }
.filters { display: grid; gap: 10px; margin-top: 12px; }
.filters:empty { display: none; }
.filter-row > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.link { color: var(--accent); font-size: 14px; text-decoration: underline; min-height: 36px; margin-bottom: 8px; }
.empty-ico { width: 56px; height: 56px; margin: 0 auto; color: var(--accent); }
.empty-ico svg { width: 100%; height: 100%; }

/* ปุ่มลอย: หัวใจ LINE Messenger */
.fab-dock {
  position: fixed; z-index: 19; right: calc(12px + env(safe-area-inset-right));
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
  display: grid; gap: 10px;
}
.fab {
  position: relative; width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; box-shadow: 0 6px 16px #3a132840;
}
.fab svg { width: 26px; height: 26px; }
.fab-heart { background: var(--accent); }
.fab-line { background: var(--line-green); }
.fab-fb { background: var(--fb-blue); }
.fab-count {
  position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: #fff; color: var(--accent); border: 2px solid var(--accent);
  font-size: 12px; font-weight: 700; line-height: 18px; text-align: center;
}
.fab.bump { animation: bump .35s ease; }
@keyframes bump { 40% { transform: scale(1.18); } }
@media (prefers-reduced-motion: reduce) { .fab.bump { animation: none; } }
.foot-note { margin: 28px 0 0; text-align: center; font-size: 12.5px; color: var(--muted); }

/* หน้าสินค้า */
.product .thumb { border-radius: 18px; font-size: 40px; }
.product h1 { font-size: 20px; font-weight: 600; line-height: 1.35; margin-top: 16px; }
.product .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.product .price { font-size: 24px; }
.status-in { color: #1c8a4b; }
.status-out { color: #c0392b; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: start; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }

/* รายการที่สนใจ */
.list-item { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item .thumb { width: 64px; border-radius: 10px; font-size: 18px; }
.list-item .name { font-size: 14px; line-height: 1.35; }
.warn { color: #b05e00; font-size: 13px; }
.total { display: flex; justify-content: space-between; font-size: 18px; font-weight: 600; margin: 18px 0; }
.remove { min-width: 44px; min-height: 44px; color: var(--muted); font-size: 13px; }

/* รีวิว */
.review { padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.review img { border-radius: 10px; margin-bottom: 10px; }
.review .who { margin-top: 8px; font-size: 13px; color: var(--muted); }

/* แผ่นเลื่อนขึ้นจากด้านล่าง */
.sheet { position: fixed; inset: 0; z-index: 40; background: #3b222980; display: flex; align-items: flex-end; justify-content: center; }
.sheet-body {
  width: 100%; max-width: 720px; max-height: 86dvh; overflow-y: auto;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0; background: var(--surface);
}
.sheet-body h2 { font-size: 17px; font-weight: 600; margin-bottom: 14px; }
.sheet-body .btn:not(.btn-line):not(.btn-fb):not(.btn-accent) { background: var(--surface-2); }
.field { display: grid; gap: 6px; margin-bottom: 16px; font-size: 14px; }
.field > span { color: var(--muted); }
.field select, .field input { height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); width: 100%; min-width: 0; }
.range { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); transform: translateX(-50%); z-index: 50;
  padding: 10px 18px; border-radius: 999px; background: var(--text); color: var(--bg); font-size: 14px; max-width: 90vw; text-align: center;
}

/* แกลเลอรีรูปหน้าสินค้า */
.gallery .thumbs { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
.gallery .thumbs::-webkit-scrollbar { display: none; }
.gallery .thumbs button { flex: none; width: 56px; height: 56px; border-radius: 10px; overflow: hidden; border: 2px solid transparent; opacity: .7; padding: 0; }
.gallery .thumbs button.on { border-color: var(--accent); opacity: 1; }
.gallery .thumbs img { width: 100%; height: 100%; object-fit: cover; }

.fb-msg { margin: 0; padding: 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: 14px; max-height: 30vh; overflow-y: auto; }

/* วิดีโอจากร้าน: แถบเลื่อนซ้ายขวาแบบรีล */
.reels { grid-column: 1 / -1; margin: 8px -16px; padding: 12px 0 4px; background: var(--surface-2); }
.reels .section-title { padding: 0 16px; margin-top: 0; }
.reel-row { display: flex; gap: 12px; overflow-x: auto; padding: 4px 16px 12px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.reel-row::-webkit-scrollbar { display: none; }
.reel { position: relative; flex: none; width: 168px; aspect-ratio: 9 / 16; border-radius: 16px; overflow: hidden; scroll-snap-align: start; background: linear-gradient(160deg, #ff7ab8, #e6007e 55%, #7a3df0); color: #fff; box-shadow: 0 4px 12px #3a132833; }
.reel img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.reel.wide { background: linear-gradient(180deg, #ff9fd0, #e6007e); }
.reel.wide img { top: 50%; bottom: auto; height: auto; aspect-ratio: 16 / 9; transform: translateY(-50%); } /* คลิปแนวนอน: เห็นภาพเต็ม ส่วนที่เหลือเป็นพื้นชมพู */
.reel-play { position: absolute; top: 50%; left: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: #0008; display: grid; place-items: center; }
.reel-play svg { width: 26px; height: 26px; }
.reel-title { position: absolute; left: 0; right: 0; bottom: 0; padding: 28px 10px 10px; font-size: 14px; font-weight: 600; line-height: 1.3; text-align: left; background: linear-gradient(transparent, #000b); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.reel.instagram::after { content: 'Instagram'; position: absolute; top: 10px; left: 10px; padding: 2px 9px; border-radius: 999px; background: #0007; font-size: 12px; }
.player { margin: 0 auto; border-radius: 14px; overflow: hidden; background: #000; }
.player iframe { display: block; width: 100%; height: 100%; border: 0; }
.player.wide { aspect-ratio: 16 / 9; background: var(--surface-2); }
.player.short { aspect-ratio: 9 / 16; max-height: 68dvh; }
.player.ig { height: min(640px, 70dvh); background: #fff; }
