:root {
  /* 声明只支持浅色，避免手机的「深色模式 / 强制深色」把界面反色成黑底 */
  color-scheme: only light;
  supported-color-schemes: light;

  --red: #9b1b1b;
  --red-dark: #7d1414;
  --gold: #b08d57;
  --cream: #faf6ef;
  --paper: #ffffff;
  --ink: #2a2521;
  --muted: #8c8177;
  --line: #ece3d6;
  --shadow: 0 6px 22px rgba(80, 50, 30, 0.08);
}

* { box-sizing: border-box; }

/* hidden 属性必须赢过后面 .item / .cart-sheet 等设置的 display */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background-color: #faf6ef;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

html {
  color-scheme: only light;
  background-color: #faf6ef;
}

/* 个别安卓浏览器即使声明了 color-scheme 仍会反色，这里再兜一层 */
@media (prefers-color-scheme: dark) {
  html, body { background-color: #faf6ef; color: #2a2521; }
}

a { color: inherit; text-decoration: none; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 14px; }

/* ---------- header ---------- */
.head {
  background: linear-gradient(180deg, #fffdf9, var(--cream));
  border-bottom: 1px solid var(--line);
  padding: 14px 0 10px;
}

.head-row { display: flex; align-items: center; gap: 12px; }

.head img.logo { width: 54px; height: 54px; object-fit: contain; }

.head h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 2px;
  color: var(--red);
  font-family: "Songti SC", "STSong", "SimSun", "Noto Serif SC", serif;
}

.head .sub { font-size: 12px; color: var(--muted); margin-top: 2px; letter-spacing: 1px; }

.head .spacer { flex: 1; }

.lang {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
}

.lang a { padding: 5px 11px; font-size: 12px; color: var(--muted); }
.lang a.on { background: var(--red); color: #fff; }

.banner {
  margin: 12px 0 0;
  padding: 11px 14px;
  border-radius: 12px;
  background: #fdf1ef;
  border: 1px solid #f2d5d0;
  color: var(--red-dark);
  font-size: 14px;
}

/* ---------- 顶部固定区：搜索 + 分类 ---------- */
.sticky-top {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(250, 246, 239, 0.97);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  margin-top: 10px;
}

.search-row {
  position: relative;
  padding-top: 10px;
}

.search-row input[type="search"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 38px 10px 38px;
  font-size: 15px;
  background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238c8177' stroke-width='2'><circle cx='11' cy='11' r='7'/><path d='M20 20l-4-4'/></svg>") no-repeat 14px center;
  color: var(--ink);
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.search-row input[type="search"]::-webkit-search-cancel-button { display: none; }

.search-row input[type="search"]:focus { outline: none; border-color: var(--gold); }

.search-row #searchClear {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-30%);
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.no-result {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 40px 0;
}

.sticky-top.searching .cats { display: none; }

.cats { margin-top: 8px; }

.cats-inner {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 9px 14px;
  scrollbar-width: none;
}

.cats-inner::-webkit-scrollbar { display: none; }

.cats a {
  flex: 0 0 auto;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--muted);
  border: 1px solid transparent;
  white-space: nowrap;
}

.cats a.on {
  background: var(--red);
  color: #fff;
  box-shadow: 0 4px 12px rgba(155, 27, 27, 0.22);
}

/* ---------- sections & items ---------- */
section.cat { padding: 18px 0 6px; scroll-margin-top: 56px; }

.cat-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 10px;
}

.cat-title h2 {
  margin: 0;
  font-size: 18px;
  font-family: "Songti SC", "STSong", "SimSun", "Noto Serif SC", serif;
  color: var(--ink);
  letter-spacing: 1px;
}

.cat-title span { font-size: 12px; color: var(--gold); letter-spacing: 0.6px; }

.cat-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

.group-label {
  margin: 14px 2px 8px;
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 1px;
}

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 9px;
  box-shadow: var(--shadow);
}

.item.off { opacity: 0.45; }

.item .info { flex: 1; min-width: 0; }

.item .cn { font-size: 16px; font-weight: 600; letter-spacing: 0.5px; }

.item .code {
  display: inline-block;
  font-size: 10px;
  color: var(--gold);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  margin-right: 7px;
  vertical-align: 2px;
  font-weight: 400;
}

.item .ru {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.35;
}

.item .meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
}

.item .price {
  font-size: 17px;
  font-weight: 700;
  color: var(--red);
  white-space: nowrap;
}

.item .price small { font-size: 12px; font-weight: 400; margin-left: 1px; }

.right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

.add {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--red);
  color: #fff;
  font-size: 20px;
  line-height: 28px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(155, 27, 27, 0.28);
}

