:root {
  --red: #9e2b25;
  --red-dark: #7d1f1a;
  --gold: #c8a24a;
  --bg: #f6f1e7;
  --card: #fffdf9;
  --ink: #2b2118;
  --muted: #8a7a66;
  --line: #e6dccb;
  --green: #3f6b4f;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: #e9e2d6;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

#app {
  max-width: 720px;
  min-height: calc(100vh - 30px);
  margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 0 40px rgba(60, 40, 20, .12);
  display: flex;
  flex-direction: column;
}

.icp-footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0));
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
}
.icp-footer a { color: var(--muted); text-decoration: none; }
.icp-footer a:hover { color: var(--red); }

/* ---------- 登录 ---------- */
.login {
  min-height: calc(100vh - 30px);
  padding: 18vh 28px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.brand { text-align: center; margin-bottom: 34px; }
.brand-mark {
  width: 92px; height: 92px; margin: 0 auto 16px;
  border-radius: 24px;
  background: var(--red);
  color: #fff;
  font-size: 52px;
  line-height: 92px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(158, 43, 37, .28);
}
.brand h1 { margin: 0; font-size: 26px; letter-spacing: 2px; }
.brand p { margin: 6px 0 0; color: var(--muted); font-size: 13px; letter-spacing: 3px; }
.login-form { width: 100%; max-width: 320px; display: grid; gap: 12px; }
.login-form input {
  height: 52px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card);
  text-align: center; letter-spacing: 2px;
}
.login-form input:focus { outline: 2px solid rgba(158, 43, 37, .35); }

/* ---------- 通用 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 14px calc(12px + env(safe-area-inset-top, 0)) 14px;
  padding-top: calc(12px + env(safe-area-inset-top, 0));
  background: rgba(246, 241, 231, .94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .title { display: flex; flex-direction: column; align-items: center; line-height: 1.25; }
.topbar .title b { font-size: 17px; }
.topbar .title small { color: var(--muted); font-size: 12px; }
.ghost { color: var(--muted); padding: 8px 10px; border-radius: 10px; font-size: 14px; }
.ghost:active { background: rgba(0, 0, 0, .05); }
.primary {
  background: var(--red); color: #fff; border-radius: 12px;
  padding: 12px 18px; font-weight: 600; letter-spacing: 1px;
  box-shadow: 0 6px 16px rgba(158, 43, 37, .22);
}
.primary:active { background: var(--red-dark); }
.primary.wide { width: 100%; height: 52px; font-size: 17px; margin-top: 10px; }
.ghost:disabled, .primary:disabled { opacity: .5; }

/* ---------- 首页 ---------- */
.home { padding: 18px 16px 40px; }
.new {
  width: 100%; display: flex; align-items: center; gap: 14px;
  padding: 18px; border-radius: 18px;
  background: linear-gradient(135deg, #a8322b, #8a221d);
  color: #fff; text-align: left;
  box-shadow: 0 10px 26px rgba(158, 43, 37, .22);
}
.new .plus {
  width: 44px; height: 44px; flex: 0 0 44px;
  border-radius: 50%; background: rgba(255, 255, 255, .16);
  font-size: 26px; line-height: 44px; text-align: center;
}
.new b { display: block; font-size: 18px; letter-spacing: 1px; }
.new small { opacity: .8; font-size: 12px; }
.library-entry {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 10px; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  text-align: left;
}
.library-entry b { display: block; font-size: 15px; }
.library-entry small { color: var(--muted); font-size: 11px; }
.library-entry .chev { font-size: 22px; color: var(--muted); }
.section-title { font-size: 13px; color: var(--muted); font-weight: 500; margin: 26px 4px 10px; letter-spacing: 1px; }
.order {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 15px 16px; margin-bottom: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  text-align: left;
}
.order:active { transform: scale(.995); }
.order-main b { display: block; font-size: 16px; }
.order-main span { color: var(--muted); font-size: 12px; }
.order-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.order-side em { font-style: normal; font-size: 11px; color: var(--muted); }
.order-side em.done { color: var(--green); }
.order-side small { color: var(--muted); font-size: 11px; }
.empty { color: var(--muted); text-align: center; padding: 30px 0; font-size: 14px; }

/* ---------- 表单 ---------- */
.form-wrap { padding: 16px 16px 46px; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; letter-spacing: 1px; }
.field input, .field select, .field textarea {
  width: 100%; height: 48px; padding: 0 12px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card);
}
.field textarea { height: auto; padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid rgba(158, 43, 37, .3); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quick-prices { display: flex; gap: 6px; margin-top: 6px; }
.quick {
  flex: 1; padding: 6px 0; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card); color: var(--muted); font-size: 13px;
}
.quick:active { border-color: var(--red); color: var(--red); }
.profit-row { display: flex; gap: 8px; align-items: center; }
.profit-row select { width: 100px; flex: 0 0 100px; }
.profit-row input { flex: 1; }
.profit-hint { display: block; margin-top: 6px; font-size: 11px; color: var(--muted); }
.weights { display: grid; gap: 8px; }
.weight-row { display: flex; align-items: center; gap: 10px; }
.weight-row span { width: 76px; flex: 0 0 76px; font-size: 14px; }
.weight-row input {
  width: 86px; height: 42px; padding: 0 10px; text-align: right;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card);
}
.weight-row em { font-style: normal; color: var(--muted); font-size: 13px; }
.weight-sum { margin-top: 6px; font-size: 12px; color: var(--muted); }
.weight-sum.bad { color: var(--red); }
.profit-row em { font-style: normal; color: var(--muted); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); font-size: 14px;
}
.chip input:checked + span { background: var(--red); border-color: var(--red); color: #fff; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink); }
.check input { width: 20px; height: 20px; accent-color: var(--red); }

/* ---------- 菜库 ---------- */
.lib-search-wrap { padding: 10px 14px 0; }
.lib-search {
  width: 100%; height: 46px; padding: 0 12px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card);
}
.library { padding: 6px 14px 40px; }
.lib-group {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 16px 2px 6px; font-size: 13px; color: var(--red);
  letter-spacing: 2px; font-weight: 600;
}
.lib-group span { color: var(--muted); font-weight: 400; letter-spacing: 0; }
.lib-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 9px 2px; border-bottom: 1px dashed var(--line);
}
.lib-row b { font-weight: 500; font-size: 16px; }
.lib-row span { font-size: 11px; color: var(--muted); text-align: right; }

