/* Layout: a corner-shop signboard header over a shelf grid; sheets slide up for cart and orders.
   Colours: chili red signage, price-tag yellow, rice-paper neutral with a faint red bias. */
:root {
  --bg: #f7f3f1;
  --surface: #ffffff;
  --sunk: #efe8e5;
  --fg: #221a18;
  --muted: #76655f;
  --line: #e4d9d5;
  --accent: #c8261c;
  --accent-fg: #ffffff;
  --tag: #ffd84a;
  --tag-fg: #221a18;
  --sign: #c8261c;
  --sign-fg: #ffffff;
  --ok: #1f7a4a;
  --warn: #a35c00;
  --shadow: 0 10px 30px rgba(40, 10, 5, .18);
  --f-cn: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --f-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-num: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171211; --surface: #221b1a; --sunk: #1b1514; --fg: #f3ebe8; --muted: #a8968f; --line: #3a2f2c;
    --accent: #ff5a4c; --accent-fg: #1a0d0b; --tag: #f2c935; --tag-fg: #1a1412; --ok: #5cc98c; --warn: #f0a650;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 15px/1.45 var(--f-body);
  -webkit-text-size-adjust: 100%;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.wrap {
  max-width: 1080px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.cn { font-family: var(--f-cn); }
.num { font-family: var(--f-num); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
h1, h2, h3 { margin: 0; text-wrap: balance; }

/* ---------- signboard header ---------- */
.sign {
  background: var(--sign); color: var(--sign-fg);
  position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top, 0px);
}
.sign .wrap { display: flex; align-items: center; gap: 12px; padding-block: 12px; flex-wrap: wrap; }
.sign h1 { font-family: var(--f-cn); font-weight: 700; font-size: 1.25rem; letter-spacing: .02em; flex: 1; min-width: 0; }
.sign h1 small { display: block; font-family: var(--f-body); font-weight: 600; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; opacity: .85; }
.sign .btn { background: rgba(255,255,255,.14); color: var(--sign-fg); border-color: rgba(255,255,255,.35); }
.sign .btn:hover { background: rgba(255,255,255,.24); }
.sign .btn.solid { background: var(--tag); color: var(--tag-fg); border-color: var(--tag); }
.who { font-size: .82rem; opacity: .95; display: flex; gap: 6px; align-items: center; min-width: 0; flex-wrap: wrap; }
.who b { word-break: break-all; }
@media (max-width: 640px) {
  .sign { position: static; }
  .sign h1 { flex-basis: 100%; }
  .sign .who { flex: 1; }
}
.who b { font-family: var(--f-num); font-weight: 600; }
.linkish { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font-size: inherit; }

/* ---------- buttons, fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg);
  border-radius: 8px; padding: 9px 14px; font-weight: 600; cursor: pointer; line-height: 1.2;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: .85rem; }
.btn.block { width: 100%; padding: 13px 16px; font-size: 1rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .linkish:focus-visible {
  outline: 3px solid var(--tag); outline-offset: 2px;
}
.badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--tag); color: var(--tag-fg); font: 600 .75rem var(--f-num);
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.field > span .cn { text-transform: none; letter-spacing: 0; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: 11px 12px; font-size: 16px; /* 16px stops iOS zooming in */
}
.field textarea { resize: vertical; min-height: 64px; }
.hint { font-size: .82rem; color: var(--muted); }
.err { color: var(--accent); font-size: .88rem; font-weight: 600; }

/* ---------- login ---------- */
.login { display: grid; gap: 18px; max-width: 440px; margin: 40px auto; padding-inline: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.login h2 { font-size: 1.35rem; }
.wechat-box {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--sunk); border: 1px dashed var(--line); border-radius: 12px; padding: 14px;
}
.wechat-box .id { font: 600 1.15rem var(--f-num); letter-spacing: .02em; user-select: all; }

/* ---------- notices ---------- */
.strip { display: flex; flex-wrap: wrap; gap: 8px 18px; padding-block: 12px; font-size: .86rem; color: var(--muted); }
.strip b { color: var(--fg); }
.notice { background: var(--tag); color: var(--tag-fg); border-radius: 10px; padding: 10px 14px; font-weight: 600; margin-top: 12px; }

/* ---------- shelf ---------- */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; padding-block: 8px 120px; }
@media (max-width: 440px) { .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.prod { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.prod .ph { aspect-ratio: 1; background: #fff; max-width: 100%; position: relative; }
.prod .ph img { width: 100%; height: 100%; object-fit: contain; }
.prod.soldout .ph img { opacity: .5; filter: grayscale(.6); }
.stock {
  position: absolute; left: 8px; top: 8px; font: 600 .72rem var(--f-body);
  background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px;
}
.stock.low { color: var(--warn); }
.stock.out { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.prod .info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; border-top: 1px solid var(--line); min-width: 0; }
.prod .n-cn { font-family: var(--f-cn); font-weight: 700; font-size: .95rem; line-height: 1.3; }
.prod .n-en { font-size: .78rem; color: var(--muted); line-height: 1.3; }
.prod .meta { font-size: .74rem; color: var(--muted); }
.prod .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 8px; flex-wrap: wrap; }
.tag { background: var(--tag); color: var(--tag-fg); font: 600 1rem var(--f-num); padding: 3px 9px; border-radius: 3px; font-variant-numeric: tabular-nums; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stepper button { border: 0; background: var(--sunk); width: 34px; height: 34px; font-size: 1.1rem; font-weight: 700; cursor: pointer; }
.stepper button:disabled { opacity: .35; cursor: not-allowed; }
.stepper span { min-width: 30px; text-align: center; font: 600 .95rem var(--f-num); }
.pre-chip { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--warn); }

/* ---------- floating cart bar ---------- */
.cartbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: var(--shadow);
}
.cartbar .inner { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.cartbar .sum { flex: 1; min-width: 0; }
.cartbar .sum b { font: 600 1.2rem var(--f-num); }

/* ---------- sheets ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 30; background: rgba(20, 8, 5, .5);
  display: flex; align-items: flex-end; justify-content: center;
  padding-top: max(24px, env(safe-area-inset-top, 0px));
}
@media (min-width: 720px) { .overlay { align-items: center; padding: 24px; } }
.sheet {
  background: var(--bg); width: min(560px, 100%); max-height: 100%; overflow: auto;
  border-radius: 16px 16px 0 0; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
@media (min-width: 720px) { .sheet { border-radius: 16px; max-height: calc(100vh - 48px); } }
.sheet header { position: sticky; top: 0; background: var(--bg); display: flex; align-items: center; gap: 10px; padding: 16px 18px 10px; border-bottom: 1px solid var(--line); z-index: 1; }
.sheet header h2 { flex: 1; font-size: 1.15rem; }
.sheet .body { padding: 16px 18px calc(20px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 16px; }
.x { border: 0; background: var(--sunk); width: 36px; height: 36px; border-radius: 50%; font-size: 1.2rem; cursor: pointer; }

.lines { display: flex; flex-direction: column; gap: 10px; }
.line { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.line img { width: 56px; height: 56px; object-fit: contain; background: #fff; border-radius: 6px; }
.line .t { min-width: 0; }
.line .t .n-cn { font-family: var(--f-cn); font-weight: 700; font-size: .9rem; }
.line .t .sub { font-size: .78rem; color: var(--muted); }
.line .r { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.totalrow { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; }
.totalrow .num { font-size: 1.4rem; }
.pay {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.pay .ways { display: flex; flex-wrap: wrap; gap: 6px; }
.pay .ways span { background: var(--sunk); border-radius: 6px; padding: 3px 8px; font-weight: 600; font-size: .85rem; }

/* ---------- orders ---------- */
.ord { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.ord .top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ord .code { font: 700 1.05rem var(--f-num); letter-spacing: .05em; }
.ord ul { margin: 0; padding-left: 18px; font-size: .9rem; }
.status { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; border: 1px solid currentColor; }
.status.new { color: var(--warn); }
.status.confirmed { color: var(--accent); }
.status.delivered { color: var(--ok); }
.status.cancelled { color: var(--muted); }
.done { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; padding-block: 8px; }
.done .code { font: 700 2rem var(--f-num); letter-spacing: .08em; background: var(--tag); color: var(--tag-fg); padding: 4px 14px; border-radius: 6px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 40;
  bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600;
  max-width: calc(100% - 32px); box-shadow: var(--shadow);
}
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: up .22s ease-out; }
  @keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
}
