:root {
  --brand: #FF7A45;
  --brand-dark: #E8622E;
  --brand-light: #FFE8DC;
  --bg: #FFF7F0;
  --card: #FFFFFF;
  --text: #2E2A27;
  --sub: #9A918A;
  --line: #F1EAE4;
  --danger: #E5483B;
  --ok: #2E9E63;
  --header-h: 48px;
  --tabs-h: 56px;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
body.noscroll { overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
img { display: block; }
[hidden] { display: none !important; }

#app { max-width: 560px; margin: 0 auto; min-height: 100vh; }

/* 顶栏 */
#top {
  position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top);
  background: var(--brand); color: #fff;
}
#top h1 { margin: 0; height: var(--header-h); line-height: var(--header-h); text-align: center; font-size: 17px; font-weight: 600; }

#view { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px); }

/* 底部 tab */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-width: 560px; margin: 0 auto;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; height: var(--tabs-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--sub); text-decoration: none; font-size: 11px; gap: 1px;
}
.tab.active { color: var(--brand); font-weight: 600; }
.tab-icon { font-size: 21px; line-height: 1; position: relative; filter: grayscale(1); opacity: .6; }
.tab.active .tab-icon { filter: none; opacity: 1; }
.tab-badge {
  position: absolute; top: -4px; right: -12px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 17px;
  font-style: normal; text-align: center; font-weight: 600;
}

