:root {
  --bg: #f4f7f5;
  --card: #ffffff;
  --text: #18241d;
  --muted: #6b7c72;
  --line: #e6ece8;
  --accent: #0fae6e;
  --accent-soft: #e3f7ee;
  --warn: #e8893b;
  --danger: #e05a5a;
  --good: #0fae6e;
  --shadow: 0 6px 20px rgba(15, 90, 60, 0.08);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1512;
    --card: #16201b;
    --text: #e8f1ec;
    --muted: #8fa399;
    --line: #243029;
    --accent: #1ed18a;
    --accent-soft: #113527;
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: 78px;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* App bar */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; gap: 2px; }
.logo { font-size: 20px; font-weight: 800; letter-spacing: .5px; color: var(--accent); }
.logo .dot { color: var(--warn); }
.sub { font-size: 11px; color: var(--muted); }
.live-badge {
  font-size: 11px; padding: 4px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.live-badge.live { background: #d9fbe9; color: #0a8a55; }

/* Cards */
.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  margin: 12px; box-shadow: var(--shadow);
}
.card-title { font-weight: 700; margin-bottom: 10px; font-size: 15px; }
.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; line-height: 1.5; }

/* Goal */
.goal-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.goal-val { font-size: 22px; color: var(--accent); font-weight: 800; }
.goal-row { display: flex; gap: 10px; margin-top: 12px; align-items: center; }
.seg { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; flex: 1; }
.seg button {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  padding: 8px 4px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.seg button.active { background: var(--accent); color: #fff; }
.goal-input {
  width: 110px; padding: 9px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); font-size: 14px; text-align: center;
}

/* Status ring */
.status-card { display: flex; align-items: center; gap: 16px; }
.ring-wrap { flex: 0 0 110px; }
.ring {
  width: 110px; height: 110px; border-radius: 50%;
  background: conic-gradient(var(--accent) 0deg, var(--line) 0deg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative;
}
.ring::before {
  content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--card);
}
.ring-num { position: relative; font-size: 24px; font-weight: 800; color: var(--accent); }
.ring-label { position: relative; font-size: 11px; color: var(--muted); }
.status-info { flex: 1; }
.status-info .row { display: flex; align-items: baseline; gap: 6px; font-size: 13px; color: var(--muted); margin: 3px 0; }
.status-info .row b { color: var(--text); font-size: 16px; }
.verdict { margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--accent); line-height: 1.4; }
.verdict.warn { color: var(--warn); }
.verdict.danger { color: var(--danger); }

/* Chips & intake */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips .chip {
  font-size: 12px; padding: 6px 11px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line); color: var(--text); cursor: pointer;
}
.chips .chip:active { transform: scale(.96); }
.add-row { display: flex; gap: 8px; margin-top: 12px; }
.add-row input {
  flex: 1; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); font-size: 13px; min-width: 0;
}
.add-row button {
  width: 42px; border: 0; border-radius: 10px; background: var(--accent); color: #fff;
  font-size: 20px; cursor: pointer;
}
.intake-list { list-style: none; padding: 0; margin: 12px 0 0; }
.intake-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.intake-list li .k { color: var(--muted); font-size: 12px; margin-left: 8px; }
.intake-list li .del { color: var(--danger); background: none; border: 0; font-size: 16px; cursor: pointer; }
.intake-list li.empty { color: var(--muted); font-size: 12px; justify-content: center; border: 0; padding: 14px 4px; }

