/* สไตล์: เหลืองมัสตาร์ดลายจุด + การ์ดครีมขอบดำหนา + ปุ่มเหลืองมีขอบ (neo-brutalist แบบเป็นมิตร) */
:root {
  --bg: #FFB81C;
  --dot: rgba(27, 27, 27, .26);
  --cream: #FFF3E2;
  --paper: #FFFBF4;
  --ink: #1B1B1B;
  --muted: #6B5F57;
  --lemon: #FFE43A;
  --cyan: #8ED6F0;
  --coral: #E8434A;
  --green: #6CBF4E;
  --blue: #6F8FE8;
  --line: 2.5px solid var(--ink);
  --hard: 4px 4px 0 var(--ink);
  --hard-sm: 3px 3px 0 var(--ink);
  --head: 'Prompt', 'Anuphan', sans-serif;
  --body: 'Anuphan', 'Noto Sans Thai', sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0; min-height: 100vh; font-family: var(--body); color: var(--ink); background: var(--bg);
  background-image: radial-gradient(var(--dot) 1.6px, transparent 1.9px);
  background-size: 18px 18px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.page {
  position: relative; z-index: 1; max-width: 1000px; margin: 0 auto;
  padding: 14px 12px 124px; display: flex; flex-direction: column; gap: 14px;
}
#home { display: flex; flex-direction: column; gap: 18px; }

/* ---------- ตัวช่วยพื้นฐาน ---------- */
.panel {
  position: relative; background: var(--cream); border: var(--line); border-radius: 26px;
  box-shadow: var(--hard); padding: 14px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px;
  border: var(--line); border-radius: 14px; background: var(--lemon); box-shadow: var(--hard-sm);
  font: 700 15px var(--head); color: var(--ink); text-decoration: none; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn svg, .round-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.btn-paper { background: var(--paper); }
.round-btn {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center; padding: 0;
  border: var(--line); border-radius: 50%; background: var(--lemon); color: var(--ink); text-decoration: none;
  cursor: pointer; box-shadow: 2px 2px 0 var(--ink); transition: transform .12s ease, box-shadow .12s ease;
}
.round-btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.round-btn:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 11px; border: 2px solid var(--ink);
  border-radius: 999px; background: var(--paper); font: 600 12.5px/1.5 var(--head);
}
.pill-cyan { background: var(--cyan); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.stitle {
  align-self: flex-start; display: inline-flex; padding: 4px 16px; border: var(--line); border-radius: 999px;
  background: var(--cream); box-shadow: var(--hard-sm); font: 700 16px/1.5 var(--head); margin-bottom: 12px;
}
.red { color: var(--coral); }

/* ---------- หัวหน้า (โปรไฟล์ + ค้นหา) ---------- */
.head { display: flex; flex-direction: column; gap: 12px; }
.appbar { display: flex; align-items: center; gap: 12px; }
.avatar-wrap { position: relative; flex: none; }
.avatar {
  position: relative; display: block; width: 56px; height: 56px; padding: 0; border: var(--line);
  border-radius: 50%; overflow: hidden; background: #E8DFCD; cursor: pointer;
}
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; transform: scale(1.75); transform-origin: 49% 27%; }
.avatar.quack img { animation: wiggle .5s ease-in-out; }
@keyframes wiggle {
  0%, 100% { transform: scale(1.75) rotate(0); }
  20% { transform: scale(1.82) rotate(-7deg); }
  45% { transform: scale(1.82) rotate(6deg); }
  70% { transform: scale(1.78) rotate(-3deg); }
}
.bubble {
  position: absolute; top: -12px; left: 38px; z-index: 3; padding: 4px 12px; border: 2px solid var(--ink);
  border-radius: 14px 14px 14px 4px; background: var(--lemon); font: 700 14px var(--head); white-space: nowrap;
  opacity: 0; transform: translateY(6px) scale(.8); transition: opacity .2s, transform .2s; pointer-events: none;
}
.avatar-wrap.show .bubble { opacity: 1; transform: none; }
.who { flex: 1; min-width: 0; }
.name { font: 700 20px/1.25 var(--head); }
.sub { font-size: 13px; line-height: 1.5; color: var(--muted); }
.en { font: 600 11px/1.4 var(--head); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.lead { font: 700 22px/1.4 var(--head); text-wrap: balance; }

/* ช่องค้นหา */
.search {
  display: flex; align-items: center; gap: 6px; min-height: 54px; padding: 4px 4px 4px 18px;
  border: var(--line); border-radius: 999px; background: var(--paper);
}
.search:focus-within { box-shadow: 0 0 0 3px var(--lemon), var(--hard-sm); }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 8px 0;
  font: 500 16px var(--body); color: var(--ink); -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: #8B7F76; }
.search input::-webkit-search-cancel-button { display: none; }
.clear {
  flex: none; width: 36px; height: 36px; display: grid; place-items: center; padding: 0; border: 0;
  border-radius: 50%; background: rgba(27, 27, 27, .1); cursor: pointer;
}
.clear svg { width: 16px; height: 16px; fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; }
.search .go { width: 44px; height: 44px; }

/* ---------- แท็บหมวดย่อย (ค้างบนหน้าจอ) ---------- */
.tabs {
  position: sticky; top: 10px; z-index: 20; display: flex; gap: 4px; padding: 5px; overflow-x: auto;
  border: var(--line); border-radius: 999px; background: var(--cream); box-shadow: var(--hard-sm);
  scrollbar-width: none; overscroll-behavior-x: contain;
}
.tabs::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 0 14px;
  border: 2px solid transparent; border-radius: 999px; background: transparent; cursor: pointer;
  font: 600 14px var(--head); white-space: nowrap; transition: background .12s;
}
.chip:hover { background: rgba(255, 228, 58, .55); }
.chip i { font-style: normal; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: rgba(27, 27, 27, .1); }
.chip[aria-pressed="true"] { background: var(--lemon); border-color: var(--ink); }
.chip[aria-pressed="true"] i { background: var(--ink); color: #fff; }
.chip.is-zero { opacity: .45; }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.count {
  padding: 7px 14px; border: var(--line); border-radius: 999px; background: var(--cream); box-shadow: var(--hard-sm);
  font: 600 13.5px/1.4 var(--head);
}
.seg {
  display: inline-flex; gap: 2px; padding: 3px; border: var(--line); border-radius: 999px; background: var(--cream);
  box-shadow: var(--hard-sm);
}
.seg button {
  width: 44px; height: 38px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 999px;
  background: transparent; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--lemon); box-shadow: inset 0 0 0 2px var(--ink); }
.seg svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- การ์ดหมวดหน้าแรก ---------- */
.tiles { display: grid; gap: 16px; }
@media (min-width: 720px) { .tiles { grid-template-columns: 1fr 1fr; } }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 10px; padding: 18px; border: var(--line);
  border-radius: 26px; background: var(--cream); box-shadow: var(--hard); transition: transform .15s ease, box-shadow .15s ease;
}
.tile:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.tile > * { position: relative; z-index: 1; }
.tile-deco { position: absolute !important; z-index: 0 !important; right: 12px; top: 12px; width: 96px; height: 96px; pointer-events: none; }
.tile-emoji {
  width: 62px; height: 62px; display: grid; place-items: center; border: var(--line); border-radius: 50%;
  background: var(--c, var(--lemon)); font-size: 30px;
}
.tile-name { font: 700 26px/1.25 var(--head); }
/* ทั้งการ์ดกดได้: ลิงก์ชื่อหมวดยืดคลุมการ์ด (ส่วนหัวต้องไม่ positioned ไม่งั้นลิงก์คลุมแค่ส่วนหัว)
   ส่วนแท็กหมวดย่อยและปุ่ม "ดูทั้งหมด" อยู่ชั้นบนสุด กดแยกได้ */