/* 通用 */
.card { background: var(--card); border-radius: 14px; margin: 12px; padding: 14px; box-shadow: 0 2px 10px rgba(255, 122, 69, .07); }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.sub { color: var(--sub); font-size: 13px; }
.price { color: var(--brand); font-weight: 600; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; color: var(--sub); padding: 80px 24px; }
.empty .big { font-size: 56px; margin-bottom: 8px; }
.empty .btn { margin-top: 20px; }
.ops { display: inline-flex; gap: 6px; align-items: center; flex-shrink: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 42px; padding: 0 20px; border-radius: 21px; font-weight: 600; font-size: 15px;
  transition: transform .08s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .5; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.soft { background: var(--brand-light); color: var(--brand-dark); }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid #F6C9C4; }
.btn.small { height: 32px; padding: 0 14px; font-size: 13px; border-radius: 16px; }
.btn.block { display: flex; width: 100%; }
.link { color: var(--brand-dark); font-size: 13px; padding: 4px 6px; }
.link.danger { color: var(--danger); }
.link.light { color: #bbb; }

.input {
  width: 100%; font: inherit; font-size: 16px; /* ≥16px 防止 iOS 自动放大 */
  border: 1px solid var(--line); background: #FCFAF8; border-radius: 10px; padding: 10px 12px;
  color: var(--text); outline: none; -webkit-appearance: none; appearance: none;
}
.input:focus { border-color: var(--brand); background: #fff; }
textarea.input { resize: none; }

.tip {
  display: flex; gap: 8px; align-items: center; margin: 12px; padding: 10px 12px;
  background: #FFF3D6; color: #8A5B00; border-radius: 12px; font-size: 13px;
}

/* 登录 */
.login { padding: 24px 20px; text-align: center; }
.login .logo { width: 132px; height: 132px; border-radius: 50%; margin: 12px auto 0; box-shadow: 0 6px 20px rgba(255, 122, 69, .25); }
.login h2 { margin: 4px 0 0; font-size: 24px; }
.login > .sub { margin: 0 0 24px; }
.roles { display: flex; gap: 12px; margin-bottom: 16px; }
.role {
  flex: 1; background: #fff; border: 2px solid transparent; border-radius: 16px; padding: 16px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: 0 2px 10px rgba(0, 0, 0, .04);
}
.role.on { border-color: var(--brand); background: #FFF3EC; }
.role-icon { font-size: 36px; }
.login .input { margin-bottom: 12px; }
.login .btn { margin-top: 8px; }

/* 点菜 */
.menu { display: flex; align-items: flex-start; }
.side {
  position: sticky; top: calc(var(--header-h) + env(safe-area-inset-top));
  width: 84px; flex-shrink: 0; max-height: calc(100vh - var(--header-h) - var(--tabs-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto; background: #F6EFE9; min-height: 50vh;
}
.side-item { display: block; width: 100%; padding: 16px 6px; font-size: 13px; color: #6F6660; text-align: center; position: relative; }
.side-item.on { background: var(--bg); color: var(--brand); font-weight: 600; }
.side-item.on::before { content: ''; position: absolute; left: 0; top: 30%; bottom: 30%; width: 3px; border-radius: 2px; background: var(--brand); }
.dishes { flex: 1; min-width: 0; }
.cat-title { margin: 0; padding: 14px 12px 4px; font-size: 13px; color: var(--sub); font-weight: 500; scroll-margin-top: calc(var(--header-h) + env(safe-area-inset-top)); }
.dish { display: flex; gap: 10px; padding: 10px 12px; }
.dish-img { width: 84px; height: 84px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: var(--brand-light); }
.ph { display: flex; align-items: center; justify-content: center; background: var(--brand-light); font-size: 28px; }
.dish-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dish-name { font-weight: 600; font-size: 16px; }
.dish-desc { flex: 1; color: var(--sub); font-size: 12px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.stepper { display: flex; align-items: center; flex-shrink: 0; }
.sbtn { width: 28px; height: 28px; border-radius: 50%; font-size: 20px; line-height: 1; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.sbtn.plus { background: var(--brand); color: #fff; }
.sbtn.minus { border: 1.5px solid var(--brand); color: var(--brand); }
.qty { min-width: 30px; text-align: center; font-weight: 600; }

#cartbar {
  position: fixed; z-index: 25; left: 12px; right: 12px; max-width: 536px; margin: 0 auto;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 10px);
  height: 54px; border-radius: 27px; background: #2E2A27; color: #fff;
  display: flex; align-items: center; overflow: hidden; box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}
.cart-icon { font-size: 26px; margin: 0 14px 0 18px; position: relative; }
.cart-icon i { position: absolute; top: -4px; right: -10px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); font-size: 11px; line-height: 18px; text-align: center; font-style: normal; font-weight: 600; }
.cart-total { font-size: 18px; margin-right: 6px; }
.go { height: 100%; padding: 0 26px; background: var(--brand); color: #fff; font-weight: 600; font-size: 16px; }

/* 弹层 */
#sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-mask { position: absolute; inset: 0; background: rgba(0, 0, 0, .4); animation: fade .2s; }
.sheet-body {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto;
  max-height: 88vh; overflow-y: auto; background: #fff; border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
@keyframes fade { from { opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 16px; }
.line { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; flex-shrink: 0; font-size: 22px; }
.note { margin: 12px 0; height: 76px; }
.submit-row { padding-top: 4px; }
.big-price { font-size: 20px; }
.big-img { width: 100%; border-radius: 12px; }

/* 订单 */
.order .items { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.order-note { margin-top: 10px; background: #FAF6F2; border-radius: 8px; padding: 8px 10px; font-size: 14px; color: #6F6660; }
.order .foot { margin-top: 10px; }
.order.s-done, .order.s-cancelled { opacity: .65; }
.pill { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 10px; flex-shrink: 0; }
.p-pending { background: #FFEDE3; color: var(--brand-dark); }
.p-cooking { background: #FFF4CF; color: #B07800; }
.p-done { background: #E2F4EA; color: var(--ok); }
.p-cancelled { background: #F0F0F0; color: #999; }

/* 后厨 */
.section-head { margin: 18px 14px 0; }
.section-head .btn + .btn { margin-left: 6px; }
.cat-head { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.kdish { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #F8F4F0; }
.kdish:last-child { border-bottom: 0; }
.kdish.off { opacity: .5; }
.tag { font-size: 11px; background: #bbb; color: #fff; border-radius: 4px; padding: 0 5px; vertical-align: 1px; }

.img-pick { display: block; cursor: pointer; }
.img-pick img, .img-pick .ph { width: 100%; height: 190px; border-radius: 12px; object-fit: cover; }
.img-pick .ph { flex-direction: column; font-size: 36px; }
.form { margin: 8px 0 16px; }
.field { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.field > span:first-child { width: 40px; flex-shrink: 0; color: #6F6660; font-size: 14px; }
.switch {
  -webkit-appearance: none; appearance: none; width: 48px; height: 28px; border-radius: 14px; background: #ddd;
  position: relative; transition: background .2s; flex-shrink: 0; margin: 0;
}
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(20px); }

#toast {
  position: fixed; left: 50%; top: 40%; z-index: 99; transform: translate(-50%, -50%) scale(.9);
  background: rgba(30, 26, 24, .88); color: #fff; padding: 10px 18px; border-radius: 12px; font-size: 14px;
  max-width: 80vw; text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