/* 自然语言录入 */
.nl-row { display: flex; gap: 8px; }
.nl-row input {
  flex: 1; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); font-size: 14px; min-width: 0;
}
.nl-row input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.nl-row button {
  padding: 0 16px; border: 0; border-radius: 10px; background: var(--accent); color: #fff;
  font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.nl-example { color: var(--accent); font-weight: 600; cursor: pointer; }
.nl-preview { margin-top: 10px; border: 1px dashed var(--line); border-radius: 12px; padding: 8px 10px; background: var(--bg); }
.nl-item { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.nl-item:last-of-type { border-bottom: 0; }
.nl-item .tick { flex: 0 0 18px; height: 18px; line-height: 18px; text-align: center; border-radius: 50%; font-size: 11px; font-weight: 700; background: var(--accent-soft); color: var(--accent); }
.nl-item .nm { flex: 1; }
.nl-item .nm em { color: var(--muted); font-style: normal; font-size: 11px; }
.nl-item .kc { color: var(--accent); font-weight: 700; font-size: 12px; }
.nl-item.miss .tick { background: #fff2e0; color: #c9762a; }
.nl-item .nl-kcal { width: 62px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); font-size: 12px; }
.nl-item .nl-mini { border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-size: 12px; padding: 6px 10px; cursor: pointer; }
.nl-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.nl-bar b { color: var(--text); }
.nl-confirm { border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; padding: 9px 14px; cursor: pointer; }

/* Menu */
.search { padding: 12px 12px 0; }
.search input {
  width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--text); font-size: 14px;
}
.cat-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 12px; }
.cat-tabs button {
  white-space: nowrap; border: 1px solid var(--line); background: var(--card);
  color: var(--muted); padding: 7px 14px; border-radius: 999px; font-size: 13px; cursor: pointer;
}
.cat-tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.order-filter { display: flex; gap: 8px; padding: 0 12px 4px; }
.order-filter button {
  flex: 1; border: 1px solid var(--line); background: var(--card); color: var(--muted);
  padding: 7px 4px; border-radius: 999px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.order-filter button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 12px 12px; }
