/* 家常菜点餐系统 · 共享样式（移动端优先，两端页面共用） */
:root {
  --bg: #faf6f0;
  --surface: #ffffff;
  --surface-2: #f3ede4;
  --text: #2b2118;
  --text-2: #6f6257;
  --text-3: #857868;
  --line: #e8dfd3;
  --primary: #d9482b;
  --primary-hover: #c23d23;
  --primary-soft: #fdeae5;
  --accent: #e8a33d;
  --accent-soft: #fff3df;
  --success: #3f9d5a;
  --success-soft: #e6f5ea;
  --info: #3b82c4;
  --info-soft: #e7f0fa;
  --danger: #d9482b;
  --danger-soft: #fdeae5;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(43, 33, 24, 0.05), 0 6px 20px rgba(43, 33, 24, 0.06);
  --shadow-lg: 0 -4px 30px rgba(43, 33, 24, 0.14);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans CJK SC", "Segoe UI", Roboto, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --topbar-h: 52px;
  --tabbar-h: 56px;
  --max-w: 720px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171310;
    --surface: #221c18;
    --surface-2: #2c2520;
    --text: #f2ebe3;
    --text-2: #b8ab9e;
    --text-3: #9a8d80;
    --line: #382f29;
    --primary: #ee6a4c;
    --primary-hover: #f57d62;
    --primary-soft: #3d221b;
    --accent: #f0b35a;
    --accent-soft: #3a2c16;
    --success: #5cb877;
    --success-soft: #1e3324;
    --info: #6aa5e0;
    --info-soft: #1c2a3a;
    --danger: #ee6a4c;
    --danger-soft: #3d221b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 -4px 30px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  --bg: #171310;
  --surface: #221c18;
  --surface-2: #2c2520;
  --text: #f2ebe3;
  --text-2: #b8ab9e;
  --text-3: #9a8d80;
  --line: #382f29;
  --primary: #ee6a4c;
  --primary-hover: #f57d62;
  --primary-soft: #3d221b;
  --accent: #f0b35a;
  --accent-soft: #3a2c16;
  --success: #5cb877;
  --success-soft: #1e3324;
  --info: #6aa5e0;
  --info-soft: #1c2a3a;
  --danger: #ee6a4c;
  --danger-soft: #3d221b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 -4px 30px rgba(0, 0, 0, 0.5);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
ul, ol { margin: 0; padding: 0; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* 布局 */
.container { width: 100%; max-width: var(--max-w); margin: 0 auto; padding: 0 16px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 顶栏 / 底栏 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding-top: var(--safe-top);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .container { display: flex; align-items: center; gap: 10px; height: var(--topbar-h); }
.topbar h1 { font-size: 18px; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: none; color: var(--text-3); font-size: 11px; position: relative;
}
.tabbar button .ico { font-size: 22px; line-height: 1; }
.tabbar button.active { color: var(--primary); }
.tabbar button .badge { position: absolute; top: 6px; left: calc(50% + 6px); }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  font-weight: 500; white-space: nowrap; user-select: none;
  transition: background 0.15s, transform 0.05s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; border-color: var(--line); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-icon { width: 44px; padding: 0; font-size: 20px; }
.btn-icon.btn-sm { width: 34px; }

/* 表单 */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 14px; font-weight: 500; color: var(--text-2); }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23a3958a' stroke-width='1.6' d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.help { font-size: 12px; color: var(--text-3); }
.search {
  display: flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 12px;
  border-radius: var(--radius-pill); background: var(--surface-2);
}
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; min-height: 40px; }
.search input::placeholder { color: var(--text-3); }

/* 卡片 / 芯片 / 标记 */
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px;
}
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 32px; padding: 0 12px; border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--text-2); font-size: 14px;
  border: 1px solid transparent; white-space: nowrap; user-select: none;
}
.chip.active { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 6px;
  font-size: 12px; line-height: 20px;
  background: var(--accent-soft); color: #9a5f0a;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tag { color: var(--accent); } }
:root[data-theme="dark"] .tag { color: var(--accent); }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--primary); color: #fff; font-size: 11px; font-weight: 600; line-height: 1;
}
.status {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: var(--radius-pill); font-size: 13px; font-weight: 500;
}
.status-pending { background: var(--accent-soft); color: #9a5f0a; }
.status-cooking { background: var(--info-soft); color: var(--info); }
.status-done { background: var(--success-soft); color: var(--success); }
.status-cancelled { background: var(--surface-2); color: var(--text-2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .status-pending { color: var(--accent); } }
:root[data-theme="dark"] .status-pending { color: var(--accent); }

/* 菜品图片 / 图标占位 */
.thumb {
  flex: 0 0 auto; width: 72px; height: 72px; border-radius: var(--radius-sm);
  background: var(--surface-2); overflow: hidden;
  display: flex; align-items: center; justify-content: center; font-size: 36px;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-lg { width: 100%; height: 200px; border-radius: 0; font-size: 84px; }

/* 数量步进器 */
.stepper { display: inline-flex; align-items: center; gap: 2px; }
.stepper button {
  width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary); font-size: 18px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.stepper button.plus { background: var(--primary); color: #fff; }
.stepper button:disabled { opacity: 0.4; }
.stepper .num { min-width: 28px; text-align: center; font-weight: 600; }

/* 底部弹层 / 对话框 */
.sheet-backdrop, .modal-backdrop {
  position: fixed; inset: 0; z-index: 40;
  -webkit-tap-highlight-color: transparent;
  background: rgba(20, 12, 8, 0.45);
  opacity: 0; transition: opacity 0.2s;
}
.sheet-backdrop.open, .modal-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-height: 88vh; max-height: 88dvh;
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: var(--shadow-lg);
  transform: translateY(100%); transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet.open { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; margin: 10px auto 0; border-radius: 2px; background: var(--line); }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 10px 16px; }
.sheet-head h2 { flex: 1; font-size: 17px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 0 16px 16px; -webkit-overflow-scrolling: touch; }
.sheet-foot {
  padding: 10px 16px calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--line); background: var(--surface);
}
.modal-backdrop { z-index: 42; } /* 确认框要盖在 .sheet(41) 之上 */
.modal {
  position: fixed; left: 50%; top: 50%; z-index: 43;
  width: calc(100% - 40px); max-width: 420px;
  transform: translate(-50%, -50%) scale(0.96);
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg);
  padding: 20px; opacity: 0; transition: opacity 0.18s, transform 0.18s;
}
.modal.open { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.modal h2 { font-size: 17px; margin-bottom: 8px; }
.modal .actions { display: flex; gap: 10px; margin-top: 18px; }
.modal .actions .btn { flex: 1; }
@media (min-width: 640px) {
  .sheet { left: 50%; right: auto; width: 100%; max-width: 560px; transform: translate(-50%, 100%); }
  .sheet.open { transform: translate(-50%, 0); }
}

/* 提示条 */
.toast-host {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 20px);
  z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  max-width: calc(100% - 40px); padding: 10px 16px; border-radius: var(--radius-sm);
  background: rgba(43, 33, 24, 0.92); color: #fff; font-size: 14px;
  box-shadow: var(--shadow); animation: toast-in 0.2s ease-out;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 空状态 / 骨架 */
.empty { text-align: center; padding: 48px 16px; color: var(--text-3); }
.empty .ico { font-size: 48px; margin-bottom: 8px; }
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* 分隔线 / 列表 */
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.list > * + * { border-top: 1px solid var(--line); }
