:root {
  --bg: #FBF7F0;
  --card: #FFFFFF;
  --ink: #2B2118;
  --muted: #8A7A6B;
  --brand: #E4572E;
  --brand-soft: #FDEBE4;
  --green: #3F7A5E;
  --green-soft: #E8F2EC;
  --amber: #F2A03D;
  --line: #EFE6DA;
  --shadow: 0 2px 14px rgba(66, 44, 24, .07);
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body { padding-bottom: calc(74px + var(--safe-b)); max-width: 620px; margin: 0 auto; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------------- 顶部 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: 14px 16px 8px;
  background: linear-gradient(180deg, #FFFDF9 60%, rgba(251, 247, 240, .92));
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid transparent;
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  font-size: 22px;
  background: var(--brand-soft);
  border-radius: 14px;
}
.brand-text { min-width: 0; }
.brand h1 { margin: 0; font-size: 19px; letter-spacing: .5px; }
#greeting { margin: 1px 0 0; font-size: 12.5px; color: var(--muted); }
.admin-link {
  text-decoration: none; font-size: 18px; opacity: .55;
  width: 38px; height: 38px; display: grid; place-items: center;
}
.admin-link:active { opacity: 1; }

.notice {
  margin: 10px 0 0; padding: 8px 12px;
  background: var(--green-soft); color: var(--green);
  border-radius: 12px; font-size: 12.5px; line-height: 1.45;
}
.notice:empty { display: none; }

.search-wrap { position: relative; margin-top: 10px; }
.search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-size: 13px; opacity: .5;
}
#search {
  width: 100%; padding: 12px 14px 12px 38px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  outline: none; box-shadow: var(--shadow); font-size: 14px;
}
#search:focus { border-color: #E9C7B6; }

/* ---------------- 分类 chips ---------------- */
.chips {
  position: sticky; top: 0; z-index: 15;
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  padding: 10px 16px 12px;
  background: var(--bg);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 15px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff;
  color: var(--muted); font-size: 13px; white-space: nowrap;
  transition: all .18s ease;
}
.chip.active {
  background: var(--ink); border-color: var(--ink); color: #FFF6EC; font-weight: 600;
}

/* ---------------- 列表 ---------------- */
.view { padding: 4px 16px 16px; }
.dish-list { display: flex; flex-direction: column; gap: 10px; }
.section-title {
  margin: 18px 2px 8px; font-size: 13px; color: var(--muted);
  letter-spacing: 2px; font-weight: 600;
}
.section-title:first-child { margin-top: 6px; }

