/* MEDSWU42 Merchandise · พื้นขาว + เวทีรูปเทาเย็น + เขียวป่าเป็นสีเดียวที่ทำงาน (ปุ่ม หัวตาราง ตัวเลือก) */
:root {
  --font-sans: 'Anuphan', ui-sans-serif, system-ui, sans-serif;
  --font-serif: 'Source Serif 4', 'Anuphan', ui-serif, serif;
  --ink: #15201b;
  --ink-2: #4a5650;
  --ink-3: #66716b;
  --line: #e3e8e5;
  --line-soft: #eef1ef;
  --stage: #f2f3f5;
  --green: #1f4a3a;
  --green-deep: #183c2f;
  --green-hover: #163729;
  --green-ink: #2a6a4f;
  --mint: #eaf6ee;
  --mint-soft: #f4faf6;
  --mint-line: #d6eadd;
  --leaf: #bfe3cd;
  --danger: #b3261e;
  /* แดงเลือดหมู = สีของปุ่มและตัวควบคุมทุกชิ้น · เขียวเหลือไว้ที่ราคา หัวตาราง และสถานะ */
  --wine: #7b1e2e;
  --wine-hover: #63172a;
  --wine-ink: #8a2536;
  --wine-soft: #fbf3f4;
  --wine-tint: #f6e4e7;
  --wine-line: #ebcfd4;
  --wine-pale: #f3cdd3;
  --r-xl: 28px;
  --r-lg: 18px;
  --r: 12px;
  --r-sm: 10px;
  --r-pill: 9999px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-lift: 0 30px 70px -30px rgba(12, 30, 22, 0.45), 0 8px 20px -12px rgba(12, 30, 22, 0.2);
  color-scheme: light;
  accent-color: var(--wine);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100svh; display: flex; flex-direction: column; background: #ffffff; color: var(--ink);
  font-family: var(--font-sans); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; color: var(--ink); }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