.tile > .tile-title { position: static; z-index: auto; }
.tile-link { text-decoration: none; }
.tile-link::after { content: ""; position: absolute; inset: 0; border-radius: 26px; z-index: 3; }
.tile > .tile-foot { z-index: auto; }
.tile-tags, .tile-foot .btn { z-index: 4; }
.tile-foot .btn { position: relative; }
.tile-blurb { font-size: 14px; line-height: 1.65; color: #3A332E; }
.tile-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tile-tags a {
  position: relative; z-index: 2; display: inline-flex; align-items: center; gap: 5px; min-height: 36px; padding: 0 12px;
  border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); font: 600 13px var(--head);
  text-decoration: none; transition: background .12s;
}
.tile-tags a:hover { background: var(--lemon); }
.tile-tags i { font-style: normal; font-size: 11.5px; color: var(--muted); }
.tile-foot { margin-top: 6px; display: flex; align-items: center; gap: 10px; }
.stack { display: flex; }
.stack span {
  position: relative; width: 38px; height: 38px; margin-left: -10px; display: grid; place-items: center; overflow: hidden;
  border: var(--line); border-radius: 50%; background: var(--paper); font-size: 17px;
}
.stack span:first-child { margin-left: 0; }
.stack img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile-count { font: 600 14px var(--head); }
.tile-foot .btn { margin-left: auto; }
.tile:hover .tile-foot .btn { background: #FFD60A; }

/* ---------- แถบเลื่อนแนวนอน (พี่เป็ดแนะนำ) ---------- */
.rail {
  display: grid; grid-auto-flow: column; grid-auto-columns: 168px; gap: 12px; margin: 0 -12px; padding: 4px 12px 14px;
  overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 12px; scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail > * { scroll-snap-align: start; }
@media (min-width: 720px) { .rail { grid-auto-columns: 200px; margin: 0; padding-inline: 0; } }

/* ---------- การ์ดสินค้า (มุมมองตาราง) ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 980px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.grid > li { display: flex; }
.card {
  position: relative; display: flex; flex-direction: column; width: 100%; overflow: hidden; border: var(--line);
  border-radius: 20px; background: var(--paper); box-shadow: var(--hard-sm); text-decoration: none; color: inherit;
  transition: transform .12s ease, box-shadow .12s ease;
}
.card:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.card:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.media {
  position: relative; display: grid; place-items: center; aspect-ratio: 1 / 1; border-bottom: var(--line);
  background: var(--c, var(--lemon)); font-size: 46px;
}
.media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.via {
  position: absolute; left: 8px; top: 8px; z-index: 1; display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px 2px 7px; border: 2px solid var(--ink); border-radius: 999px; background: #fff; font: 700 11px/1.5 var(--head);
}
.via::before { content: ""; width: 8px; height: 8px; border: 1.5px solid var(--ink); border-radius: 50%; background: var(--pc, var(--ink)); }
.badge {
  position: absolute; right: 8px; top: 8px; z-index: 1; padding: 2px 9px; border: 2px solid var(--ink); border-radius: 999px;
  background: var(--coral); color: #fff; font: 700 11px/1.5 var(--head);
}
.body { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 12px; }
.txt { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.tag {
  align-self: flex-start; padding: 1px 10px; border: 2px solid var(--ink); border-radius: 999px;
  background: var(--c, var(--lemon)); font: 600 11.5px/1.6 var(--head);
}
.card-name {
  font: 600 15px/1.4 var(--head); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-detail {
  font-size: 12.5px; line-height: 1.5; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.note { padding: 7px 10px; border: 2px dashed var(--ink); border-radius: 4px 12px 12px 12px; background: #FFF1B8; font-size: 12.5px; line-height: 1.5; }
.note b { font-family: var(--head); font-weight: 600; color: var(--coral); }
.cta {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 10px;
  border: 2.5px solid var(--ink); border-radius: 12px; background: var(--lemon); box-shadow: 2px 2px 0 var(--ink);
  font: 700 14px var(--head); transition: background .12s;
}
.cta svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.card:hover .cta, .row:hover .row-go { background: #FFD60A; }
.is-draft { outline: 3px dashed var(--coral); outline-offset: -3px; }
.is-draft::after {
  content: "ตัวอย่าง · ยังไม่ขึ้นเว็บจริง"; position: absolute; left: 0; right: 0; bottom: 0; padding: 3px; background: var(--coral);
  color: #fff; font-size: 11px; text-align: center;
}

/* ---------- แถวสินค้า (มุมมองรายการ) ---------- */
.rows {
  width: 100%; max-width: 780px; margin: 0 auto; padding: 0; list-style: none; overflow: hidden;
  border: var(--line); border-radius: 22px; background: var(--paper); box-shadow: var(--hard);
}
.rows > li + li { border-top: 2.5px solid var(--ink); }
.row {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 76px; padding: 10px 12px;
  text-decoration: none; color: inherit; transition: background .12s;
}
.row:hover { background: #FFF0C2; }
.thumb {
  position: relative; flex: none; width: 56px; height: 56px; display: grid; place-items: center; overflow: hidden;
  border: var(--line); border-radius: 50%; background: var(--c, var(--lemon)); font-size: 26px;
}
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.row .txt { flex: 1; min-width: 0; gap: 2px; }
.row-name { font: 600 15px/1.4 var(--head); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-sub { font-size: 12.5px; line-height: 1.5; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub b { color: var(--ink); font-family: var(--head); font-weight: 600; }
.row-go { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border: var(--line); border-radius: 50%; background: var(--lemon); }
.row-go svg { width: 18px; height: 18px; fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- ไม่พบข้อมูล ---------- */
.empty { padding: 28px 18px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-emoji { font-size: 46px; line-height: 1; }
.empty h3 { font: 700 20px/1.4 var(--head); }
.empty p { color: var(--muted); font-size: 14px; line-height: 1.6; }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 8px; }

/* ---------- ท้ายหน้า ---------- */
.note-box {
  padding: 14px 18px; border: 2.5px dashed var(--ink); border-radius: 20px; background: rgba(255, 243, 226, .85);
  font-size: 13px; line-height: 1.7; color: #3A332E; text-align: center;
}
.note-box strong { display: block; font: 700 15px var(--head); color: var(--ink); }

/* ---------- แถบเมนูล่าง ---------- */
.dock {
  position: fixed; left: 50%; bottom: 12px; z-index: 40; transform: translateX(-50%);
  display: flex; gap: 2px; width: min(calc(100vw - 24px), 440px); padding: 6px;
  border: var(--line); border-radius: 26px; background: var(--cream); box-shadow: var(--hard);
}
.dock > * {
  flex: 1; min-width: 0; min-height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 0 4px; border: 0; border-radius: 18px; background: transparent; cursor: pointer; text-decoration: none;
  font: 600 12px/1.2 var(--head); color: var(--ink);
}
.dock > *:hover { background: rgba(255, 228, 58, .45); }
.dock svg { width: 23px; height: 23px; fill: none; stroke: var(--ink); stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.dock span { max-width: 100%; padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock [aria-current="page"] svg { fill: var(--lemon); }
.dock [aria-current="page"] span {
  background: linear-gradient(transparent 56%, var(--lemon) 56%, var(--lemon) 92%, transparent 92%);
}

/* ปุ่มกลับขึ้นบน + ข้อความแจ้ง */
.fab {
  position: fixed; right: 16px; bottom: 96px; z-index: 41; width: 54px; height: 54px; display: grid; place-items: center; padding: 0;
  border: var(--line); border-radius: 50%; background: var(--lemon); box-shadow: var(--hard-sm); cursor: pointer;
  opacity: 0; transform: translateY(12px) scale(.9); pointer-events: none; transition: opacity .2s, transform .2s;
}
.fab.show { opacity: 1; transform: none; pointer-events: auto; }
.fab svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.toast {
  position: fixed; left: 50%; bottom: 100px; z-index: 60; max-width: calc(100vw - 32px); padding: 10px 18px;
  border: 2px solid var(--ink); border-radius: 999px; background: var(--ink); color: #fff; font: 600 14px var(--head);
  opacity: 0; transform: translate(-50%, 10px); pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- ลายเรขาคณิตด้านข้าง (จอกว้างเท่านั้น) ---------- */
.bg-deco { position: fixed; inset: 0; z-index: 0; display: none; pointer-events: none; }
.bg-deco svg { position: absolute; }
@media (min-width: 1280px) { .bg-deco { display: block; } }

@media (prefers-reduced-motion: reduce) {
  .avatar.quack img { animation: none; }
  .btn, .round-btn, .tile, .card, .fab, .toast, .bubble { transition: none; }
}