/* ---------- 菜单 ---------- */
.tabs {
  display: flex; gap: 6px; padding: 10px 12px;
  overflow-x: auto; border-bottom: 1px solid var(--line);
  background: var(--bg); position: sticky; top: 61px; z-index: 15;
}
.tab {
  flex: 0 0 auto; padding: 8px 16px; border-radius: 999px;
  font-size: 14px; color: var(--muted); background: #efe7d8;
}
.tab.on { background: var(--ink); color: #fff; }
.menu { flex: 1; padding: 8px 14px 170px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.col h2 {
  font-size: 13px; color: var(--red); letter-spacing: 3px;
  margin: 4px 0 8px; font-weight: 600;
  border-bottom: 2px solid var(--gold); padding-bottom: 6px;
}
.col h2 .count {
  float: right; font-style: normal; font-size: 11px;
  color: var(--muted); letter-spacing: 0; font-weight: 400;
}
.col h2 .count.warn { color: var(--red); font-weight: 600; }
.dish-row {
  position: relative; display: flex; align-items: stretch;
  border-bottom: 1px dashed var(--line);
}
.dish {
  display: block; width: 100%; text-align: left;
  padding: 9px 2px 9px 18px; font-size: 17px; line-height: 1.35;
  color: var(--ink);
}
.dish.plain { padding-left: 2px; }
.dish-x {
  position: absolute; left: -3px; top: 5px; z-index: 2;
  width: 24px; height: 30px; line-height: 27px;
  font-size: 15px; color: #c7b9a3; border-radius: 50%;
  text-align: center;
}
.dish-x:active { color: var(--red); background: rgba(158, 43, 37, .1); }
.dish:active { color: var(--red); background: rgba(158, 43, 37, .04); }
.add-dish {
  display: block; width: 100%; margin-top: 8px; padding: 10px;
  border: 1px dashed var(--line); border-radius: 10px;
  color: var(--muted); font-size: 14px; background: transparent;
}
.add-dish:active { color: var(--red); border-color: var(--red); }
.foot { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 10px; }
.foot-row { display: flex; gap: 10px; padding: 5px 0; align-items: baseline; }
.foot-label { flex: 0 0 auto; font-size: 12px; color: var(--red); letter-spacing: 2px; }
.foot-items { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.foot-items .dish { width: auto; border: 0; padding: 2px 0; font-size: 15px; }
.foot-dish { display: inline-flex; align-items: center; gap: 1px; }
.dish-x.mini { position: static; width: 18px; height: 22px; line-height: 20px; font-size: 13px; }
.add-mini {
  width: 26px; height: 26px; border: 1px dashed var(--line);
  border-radius: 50%; color: var(--muted); font-size: 16px; line-height: 1;
}
.add-mini:active { color: var(--red); border-color: var(--red); }
.notes { margin-top: 16px; color: var(--muted); font-size: 12px; }
.notes p { margin: 3px 0; }
.eco {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin: 10px 14px 0; padding: 10px 12px;
  background: #fff8e8; border: 1px solid #eadfc6; border-radius: 12px;
}
.eco div { min-width: 0; }
.eco span { display: block; font-size: 11px; color: var(--muted); }
.eco b { display: block; font-size: 15px; color: var(--ink); }
.eco.warn { background: #fff1e6; border-color: #d9a441; }
.eco p { grid-column: 1 / -1; margin: 2px 0 0; font-size: 12px; color: var(--red); }

/* ---------- 底栏 ---------- */
.bottombar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 0; width: min(720px, 100%); z-index: 30;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0));
  background: rgba(255, 253, 249, .97);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.editbar { display: flex; gap: 8px; margin-bottom: 8px; }
.editbar input {
  flex: 1; height: 42px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); font-size: 14px;
}
.editbar button {
  width: 52px; border-radius: 10px; background: var(--ink); color: #fff; font-weight: 600;
}
.actions { display: flex; gap: 8px; align-items: center; }
.actions .primary { flex: 1; height: 46px; }

/* ---------- 弹层 ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(30, 20, 10, .38); z-index: 40; }
.sheet {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(720px, 100%); max-height: 72vh; overflow-y: auto;
  background: var(--card); z-index: 50;
  border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(22px + env(safe-area-inset-bottom, 0));
  box-shadow: 0 -10px 40px rgba(40, 20, 10, .18);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet-head b { font-size: 18px; margin: 0 6px; }
.sheet-head small { color: var(--muted); }
.sheet-tip { margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.sheet-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.sheet-actions .ghost {
  flex: 1; padding: 9px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); color: var(--ink);
}
.add-search {
  width: 100%; height: 46px; padding: 0 12px; margin-bottom: 10px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
}
.cand.custom {
  justify-content: center; border-style: dashed;
  color: var(--red); background: #fff8f4;
}
.cands { display: grid; gap: 8px; }
.cand {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 14px; border-radius: 12px; background: var(--bg);
  border: 1px solid var(--line); text-align: left;
}
.cand span { font-size: 16px; }
.cand em { font-style: normal; font-size: 11px; color: var(--muted); }
.cand:active { border-color: var(--red); }
.vers { display: grid; gap: 8px; }
.ver { display: flex; justify-content: space-between; align-items: center; padding: 12px; background: var(--bg); border-radius: 12px; }
.ver b { margin-right: 8px; }
.ver span { font-size: 13px; }
.ver small { display: block; color: var(--muted); font-size: 11px; }
.ver em { font-style: normal; color: var(--green); font-size: 12px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%);
  max-width: 86vw; padding: 11px 18px; border-radius: 999px;
  background: rgba(43, 33, 24, .92); color: #fff; font-size: 14px;
  z-index: 99; text-align: center;
}

@media (max-width: 380px) {
  .dish { font-size: 15.5px; }
  .cols { gap: 10px; }
}
