/* FAH SHOP — mobile first
   ออกแบบให้ใช้บนมือถือเป็นหลัก: ปุ่มอยู่ในระยะนิ้วโป้ง แตะง่าย อ่านสบาย
   หน้าร้านใช้โทนมืดตามแบบอ้างอิง ส่วนหลังบ้านยังปรับตามเครื่องอัตโนมัติ */

:root {
  color-scheme: light dark;

  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-2: #f1f1f4;
  --line: #e5e5ea;
  --line-strong: #d8d8de;
  --fg: #16161a;
  --fg-2: #6e6e78;
  --accent: #4f46e5;
  --accent-fg: #ffffff;
  --accent-soft: #eef0ff;
  --ok: #14804a;
  --ok-soft: #e6f4ec;
  --warn: #b45309;
  --warn-soft: #fdf1e1;
  --err: #c02626;
  --err-soft: #fdeceb;

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --shadow: 0 1px 2px rgba(16, 16, 24, .04), 0 8px 24px -12px rgba(16, 16, 24, .14);
  --shadow-lift: 0 2px 4px rgba(16, 16, 24, .05), 0 18px 40px -20px rgba(16, 16, 24, .28);
  --tap: 48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0d;
    --surface: #141418;
    --surface-2: #1c1c22;
    --line: #26262e;
    --line-strong: #33333d;
    --fg: #f3f3f6;
    --fg-2: #9b9ba6;
    --accent: #8b93f8;
    --accent-fg: #0f0f16;
    --accent-soft: rgba(139, 147, 248, .13);
    --ok: #55d391;
    --ok-soft: rgba(85, 211, 145, .12);
    --warn: #f0b45a;
    --warn-soft: rgba(240, 180, 90, .12);
    --err: #f4796f;
    --err-soft: rgba(244, 121, 111, .12);
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px -12px rgba(0, 0, 0, .7);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, .55), 0 20px 44px -20px rgba(0, 0, 0, .8);
  }
}

/* หน้าร้านและหน้าบัญชีใช้โทนมืดเสมอให้หน้าตาเหมือนกันทุกเครื่อง */
body.storefront-shell {
  color-scheme: dark;
  --bg: #101012;
  --surface: #050506;
  --surface-2: #19191c;
  --line: #29292e;
  --line-strong: #3a3a40;
  --fg: #f5f5f7;
  --fg-2: #a3a3ad;
  --accent: #f4f4f5;
  --accent-fg: #0a0a0c;
  --accent-soft: #242429;
  --ok: #5ddd9a;
  --ok-soft: rgba(93, 221, 154, .13);
  --warn: #f0b45a;
  --warn-soft: rgba(240, 180, 90, .12);
  --err: #f4796f;
  --err-soft: rgba(244, 121, 111, .12);
  --shadow: 0 1px 2px rgba(0, 0, 0, .55), 0 12px 28px -16px rgba(0, 0, 0, .9);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, .6), 0 20px 44px -20px rgba(0, 0, 0, .9);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  /* -apple-system ครอบคลุมภาษาไทยบน iOS, Noto Sans Thai บน Android */
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans Thai", "IBM Plex Sans Thai",
               "Sarabun", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  /* ภาษาไทยมีวรรณยุกต์บน-ล่าง ต้องการระยะบรรทัดมากกว่าอังกฤษ */
  line-height: 1.7;
  letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); text-decoration: none; }
a:active { opacity: .7; }

h1 { font-size: 1.5rem; line-height: 1.35; letter-spacing: -0.02em; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; line-height: 1.45; letter-spacing: -0.01em; margin: 1.5rem 0 .6rem; }
p  { margin: .35rem 0; }

.dim   { color: var(--fg-2); }
.small { font-size: .8125rem; line-height: 1.6; }
.mono  { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; }
.num   { font-variant-numeric: tabular-nums; }   /* ตัวเลขไม่ขยับตอนนับถอยหลัง */
.right { text-align: right; }
.center{ text-align: center; }
.mt    { margin-top: 1rem; }