.food {
  background: var(--card); border-radius: 14px; padding: 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px; cursor: pointer; position: relative;
}
.food .fname { font-weight: 700; font-size: 14px; line-height: 1.3; }
.food .fkcal {
  align-self: flex-start; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
}
.fkcal.lo { background: #e3f7ee; color: #0a8a55; }
.fkcal.mid { background: #fff2e0; color: #c9762a; }
.fkcal.hi { background: #fde4e4; color: #cf4a4a; }
.food .ftags { display: flex; flex-wrap: wrap; gap: 4px; }
.food .ftags span { font-size: 10px; color: var(--muted); background: var(--bg); padding: 2px 6px; border-radius: 6px; }
.food .fmacros { font-size: 11px; color: var(--muted); margin-top: 2px; }
.food .fprice { font-size: 12px; color: var(--accent); font-weight: 700; }
.food .fadd {
  position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: var(--accent); color: #fff; font-size: 16px; line-height: 1; cursor: pointer;
}

/* Recommendation */
.budget-card { background: linear-gradient(135deg, var(--accent), #0c8f5b); color: #fff; }
.budget-card .budget-top { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.budget-num { font-size: 24px; font-weight: 800; }
.budget-card .hint { color: rgba(255,255,255,.85); }
.rec {
  background: var(--card); border-radius: var(--radius); padding: 14px; margin: 12px;
  box-shadow: var(--shadow); border-left: 4px solid var(--accent);
}
.rec-head { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; }
.rec-head .tag { font-size: 11px; background: var(--accent-soft); color: var(--accent); padding: 2px 8px; border-radius: 999px; }
.rec-items { margin: 10px 0; }
.rec-items .ri { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.rec-items .ri span:last-child { color: var(--muted); }
.rec-stats { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.rec-stats .st { font-size: 12px; background: var(--bg); border-radius: 8px; padding: 5px 9px; }
.rec-stats .st b { color: var(--accent); }
.rec .fit { font-size: 12px; font-weight: 700; margin-top: 6px; }
.fit.ok { color: var(--good); }
.fit.over { color: var(--danger); }
.rec-add {
  width: 100%; margin-top: 10px; padding: 10px; border: 0; border-radius: 10px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 14px; cursor: pointer;
}

/* Tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding: 6px 0; z-index: 20;
}
.tabbar .tab {
  flex: 1; border: 0; background: none; color: var(--muted); font-size: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; padding: 4px 0;
}
.tabbar .tab span { font-size: 18px; }
.tabbar .tab.active { color: var(--accent); font-weight: 700; }

/* ===== 购物车 / 下单 ===== */
.food { position: relative; }
.food .fcart {
  position: absolute; top: 10px; right: 44px; width: 26px; height: 26px;
  border-radius: 50%; border: 0; background: #ff7a18; color: #fff; font-size: 14px; line-height: 1; cursor: pointer;
}
.food .fcart.locked { background: #c4cdc8; cursor: not-allowed; font-size: 13px; }
.cart-list { list-style: none; padding: 0; margin: 10px 0; }
.cart-item { display: flex; align-items: center; gap: 8px; padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
.cart-item .ci-name { flex: 1; }
.cart-item .ci-name small { display: block; color: var(--muted); font-size: 11px; }
.cart-item .ci-kcal { color: var(--muted); font-size: 12px; }
.qty { display: flex; align-items: center; gap: 6px; }
.qty button { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--accent); font-size: 15px; cursor: pointer; }
.qty .qn { min-width: 18px; text-align: center; font-weight: 700; }
.cart-empty { color: var(--muted); font-size: 13px; padding: 14px 4px; text-align: center; }
.cart-summary { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 13px; display: flex; justify-content: space-between; }
.cart-summary b { color: var(--accent); }

.store-row { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding: 10px; background: var(--bg); border-radius: 10px; }
.store-name { font-weight: 700; font-size: 14px; }
.store-code { font-size: 11px; color: var(--muted); }
.link { border: 0; background: none; color: var(--accent); font-weight: 700; cursor: pointer; font-size: 13px; }
.store-search { margin-top: 10px; }
.store-inputs { display: flex; gap: 8px; }
.store-inputs input { flex: 1; }
.store-search > button { width: 100%; margin-top: 8px; padding: 8px; border: 0; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 700; cursor: pointer; }
.store-list { margin-top: 8px; }
.store-list .sitem { padding: 8px; border-bottom: 1px solid var(--line); font-size: 13px; cursor: pointer; }
.store-list .sitem:hover { background: var(--bg); }
.store-list .sitem small { color: var(--muted); }

.primary { width: 100%; margin-top: 12px; padding: 12px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 800; font-size: 15px; cursor: pointer; }
.primary:disabled { opacity: .5; cursor: not-allowed; }
.primary.order { background: #ff7a18; }
.price-preview { margin-top: 10px; padding: 12px; background: var(--bg); border-radius: 10px; font-size: 13px; }
.price-preview .pp-total { font-size: 20px; font-weight: 800; color: var(--accent); }
.price-preview .pp-line { display: flex; justify-content: space-between; padding: 3px 0; color: var(--muted); }
.pp-error { color: var(--danger); font-weight: 700; font-size: 13px; line-height: 1.6; }
.pp-error small { color: var(--muted); font-weight: 400; }
.takeway { margin-top: 12px; }
.addr-row { margin-top: 12px; }
.order-note { font-size: 12px; color: #c9760a; margin: 8px 2px 0; }
.order-result { margin-top: 12px; padding: 14px; background: #eafaf2; border: 1px solid #b6e8cf; border-radius: 10px; font-size: 14px; }
.order-result .or-no { font-size: 18px; font-weight: 800; color: #0a9d5b; }
.order-result a { color: var(--accent); word-break: break-all; }
.order-result .or-tip { font-size: 12px; color: var(--muted); margin-top: 6px; }

.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 24px; }
.modal { background: var(--card); border-radius: 14px; padding: 18px; width: 100%; max-width: 360px; box-shadow: var(--shadow); }
.modal-title { font-weight: 800; font-size: 16px; margin-bottom: 10px; }
.modal-body { font-size: 13px; color: var(--muted); line-height: 1.6; max-height: 50vh; overflow: auto; }
.modal-body b { color: var(--text); }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions button { flex: 1; padding: 11px; border-radius: 10px; font-weight: 700; cursor: pointer; }
.ghost { border: 1px solid var(--line); background: var(--card); color: var(--muted); }
.rec-cart { width: 100%; margin-top: 8px; padding: 9px; border: 1px solid var(--accent); border-radius: 10px; background: var(--card); color: var(--accent); font-weight: 700; font-size: 13px; cursor: pointer; }
.hidden { display: none !important; }