.add:active { transform: scale(0.94); }

.stepper {
  display: none;
  align-items: center;
  gap: 8px;
}

.stepper.show { display: flex; }

.stepper button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--red);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.stepper button.plus { background: var(--red); color: #fff; border-color: var(--red); }

.stepper .qty { min-width: 16px; text-align: center; font-weight: 600; }

.soldout { font-size: 12px; color: var(--muted); }

/* ---------- cart bar ---------- */
.cartbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px rgba(80, 50, 30, 0.08);
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
}

.cartbar .row { display: flex; align-items: center; gap: 12px; }

.cartbar .icon { position: relative; font-size: 22px; }

button.icon {
  position: relative;
  font-size: 22px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
}

button.icon:active { transform: scale(0.94); }

.cartbar .badge {
  position: absolute;
  top: -6px;
  right: -10px;
  background: var(--red);
  color: #fff;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  padding: 0 4px;
}

.cartbar .sum { flex: 1; }

.cartbar .sum b { font-size: 19px; color: var(--red); }

.cartbar .sum div { font-size: 12px; color: var(--muted); }

.cartbar .go {
  border: none;
  border-radius: 999px;
  padding: 12px 26px;
  background: linear-gradient(180deg, #a82121, var(--red-dark));
  color: #fff;
  font-size: 15px;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(155, 27, 27, 0.3);
}

.cartbar .go:disabled { opacity: 0.4; box-shadow: none; cursor: default; }

.footer-note {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 18px 0 130px;
  line-height: 1.7;
}

/* ---------- checkout ---------- */
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin: 14px 0;
  box-shadow: var(--shadow);
}

.panel h2 { margin: 0 0 12px; font-size: 16px; }

.lines { display: flex; flex-direction: column; gap: 9px; }

.line { display: flex; align-items: baseline; gap: 10px; font-size: 14px; }
.line .grow { flex: 1; }
.line .q { color: var(--muted); font-size: 13px; }

.line-sum { min-width: 64px; text-align: right; }

.line-del {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.line.bad { background: #fdf1ef; border-radius: 8px; padding: 4px 6px; margin: 0 -6px; }
.line.bad .grow { color: var(--red); font-weight: 600; }

.total-row {
  display: flex;
  justify-content: space-between;
  border-top: 1px dashed var(--line);
  margin-top: 12px;
  padding-top: 12px;
  font-size: 16px;
}

.total-row b { color: var(--red); font-size: 19px; }

label.field { display: block; margin-bottom: 12px; }

label.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }

input[type="text"], input[type="tel"], input[type="date"],
input[type="number"], input[type="password"], textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 12px;
  font-size: 15px;
  background: #fffdfa;
  color: var(--ink);
  font-family: inherit;
}

input:focus, textarea:focus { outline: none; border-color: var(--gold); }

.seg { display: flex; gap: 8px; }

.seg button {
  flex: 1;
  padding: 11px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #fffdfa;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
}

.seg button.on {
  border-color: var(--red);
  background: #fdf3f2;
  color: var(--red);
  font-weight: 600;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  margin: 8px 0 0;
}