/* ---------------------------------------------------------- โครงหน้า -- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: max(.7rem, env(safe-area-inset-top)) 1.15rem .7rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--line); }

.site-status {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem;
  width: 100%; max-width: 620px; margin: .75rem auto .35rem; padding: 0 1.15rem;
}
.site-stat {
  display: flex; flex-direction: column; justify-content: center;
  min-width: 0; min-height: 108px; padding: 1rem 1.15rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow); line-height: 1.25;
}
.site-stat-label { color: var(--fg); font-size: .95rem; }
.site-stat-value { display: flex; align-items: baseline; gap: .35rem; min-width: 0; }
.site-stat-value strong {
  color: var(--fg); font-size: clamp(2rem, 9vw, 2.55rem); font-weight: 450;
  letter-spacing: -.045em; line-height: 1.05;
}
.site-stat-value small { color: var(--fg-2); font-size: .9rem; white-space: nowrap; }

.brand {
  color: var(--fg); font-weight: 650; font-size: 1.0625rem;
  letter-spacing: -0.02em; display: flex; align-items: center; gap: .5rem;
}
.brand .dot {
  width: 22px; height: 22px; border-radius: 7px; flex: none;
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #ec4899));
}

.topnav { display: none; align-items: center; gap: .35rem; }
@media (min-width: 760px) { .topnav { display: flex; } }
.topnav a, .topnav button {
  color: var(--fg-2); font-size: .9rem; font-weight: 500;
  padding: .45rem .7rem; border-radius: var(--r-sm);
  background: none; border: 0; font-family: inherit; cursor: pointer;
}
.topnav a:hover, .topnav button:hover { background: var(--surface-2); color: var(--fg); }
.topnav a.on { color: var(--fg); background: var(--surface-2); }

.mobile-logout { display: flex; margin: 0; }

/* กลุ่มปุ่มมุมขวาของแถบบน (ติดตั้งเกม + Logout) */
.topbar-actions { display: flex; align-items: center; gap: .45rem; margin-left: auto; }
@media (min-width: 760px) { .topbar-actions { display: none; } }

/* ปุ่มติดตั้งตัวเกม: ทรงเดียวกับปุ่ม Logout ที่อยู่ข้าง ๆ + ไอคอนไล่สีชุดเดียวกับโลโก้
   (.topnav a ทับสไตล์ปุ่มได้ จึงต้องมี selector ที่เจาะจงกว่าอยู่ในชุดเดียวกัน) */