.dish {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--card); border-radius: var(--radius);
  padding: 13px 14px; box-shadow: var(--shadow);
  border: 1px solid rgba(239, 230, 218, .7);
  transition: transform .12s ease;
}
.dish:active { transform: scale(.985); }
.dish-thumb {
  width: 52px; height: 52px; flex: none; border-radius: 15px;
  display: grid; place-items: center; font-size: 25px;
  background: linear-gradient(145deg, #FFF3E6, #FDE8DA);
}
.dish-body { flex: 1; min-width: 0; }
.dish-name { margin: 0 0 3px; font-size: 16px; font-weight: 600; letter-spacing: .3px; }
.dish-desc {
  margin: 0; font-size: 12.5px; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.dish-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.tag {
  font-size: 11px; padding: 2px 7px; border-radius: 6px;
  background: #F7F2EA; color: #8B7B6A;
}
.tag.spicy { background: #FDECE7; color: #C4471F; }
.tag.cilantro { background: var(--green-soft); color: var(--green); }
.tag.off { background: #F2F2F2; color: #A9A9A9; }

.add-btn {
  flex: none; align-self: center;
  width: 34px; height: 34px; border-radius: 50%;
  border: none; background: var(--brand); color: #fff;
  font-size: 20px; line-height: 1; display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(228, 87, 46, .3);
}
.add-btn:active { transform: scale(.9); }

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

/* ---------------- 菜单篮 ---------------- */
.cart-list { display: flex; flex-direction: column; gap: 10px; }
.cart-item {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card); border-radius: var(--radius);
  padding: 13px 14px; box-shadow: var(--shadow);
}
.cart-main { flex: 1; min-width: 0; }
.cart-item h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.cart-opts { margin: 0; font-size: 12px; color: var(--muted); }
.cart-opts span + span::before { content: " · "; }

.stepper { display: inline-flex; align-items: center; gap: 2px; }
.stepper button {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: 16px; line-height: 1; display: grid; place-items: center;
}
.stepper span { min-width: 26px; text-align: center; font-size: 14px; }
.stepper.big button { width: 34px; height: 34px; font-size: 18px; }
.stepper.big span { font-size: 16px; font-weight: 600; }

.cart-foot { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); letter-spacing: 1px; }
.field input, .field textarea, .text-input {
  width: 100%; padding: 11px 13px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; outline: none; font-size: 14px;
  resize: none;
}
.field input:focus, .field textarea:focus, .text-input:focus { border-color: #E9C7B6; }

.primary-btn {
  width: 100%; padding: 14px; border: none; border-radius: 15px;
  background: var(--brand); color: #fff; font-size: 15.5px; font-weight: 600;
  letter-spacing: 1px; box-shadow: 0 8px 20px rgba(228, 87, 46, .25);
}
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled { background: #D8CFC5; box-shadow: none; }
.ghost-btn {
  padding: 12px 18px; border-radius: 14px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 14px;
}

/* ---------------- 订单 ---------------- */
.order-list { display: flex; flex-direction: column; gap: 12px; }
.order {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.order-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.order-who { font-size: 14px; font-weight: 600; }
.order-time { font-size: 11.5px; color: var(--muted); }
.status {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  background: #FFF4D9; color: #9A6B00;
}
.status.done { background: var(--green-soft); color: var(--green); }
.order-items { margin: 0; padding: 0; list-style: none; font-size: 13px; }
.order-items li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 4px 0; border-bottom: 1px dashed #F4EDE4;
}
.order-items li:last-child { border-bottom: none; }
.order-items em { font-style: normal; color: var(--muted); font-size: 12px; }
.order-note {
  margin: 8px 0 0; font-size: 12.5px; color: var(--brand);
  background: var(--brand-soft); padding: 7px 10px; border-radius: 10px;
}

/* ---------------- 底部 tab ---------------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
  width: 100%; max-width: 620px;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 8px 8px calc(8px + var(--safe-b));
  background: rgba(255, 253, 249, .96);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  z-index: 30;
}
.tab {
  position: relative; border: none; background: none; color: var(--muted);
  font-size: 11.5px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 0; letter-spacing: 1px;
}
.tab span { font-size: 19px; line-height: 1.1; filter: grayscale(1); opacity: .6; }
.tab.active { color: var(--brand); font-weight: 600; }
.tab.active span { filter: none; opacity: 1; }
.badge {
  position: absolute; top: 0; right: 50%; margin-right: -26px;
  min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--brand); color: #fff; border-radius: 999px;
  font-size: 10.5px; font-style: normal; line-height: 17px; text-align: center;
}

/* ---------------- 详情弹层 ---------------- */
.sheet-mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(43, 33, 24, .42);
  display: flex; align-items: flex-end;
  animation: fade .18s ease;
}
.sheet {
  width: 100%; max-width: 620px; margin: 0 auto;
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  padding: 8px 20px calc(20px + var(--safe-b));
  max-height: 88vh; overflow-y: auto;
  animation: rise .26s cubic-bezier(.2, .9, .25, 1);
}
@keyframes rise { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet-grab { width: 40px; height: 4px; border-radius: 4px; background: #E3D7C9; margin: 4px auto 14px; }
.sheet-head { display: flex; gap: 12px; align-items: flex-start; }
.sheet-emoji {
  width: 56px; height: 56px; border-radius: 18px; flex: none;
  background: linear-gradient(145deg, #FFF3E6, #FBE0CE);
  display: grid; place-items: center; font-size: 28px;
}
.sheet-head h2 { margin: 4px 0 4px; font-size: 20px; }
.sheet-tags { margin: 0; font-size: 12px; color: var(--muted); }
.sheet-close {
  margin-left: auto; width: 32px; height: 32px; border-radius: 50%;
  border: none; background: #F1E9DF; color: var(--muted); font-size: 14px;
}
.sheet-desc {
  margin: 14px 0 4px; font-size: 13.5px; color: #6C5C4D; line-height: 1.6;
  background: #fff; border-radius: 14px; padding: 12px 14px; border: 1px solid var(--line);
}
.opt-group { margin-top: 16px; }
.opt-group h3 { margin: 0 0 8px; font-size: 12.5px; color: var(--muted); letter-spacing: 1px; font-weight: 600; }
.opt-group.row { display: flex; align-items: center; justify-content: space-between; }
.opt-group.row h3 { margin: 0; }

.segmented { display: flex; gap: 6px; background: #F3ECE2; padding: 4px; border-radius: 13px; }
.segmented button {
  flex: 1; padding: 8px 0; border: none; border-radius: 10px;
  background: transparent; color: var(--muted); font-size: 13px;
}
.segmented button.on { background: #fff; color: var(--brand); font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,.06); }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
.switch input { appearance: none; width: 44px; height: 26px; border-radius: 999px; background: #E3D7C9; position: relative; transition: .2s; }
.switch input:checked { background: var(--green); }
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked::after { transform: translateX(18px); }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  padding: 7px 13px; border-radius: 999px; font-size: 12.5px;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
}
.pill.on { background: var(--brand-soft); border-color: #F3C4B2; color: var(--brand); font-weight: 600; }

.sheet-foot { display: flex; gap: 12px; align-items: center; margin-top: 22px; }
.sheet-foot .primary-btn { flex: 1; }

/* ---------------- 成功 & toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%);
  background: rgba(43, 33, 24, .92); color: #fff; font-size: 13px;
  padding: 10px 18px; border-radius: 999px; z-index: 80;
  animation: fade .2s ease;
}
.done-mask {
  position: fixed; inset: 0; z-index: 90; background: rgba(43, 33, 24, .45);
  display: grid; place-items: center; padding: 24px;
}
.done-card {
  background: var(--bg); border-radius: 24px; padding: 28px 24px 22px;
  text-align: center; width: 100%; max-width: 330px;
  animation: rise .3s cubic-bezier(.2, .9, .25, 1);
}
.done-icon { font-size: 46px; }
.done-card h2 { margin: 8px 0 6px; font-size: 20px; }
.done-card p { margin: 0 0 20px; font-size: 13px; color: var(--muted); }
.done-actions { display: flex; gap: 10px; }
.done-actions .primary-btn { flex: 1; }

/* 切到菜单篮/订单时收起搜索与分类，界面更干净 */
body[data-view="cart"] .search-wrap,
body[data-view="orders"] .search-wrap,
body[data-view="cart"] .chips,
body[data-view="orders"] .chips { display: none; }

/* 弹层底部留一点呼吸空间 */
.sheet { padding-bottom: calc(28px + var(--safe-b)); }

/* 后台标题区的副标题（index 用 #greeting，后台用普通 p） */
.brand-text p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.tag.note { background: #FFF3E0; color: #B26A00; }
