:root {
  --bg: #F3EEF1;
  --app-bg: #FFF7FA;
  --surface: #FFFFFF;
  --surface-muted: #FFF5F8;
  --text: #2B2028;
  --text-muted: #8A7680;
  --border: rgba(219, 39, 119, 0.16);
  --border-soft: rgba(219, 39, 119, 0.10);
  --brand: #DB2777;
  --brand-soft: #FCE7F3;
  --brand-soft-strong: #FBCFE8;
  --brand-text: #9D174D;
  --brand-on: #FFFFFF;
  --danger: #E0525A;

  --radius-s: 8px;
  --radius: 12px;
  --radius-l: 18px;
  --radius-full: 999px;
  --gap-1: 4px;
  --gap-2: 8px;
  --gap-3: 12px;
  --gap-4: 16px;
  --gap-5: 20px;

  --font: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "SF Pro Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 2px 10px rgba(157, 23, 77, 0.06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* hidden 必须压得住组件自己的 display */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

body { display: flex; justify-content: center; }

.app {
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  background: var(--app-bg);
  display: flex;
  flex-direction: column;
  padding: 16px 14px calc(84px + env(safe-area-inset-bottom));
  gap: 12px;
  position: relative;
}

/* ---------- 顶部 ---------- */
.hd { display: flex; align-items: center; gap: 10px; }
.avatar {
  flex: none; width: 42px; height: 42px; border-radius: 50%;
  background: var(--brand-soft); border: 1.5px solid var(--brand-soft-strong);
  display: flex; align-items: center; justify-content: center;
  color: var(--brand-text); font-size: 17px; font-weight: 600; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hd-id { flex: 1; min-width: 0; }
.hd-id h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: 0.2px; }
.hd-id p { margin: 1px 0 0; font-size: 12.5px; color: var(--text-muted); }

.btn-pill {
  flex: none; border: 1.5px solid var(--brand); background: var(--surface);
  color: var(--brand-text); font-family: var(--font); font-size: 13px;
  padding: 7px 13px; border-radius: var(--radius-full); cursor: pointer;
}
.btn-icon {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text-muted); display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
}

/* ---------- 搜索 ---------- */
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-full); padding: 9px 14px;
}
.search:focus-within { border-color: var(--brand); }
.search-icon { flex: none; color: var(--text-muted); }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font-family: var(--font); font-size: 14px; color: var(--text); padding: 0;
  -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: var(--text-muted); }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear {
  flex: none; border: 0; background: var(--brand-soft); color: var(--brand-text);
  width: 20px; height: 20px; border-radius: 50%; font-size: 15px; line-height: 1;
  cursor: pointer; padding: 0;
}

/* ---------- 主体：左侧分类 + 右侧列表 ---------- */
.main { display: flex; gap: 10px; align-items: flex-start; flex: 1; }

.cats {
  flex: none; width: 78px;
  display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 8px;
}
.cat {
  width: 100%; border: 1.5px solid transparent; background: transparent;
  color: var(--text-muted); font-family: var(--font); font-size: 13.5px;
  padding: 12px 4px; border-radius: var(--radius); cursor: pointer; text-align: center;
}
.cat.on {
  border-color: var(--brand-soft-strong); background: var(--brand-soft);
  color: var(--brand-text); font-weight: 600;
}

.list-wrap { flex: 1; min-width: 0; }