* { -webkit-tap-highlight-color: transparent; }
#view { flex: 1 0 auto; outline: none; }
::selection { background: #cfe8da; color: var(--ink); }
input, textarea { caret-color: var(--wine); }
* { scrollbar-width: thin; scrollbar-color: #c9d2cd transparent; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
.ic { flex: none; }
.serif-price { font-family: var(--font-serif); font-style: italic; font-weight: 400; font-variant-numeric: lining-nums; letter-spacing: -0.01em; }
:focus-visible { outline: 3px solid rgba(123, 30, 46, 0.4); outline-offset: 2px; }

.skip { position: absolute; left: 12px; top: -60px; z-index: 50; padding: 10px 14px; border-radius: var(--r-sm); background: var(--wine); color: #fff; }
.skip:focus { top: 12px; }

/* ---- ปุ่ม/ช่องกรอก ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 22px; border: 0; border-radius: var(--r);
  background: var(--wine); color: #fff; font-weight: 600; font-size: 16px; cursor: pointer;
  transition: background-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.btn:hover { background: var(--wine-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { background: #c9d1cd; color: #f6f8f7; cursor: not-allowed; transform: none; }
.btn-ghost { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-ghost:hover { background: var(--wine-soft); box-shadow: inset 0 0 0 1.5px var(--wine-line); }
.btn-light { background: #fff; color: var(--wine); }
.btn-light:hover { background: var(--wine-tint); }
.btn-sm { height: 38px; padding: 0 14px; font-size: 14.5px; border-radius: var(--r-sm); }
.btn-danger { background: #fff; color: var(--danger); box-shadow: inset 0 0 0 1.5px #f0d3d0; }
.btn-danger:hover { background: #fdf3f2; }
.link-btn {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 0; border: 0; background: none;
  color: var(--wine-ink); font-weight: 600; font-size: 14px; cursor: pointer;
  text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 4px; transition: text-decoration-color 160ms ease;
}
.link-btn:hover { text-decoration-color: currentColor; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--ink); cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}
.icon-btn:hover { background: var(--wine-soft); border-color: var(--wine-line); }
.icon-btn:active { transform: scale(0.95); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.field small { font-size: 12.5px; color: var(--ink-3); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: var(--r-sm);
  background: #fff; color: var(--ink); font-size: 15px; transition: border-color 160ms ease, box-shadow 160ms ease;
}
.field textarea { resize: vertical; line-height: 1.55; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--wine-ink); box-shadow: 0 0 0 3px rgba(123, 30, 46, 0.12); }
.field input[readonly] { background: var(--stage); color: var(--ink-3); }
.field input[type="color"] { padding: 4px; height: 44px; cursor: pointer; }
.field input::placeholder, .field textarea::placeholder { color: #9aa49f; }

/* ---- header ---- */
.bar {
  position: sticky; top: 0; z-index: 20; height: 64px; padding: 0 max(20px, env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: rgba(255, 255, 255, 0.96); transition: box-shadow 200ms ease;
}
.bar.is-scrolled { box-shadow: 0 1px 0 var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand img { width: 32px; height: 32px; }
.brand-word { font-weight: 700; font-size: 17px; letter-spacing: 0.01em; }
.brand-sub { font-family: var(--font-serif); font-style: italic; font-size: 19px; color: var(--green-ink); margin-left: -3px; }
.bar-actions { display: flex; align-items: center; gap: 4px; }
#accountSlot { display: contents; }
.bar-btn {
  position: relative; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  border: 0; border-radius: var(--r-pill); background: none; color: var(--ink-2); font-size: 14.5px; font-weight: 500; cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}
.bar-btn:hover, .bar-btn[aria-current="page"] { background: var(--stage); color: var(--ink); }
.bar-ic { display: inline-grid; }
.bar-cart { background: var(--wine); color: #fff; padding: 0 16px; }
.bar-cart:hover, .bar-cart[aria-current="page"] { background: var(--wine-hover); color: #fff; }
.cart-count {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; margin-right: -6px;
  border-radius: 11px; background: #fff; color: var(--wine); font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.cart-count.bump { animation: bump 420ms var(--ease-out); }
@keyframes bump { 30% { transform: scale(1.35); } }
.avatar {
  position: relative; display: inline-grid; place-items: center; width: 28px; height: 28px; overflow: hidden;
  border-radius: 50%; background: var(--mint); color: var(--green); font-size: 13px; font-weight: 700;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.bar-me { padding-left: 6px; }
.bar-login { box-shadow: inset 0 0 0 1.5px var(--line); }
/* เมนูบัญชี */
.me { position: relative; }
.me-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; min-width: 240px; padding: 8px; border-radius: 16px;
  background: #fff; box-shadow: var(--shadow-lift), 0 0 0 1px var(--line-soft); animation: pd-in 220ms var(--ease-out);
}
.me-menu[hidden] { display: none; }
.me-who { display: grid; gap: 2px; padding: 10px 12px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line-soft); }
.me-who span { font-size: 13.5px; color: var(--ink-3); word-break: break-all; }
.me-menu [role=menuitem] {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 0 12px; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--ink); font-size: 15px; text-align: left; cursor: pointer;
}
.me-menu [role=menuitem]:hover, .me-menu [role=menuitem]:focus-visible { background: var(--stage); outline: none; }
.me-out { color: var(--danger) !important; }

/* ---- โฆษณาตัวใหญ่: แผงเวทีเทาเต็มความกว้าง ข้อความซ้าย เสื้อขวา · มีรูปโฆษณา = รูปเต็มแผง ---- */
.home { width: min(1280px, 100% - 32px); margin: 8px auto 0; }
.hero {
  position: relative; overflow: hidden; border-radius: var(--r-xl); background: var(--stage);
  min-height: clamp(480px, calc(100svh - 96px), 760px);
}
.hero-track { position: absolute; inset: 0; }
.slide {
  position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr); align-items: center;
  gap: clamp(16px, 3vw, 40px); padding: clamp(32px, 5vw, 72px); visibility: hidden;
}
.slide.is-on { visibility: visible; }
.slide-copy { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: flex-start; gap: 16px; max-width: 36rem; padding-bottom: 48px; }
.slide-status {
  display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 6px 12px 6px 10px; border-radius: var(--r-pill);
  background: #fff; color: var(--green-ink); font-size: 14px; font-weight: 600; box-shadow: inset 0 0 0 1px var(--mint-line);
}
.slide-name { font-size: clamp(2.75rem, 6vw, 5.5rem); line-height: 1; letter-spacing: -0.025em; font-weight: 700; text-wrap: balance; }
.slide-tagline { margin: -2px 0 0; color: var(--ink-2); font-size: clamp(16px, 1.4vw, 19px); max-width: 32ch; text-wrap: pretty; }
.slide-price { margin: 4px 0 0; color: var(--green-ink); font-size: clamp(2.2rem, 3.8vw, 3.4rem); line-height: 1; }
.slide-copy .btn { margin-top: 10px; height: 56px; padding: 0 32px; font-size: 17px; box-shadow: 0 12px 24px -14px rgba(99, 23, 42, 0.8); }
.slide-art { position: relative; align-self: stretch; display: grid; place-items: center; min-height: 0; }
.hero-tee {
  width: min(92%, 600px); max-height: 92%; object-fit: contain; rotate: -5deg;
  filter: drop-shadow(0 30px 30px rgba(20, 32, 27, 0.16));
}
.slide.is-ad { display: block; padding: 0; }
.ad { position: absolute; inset: 0; display: block; }
.ad:focus-visible { outline-offset: -4px; }
.hero-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slide.is-ad.is-on .ad { animation: fade 700ms ease both; }

/* ป้ายแขวนราคาตามจำนวน */
.hangtag {
  position: absolute; right: 4%; top: 10%; z-index: 3; width: 156px; padding: 30px 16px 14px;
  border-radius: 14px; background: #fff; color: var(--ink); rotate: 7deg; transform-origin: 50% 0;
  box-shadow: 0 18px 32px -16px rgba(20, 32, 27, 0.35), 0 0 0 1px rgba(20, 32, 27, 0.04);
}
.hangtag::before {
  content: ''; position: absolute; left: 50%; bottom: 100%; width: 1.5px; height: 64px; margin-left: -1px;
  background: linear-gradient(rgba(74, 86, 80, 0.15), rgba(74, 86, 80, 0.5)); transform-origin: bottom; rotate: -16deg;
}
.hangtag-hole { position: absolute; top: 11px; left: 50%; width: 11px; height: 11px; margin-left: -5.5px; border-radius: 50%; background: var(--green); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4); }
.hangtag dl { margin: 0; display: grid; gap: 7px; }
.hangtag dl div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; border-top: 1px dashed var(--line); padding-top: 7px; }
.hangtag dl div:first-child { border-top: 0; padding-top: 0; }
.hangtag dt { font-size: 12.5px; color: var(--ink-3); font-weight: 500; }
.hangtag dd { margin: 0; font-family: var(--font-serif); font-style: italic; font-size: 20px; color: var(--green-ink); line-height: 1; }

/* การเปลี่ยนสไลด์: เสื้อเลื่อนเข้าจากขวา ข้อความลอยขึ้น */
.slide .slide-copy > *, .slide .slide-art { opacity: 0; }
.slide.is-on .slide-copy > * { animation: rise 700ms var(--ease-out) both; }
.slide.is-on .slide-copy > :nth-child(2) { animation-delay: 60ms; }
.slide.is-on .slide-copy > :nth-child(3) { animation-delay: 110ms; }
.slide.is-on .slide-copy > :nth-child(4) { animation-delay: 150ms; }
.slide.is-on .slide-copy > :nth-child(5) { animation-delay: 190ms; }
.slide.is-on .slide-art { animation: tee-in 900ms var(--ease-out) both; }
.slide.is-on .hangtag { animation: swing 1600ms 300ms var(--ease-out) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes tee-in { from { opacity: 0; transform: translateX(48px) rotate(3deg); } to { opacity: 1; transform: none; } }
@keyframes swing { 0% { rotate: 18deg; } 45% { rotate: 2deg; } 75% { rotate: 9deg; } 100% { rotate: 7deg; } }

.hero-nav { position: absolute; z-index: 4; left: clamp(32px, 5vw, 72px); bottom: clamp(24px, 3vw, 40px); display: flex; align-items: center; gap: 14px; }
.hero-nav .icon-btn { width: 38px; height: 38px; }
.hero:has(.is-ad.is-on) .hero-nav { padding: 6px 10px; border-radius: var(--r-pill); background: rgba(255, 255, 255, 0.9); }
.hero-dots { display: flex; gap: 6px; }
.dot { position: relative; width: 26px; height: 24px; padding: 0; border: 0; background: none; cursor: pointer; }
.dot i { position: absolute; left: 0; right: 0; top: 50%; height: 3px; margin-top: -1.5px; overflow: hidden; border-radius: 2px; background: rgba(21, 32, 27, 0.14); }
.dot[aria-current="true"] i::after { content: ''; position: absolute; inset: 0; background: var(--wine); transform-origin: left; }
.hero.is-ticking .dot[aria-current="true"] i::after { animation: tick var(--progress-ms, 6s) linear both; }
.hero.is-paused .dot[aria-current="true"] i::after { animation-play-state: paused; }
@keyframes tick { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---- หน้าแรก: รายการสินค้า ---- */
.catalog { padding: 56px 0 96px; }
.catalog-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 24px; }
.catalog-head h1 { font-size: clamp(1.6rem, 2.6vw, 2.1rem); letter-spacing: -0.01em; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: var(--r-pill);
  background: #fff; color: var(--ink-2); font-size: 14.5px; font-weight: 500; cursor: pointer; transition: all 160ms ease;
}
.chip span { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.chip:hover { border-color: #c6d0ca; color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--wine); border-color: var(--wine); color: #fff; }
.chip[aria-pressed="true"] span { color: var(--wine-pale); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 36px 22px; }
.card { display: flex; flex-direction: column; gap: 14px; color: inherit; }
.card-stage { position: relative; aspect-ratio: 1 / 1.06; border-radius: var(--r-lg); background: var(--stage); perspective: 1400px; overflow: hidden; }
.card-flip { position: absolute; inset: 7%; transform-style: preserve-3d; transition: transform 800ms var(--ease-out); }
.card-face { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; backface-visibility: hidden; transition: scale 500ms var(--ease-out); }
.card-back { transform: rotateY(180deg); }
.card-noimg { position: absolute; inset: 0; display: grid; place-items: center; color: #b7c0bb; }
@media (hover: hover) {
  .card.can-flip:hover .card-flip { transform: rotateY(180deg); }
  .card:not(.can-flip):hover .card-face { scale: 1.04; }
}
.card:focus-visible { outline: none; }
.card:focus-visible .card-stage { outline: 3px solid rgba(123, 30, 46, 0.4); outline-offset: 3px; }
.card-body { display: grid; gap: 4px; padding: 0 2px; }
.card-name { font-size: 16.5px; font-weight: 600; letter-spacing: 0.005em; }
.card-price { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 0; color: var(--green-ink); font-size: 22px; line-height: 1.2; }
.card-from { font-size: 13px; color: var(--green-ink); font-weight: 500; padding: 2px 8px; border-radius: var(--r-pill); background: var(--mint); }
.card-meta { margin: 0; font-size: 13.5px; color: var(--ink-3); }
.swatches { display: flex; gap: 6px; margin: 4px 0 0; }
.swatches i { width: 14px; height: 14px; border-radius: 50%; background: var(--swatch); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18); }
.badge { position: absolute; top: 12px; left: 12px; padding: 4px 10px; border-radius: var(--r-pill); font-size: 12.5px; font-weight: 600; }
.badge-out { background: var(--ink); color: #fff; }
.card.is-skeleton .card-stage { animation: shimmer 1.4s ease-in-out infinite; }

/* ---- สถานะว่าง/โหลด ---- */
.empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 72px 20px; text-align: center; color: var(--ink-3); }
.empty h1, .empty h2 { font-size: 22px; color: var(--ink); }
.empty p { margin: 0 0 10px; max-width: 42ch; color: var(--ink-2); text-wrap: pretty; }
.sk { border-radius: var(--r-sm); background: var(--stage); animation: shimmer 1.4s ease-in-out infinite; }
.sk-line { height: 18px; width: 70%; }
.sk-short { height: 18px; width: 35%; }
.sk-title { height: 40px; width: 60%; margin-top: 8px; }
.sk-price { height: 32px; width: 25%; margin-top: 14px; }
.sk-block { height: 260px; margin-top: 28px; border-radius: var(--r-lg); }
@keyframes shimmer { 50% { opacity: 0.55; } }

/* ---- หน้าต่างสินค้า ---- */
.pd {
  width: min(1160px, 100vw - 48px); height: min(940px, 100dvh - 40px); max-width: none; max-height: none;
  padding: 0; border: 0; border-radius: var(--r-xl); background: #fff; color: var(--ink); overflow: hidden;
  box-shadow: var(--shadow-lift);
}
.pd::backdrop { background: rgba(14, 24, 19, 0.5); }
.pd[open] { animation: pd-in 420ms var(--ease-out); }
.pd[open]::backdrop { animation: fade 300ms ease; }
@keyframes pd-in { from { opacity: 0; transform: translateY(18px) scale(0.975); } }
@keyframes fade { from { opacity: 0; } }
html:has(.pd[open]), html:has(.signin[open]) { overflow: hidden; }

.pd-shell { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); height: 100%; }
.pd-media { position: relative; display: grid; place-items: center; background: var(--stage); min-height: 0; }
.pd-stage { width: 100%; height: 100%; display: grid; place-items: center; perspective: 1800px; }
.pd-flip { position: relative; width: min(92%, 620px); aspect-ratio: 600 / 640; transform-style: preserve-3d; transition: transform 900ms var(--ease-out); }
.pd-flip.is-back { transform: rotateY(180deg); }
.pd-face { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; backface-visibility: hidden; }
.pd-back { transform: rotateY(180deg); }
.pd-flipbtn { position: absolute; top: 22px; left: 22px; box-shadow: 0 2px 8px rgba(12, 30, 22, 0.08); }
.pd-flipbtn .ic { transition: rotate 600ms var(--ease-out); }
.pd-flipbtn[aria-pressed="true"] .ic { rotate: -180deg; }
.pd-side { position: absolute; bottom: 20px; left: 50%; translate: -50% 0; display: flex; padding: 3px; border-radius: var(--r-pill); background: rgba(255, 255, 255, 0.85); box-shadow: 0 1px 0 rgba(20, 32, 27, 0.06), inset 0 0 0 1px var(--line); }
.pd-side[hidden] { display: none; }
.pd-side button { height: 32px; padding: 0 14px; border: 0; border-radius: var(--r-pill); background: none; color: var(--ink-2); font-size: 13.5px; font-weight: 500; cursor: pointer; transition: background-color 200ms ease, color 200ms ease; }
.pd-side button[aria-pressed="true"] { background: var(--wine); color: #fff; }

.pd-info { position: relative; display: flex; flex-direction: column; min-height: 0; padding-top: 58px; }
.pd-x { position: absolute; top: 22px; right: 22px; z-index: 2; }
.pd-scroll:focus { outline: none; }
/* ขอบล่างจาง: บอกว่ายังเลื่อนดูต่อได้ (มือถือปิด เพราะทั้งหน้าเลื่อนเป็นชิ้นเดียว) */
.pd-scroll { mask-image: linear-gradient(#000 calc(100% - 28px), transparent); }
.pd-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0 44px 20px 36px; overscroll-behavior: contain; }
.pd-name { padding-right: 52px; font-size: clamp(1.75rem, 2.6vw, 2.2rem); font-weight: 600; line-height: 1.15; letter-spacing: 0.005em; text-wrap: balance; }
.pd-price { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 8px 0 0; color: var(--green-ink); }
.pd-price .serif-price { font-size: 30px; line-height: 1.1; }
.pd-from { font-size: 14px; color: var(--ink-3); }
.pd-status { display: inline-flex; align-items: center; gap: 7px; margin: 12px 0 0; padding: 5px 12px 5px 10px; border-radius: var(--r-pill); background: var(--mint); color: var(--green-ink); font-size: 13.5px; font-weight: 600; }
.pd-status.is-closed { background: #f3f3f3; color: var(--ink-2); }
.pd-h { margin: 22px 0 10px; font-size: 19px; font-weight: 700; }
.pd-chosen { margin-left: 8px; color: var(--wine-ink); font-weight: 600; }
.pd-desc { margin: -4px 0 18px; color: var(--ink-2); line-height: 1.65; max-width: 62ch; white-space: pre-line; }

.pd-tables { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); border: 1px solid var(--mint-line); border-radius: var(--r-lg); overflow: hidden; }
.pd-tables.is-single { grid-template-columns: 1fr; }
.pd-table + .pd-table { border-left: 1px solid var(--mint-line); }
.pd-thead { display: flex; align-items: center; gap: 9px; height: 44px; padding: 0 16px; background: var(--green); color: #fff; font-size: 15.5px; font-weight: 600; }
.pd-tiers .pd-thead { background: var(--green-deep); }
.pd-thead .ic { opacity: 0.85; }
.pd-table table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.pd-table thead th { padding: 7px 16px; background: var(--mint-soft); color: var(--green-ink); font-size: 12.5px; font-weight: 600; text-align: center; border-bottom: 1px solid var(--mint-line); }
.pd-table thead th:first-child { text-align: left; }
.pd-table tbody th, .pd-table tbody td { padding: 6.5px 16px; font-size: 14.5px; border-top: 1px solid var(--line-soft); transition: background-color 200ms ease; }
.pd-table tbody tr:first-child > * { border-top: 0; }
.pd-table tbody th { text-align: left; font-weight: 700; }
.pd-sizes tbody td { text-align: center; color: var(--ink-2); }
.pd-tiers tbody th { font-weight: 600; }
.pd-tiers tbody td { text-align: right; font-weight: 700; }
.pd-tiers thead th:last-child { text-align: right; }
.pd-table tbody tr.is-on > * { background: var(--mint); }
.pd-tiers tbody tr.is-on td { color: var(--green-ink); }
.pd-sizes.flash { animation: flash 1200ms ease; }
@keyframes flash { 0%, 100% { box-shadow: none; } 25% { box-shadow: inset 0 0 0 3px rgba(123, 30, 46, 0.35); } }

.pd-pick-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.pd-pick-head .pd-h { margin-bottom: 10px; }
.pd-colors { display: flex; gap: 12px; flex-wrap: wrap; }
.opt {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 46px; padding: 0 22px; border: 1.5px solid #dde2df; border-radius: var(--r-sm);
  background: #fff; color: var(--ink); font-size: 16px; font-weight: 500; cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}
.opt:hover:not(:disabled) { border-color: #a9b7b0; }
.opt.is-on { border-color: var(--wine-ink); background: var(--wine-tint); color: var(--wine); font-weight: 600; box-shadow: inset 0 0 0 0.5px var(--wine-ink); }
.opt-color { min-width: 96px; }
.opt-color i { width: 14px; height: 14px; border-radius: 50%; background: var(--swatch); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2); }
.pd-sizegrid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.opt-size { flex-direction: column; gap: 0; min-height: 50px; padding: 0 6px; font-variant-numeric: tabular-nums; }
.opt-size small { font-size: 11.5px; line-height: 1.1; color: var(--wine-ink); font-weight: 600; }
.opt.is-out { background: #f6f7f8; border-color: #eef0f1; color: #b4bbb8; text-decoration: line-through; cursor: not-allowed; }
.pd-hint { min-height: 0; margin: 10px 0 0; color: var(--danger); font-size: 14px; font-weight: 500; }
.pd-hint:empty { display: none; }
.shake { animation: shake 420ms ease; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.pd-buy { padding: 10px 44px 26px 36px; background: #fff; }
.pd-incart { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; font-size: 13.5px; color: var(--ink-2); }
.pd-incart:empty { display: none; }
.pd-incart a { display: inline-flex; align-items: center; gap: 2px; flex: none; color: var(--green-ink); font-weight: 600; }
.pd-buyrow { display: flex; gap: 12px; }
.qty { display: inline-flex; align-items: center; height: 58px; border: 1.5px solid var(--line); border-radius: var(--r); background: #fff; }
.qty-btn { display: grid; place-items: center; width: 44px; height: 100%; padding: 0; border: 0; background: none; color: var(--ink); cursor: pointer; border-radius: var(--r); }
.qty-btn:hover:not(:disabled) { background: var(--wine-soft); color: var(--wine); }
.qty-btn:disabled { color: #c3cac6; cursor: default; }
.qty-n { min-width: 28px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.btn-buy { flex: 1; height: 58px; font-size: 17px; border-radius: var(--r); box-shadow: 0 10px 22px -14px rgba(99, 23, 42, 0.8); }
.btn-buy.is-added { background: var(--wine-ink); }
.qty-sm { height: 40px; border-radius: var(--r-sm); }
.qty-sm .qty-btn { width: 36px; border-radius: var(--r-sm); }

.pd-missing { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 40px; }
.pd-missing .pd-x { top: 22px; right: 22px; }
.pd-missing p { margin: 0 0 8px; color: var(--ink-2); }
.pd-shell.is-loading .pd-media { animation: shimmer 1.4s ease-in-out infinite; }
.pd-shell.is-loading .pd-info { padding: 44px 36px; }

/* ---- เข้าสู่ระบบ ---- */
.signin { width: min(400px, 100vw - 32px); padding: 0; border: 0; border-radius: 24px; box-shadow: var(--shadow-lift); color: var(--ink); }
.signin::backdrop { background: rgba(14, 24, 19, 0.5); }
.signin[open] { animation: pd-in 360ms var(--ease-out); }
.signin-card:focus { outline: none; }
.signin-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 36px 28px 28px; text-align: center; }
.signin-x { position: absolute; top: 14px; right: 14px; }
.signin-card h2 { font-size: 24px; margin-top: 4px; }
.signin-why { margin: -4px 0 10px; color: var(--ink-2); font-size: 15px; text-wrap: pretty; }
.signin-google { width: 100%; height: 50px; }
.signin-error { margin: 0; color: var(--danger); font-size: 14px; }
.signin-error:empty { display: none; }

/* ---- หน้าทั่วไป ---- */
.page { width: min(1120px, 100% - 40px); margin: 0 auto; padding: 36px 0 96px; }
.page-title { font-size: clamp(1.75rem, 3vw, 2.25rem); letter-spacing: -0.01em; margin-bottom: 28px; }

/* ---- ตะกร้า: แผงเลื่อนจากขวา ---- */
.drawer {
  position: fixed; inset: 0 0 0 auto; width: min(440px, 100vw); height: 100dvh; max-width: none; max-height: none; margin: 0;
  padding: 0; border: 0; background: #fff; color: var(--ink); box-shadow: -30px 0 70px -30px rgba(12, 30, 22, 0.4);
}
.drawer::backdrop { background: rgba(14, 24, 19, 0.45); }
.drawer[open] { animation: drawer-in 380ms var(--ease-out); }
.drawer[open]::backdrop { animation: fade 260ms ease; }
.drawer.is-closing { animation: drawer-out 220ms ease-in forwards; }
.drawer.is-closing::backdrop { opacity: 0; transition: opacity 220ms ease; }
@keyframes drawer-in { from { transform: translateX(100%); } }
@keyframes drawer-out { to { transform: translateX(100%); } }
html:has(.drawer[open]) { overflow: hidden; }
.drawer-shell { display: flex; flex-direction: column; height: 100%; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 14px 24px; box-shadow: 0 1px 0 var(--line); }
.drawer-head h2 { font-size: 22px; }
.drawer-body:focus { outline: none; }
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 22px 24px 8px; }
.drawer-body .empty { padding: 56px 8px; }
.drawer-body .empty h3 { font-size: 19px; color: var(--ink); }
.drawer-body .sk-block { margin-top: 0; height: 180px; }
.drawer-foot { display: grid; gap: 14px; padding: 18px 24px calc(20px + env(safe-area-inset-bottom)); box-shadow: 0 -1px 0 var(--line); }
.drawer-foot:empty { display: none; }
.cart-group { padding: 0 0 20px; margin-bottom: 20px; border-bottom: 1px solid var(--line-soft); }
.cart-group:last-child { border-bottom: 0; margin-bottom: 0; }
.cart-ghead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cart-ghead h3 { font-size: 17px; }
.cart-ghead a:hover { color: var(--green-ink); }
.cart-ghead p { margin: 0; color: var(--ink-2); font-size: 14.5px; }
.cart-ghead .serif-price { color: var(--green-ink); font-size: 18px; }
.cart-nudge { display: inline-flex; align-items: center; gap: 7px; margin: 10px 0 0; padding: 6px 12px; border-radius: var(--r-pill); background: var(--mint); color: var(--green-ink); font-size: 13.5px; font-weight: 500; }
.cart-warn { margin: 6px 0 0; color: var(--danger); font-size: 13.5px; font-weight: 500; }
.cart-items { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 12px; }
.cart-item { display: grid; grid-template-columns: 68px minmax(0, 1fr) auto; align-items: start; gap: 14px; }
.cart-what { display: grid; gap: 8px; justify-items: start; }
.cart-thumb { display: grid; place-items: center; width: 68px; height: 72px; border-radius: var(--r); background: var(--stage); color: #b7c0bb; }
.cart-thumb img { width: 84%; height: 84%; object-fit: contain; }
.cart-variant { margin: 0; font-weight: 600; }
.cart-line-price { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.cart-gone { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-radius: var(--r); background: var(--stage); }
.cart-gone p { margin: 0; color: var(--ink-2); }
.sum-rows { display: grid; gap: 10px; margin: 0; font-variant-numeric: tabular-nums; }
.sum-rows div { display: flex; justify-content: space-between; gap: 12px; color: var(--ink-2); }
.sum-rows dd { margin: 0; }
.sum-save dd { color: var(--green-ink); font-weight: 600; }
.sum-total { padding-top: 12px; border-top: 1px solid var(--line); align-items: baseline; color: var(--ink) !important; font-weight: 600; }
.sum-total .serif-price { font-size: 28px; color: var(--green-ink); font-weight: 400; }
.sum-note:empty { display: none; }
.sum-note { margin: 0; font-size: 13.5px; color: var(--ink-3); text-wrap: pretty; }
.sum-pay { width: 100%; height: 54px; }

/* ---- แอดมิน ---- */
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.admin-head .page-title { margin-bottom: 0; }
.editor .admin-head { flex-direction: column; align-items: flex-start; gap: 6px; margin-bottom: 24px; }
.admin-note { margin: 0 0 16px; color: var(--ink-3); font-size: 14px; }
.admin-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.admin-table th, .admin-table td { padding: 12px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; font-size: 15px; }
.admin-table thead th { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.admin-prod { display: flex; align-items: center; gap: 14px; }
.admin-prod:hover strong { color: var(--green-ink); }
.admin-prod small { display: block; color: var(--ink-3); font-weight: 400; font-size: 13px; }
.admin-thumb { display: grid; place-items: center; width: 52px; height: 56px; border-radius: var(--r-sm); background: var(--stage); flex: none; }
.admin-thumb img { width: 84%; height: 84%; object-fit: contain; }
.state { display: inline-block; padding: 3px 10px; border-radius: var(--r-pill); background: var(--stage); color: var(--ink-3); font-size: 13px; font-weight: 600; }
.state.is-on { background: var(--mint); color: var(--green-ink); }

.ed-sec { margin: 0 0 20px; padding: 22px 22px 24px; border: 1px solid var(--line); border-radius: 20px; }
.ed-sec legend { padding: 0 8px; margin-left: -8px; font-weight: 700; font-size: 17px; }
.ed-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.ed-wide { grid-column: 1 / -1; }
.ed-rows { display: grid; gap: 8px; margin-bottom: 14px; }
.ed-row { display: flex; align-items: flex-end; gap: 10px; }
.ed-row .field { flex: 1; }
/* หัวช่องแสดงแค่แถวแรก แถวอื่นเหลือไว้ให้ screen reader */
.ed-row + .ed-row .field > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ed-row .field-name { flex: 0 0 150px; }
.ed-row .field-hex { flex: 0 0 64px; }
.ed-row .field-chest, .ed-row .field-length, .ed-row .field-min { flex: 0 0 140px; }
#edSizes .ed-row .field-name, #edTiers .ed-row .field-price { flex: 0 0 140px; }
#edSizes .ed-row, #edTiers .ed-row { justify-content: flex-start; }
.ed-row .ed-del { flex: none; margin-bottom: 2px; color: var(--ink-3); }
.ed-row .ed-del:hover { color: var(--danger); }
.ed-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.ed-sub { margin: 22px 0 10px; font-size: 15px; }
.stock-wrap { overflow-x: auto; }
.stock { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.stock th { padding: 6px 8px; font-size: 13px; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.stock tbody th { text-align: left; }
.stock td { padding: 3px; }
.stock input { width: 60px; height: 38px; padding: 0 6px; border: 1.5px solid var(--line); border-radius: 8px; text-align: center; font-size: 14.5px; }
.stock input:focus { outline: none; border-color: var(--wine-ink); }
.switch-row { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; font-size: 15px; font-weight: 500; align-self: end; }
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { position: relative; width: 46px; height: 28px; flex: none; border-radius: 14px; background: #d5dbd8; transition: background-color 200ms ease; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 260ms var(--ease-out); }
.switch-row input:checked + .switch { background: var(--wine); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.switch-row input:focus-visible + .switch { outline: 3px solid rgba(123, 30, 46, 0.4); outline-offset: 2px; }
.ed-bar {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin: 0 -12px; padding: 14px 12px calc(14px + env(safe-area-inset-bottom)); background: #fff; box-shadow: 0 -1px 0 var(--line);
}
.ed-msg { flex: 1; margin: 0; font-size: 14px; color: var(--ink-2); text-align: right; }
.ed-msg.is-error { color: var(--danger); font-weight: 500; }

/* ---- ช่องอัปโหลดรูป (image-slot.js) ---- */
.ed-color { align-items: flex-start; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px dashed var(--line); }
.ed-color:last-child { border-bottom: 0; }
.ed-color .ed-del { margin-top: 26px; }
.ed-slots { display: flex; gap: 12px; flex-wrap: wrap; }
.ed-noimg:empty { display: none; }
.ed-noimg { margin-bottom: 14px; }
.slot { display: grid; gap: 6px; width: 132px; }
.slot-wide { width: min(100%, 520px); }
.slot-label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.slot-tile {
  position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 1 / 1.06; padding: 0; overflow: hidden;
  border: 1.5px dashed #cdd5d0; border-radius: var(--r); background: var(--stage); color: var(--ink-3); cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease;
}
.slot-wide .slot-tile { aspect-ratio: 16 / 9; }
.slot-tile:hover, .slot-tile.is-drop { border-color: var(--wine-ink); background: var(--wine-soft); color: var(--wine); }
.slot-tile.has-img { border-style: solid; border-color: var(--line); }
.slot-tile img { position: absolute; inset: 8%; width: 84%; height: 84%; object-fit: contain; }
.slot-wide .slot-tile img { inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slot-empty { display: grid; justify-items: center; gap: 4px; padding: 8px; text-align: center; }
.slot-empty small { font-size: 12px; line-height: 1.3; }
.slot-tile.has-img .slot-empty { display: none; }
.slot-tile.is-broken::after { content: 'เปิดรูปไม่ได้'; position: absolute; inset: auto 6px 6px; padding: 2px 6px; border-radius: 6px; background: #fdecea; color: var(--danger); font-size: 11.5px; font-weight: 600; }
.slot-busy { position: absolute; inset: 0; display: none; place-items: center; background: rgba(255, 255, 255, 0.6); }
.slot-busy::after { content: ''; width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--wine-line); border-top-color: var(--wine); animation: spin 800ms linear infinite; }
.slot-tile.is-busy { cursor: progress; }
.slot-tile.is-busy .slot-busy { display: grid; }
@keyframes spin { to { rotate: 360deg; } }
.slot-actions { display: flex; gap: 12px; }
.slot-actions .link-btn { font-size: 13px; padding: 0; }
.slot-clear { color: var(--ink-3) !important; }
.slot-clear:hover { color: var(--danger) !important; }
.slot-link { width: 100%; height: 36px; padding: 0 10px; border: 1.5px solid var(--line); border-radius: var(--r-sm); font-size: 13.5px; }
.slot-link:focus { outline: none; border-color: var(--wine-ink); }

/* ---- แอดมินร้าน: เมนูซ้าย + เนื้อหา ---- */
.adm { width: min(1280px, 100% - 40px); display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 40px; align-items: start; }
.adm-nav { position: sticky; top: 88px; display: grid; gap: 2px; }
.adm-who { display: grid; margin: 0 0 12px; padding: 0 12px; font-size: 17px; font-weight: 700; }
.adm-who span { font-size: 13px; font-weight: 500; color: var(--ink-3); }
.adm-nav a {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: 15px; font-weight: 500; transition: background-color 160ms ease, color 160ms ease;
}
.adm-nav a:hover { background: var(--stage); color: var(--ink); }
.adm-nav a[aria-current="page"] { background: var(--wine-tint); color: var(--wine); font-weight: 600; }
.adm-main { min-width: 0; }
.adm-main .page-title { font-size: clamp(1.5rem, 2.4vw, 1.9rem); }
.adm-main > .admin-head { margin-bottom: 18px; }
.adm-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ประวัติการสั่งซื้อ */
.ord-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 14px; }
.ord-search { display: flex; align-items: center; gap: 8px; flex: 0 1 320px; height: 40px; padding: 0 12px; border: 1.5px solid var(--line); border-radius: var(--r-pill); color: var(--ink-3); }
.ord-search:focus-within { border-color: var(--wine-ink); box-shadow: 0 0 0 3px rgba(123, 30, 46, 0.12); }
.ord-search input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font-size: 14.5px; color: var(--ink); }
.ord-table tbody tr { cursor: pointer; transition: background-color 140ms ease; }
.ord-table tbody tr:hover, .ord-table tbody tr:focus-visible { background: var(--wine-soft); outline: none; }
.ord-table td, .ord-table th { vertical-align: top; }
.ord-table small { display: block; margin-top: 2px; font-size: 12.5px; color: var(--ink-3); font-weight: 400; }
.ord-table .num { text-align: right; white-space: nowrap; }
.ord-date { white-space: nowrap; color: var(--ink-2); }
.ord-items { color: var(--ink-2); max-width: 32ch; }
.ord-none { padding: 32px 0; text-align: center; }
.st-paid, .ff-delivered { background: var(--mint); color: var(--green-ink); }
.st-pending { background: #fff4dc; color: #7a5300; }
.st-expired, .st-cancelled, .st-refunded { background: var(--stage); color: var(--ink-3); }
.ff-preparing { background: #fff4dc; color: #7a5300; }
.ff-shipped { background: #e7f0fb; color: #1d4f8a; }

/* รายละเอียดคำสั่งซื้อ */
.od { width: min(560px, 100vw - 32px); max-height: min(860px, 100dvh - 40px); padding: 0; border: 0; border-radius: 24px; box-shadow: var(--shadow-lift); color: var(--ink); }
.od::backdrop { background: rgba(14, 24, 19, 0.5); }
.od[open] { animation: pd-in 320ms var(--ease-out); }
.od-card { display: flex; flex-direction: column; max-height: inherit; }
.od-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 22px 16px 26px; box-shadow: 0 1px 0 var(--line-soft); }
.od-head h2 { font-size: 20px; }
.od-head p { margin: 2px 0 0; font-size: 13.5px; color: var(--ink-3); }
.od-body:focus { outline: none; }
.od-body { overflow-y: auto; padding: 6px 26px 8px; }
.od-body section { padding: 16px 0; border-bottom: 1px solid var(--line-soft); }
.od-body section:last-child { border-bottom: 0; }
.od-body h3 { margin-bottom: 8px; font-size: 14px; color: var(--ink-3); font-weight: 600; }
.od-body p { margin: 0; }
.od-address { white-space: pre-line; color: var(--ink-2); margin-top: 4px !important; }
.od-items table { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-variant-numeric: tabular-nums; }
.od-items th, .od-items td { padding: 7px 0; text-align: left; font-size: 15px; vertical-align: top; }
.od-items th { font-weight: 600; }
.od-items th small { display: block; font-weight: 400; font-size: 13px; color: var(--ink-3); }
.od-items td { padding-left: 12px; color: var(--ink-2); white-space: nowrap; }
.od-items .num { text-align: right; color: var(--ink); }
.od-steps { display: grid; gap: 6px; margin-bottom: 14px; }
.od-steps label { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px; border: 1.5px solid #dde2df; border-radius: var(--r-sm); cursor: pointer; font-weight: 500; }
.od-steps label:has(input:checked) { border-color: var(--wine-ink); background: var(--wine-tint); color: var(--wine); }
.od-steps input { accent-color: var(--wine); }
.od-foot { display: flex; align-items: center; gap: 12px; padding: 14px 22px 20px 26px; box-shadow: 0 -1px 0 var(--line-soft); }

/* ผู้ดูแลร้าน */
.team-form { margin-bottom: 24px; }
.team-title { margin-top: 0; }
.team-perms { display: grid; gap: 8px; margin: 18px 0 18px; padding: 0; border: 0; }
.team-perms legend { font-weight: 600 !important; font-size: 13.5px !important; } .team-perms legend { padding: 0; margin-left: 0; margin-bottom: 8px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.team-perms small, .check small { display: block; font-size: 13px; font-weight: 400; color: var(--ink-3); }
.team-owner { align-self: start; margin-bottom: 4px; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 15px; font-weight: 500; }
.check input { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--wine); }
.check:has(input:disabled) { opacity: 0.55; cursor: default; }
.team-form .ed-msg { text-align: left; }
.team-rows { list-style: none; margin: 0; padding: 0; }
.team-rows li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px 16px; padding: 14px 4px; border-bottom: 1px solid var(--line-soft); }
.team-who strong { word-break: break-all; }
.team-who em { font-style: normal; color: var(--ink-3); font-weight: 500; }
.team-who small { display: block; color: var(--ink-3); font-size: 13.5px; }
.team-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.team-act { display: flex; gap: 6px; }
.team-del:hover { color: var(--danger); }

/* ---- footer + toast ---- */
.foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; width: min(1280px, 100% - 32px); margin: 0 auto; padding: 24px 0 calc(28px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--ink-3); font-size: 13.5px; }
.foot p { margin: 0; }
.foot a:hover { color: var(--green-ink); }
html[data-view="admin"] .foot { display: none; }
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 3000; max-width: calc(100% - 32px); padding: 11px 18px;
  border-radius: var(--r-pill); background: #13261d; color: #fff; font-size: 14.5px; text-align: center;
  box-shadow: 0 14px 30px -12px rgba(0, 0, 0, 0.45); opacity: 0; visibility: hidden; transform: translate(-50%, 8px);
  transition: opacity 0.25s ease, transform 0.3s ease, visibility 0s linear 0.3s;
}
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition: opacity 0.25s ease, transform 0.3s ease; }

/* ---- จอกลาง ---- */
@media (max-width: 1024px) {
  .pd-scroll { padding: 0 28px 16px 28px; }
  .pd-buy { padding: 12px 28px 26px; }
  .pd-sizegrid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
}

/* ---- มือถือ/แท็บเล็ตแนวตั้ง: modal เต็มจอ รูปอยู่บน ---- */
@media (max-width: 820px) {
  .bar-label { display: none; }
  .bar-cart { padding: 0 12px; }
  .bar-btn { padding: 0 10px; }
  .bar-cart .cart-count { margin-right: -4px; }

  .hero { min-height: 0; }
  .hero-track { position: relative; display: grid; }
  .slide { position: relative; grid-area: 1 / 1; grid-template-columns: 1fr; grid-template-rows: auto auto; gap: 8px; padding: 16px 20px 80px; }
  .slide-art { order: -1; height: min(68vw, 320px); overflow: hidden; }
  .hero-tee { height: 84%; width: auto; max-width: 84%; }
  .slide-copy { padding: 0; }
  .slide.is-ad { aspect-ratio: 4 / 5; }
  .hangtag { width: 112px; right: 0; top: 12%; padding: 24px 10px 10px; }
  .hangtag::before { height: 40px; }
  .hangtag dd { font-size: 17px; }
  .slide-copy { gap: 12px; }
  .slide-copy .btn { width: 100%; margin-top: 6px; }
  .hero-nav { left: 20px; right: 20px; bottom: 18px; justify-content: space-between; }

  .catalog { padding: 40px 0 72px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 12px; }
  .card { gap: 10px; }
  .card-name { font-size: 15px; }
  .card-price { font-size: 19px; gap: 6px; }
  .card-from { font-size: 12px; padding: 1px 7px; }

  .pd { width: 100vw; height: 100dvh; border-radius: 0; }
  .pd[open] { animation: sheet-in 460ms var(--ease-out); }
  .pd-shell { display: block; height: 100%; overflow-y: auto; overscroll-behavior: contain; }
  .pd-media { height: min(56svh, 470px); }
  .pd-flip { width: auto; height: 82%; }
  .pd-info { display: block; padding-top: 0; }
  .pd-x { position: fixed; top: calc(14px + env(safe-area-inset-top)); right: 14px; box-shadow: 0 2px 8px rgba(12, 30, 22, 0.1); }
  .pd-flipbtn { top: calc(14px + env(safe-area-inset-top)); left: 14px; }
  .pd-scroll { overflow: visible; padding: 24px 20px 8px; mask-image: none; }
  .pd-name { padding-right: 0; }
  /* มือถือ: เลือกสี/ไซซ์ก่อน ตารางไว้ล่าง (Size Guide เลื่อนลงไปหา) */
  .pd-scroll { display: flex; flex-direction: column; }
  .pd-scroll > * { flex: none; }
  .pd-scroll > .pd-name, .pd-scroll > .pd-price { align-self: stretch; }
  .pd-scroll > .pd-status { align-self: flex-start; }
  .pd-more, .pd-desc, .pd-tables { order: 2; }
  .pd-tables { margin-bottom: 12px; }
  .pd-buy { position: sticky; bottom: 0; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -1px 0 var(--line); }
  .qty, .btn-buy { height: 54px; }
  .pd-sizegrid { gap: 8px; }
  .opt { min-height: 48px; font-size: 15px; padding: 0 16px; }

  .ed-grid { grid-template-columns: 1fr; }
}
@keyframes sheet-in { from { transform: translateY(6%); opacity: 0; } }

@media (max-width: 560px) {
  .home { width: calc(100% - 20px); margin-top: 4px; }
  .slide-name { font-size: clamp(2.1rem, 10vw, 2.6rem); }
  .pd-tables { grid-template-columns: 1fr; }
  .pd-table + .pd-table { border-left: 0; border-top: 1px solid var(--mint-line); }
  .pd-thead { height: 48px; font-size: 15px; }
  .page { width: calc(100% - 32px); padding-top: 24px; }
  .hero { border-radius: 22px; }
  .ed-sec { padding: 18px 14px 20px; }
  .ed-row { flex-wrap: wrap; }
  .ed-row .field { flex: 1 1 40%; }
  .admin-table:not(.ord-table) thead th:nth-child(4), .admin-table:not(.ord-table) td:nth-child(4), .admin-table:not(.ord-table) thead th:nth-child(3), .admin-table:not(.ord-table) td:nth-child(3) { display: none; }
}
@media (max-width: 440px) {
  .bar { padding: 0 12px; }
  .brand { gap: 8px; }
  .brand img { width: 28px; height: 28px; }
  .brand-word { font-size: 15px; }
  .brand-sub { font-size: 17px; }
  .bar-actions { gap: 0; }
}
@media (max-width: 340px) {
  .brand-word { display: none; }
  .pd-sizegrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* แอดมินร้านบนมือถือ: เมนูเป็นแถบเลื่อนแนวนอน · ตารางคำสั่งซื้อเป็นการ์ด */
@media (max-width: 820px) {
  .adm { width: calc(100% - 32px); grid-template-columns: 1fr; gap: 20px; }
  .adm-nav { position: static; display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
  .adm-who { display: none; }
  .adm-nav a { flex: none; min-height: 40px; border: 1.5px solid var(--line); border-radius: var(--r-pill); }
  .adm-nav a[aria-current="page"] { border-color: transparent; }
  .ord-search { flex: 1 1 100%; }
  .ord-table thead { display: none; }
  .ord-table, .ord-table tbody, .ord-table tr, .ord-table td, .ord-table th { display: block; }
  .ord-table tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 14px 4px; border-bottom: 1px solid var(--line-soft); }
  .ord-table td, .ord-table th { padding: 0; border: 0; }
  .ord-table .ord-date { grid-column: 1 / -1; order: -1; font-size: 13px; }
  .ord-table .ord-date small { display: inline; margin-left: 6px; }
  .ord-table .ord-items { grid-column: 1 / -1; max-width: none; font-size: 14px; }
  .ord-table td:nth-child(5), .ord-table td:nth-child(6) { display: flex; align-items: center; gap: 6px; }
  .ord-table td:nth-child(6) small { margin: 0; }
  .team-rows li { grid-template-columns: minmax(0, 1fr) auto; }
  .team-tags { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
}

/* ลดการเคลื่อนไหว: ไม่พลิก 3D ใช้จางแทน · ไม่มีแอนิเมชันเข้า */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
  .pd-flip, .card-flip { transform: none !important; }
  .pd-back, .card-back { transform: none; opacity: 0; }
  .pd-flip.is-back .pd-back { opacity: 1; }
  .pd-flip.is-back .pd-front { opacity: 0; }
  .card.can-flip:hover .card-back { opacity: 1; }
}
