/* หน้าเดียวกว้างเท่ามือถือ: แถบของประจำด้านบน การ์ดโปรด้านล่าง ปุ่มเพิ่มโปรติดขอบล่าง
   ธีมสว่างธีมเดียว พื้นครีมลายจุดชมพูเหมือนรูปปก LINE ป้ายโปรหน้าตาเหมือนป้ายราคาเหลืองบนชั้นวาง */
:root {
  --bg: #FFF6E0;
  --surface: #FFFFFF;
  --surface-2: #FFF9EC;
  --ink: #1B2232;
  --muted: #6B6253;
  --line: #EADFC4;
  --tag: #FFD43B;
  --tag-ink: #1B2232;
  --sale: #E64980;
  --good: #2B8A3E;
  --warn: #C2410C;
  --btn: #1B2232;
  --btn-ink: #FFFFFF;
  --focus: #3B5BDB;
  --f-display: "Mitr", "Noto Sans Thai", Tahoma, sans-serif;
  --f-body: "IBM Plex Sans Thai Looped", "Noto Sans Thai", Tahoma, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { padding-top: env(safe-area-inset-top, 0px); background: var(--bg); }
body {
  margin: 0; color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.5;
  /* ลายหน้าแมวจางๆ สลับฟันปลา */
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cdefs%3E%3Cg id='c' fill='%23F06595' fill-opacity='.13'%3E%3Cpath d='M-6.5 -1.5 L-7.2 -8.5 L-1.8 -5 Z M6.5 -1.5 L7.2 -8.5 L1.8 -5 Z' stroke='%23F06595' stroke-opacity='.13' stroke-width='1' stroke-linejoin='round'/%3E%3Cellipse rx='7.5' ry='6' cy='0.5'/%3E%3C/g%3E%3C/defs%3E%3Cuse href='%23c' x='14' y='15'/%3E%3Cuse href='%23c' x='42' y='43'/%3E%3C/svg%3E") 0 0 / 56px 56px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
img { max-width: 100%; }
[hidden] { display: none !important; }
.wrap { max-width: 560px; margin: 0 auto; padding-block: 20px 120px; display: grid; gap: 18px; }
.stack { display: grid; gap: 10px; }
h1, h2, .num { font-family: var(--f-display); }
h1 { font-size: 26px; font-weight: 600; margin: 0; line-height: 1.2; text-wrap: balance; }
h2 { font-size: 16px; font-weight: 500; margin: 0; }
.sub { color: var(--muted); margin: 2px 0 0; font-size: 14px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ghost { background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.ghost:hover { background: var(--surface-2); }
.ghost.small { padding: 2px 10px; }
.ghost.line-add { background: #06C755; border-color: #06C755; color: #fff; font-weight: 600; }
.ghost.line-add:hover { background: #05B04B; }
.banner { background: var(--surface); border: 1px dashed var(--line); border-radius: 12px; padding: 10px 14px; color: var(--muted); font-size: 14px; }
.meta { font-size: 12.5px; color: var(--muted); margin: 0; }

.watch { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.wchip { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 2px; min-width: 0; }
.wchip b { font-family: var(--f-display); font-weight: 500; font-size: 14px; overflow-wrap: anywhere; }
.wchip span { font-size: 12.5px; color: var(--muted); }
.wchip.has span { color: var(--sale); font-weight: 600; }
.wchip[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.fbtn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13.5px; }
.fbtn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

.hunters { display: grid; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.rank { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.rank li { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 6px; }
.rank .medal { font-size: 20px; line-height: 1; }
.rank b { font-family: var(--f-display); font-weight: 500; overflow-wrap: anywhere; }
.rank .cnt { font-variant-numeric: tabular-nums; color: var(--sale); font-weight: 600; font-size: 14px; }
.pickers { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.pickers select { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 7px 8px; background: var(--surface); font-size: 14px; }
.thead { display: flex; align-items: flex-start; gap: 8px; }
.thead .ctitle { flex: 1; min-width: 0; }
.star { border: 0; background: transparent; font-size: 22px; line-height: 1; padding: 0 2px; color: var(--muted); }
.star.on { color: #F59F00; }
.list { display: grid; gap: 10px; }
.card { background: var(--surface); border-radius: 14px; padding: 12px; display: grid; grid-template-columns: 84px 1fr; gap: 12px; border: 1px solid var(--line); }
.card.mine { border-color: color-mix(in srgb, var(--sale) 45%, var(--line)); }
.card.done { opacity: .55; }
.thumb { width: 84px; height: 84px; border-radius: 10px; background: #fff; border: 1px solid var(--line); padding: 0; overflow: hidden; display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cbody { min-width: 0; display: grid; gap: 4px; }
.ctitle { font-family: var(--f-display); font-weight: 500; font-size: 15.5px; line-height: 1.3; overflow-wrap: anywhere; }
.row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tag { position: relative; background: var(--tag); color: var(--tag-ink); font-family: var(--f-display); font-weight: 600; font-size: 13px; padding: 1px 9px 1px 16px; border-radius: 3px 6px 6px 3px; line-height: 1.6; }
.tag::before { content: ""; position: absolute; left: 5px; top: 50%; width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%; background: var(--surface); }
.pill { font-size: 12px; padding: 0 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); line-height: 1.7; }
.pill.fav { color: var(--sale); background: color-mix(in srgb, var(--sale) 12%, transparent); }
.pill.low { color: #fff; background: var(--good); font-weight: 600; }
.pill.wait { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.price { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.price .num { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.price .num small { font-size: 13px; font-weight: 400; }
.price s { color: var(--muted); font-size: 13px; }
.price .save { color: var(--sale); font-weight: 600; font-size: 13.5px; }
.soon { color: var(--warn); font-weight: 600; }
.place { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.place b { font-weight: 600; }
/* ปุ่ม "นำทาง" (ห้าง) สีเขียวพาสเทล / ปุ่ม "ไปที่ Lazada/Shopee" (ร้านออนไลน์) สีฟ้าพาสเทล */
.go { background: #C9F2D4; color: #1E6B34; border: 1px solid #8FD9A5; border-radius: 999px; padding: 3px 12px; font-size: 13px; text-decoration: none; font-weight: 600; display: inline-flex; gap: 4px; align-items: center; }
.go:hover { background: #B2EBC2; }
.go.shop { background: #D3E7FF; color: #1D4E89; border-color: #9CC4F2; }
.go.shop:hover { background: #BCD9FB; }
.acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.acts button { border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 500; background: var(--surface); }
.act-bought { color: #1E6B34; border: 1px solid #8FD9A5; }
.act-bought.on { background: var(--good); color: #fff; border-color: var(--good); }
.act-report { color: #A3520F; border: 1px solid #F2B47A; }
.act-report.on { background: #FFF1E0; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; background: var(--surface); border-radius: 14px; border: 1px dashed var(--line); }
.more { justify-self: start; }
.loadmore { width: 100%; padding: 12px; font-size: 15px; }
.totop {
  position: fixed; z-index: 6; left: max(16px, env(safe-area-inset-left, 0px)); bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  display: grid; justify-items: center; gap: 0; width: 56px; padding: 6px 0 4px; border-radius: 16px;
  background: var(--tag); color: var(--ink); border: 2px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
  font-family: var(--f-display); font-weight: 600; font-size: 16px; line-height: 1.1;
}
.totop span { font-size: 11px; font-weight: 500; }
.picks { display: grid; gap: 10px; background: var(--surface); border: 2px solid var(--ink); border-radius: 16px; padding: 12px 14px; box-shadow: 0 4px 0 var(--ink); }
.picklist { display: grid; gap: 8px; }
.pick { display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: center; text-align: left; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.pick:hover { border-color: var(--sale); }
.pthumb { width: 56px; height: 56px; border-radius: 8px; background: #fff; overflow: hidden; display: grid; place-items: center; }
.pthumb img { width: 100%; height: 100%; object-fit: contain; }
.pbody { display: grid; gap: 1px; min-width: 0; }
.pbody b { font-family: var(--f-display); font-weight: 500; font-size: 14px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.plabel { justify-self: start; background: var(--tag); font-family: var(--f-display); font-weight: 600; font-size: 12px; padding: 0 8px; border-radius: 6px; }
.pprice { font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.pwhy { font-size: 12px; color: var(--sale); }
.card.flash { box-shadow: 0 0 0 3px var(--sale); transition: box-shadow .3s; }
.reportbox { display: grid; gap: 8px; margin-top: 6px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px dashed var(--line); }
.reportbox b { font-family: var(--f-display); font-weight: 500; font-size: 14px; }
.reasons { display: flex; flex-wrap: wrap; gap: 6px; }
.reasons label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); cursor: pointer; }
.reasons label:has(input:checked) { border-color: var(--sale); color: var(--sale); font-weight: 600; }
.reasons input { accent-color: var(--sale); margin: 0; }
.rnote { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--surface); font-size: 13.5px; }
.reportbox .primary { padding: 6px 16px; font-size: 14px; }
.affnote { margin: 0; padding: 10px 14px; border-radius: 14px; background: #FFEBD6; border: 1px dashed #F2A65A; color: #8A4B12; font-size: 13px; line-height: 1.5; }

.panel { background: var(--surface); border-radius: 16px; border: 1px solid var(--line); padding: 14px; display: grid; gap: 12px; }
.dhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 8px; justify-items: center; text-align: center; color: var(--muted); background: var(--surface-2); }
.drop.over { border-color: var(--ink); }
.drop img { max-height: 220px; border-radius: 8px; }
.drop label { background: var(--btn); color: var(--btn-ink); padding: 8px 16px; border-radius: 999px; cursor: pointer; font-weight: 500; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.primary { background: var(--btn); color: var(--btn-ink); border: 0; border-radius: 999px; padding: 10px 18px; font-weight: 500; font-family: var(--f-display); }
.primary:disabled { opacity: .5; cursor: default; }
.status { font-size: 13.5px; color: var(--muted); min-height: 1em; }
.status.err { color: var(--sale); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid .wide { grid-column: 1 / -1; }
.fld { display: grid; gap: 2px; min-width: 0; }
.fld > span { font-size: 12px; color: var(--muted); }
.fld input, .fld select { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--surface); }
.calc { font-size: 14px; font-weight: 500; }
.calc b { color: var(--sale); }
.wrow { display: grid; grid-template-columns: 1fr 1.4fr auto auto; gap: 6px; }
.wrow input, .wrow select { min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--surface); }
.wrow button { border: 0; background: var(--surface-2); border-radius: 8px; padding: 0 10px; }
#wrows { display: grid; gap: 6px; }

.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
}
.bar .in { max-width: 560px; margin: 0 auto; display: flex; gap: 8px; }
.bar .primary { flex: 1; padding: 12px; font-size: 16px; display: flex; align-items: center; justify-content: center; gap: 8px; }
/* การ์ดหน้าหลักแบบย่อ: กดทั้งการ์ดเพื่อดูรายละเอียด */
.card.mini { cursor: pointer; grid-template-columns: 92px 1fr; align-items: center; }
.card.mini:hover { border-color: var(--sale); }
.card.mini .thumb { width: 92px; height: 92px; }
.card.mini .ctitle { font-size: 14.5px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card.mini .price .num { font-size: 22px; }
.card.mini .save { color: var(--sale); font-weight: 600; font-size: 13px; }
.card.mini .soon { font-size: 12.5px; }
.thumb img.ph { width: 70%; height: 70%; opacity: .85; border-radius: 12px; }
.mfoot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 4px; }
.more-hint { color: var(--sale); font-weight: 600; }

/* หน้ารายละเอียด */
body.noscroll { overflow: hidden; }
.sheet { position: fixed; inset: 0; z-index: 15; background: rgba(27, 34, 50, .45); overflow-y: auto; overscroll-behavior: contain;
  padding: calc(12px + env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); }
.sheet-in { max-width: 560px; margin: 0 auto; background: var(--bg); border-radius: 18px; padding: 12px; display: grid; gap: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.sheet-head { display: flex; }
/* ปุ่มกลับ หน้าตาเดียวกับปุ่ม "บนสุด" */
.backbtn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 16px; background: var(--tag); color: var(--ink);
  border: 2px solid var(--ink); box-shadow: 0 3px 0 var(--ink); font-family: var(--f-display); font-weight: 600; font-size: 15px; }
.sheet .card { grid-template-columns: 1fr; }
.sheet .thumb { width: 100%; height: 240px; }
.sheet .ctitle { font-size: 18px; }
.sheet .price .num { font-size: 28px; }
/* ในหน้ารายละเอียด ปุ่มนำทาง/ไปที่ร้าน เป็นปุ่มหลัก ใหญ่เต็มความกว้าง */
.sheet .place { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet .place > :not(a) { grid-column: 1 / -1; }            /* ข้อความร้าน/ค่าส่ง เต็มบรรทัด */
.sheet .place .go, .sheet .place .ghost { justify-content: center; padding: 8px 14px; font-size: 14.5px; border-radius: 12px; }
.sheet .place .go { order: 2; border-width: 1.5px; box-shadow: 0 2px 0 rgba(27, 34, 50, .14); }   /* นำทาง/ไปที่ร้าน อยู่ขวา */
.sheet .place .ghost { order: 1; }                                                                  /* ดูสินค้า อยู่ซ้าย */
.sheet .place:not(:has(.ghost)) .go { grid-column: 1 / -1; }

.viewer { position: fixed; inset: 0; z-index: 25; background: rgba(10, 12, 18, .86); display: grid; place-items: center; padding: 16px; }
.viewer img { max-height: 90vh; border-radius: 8px; background: #fff; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 8px 16px; border-radius: 999px; font-size: 14px; z-index: 30; max-width: calc(100% - 32px); }
@media (max-width: 380px) { .grid { grid-template-columns: 1fr; } .wrow { grid-template-columns: 1fr 1fr; } .wrow button { padding: 4px; } }