.submit {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 15px;
  font-size: 16px;
  letter-spacing: 2px;
  color: #fff;
  background: linear-gradient(180deg, #a82121, var(--red-dark));
  box-shadow: 0 8px 20px rgba(155, 27, 27, 0.3);
  cursor: pointer;
}

.submit:disabled { opacity: 0.5; }

.alert {
  display: none;
  background: #fdf1ef;
  border: 1px solid #f2d5d0;
  color: var(--red-dark);
  padding: 11px 13px;
  border-radius: 11px;
  font-size: 14px;
  margin-bottom: 12px;
}

.alert.show { display: block; }

.big-check {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #f2f8f2;
  color: #4a8b4a;
  font-size: 38px;
  line-height: 72px;
  text-align: center;
  margin: 0 auto 14px;
}

.order-no {
  text-align: center;
  font-size: 42px;
  font-weight: 700;
  color: var(--red);
  letter-spacing: 2px;
  margin: 4px 0 2px;
}

/* ---------- admin ---------- */
.admin-head {
  background: #2a2521;
  color: #fff;
  padding: 12px 0;
}

.admin-head .row { display: flex; align-items: center; gap: 16px; }

.admin-head .brand { font-size: 15px; letter-spacing: 1px; }

.admin-head nav { display: flex; gap: 4px; flex: 1; }

.admin-head nav a {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: #cfc7bd;
}

.admin-head nav a.on { background: rgba(255, 255, 255, 0.14); color: #fff; }

.admin-head .out { font-size: 13px; color: #a89f95; }

.cols { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }

.col { flex: 1 1 300px; min-width: 280px; }

.col > h2 {
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 1px;
  margin: 16px 0 10px;
}

.ord {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.ord.new { border-left-color: var(--red); background: #fffaf9; }
.ord.accepted { border-left-color: var(--gold); }
.ord.done { border-left-color: #6b9b6b; opacity: 0.82; }
.ord.cancelled { border-left-color: #b9b2a9; opacity: 0.6; }

.ord .top { display: flex; align-items: baseline; gap: 10px; }
.ord .no { font-size: 18px; font-weight: 700; color: var(--red); }
.ord .time { font-size: 12px; color: var(--muted); flex: 1; }
.ord .mode {
  font-size: 11px;
  border-radius: 6px;
  padding: 2px 7px;
  background: #f4efe7;
  color: var(--gold);
}

.ord .cust { font-size: 14px; margin: 8px 0 6px; }
.ord .cust b { font-weight: 600; }
.ord .addr { font-size: 13px; color: var(--muted); }

.ord ul { margin: 6px 0; padding-left: 18px; font-size: 14px; line-height: 1.6; }
.ord .cmt { font-size: 13px; color: var(--red-dark); background: #fdf6f0; padding: 6px 9px; border-radius: 8px; margin-top: 6px; }
.ord .foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.ord .foot .sum { flex: 1; font-size: 16px; font-weight: 700; color: var(--red); }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  padding: 7px 13px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
}

.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { color: var(--muted); }
.btn:active { transform: scale(0.97); }

table.items { width: 100%; border-collapse: collapse; font-size: 14px; }
table.items th {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
}
table.items td { padding: 7px 6px; border-bottom: 1px solid #f5efe6; vertical-align: middle; }
table.items input[type="text"], table.items input[type="number"] {
  padding: 6px 8px;
  font-size: 14px;
  border-radius: 8px;
}
table.items .catrow td {
  background: #f7f2ea;
  font-weight: 600;
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 1px;
}

.num { width: 78px; }
.code-cell { width: 62px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }

.qr-card { text-align: center; }
.qr-card img { width: 260px; max-width: 80vw; }

.pill { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: #f4efe7; color: var(--gold); }
.pill.ok { background: #eef7ee; color: #4a8b4a; }
.pill.bad { background: #fdf1ef; color: var(--red); }

/* ---------- 售罄提示 ---------- */
.soldout-tag {
  font-size: 12px;
  color: #fff;
  background: #b9b2a9;
  border-radius: 6px;
  padding: 3px 9px;
  white-space: nowrap;
}

.soldout-tag.inline { font-size: 10px; padding: 1px 6px; vertical-align: 1px; }

.item.off { opacity: 0.55; }
.item.off .price { color: var(--muted); }

.item.shake { animation: shake 0.5s; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.cartbar .warn { color: var(--red); font-weight: 600; }

/* ---------- 购物车面板 ---------- */
.sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(30, 20, 15, 0.38);
}

.cart-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 61;
  max-height: 76vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 30px rgba(60, 40, 25, 0.18);
  animation: slideUp 0.22s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(18px); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}

.sheet-head b { font-size: 17px; }
.sheet-head .sheet-note { flex: 1; font-size: 12px; color: var(--muted); }

.sheet-head button {
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
}

.sheet-body { overflow-y: auto; padding: 6px 16px; flex: 1; }

.sheet-empty {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 32px 0;
}

.cart-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid #f5efe6;
}

.cart-line.off .cl-name { color: var(--muted); text-decoration: line-through; }
.cl-info { flex: 1; min-width: 0; }
.cl-name { font-size: 15px; }
.cl-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.cl-ctrl { display: flex; align-items: center; gap: 6px; }

.cl-ctrl button {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--red);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.cl-ctrl button.plus { background: var(--red); color: #fff; border-color: var(--red); }
.cl-ctrl button[disabled] { opacity: 0.35; }
.cl-ctrl .qty { min-width: 16px; text-align: center; font-weight: 600; }

.cl-price {
  width: 68px;
  text-align: right;
  font-weight: 600;
  color: var(--red);
  font-size: 15px;
}

.cl-del {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.sheet-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}

.sheet-total { flex: 1; font-size: 15px; }
.sheet-total b { font-size: 19px; color: var(--red); }

body.sheet-open { overflow: hidden; }

@media (max-width: 560px) {
  .head h1 { font-size: 19px; }
  table.items { font-size: 13px; }
  .admin-head nav a { padding: 6px 9px; font-size: 13px; }
}
