/* Layout: one phone-width column, centred on larger screens */
:root {
  --bg: #eceff3;
  --ink: #18212b;
  --muted: #5b6673;
  --line: #d5dbe3;
  --accent: #2343b0;
  --accent-ink: #ffffff;
  --surface: #ffffff;
  --surface-2: #f3f5f8;
  --app-bg: #f7f8fa;
  --ok: #1b7543;
  --ok-bg: #e0f2e7;
  --sold: #b3322b;
  --sold-bg: #fbe5e3;
  --pause: #8f5d0c;
  --pause-bg: #f9eed6;
  --scrim: rgba(12, 18, 28, 0.48);
  --shop: #2343b0;
  --gl: max(16px, env(safe-area-inset-left, 0px));
  --gr: max(16px, env(safe-area-inset-right, 0px));
  --font-ui: "Kantumruy Pro", "Noto Sans Khmer", "Khmer UI", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Bricolage Grotesque", "Kantumruy Pro", "Khmer UI", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1116; --ink: #e6ebf1; --muted: #98a4b2; --line: #2a3542;
    --accent: #8197ff; --accent-ink: #0d1433; --surface: #1a222c; --surface-2: #222c38; --app-bg: #131a22;
    --ok: #5fcb8c; --ok-bg: #15301f; --sold: #ff8b80; --sold-bg: #3b1b19;
    --pause: #e8b55e; --pause-bg: #33270f; --scrim: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-ui); font-size: 15px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); }

.shell {
  max-width: 520px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; background: var(--app-bg); position: relative;
}
@media (min-width: 560px) { .shell { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
.screen { flex: 1; }
.center-msg { padding: 64px var(--gr) 64px var(--gl); text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 12px; align-items: center; }
.center-msg h1 { color: var(--ink); font-family: var(--font-display); font-size: 24px; }

/* ---------- top bar & tab bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) var(--gr) 12px var(--gl);
  background: var(--app-bg); border-bottom: 1px solid var(--line);
}
.grow { flex: 1; min-width: 0; }
.ttl { font-weight: 700; font-size: 17px; line-height: 1.25; overflow-wrap: anywhere; }
.ttl.center { text-align: center; }
.sub { font-size: 12.5px; color: var(--muted); }
.tabbar {
  position: sticky; bottom: 0; z-index: 3; display: flex;
  border-top: 1px solid var(--line); background: var(--surface);
  padding: 0 var(--gr) calc(4px + env(safe-area-inset-bottom, 0px)) var(--gl);
}
.tabbar button {
  flex: 1; border: 0; background: none; padding: 9px 0 4px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.tabbar button[aria-current="page"] { color: var(--accent); }
.tabbar svg { width: 22px; height: 22px; }

.logo {
  width: 40px; height: 40px; flex: none; border-radius: 12px; overflow: hidden;
  display: grid; place-items: center; background: var(--shop); color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: 16px;
}

/* ---------- buttons, pills, segmented controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14.5px; line-height: 1.2;
  text-decoration: none; text-align: center;
}
.btn.sm { padding: 7px 12px; font-size: 14px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.shop { background: var(--shop); border-color: var(--shop); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); padding-inline: 4px; }
.btn.danger { color: var(--sold); align-self: flex-start; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn.block { width: 100%; padding-block: 12px; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; font-size: 14px; text-align: left; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; flex-wrap: nowrap; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; line-height: 1.6; }
.pill.available { color: var(--ok); background: var(--ok-bg); }
.pill.soldout { color: var(--sold); background: var(--sold-bg); }
.pill.paused { color: var(--pause); background: var(--pause-bg); }

.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; padding: 3px; border-radius: 11px; background: var(--surface-2); }
.seg.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg button { border: 0; background: transparent; border-radius: 8px; padding: 7px 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); line-height: 1.3; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.seg button[aria-pressed="true"].available { background: var(--ok-bg); color: var(--ok); box-shadow: none; }
.seg button[aria-pressed="true"].soldout { background: var(--sold-bg); color: var(--sold); box-shadow: none; }
.seg button[aria-pressed="true"].paused { background: var(--pause-bg); color: var(--pause); box-shadow: none; }

.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--surface); flex: none; }
.lang button { border: 0; background: none; border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* ---------- forms ---------- */
.form { padding: 18px var(--gr) 32px var(--gl); display: flex; flex-direction: column; gap: 22px; }
.field { display: flex; flex-direction: column; gap: 8px; border: 0; padding: 0; margin: 0; min-width: 0; }
.label { font-weight: 600; font-size: 14px; padding: 0; }
.sublabel { font-size: 13px; color: var(--muted); }
.input { width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 16px; }
textarea.input { resize: vertical; min-height: 76px; }
.input::placeholder { color: var(--muted); opacity: 0.75; }
.prefix { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.prefix span { padding: 11px 0 11px 12px; color: var(--muted); font-size: 15px; white-space: nowrap; }
.prefix input { border: 0; background: transparent; padding: 11px 12px 11px 2px; flex: 1; min-width: 0; font-size: 16px; }
.prefix:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.prefix input:focus-visible { outline: none; }
.err { color: var(--sold); font-size: 13.5px; }
.okmsg { color: var(--ok); font-size: 13.5px; }
.fine { font-size: 12.5px; color: var(--muted); }
.note { font-size: 13.5px; color: var(--muted); }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.check span { display: flex; flex-direction: column; gap: 2px; }
.check b { font-weight: 600; font-size: 14.5px; }
.check small { font-size: 12.5px; color: var(--muted); }
.price-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 8px; align-items: center; }
.fstack { display: flex; flex-direction: column; gap: 16px; }
.box { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); }

.photos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ptile { aspect-ratio: 1; max-width: 100%; border-radius: 12px; overflow: hidden; position: relative; background: var(--surface-2); }
.ptile img, .pthumb img, .ph img, .slide img { width: 100%; height: 100%; display: block; object-fit: cover; }
.ptile .rm { position: absolute; top: 5px; right: 5px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.62); color: #fff; font-size: 18px; line-height: 1; display: grid; place-items: center; }
.ptile .cover { position: absolute; left: 6px; bottom: 6px; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: rgba(0, 0, 0, 0.62); color: #fff; }
.addtile { border: 1.5px dashed var(--line); background: var(--surface); display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 12.5px; font-weight: 600; cursor: pointer; line-height: 1.3; }
.addtile b { display: block; font-size: 24px; font-weight: 400; color: var(--accent); }
.nophoto { width: 100%; height: 100%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); font-size: 11.5px; text-align: center; padding: 4px; }
.wrapchips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { flex: none; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 13.5px; font-weight: 600; line-height: 1.4; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.dashed { border-style: dashed; color: var(--muted); }

/* ---------- sign-in ---------- */
.auth { padding: calc(40px + env(safe-area-inset-top, 0px)) var(--gr) 40px var(--gl); display: flex; flex-direction: column; gap: 22px; }
.auth-top { display: flex; justify-content: space-between; align-items: center; }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 20px; }
.auth h1 { font-family: var(--font-display); font-size: 30px; line-height: 1.1; text-wrap: balance; }

/* ---------- seller product list ---------- */
.summary { display: flex; gap: 14px; flex-wrap: wrap; padding: 14px var(--gr) 2px var(--gl); font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.summary span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.available { background: var(--ok); } .dot.soldout { background: var(--sold); } .dot.paused { background: var(--pause); }
.plist { padding: 12px var(--gr) 28px var(--gl); display: flex; flex-direction: column; gap: 10px; }
.cat-h { display: flex; justify-content: space-between; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-top: 10px; }
.prow { display: grid; grid-template-columns: 60px minmax(0, 1fr); gap: 8px 12px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.pthumb { grid-row: span 2; width: 60px; height: 76px; border-radius: 10px; overflow: hidden; padding: 0; border: 0; background: var(--surface-2); }
.pinfo { border: 0; background: none; padding: 0; text-align: left; display: flex; flex-direction: column; min-width: 0; }
.pname { font-weight: 600; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.pmeta { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 14px; align-items: center; }

/* ---------- share ---------- */
.stack { padding: 18px var(--gr) 32px var(--gl); display: flex; flex-direction: column; gap: 16px; }
.poster { background: #ffffff; color: #18212b; border-radius: 20px; overflow: hidden; border: 1px solid var(--line); }
.poster-top { background: var(--shop); color: #fff; padding: 16px; display: flex; gap: 12px; align-items: center; }
.poster-top .logo { background: rgba(255, 255, 255, 0.2); }
.poster-name { font-family: var(--font-display); font-weight: 700; font-size: 19px; line-height: 1.2; overflow-wrap: anywhere; }
.poster-line { font-size: 13.5px; opacity: 0.92; }
.qr { width: 62%; max-width: 240px; margin: 20px auto 8px; aspect-ratio: 1; }
.qr svg { width: 100%; height: 100%; display: block; }
.poster-url { text-align: center; font-size: 13px; font-weight: 600; color: #4a5562; padding: 0 12px 16px; overflow-wrap: anywhere; }
.quote { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 14px; overflow-wrap: anywhere; user-select: all; }

/* ---------- customer catalog ---------- */
.chero { background: var(--shop); color: #fff; padding: calc(18px + env(safe-area-inset-top, 0px)) var(--gr) 16px var(--gl); display: flex; flex-direction: column; gap: 14px; }
.chero-top { display: flex; gap: 12px; align-items: flex-start; }
.chero .logo { width: 52px; height: 52px; border-radius: 15px; font-size: 20px; background: rgba(255, 255, 255, 0.2); }
.chero h1 { font-family: var(--font-display); font-size: 23px; line-height: 1.15; overflow-wrap: anywhere; }
.ctag { font-size: 13px; opacity: 0.9; }
.cmeta { font-size: 12.5px; opacity: 0.92; display: flex; gap: 6px; flex-wrap: wrap; }
.cbtns { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; }
.cbtn { border: 0; border-radius: 12px; padding: 10px; background: #fff; color: #18212b; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.cbtn svg { width: 18px; height: 18px; }
.chero .lang { border-color: rgba(255, 255, 255, 0.35); background: rgba(255, 255, 255, 0.12); }
.chero .lang button { color: rgba(255, 255, 255, 0.85); }
.chero .lang button[aria-pressed="true"] { background: #fff; color: #18212b; }
.ctools { position: sticky; top: 0; z-index: 3; background: var(--app-bg); padding: calc(12px + env(safe-area-inset-top, 0px)) var(--gr) 10px var(--gl); display: flex; flex-direction: column; gap: 10px; }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 38px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gr)) 0 calc(-1 * var(--gl)); padding: 0 var(--gr) 2px var(--gl); }
.chips::-webkit-scrollbar { display: none; }
.cview .chip[aria-pressed="true"] { background: var(--shop); border-color: var(--shop); color: #fff; }
.cgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; padding: 6px var(--gr) 20px var(--gl); }
.cempty { padding: 40px 24px; text-align: center; color: var(--muted); }
.card { border: 0; background: none; padding: 0; text-align: left; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.card .ph { aspect-ratio: 4 / 5; max-width: 100%; border-radius: 14px; overflow: hidden; position: relative; margin-bottom: 4px; background: var(--surface-2); }
.card.dim .ph img { opacity: 0.5; filter: grayscale(0.7); }
.card .badge { position: absolute; left: 8px; top: 8px; }
.card .nm { font-weight: 600; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.card .pr { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.made { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 16px calc(28px + env(safe-area-inset-bottom, 0px)); }
.made a { color: var(--muted); text-decoration: none; }
.made b { color: var(--ink); font-weight: 600; }

/* ---------- sheets & toast ---------- */
.sheet-layer { position: fixed; inset: 0; z-index: 20; background: var(--scrim); display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.sheet { position: relative; width: 100%; max-width: 520px; background: var(--surface); border-radius: 22px 22px 0 0; max-height: 92%; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom, 0px); animation: rise 0.22s ease-out; }
@keyframes rise { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.close-x { position: absolute; top: 10px; right: 10px; z-index: 2; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 20px; line-height: 1; display: grid; place-items: center; }
.close-x.plain { background: var(--surface-2); color: var(--ink); }
.carousel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.carousel::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; aspect-ratio: 1; scroll-snap-align: start; background: var(--surface-2); }
.dots { text-align: center; font-size: 12px; color: var(--muted); padding-top: 8px; font-variant-numeric: tabular-nums; }
.sheet-body { padding: 16px var(--gr) 22px var(--gl); display: flex; flex-direction: column; gap: 12px; }
.sheet-body h2 { font-family: var(--font-display); font-size: 21px; line-height: 1.2; overflow-wrap: anywhere; }
.sprice { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sheet-eyebrow { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.msg { margin: 0; white-space: pre-wrap; font: inherit; font-size: 14px; background: var(--surface-2); border-radius: 14px 14px 14px 4px; padding: 12px 14px; overflow-wrap: anywhere; user-select: all; }
.toast {
  position: fixed; left: 50%; translate: -50% 0; width: min(496px, calc(100% - 24px));
  bottom: calc(80px + env(safe-area-inset-bottom, 0px)); z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 14px; border-radius: 14px; background: var(--ink); color: var(--bg); font-size: 14px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}
.toast.low { bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
.toast button { border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; padding: 0; }

/* ---------- landing ---------- */
.landing { padding: calc(48px + env(safe-area-inset-top, 0px)) var(--gr) 48px var(--gl); display: flex; flex-direction: column; gap: 28px; }
.landing h1 { font-family: var(--font-display); font-size: clamp(34px, 9vw, 46px); line-height: 1.02; letter-spacing: -0.015em; text-wrap: balance; }
.landing .lede { font-size: 17px; color: var(--muted); }
.landing ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