/* ---------- 菜品列表 ---------- */
.list { display: flex; flex-direction: column; gap: 9px; }
.dish {
  display: flex; align-items: center; gap: 11px;
  background: var(--surface); border: 1.5px solid var(--border-soft);
  border-radius: var(--radius); padding: 9px 11px; box-shadow: var(--shadow);
  transition: border-color .12s, background .12s;
}
.dish.on { border-color: var(--brand); background: var(--brand-soft); }
.thumb {
  flex: none; width: 64px; height: 64px; border-radius: var(--radius-s);
  object-fit: cover; display: block; background: var(--surface-muted);
  border: 1px solid var(--border-soft);
}
.dish-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dish-name { font-size: 15.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dish-meta { font-size: 12.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.add-btn {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  border: 1.5px solid var(--brand); background: var(--surface); color: var(--brand);
  font-size: 17px; line-height: 1; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center; font-family: var(--font);
}
.dish.on .add-btn { background: var(--brand); color: var(--brand-on); border-color: var(--brand); }

.placeholder { text-align: center; color: var(--text-muted); font-size: 13.5px; padding: 30px 20px; }

/* ---------- 底部已选条 ---------- */
.cartbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 430px;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--app-bg) 62%, rgba(255, 247, 250, 0));
}
.btn-primary, .btn-ghost, .btn-danger {
  font-family: var(--font); border-radius: var(--radius-full);
  cursor: pointer; border: 1.5px solid transparent; padding: 12px 18px;
  font-size: 15px; font-weight: 600;
}
.btn-primary { flex: 1; background: var(--brand); color: var(--brand-on); border-color: var(--brand); }
.btn-primary:disabled { background: var(--brand-soft-strong); color: #FFFFFF; border-color: transparent; opacity: .6; cursor: default; }
.btn-ghost { flex: none; background: var(--surface); color: var(--brand-text); border-color: var(--border); font-weight: 500; }
.btn-danger { background: var(--surface); color: var(--danger); border-color: rgba(224, 82, 90, .3); font-weight: 500; }
.btn-ghost.wide, .btn-danger.wide { width: 100%; text-align: center; }

/* ---------- 面板 ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(43, 32, 40, .34); }
.sheet-panel {
  position: relative; width: 100%; max-width: 430px; max-height: 92vh;
  background: var(--app-bg); border-radius: var(--radius-l) var(--radius-l) 0 0;
  display: flex; flex-direction: column;
  animation: rise .18s ease-out;
}
@keyframes rise { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-hd {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 16px 10px;
}
.sheet-title h2 { margin: 0; font-size: 17px; font-weight: 600; }
.sheet-title p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-muted); }
.sheet-body {
  flex: 1; overflow-y: auto; padding: 0 16px;
  display: flex; flex-direction: column; gap: 14px;
}
.sheet-ft {
  display: flex; gap: 10px; padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-soft);
}
.sheet-ft .btn-primary { flex: 1; }
.link {
  border: 0; background: transparent; color: var(--brand-text);
  font-family: var(--font); font-size: 13.5px; font-weight: 500;
  cursor: pointer; padding: 2px 0;
}

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.label { font-size: 12.5px; font-weight: 600; color: var(--brand-text); }
.input {
  width: 100%; border: 1.5px solid var(--border); background: var(--surface);
  border-radius: var(--radius); padding: 10px 12px;
  font-family: var(--font); font-size: 14.5px; color: var(--text);
  outline: 0; resize: none;
}
.input:focus { border-color: var(--brand); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text-muted); font-family: var(--font); font-size: 13px;
  padding: 7px 13px; border-radius: var(--radius-full); cursor: pointer;
}
.chip.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-text); font-weight: 600; }

/* ---------- 点单行 ---------- */
.line {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1.5px solid var(--border-soft);
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 9px;
}
.line-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.line-name { font-size: 15px; font-weight: 500; }
.line-note {
  border: 0; border-bottom: 1px dashed var(--border); background: transparent;
  font-family: var(--font); font-size: 12.5px; color: var(--text);
  padding: 1px 0 2px; outline: 0; width: 100%;
}
.line-note::placeholder { color: var(--text-muted); }
.line-note:focus { border-bottom-color: var(--brand); }
.stepper { flex: none; display: flex; align-items: center; gap: 8px; }
.stepper button {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1.5px solid var(--brand); background: var(--surface); color: var(--brand);
  font-size: 16px; line-height: 1; cursor: pointer; padding: 0; font-family: var(--font);
}
.stepper .step-plus { background: var(--brand); color: var(--brand-on); }
.stepper .qty { min-width: 16px; text-align: center; font-size: 14.5px; font-weight: 600; }

/* ---------- 配图预览 ---------- */
.preview { display: flex; flex-direction: column; gap: 8px; }
.preview img {
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block;
  border-radius: var(--radius); border: 1.5px solid var(--border-soft); background: var(--surface-muted);
}
.preview-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hint { font-size: 12.5px; color: var(--text-muted); }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  z-index: 90; max-width: 300px;
  background: rgba(43, 32, 40, .92); color: #FFF;
  font-size: 13.5px; padding: 11px 16px; border-radius: var(--radius-full);
  text-align: center; box-shadow: 0 4px 18px rgba(43, 32, 40, .22);
}
