/* YayBill LINE app — หน้าแบบแอปค้นหา (ไม่เลียนหน้าแชท LINE) · สงวนลิขสิทธิ์ */
:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --ink: #1c1b1a;
  --muted: #66625b;
  --line: #e4e1d8;
  --brand: #3d38a8;
  --brand-ink: #ffffff;
  --deal-bg: #ecebfb;
  --deal-ink: #2f2b87;
  --warn-bg: #fdf1dc;
  --warn-ink: #7a4a05;
  --tap: #efede6;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514;
    --surface: #201f1d;
    --ink: #f2f0ea;
    --muted: #a9a59b;
    --line: #34322e;
    --brand: #8f8af0;
    --brand-ink: #141238;
    --deal-bg: #2c2a5c;
    --deal-ink: #d9d7ff;
    --warn-bg: #3a2c12;
    --warn-ink: #f6d59a;
    --tap: #2a2926;
    color-scheme: dark;
  }
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans Thai", system-ui, -apple-system, "Noto Sans Thai", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
button,
input {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 20px 0 8px;
}

/* แถบบน: ย้อนกลับ · ชื่อหน้า · บัตรของฉัน */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.top h1 {
  flex: 1;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.iconbtn {
  width: 44px;
  height: 44px;
  margin-left: -10px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: none;
}
.iconbtn[hidden] {
  display: none;
}
.walletbtn {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  white-space: nowrap;
}
main {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px calc(24px + env(safe-area-inset-bottom));
}

/* ค้นหา (ช่องใหญ่ + รายการแนะนำ) */
.searchwrap {
  position: relative;
  z-index: 4;
}
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 0 16px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--muted);
}
.search:focus-within {
  border-color: var(--brand);
}
.search svg {
  width: 26px;
  height: 26px;
}
.search input {
  flex: 1;
  min-width: 0;
  height: 60px;
  border: 0;
  outline: 0;
  background: none;
  font-size: 19px;
  color: var(--ink);
}
.suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}
.suggest[hidden] {
  display: none;
}
.opt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 8px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
}
.opt:last-child {
  border-bottom: 0;
}
.opt:active {
  background: var(--tap);
}

/* ร้านใกล้คุณ */
.locate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  margin-top: 12px;
  border: 0;
  border-radius: 14px;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 600;
}
.small {
  font-size: 13px;
  text-align: center;
  margin: 6px 0 0;
}
.muted {
  color: var(--muted);
}
.pad {
  padding: 8px 2px;
}
.warn {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-size: 14px;
}
.link {
  width: 100%;
  min-height: 44px;
  border: 0;
  background: none;
  color: var(--brand);
  font-weight: 600;
}

/* แถวร้าน */
.list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}
.shop {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
}
.shop:last-child {
  border-bottom: 0;
}
.shop:active,
.tile:active,
.chip:active {
  background: var(--tap);
}
.ic {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--tap);
}
.mid {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.name {
  font-weight: 500;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.sub {
  font-size: 13px;
  color: var(--muted);
}
.deal {
  flex: 0 1 auto;
  max-width: 45%;
  padding: 4px 10px;
  border-radius: 10px;
  background: var(--deal-bg);
  color: var(--deal-ink);
  font-size: 13px;
  font-weight: 600;
  text-align: right;
}

/* สถานการณ์ */
.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.tile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  text-align: left;
  font-size: 15px;
  line-height: 1.3;
}
.tile svg {
  flex: 0 0 auto;
  color: var(--brand);
}
.credit {
  margin: 24px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.prose {
  white-space: pre-wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

/* ยอดชำระ */
.amounts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.amounts .label {
  width: 100%;
  font-size: 14px;
  color: var(--muted);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.chip {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 15px;
}
.chip.on {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 600;
}
.own {
  width: 110px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

/* การ์ดคำตอบ: เรียงลงล่าง (ไม่ใช่กล่องแชท) */
.answer {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.answer .row,
.answer .carousel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.answer .say {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  white-space: pre-wrap;
}
.bubble {
  display: flex;
  flex-direction: column;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  color: #111;
  border: 1px solid var(--line);
}
.answer .carousel:has(.bubble.micro) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.bubble .body {
  flex: 1;
}
.box {
  display: flex;
  min-width: 0;
}
.box.v {
  flex-direction: column;
}
.box.h {
  flex-direction: row;
  align-items: flex-start;
}
.t {
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.35;
}
.sep {
  border-top: 1px solid #e5e7eb;
}
.btn {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
}
.btn.primary {
  background: #3d38a8;
  color: #fff;
}
.btn.secondary {
  background: #eeedf6;
  color: #111;
}
.btn.link {
  background: none;
  color: #3d38a8;
}
.tap {
  cursor: pointer;
}

.lineonly {
  max-width: 420px;
  margin: 18vh auto;
  padding: 24px 16px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.lineonly .open {
  display: inline-block;
  margin-top: 12px;
  padding: 12px 24px;
  border-radius: 12px;
  background: var(--brand);
  color: var(--brand-ink);
  text-decoration: none;
  font-weight: 600;
}
.err {
  text-align: center;
  color: #b91c1c;
}