.install-btn, .topnav .install-btn {
  display: inline-flex; align-items: center; gap: .45rem;
  min-height: 40px; padding: 0 .8rem 0 .55rem;
  color: var(--fg); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 12px;
  font-size: .8125rem; font-weight: 600; white-space: nowrap;
  transition: border-color .15s ease, transform .12s ease, box-shadow .15s ease;
}
.install-btn:hover, .topnav .install-btn:hover {
  color: var(--fg); background: var(--surface-2);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.install-btn:active { transform: scale(.97); }
.install-btn .ic {
  width: 24px; height: 24px; border-radius: 8px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #ec4899));
  color: var(--accent-fg);
}
.install-btn .ic svg { width: 15px; height: 15px; }
/* จอแคบมาก (iPhone SE) เหลือไอคอนอย่างเดียว ไม่ให้แถบบนล้น */
@media (max-width: 379px) {
  .install-btn { padding: 0; width: 40px; justify-content: center; font-size: 0; gap: 0; }
}
.mobile-logout button {
  min-height: 40px; padding: 0 .85rem;
  color: var(--fg); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 12px;
  font: inherit; font-size: .8125rem; font-weight: 600; cursor: pointer;
}
@media (min-width: 760px) { .mobile-logout { display: none; } }

main {
  width: 100%; max-width: 620px; margin: 0 auto; padding: 1rem 1.15rem 2.5rem;
  flex: 1 0 auto;
}
main.wide { max-width: 1100px; }

/* แถบเมนูอยู่ท้ายหน้า ไม่ลอยทับเนื้อหา และซ่อนบนจอใหญ่ */
.tabbar {
  position: static; width: 100%; margin-top: auto; z-index: 30;
  flex: 0 0 auto;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: .3rem .4rem max(.3rem, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
}
@media (min-width: 760px) { .tabbar { display: none; } }
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: 52px; color: var(--fg-2);
  font-size: .6875rem; font-weight: 500; border-radius: 12px;
}
.tabbar a.on { color: var(--accent); }
.tabbar a:active { background: var(--surface-2); }
.tabbar svg { width: 22px; height: 22px; stroke-width: 1.7; }

footer {
  width: 100%; max-width: 620px; margin: 0 auto; padding: 1.5rem 1.15rem 2rem;
  color: var(--fg-2); font-size: .75rem; text-align: center; line-height: 1.8;
}

/* แถบเมนูย่อยของแอดมิน เลื่อนแนวนอนได้บนมือถือ */
.subnav-wrap {
  position: relative; z-index: 15;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.subnav {
  display: flex; gap: .3rem; overflow-x: auto; scrollbar-width: none;
  max-width: 1100px; margin: 0 auto; padding: .5rem 1.15rem;
  -webkit-overflow-scrolling: touch;
}
.subnav::-webkit-scrollbar { display: none; }
.subnav a {
  flex: none; padding: .4rem .8rem; border-radius: 999px;
  font-size: .875rem; font-weight: 500; color: var(--fg-2); white-space: nowrap;
}
.subnav a.on { background: var(--fg); color: var(--bg); }

/* ------------------------------------------------------------ ส่วนประกอบ -- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 1.15rem;
  margin-bottom: .85rem;
  box-shadow: var(--shadow);
}
.card.flush { padding: 0; overflow: hidden; }
.card h2:first-child, .card h1:first-child { margin-top: 0; }

.grid { display: grid; gap: .85rem; }
.grid > .card { margin-bottom: 0; }

/* ปุ่ม: สูง 48px ตามระยะแตะขั้นต่ำ และเต็มความกว้างบนมือถือ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--tap); padding: 0 1.35rem;
  background: var(--accent); color: var(--accent-fg);
  border: 0; border-radius: 14px;
  font: inherit; font-weight: 600; letter-spacing: -0.01em;
  cursor: pointer; text-align: center;
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(.975); opacity: .9; }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn.block { display: flex; width: 100%; }
.btn.ghost {
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--line-strong); box-shadow: var(--shadow);
}
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: var(--err); color: #fff; }
.btn.sm { min-height: 38px; padding: 0 .9rem; font-size: .85rem; border-radius: 11px; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.btn-row > * { flex: 1 1 auto; }

.inline { display: inline; }

/* ฟอร์ม — font-size 16px กัน iOS ซูมเองตอนโฟกัส */
label { display: block; margin: 0 0 .35rem; font-size: .8125rem; font-weight: 500; color: var(--fg-2); }
input, select, textarea {
  width: 100%; min-height: var(--tap);
  padding: .7rem .9rem;
  background: var(--surface-2); color: var(--fg);
  border: 1px solid transparent; border-radius: 13px;
  font: inherit; font-size: 16px;
  transition: border-color .15s ease, background .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
textarea { min-height: 8.5rem; font-family: ui-monospace, Menlo, monospace; font-size: 14px; line-height: 1.6; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--accent); }
input[type="file"] { padding: .55rem .7rem; }
.field { margin-bottom: .85rem; }
.field:last-child { margin-bottom: 0; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.row > div { flex: 1 1 150px; }

/* ป้ายสถานะ */
.tag {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .6rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600; letter-spacing: 0;
  background: var(--surface-2); color: var(--fg-2);
}
.tag.PAID, .tag.SOLD, .tag.AVAILABLE, .tag.RESOLVED, .tag.VERIFIED { background: var(--ok-soft); color: var(--ok); }
.tag.PENDING, .tag.RESERVED, .tag.NEW, .tag.PROCESSING { background: var(--warn-soft); color: var(--warn); }
.tag.REVIEW { background: var(--accent-soft); color: var(--accent); }
.tag.REJECTED, .tag.ERROR { background: var(--err-soft); color: var(--err); }
.tag.CANCELLED, .tag.EXPIRED, .tag.IGNORED { background: var(--surface-2); color: var(--fg-2); }

.flash {
  display: flex; gap: .6rem;
  padding: .85rem 1rem; border-radius: var(--r-sm);
  margin-bottom: .85rem; font-size: .9rem; line-height: 1.6;
  border: 1px solid transparent;
}
.flash.ok   { background: var(--ok-soft);   color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.flash.err  { background: var(--err-soft);  color: var(--err);  border-color: color-mix(in srgb, var(--err) 25%, transparent); }

/* ---- Modal แจ้งผล: เด้งกลางจอ ปิดเองเมื่อสำเร็จ ค้างไว้เมื่อพลาด ---- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 1.25rem calc(1.25rem + env(safe-area-inset-right)) calc(1.25rem + env(safe-area-inset-bottom))
           calc(1.25rem + env(safe-area-inset-left));
  background: rgba(8, 8, 14, .55);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: modal-fade .18s ease-out;
}
.modal-backdrop.closing { animation: modal-fade .16s ease-in reverse; }

.modal {
  width: min(24rem, 100%);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lift);
  padding: 1.6rem 1.4rem 1.2rem; text-align: center;
  animation: modal-pop .22s cubic-bezier(.2, .9, .3, 1.25);
}
@media (prefers-reduced-motion: reduce) {
  .modal-backdrop, .modal, .modal-icon svg { animation: none; }
}

.modal-icon {
  width: 60px; height: 60px; margin: 0 auto .9rem;
  display: grid; place-items: center; border-radius: 50%;
}
.modal-icon svg { width: 30px; height: 30px; stroke-width: 2.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.modal-icon svg path, .modal-icon svg circle {
  stroke-dasharray: 48; stroke-dashoffset: 48;
  animation: modal-draw .45s .1s ease-out forwards;
}
.modal.ok   .modal-icon { background: var(--ok-soft);   color: var(--ok); }
.modal.warn .modal-icon { background: var(--warn-soft); color: var(--warn); }
.modal.err  .modal-icon { background: var(--err-soft);  color: var(--err); }

.modal-title { font-size: 1.12rem; font-weight: 650; letter-spacing: -.015em; margin: 0 0 .35rem; }
.modal-text  { color: var(--fg-2); font-size: .92rem; line-height: 1.65; margin: 0 0 1.15rem; word-break: break-word; }
.modal .btn  { width: 100%; }
.modal-more  { margin-top: .55rem; font-size: .85rem; color: var(--fg-2); }

@keyframes modal-fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes modal-pop  { from { opacity: 0; transform: translateY(14px) scale(.96) } to { opacity: 1; transform: none } }
@keyframes modal-draw { to { stroke-dashoffset: 0 } }

/* รายการแบบแถว แทนตารางบนมือถือ */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: .85rem;
  padding: .95rem 1.15rem; border-bottom: 1px solid var(--line);
  color: inherit; min-height: 60px;
}
.list-item:last-child { border-bottom: 0; }
a.list-item:active { background: var(--surface-2); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 550; letter-spacing: -0.01em; }

.empty { padding: 2.5rem 1.15rem; text-align: center; color: var(--fg-2); }
.empty .big { font-size: 2rem; line-height: 1; margin-bottom: .6rem; opacity: .5; }

/* ------------------------------------------------------------- สินค้า -- */

/* การ์ดสินค้า: ภาพหน้าปกเต็มความกว้าง แล้วค่อยชื่อกับราคา */
.product-card { display: block; padding: 0; overflow: hidden; }
.storefront-shell .product-card { border-radius: var(--r-lg); }
.product-card:active { transform: scale(.99); }

.banner, .hero-banner {
  position: relative;
  aspect-ratio: 16 / 9;          /* ทุกภาพสัดส่วนเท่ากัน หน้าเว็บจึงดูเป็นระเบียบ */
  background: var(--surface-2);
  overflow: hidden;
}
.banner img, .hero-banner img,
.banner-clip {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

/* เบราว์เซอร์ทุกเจ้าห้าม autoplay พร้อมเสียง คลิปจึงเริ่มแบบเงียบ
   แล้วให้ปุ่มนี้เป็น "การกดของผู้ใช้" ที่ปลดล็อกเสียง */
.sound-toggle {
  position: absolute; right: .6rem; bottom: .6rem; z-index: 2;
  width: 40px; height: 40px; padding: 0; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.05rem; line-height: 1;
  background: rgba(8, 8, 12, .55); color: #fff;
  border: 1px solid rgba(255, 255, 255, .22);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  cursor: pointer; transition: transform .15s ease, background .15s ease;
}
.sound-toggle:active { transform: scale(.92); }
.sound-toggle .sound-on { display: none; }
.sound-toggle.on { background: rgba(8, 8, 12, .75); }
.sound-toggle.on .sound-on  { display: block; }
.sound-toggle.on .sound-off { display: none; }
.product-card .banner { height: clamp(190px, 32vw, 270px); aspect-ratio: auto; }
.hero-banner {
  border-radius: var(--r); margin-bottom: 1rem;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.banner .sold-out {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(8, 8, 12, .62);
  color: #fff; font-weight: 600; letter-spacing: .01em;
  backdrop-filter: blur(1.5px);
}

.product-card .body { display: flex; align-items: center; gap: .9rem; padding: .95rem 1.1rem; }
.product-card .name { display: block; font-weight: 620; letter-spacing: -0.01em; font-size: 1.05rem; }
.product-card .thumb {
  width: 52px; height: 52px; border-radius: 14px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent-soft), var(--surface-2));
  color: var(--accent); font-weight: 700; font-size: 1.1rem;
}
.product-card .grow { flex: 1; min-width: 0; }
.price { font-size: 1.25rem; font-weight: 680; letter-spacing: -0.02em; }
.price small { font-size: .75rem; font-weight: 500; color: var(--fg-2); }

/* ตัวเลือกแพ็กเกจ */
.plan {
  display: flex; align-items: center; gap: .85rem;
  padding: .95rem 1.05rem; margin-bottom: .55rem;
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: var(--r); cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.plan:active { transform: scale(.99); }
.plan:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.plan .grow { flex: 1; min-width: 0; }
.plan .title { color: var(--fg); font-size: 1rem; font-weight: 600; }
.plan.out { opacity: .45; pointer-events: none; }
.plan input { flex: none; width: 20px; height: 20px; }

/* ------------------------------------------------------- หน้าชำระเงิน -- */

.pay-hero { text-align: center; padding: 1.6rem 1.15rem; }
.amount {
  font-size: 2.6rem; font-weight: 700; letter-spacing: -0.035em; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.amount .cur { font-size: 1.4rem; font-weight: 600; color: var(--fg-2); vertical-align: .35rem; margin-right: .15rem; }
.amount .sat { color: var(--accent); }

.qr {
  display: inline-block; padding: .9rem; line-height: 0;
  background: #fff; border-radius: var(--r-lg);
  box-shadow: var(--shadow-lift);
}
.qr img { width: min(260px, 62vw); height: auto; display: block; }

.countdown {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, Menlo, monospace;
  font-weight: 600; letter-spacing: .01em;
}
.countdown.warn { color: var(--warn); }
.countdown.over { color: var(--err); }

.bank-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem 0; border-bottom: 1px solid var(--line);
}
.bank-row:last-child { border-bottom: 0; }
.bank-row .k { color: var(--fg-2); font-size: .85rem; flex: none; }
.bank-row .v { font-weight: 550; text-align: right; word-break: break-word; }

/* โลโก้ช่องทางชำระเงิน วางต่อท้ายข้อความ ไม่ดันบรรทัดให้สูงขึ้น */
.pay-logo {
  height: 1.6em; width: auto; vertical-align: -.45em;
  margin-left: .4rem; border-radius: 6px;
}

.keybox {
  padding: .95rem 1.05rem;
  background: var(--surface-2); border: 1px dashed var(--line-strong);
  border-radius: 14px;
  font-family: ui-monospace, Menlo, monospace; font-size: .95rem;
  word-break: break-all; line-height: 1.6;
}
.keybox.revealed { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }

/* ปุ่มซื้อหลักยังติดขอบล่าง แต่ไม่ต้องเผื่อ bottom tab ที่ย้ายไปท้ายหน้าแล้ว */
.sticky-bar {
  position: sticky; bottom: max(.5rem, env(safe-area-inset-bottom));
  margin: 1rem -0.15rem 0; padding: .15rem;
  z-index: 10;
}
@media (min-width: 760px) { .sticky-bar { position: static; } }

/* ------------------------------------------------------------- แอดมิน -- */

.stat { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat-grid { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat-grid .card { margin: 0; padding: .95rem 1.05rem; }
.stat-grid .finance .stat { font-size: clamp(1.3rem, 5vw, 1.75rem); }
.integration-summary {
  display: grid; gap: .65rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.integration-summary p { margin: 0; padding: .7rem; border-radius: var(--r-sm); background: var(--surface-2); }

.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -1.15rem; padding: 0 1.15rem; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { padding: .7rem .55rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { color: var(--fg-2); font-weight: 600; font-size: .75rem; white-space: nowrap; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }

.admin-thumb {
  width: 100%; max-width: 320px; aspect-ratio: 16/9; object-fit: cover;
  border-radius: var(--r-sm); border: 1px solid var(--line); margin-bottom: .8rem; display: block;
}

.bar { height: 8px; border-radius: 4px; background: var(--accent); min-width: 3px; }
.slip { width: 96px; border-radius: var(--r-sm); border: 1px solid var(--line); display: block; }

details > summary {
  cursor: pointer; color: var(--accent); font-size: .875rem;
  list-style: none; padding: .35rem 0;
}
details > summary::-webkit-details-marker { display: none; }

hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }

@media (max-width: 759px) {
  .storefront-shell .topbar {
    top: max(.5rem, env(safe-area-inset-top));
    margin: max(.5rem, env(safe-area-inset-top)) .75rem 0;
    padding: .62rem .8rem;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    border: 1px solid var(--line); border-radius: var(--r-lg);
    box-shadow: var(--shadow);
  }
  .storefront-shell .topbar.scrolled { border-color: var(--line-strong); }

  /* ภาพกว้างเหมือนแบบอ้างอิง แต่จำกัดความสูงไม่ให้กินจอโทรศัพท์ */
  .product-card { display: block; min-height: 0; }
  .product-card .banner {
    width: 100%; height: clamp(140px, 42vw, 180px); min-height: 0; aspect-ratio: auto;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .product-card .body {
    display: flex; align-items: center; gap: .7rem; padding: .75rem .9rem;
  }
  .product-card .body > .right { text-align: right; }
  .product-card .price { font-size: 1.05rem; }
  .hero-banner {
    width: min(100%, 280px); max-height: 158px; margin: .25rem auto 1rem;
  }
  .subnav-wrap { position: relative; top: auto; }
  .tablewrap { border-radius: 0; }
}

@media (max-width: 350px) {
  .product-card .banner { height: 136px; }
  .site-status { gap: .35rem; padding-inline: .75rem; }
  .site-stat { min-height: 96px; padding: .8rem .85rem; }
  .site-stat-value strong { font-size: 1.8rem; }
  .site-stat-value small { font-size: .78rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ------------------------------------------------------------ ยศสมาชิก -- */
/* ใช้โทน การ์ด และตัวแปรสีเดิมของร้าน เพิ่มเฉพาะป้ายยศกับแถบความคืบหน้า */

.rank-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .22rem .6rem; border-radius: 999px;
  font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; white-space: nowrap;
  color: var(--rank, var(--fg-2));
  background: color-mix(in srgb, var(--rank, var(--fg-2)) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--rank, var(--fg-2)) 35%, transparent);
}
.rank-chip.lv1 { --rank: #9b9ba6; }
.rank-chip.lv2 { --rank: #cd7f32; }
.rank-chip.lv3 { --rank: #c3cad8; }
.rank-chip.lv4 { --rank: #f0b45a; }
.rank-chip.lv5 { --rank: #7fd8e8; }
.rank-chip.lv6 { --rank: #8b93f8; }
.rank-chip.lv7 { --rank: #c98bf8; }
.rank-chip.lv8 { --rank: #ff9ecb; }

/* การ์ดยศในหน้าประวัติของสมาชิก */
.rank-card { background:
  linear-gradient(160deg, color-mix(in srgb, var(--accent) 9%, var(--surface)), var(--surface) 60%); }
.rank-head { display: flex; align-items: center; gap: .7rem; }
.rank-title strong { font-size: 1.15rem; letter-spacing: .02em; }
.rank-title .dim { margin-left: .35rem; }
.rank-meta { display: flex; gap: 1.4rem; margin: 1rem 0 .8rem; }
.rank-meta > div { flex: 1 1 0; min-width: 0; }
.rank-num {
  display: block; margin-top: .15rem;
  font-size: clamp(1.35rem, 6vw, 1.7rem); font-weight: 700; letter-spacing: -0.02em;
}
.rank-track {
  height: 10px; border-radius: 999px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--line);
}
.rank-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #ec4899));
  transition: width .4s ease;
}
.rank-next { margin: .65rem 0 0; font-size: .9rem; }

/* จุดเล็ก ๆ ที่ยศไปโผล่ในหน้าอื่น */
.rank-note { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  margin: 0 0 .7rem; font-size: .88rem; color: var(--fg-2); }
.rank-mini { display: flex; align-items: center; gap: .75rem; }
.rank-mini .grow { flex: 1; min-width: 0; }
.rank-legend { display: flex; flex-wrap: wrap; gap: .4rem; }
.rank-edit { margin-bottom: .7rem; padding-bottom: .7rem; border-bottom: 1px solid var(--line); }
.rank-edit:last-of-type { border-bottom: 0; }
.rank-edit-chip { flex: 0 0 auto; }
.rank-edit-active { flex: 0 0 auto; }
.rank-edit-active label { display: flex; align-items: center; gap: .4rem; margin: 0; }

/* ราคาปกติที่ถูกส่วนลดหักแล้ว */
.price .was {
  display: block; font-size: .78rem; font-weight: 500;
  color: var(--fg-2); text-decoration: line-through;
}
.price-breakdown .bank-row.off .v { color: var(--ok); }
.price-breakdown .bank-row.total { border-top: 1px solid var(--line); font-weight: 700; }
.price-breakdown .bank-row.total .v { font-size: 1.1rem; }
