* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
body { font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif; background:#f6f4ef; color:#333; }
input,select,textarea,button { font-family:inherit; font-size:16px; }

/* ===== 登录 ===== */
html, body { height:100%; overflow:hidden; overscroll-behavior-x:none; touch-action:pan-y; }
#loginView { height:100vh; display:flex; align-items:center; justify-content:center; background:linear-gradient(160deg,#fff8ec,#ffe8cf); padding:24px; }
.login-card { background:#fff; border-radius:24px; padding:36px 28px; width:100%; max-width:400px; box-shadow:0 8px 30px rgba(180,130,60,.18); text-align:center; }
.login-logo { font-size:56px; }
.login-title { font-size:26px; margin:10px 0 4px; color:#8a5a23; letter-spacing:1px; }
.login-sub { color:#b58a55; font-size:14px; margin-bottom:24px; }

/* ===== 通用控件 ===== */
.text-input { width:100%; padding:12px 14px; border:1.5px solid #e5d9c5; border-radius:12px; background:#fffdf8; margin:6px 0; }
.text-input:focus { outline:none; border-color:#d4a45f; }
.text-area { width:100%; padding:12px 14px; border:1.5px solid #e5d9c5; border-radius:12px; background:#fffdf8; line-height:1.6; resize:vertical; }
.btn { padding:12px 18px; border:none; border-radius:12px; cursor:pointer; font-weight:600; }
.btn-primary { background:linear-gradient(135deg,#e8a04c,#d4822f); color:#fff; }
.btn-primary:active { filter:brightness(.94); }
.btn-ghost { background:#f3ece0; color:#8a5a23; }
.btn-mini { padding:6px 12px; font-size:13px; border:none; border-radius:8px; cursor:pointer; }
.btn-block { width:100%; margin-top:8px; }
.icon-btn { background:none; border:none; font-size:22px; cursor:pointer; color:#8a5a23; }
.err-msg { color:#e05252; font-size:14px; margin-top:10px; min-height:18px; }
.tip-text { color:#8a7a66; font-size:13px; line-height:1.6; margin:8px 0; }
.tip-text code { background:#f3ece0; padding:2px 6px; border-radius:6px; }
.success-msg { color:#3b9e5a; font-size:14px; margin-top:12px; text-align:center; }
.row-place { display:flex; align-items:center; gap:10px; margin:10px 0; }

/* ===== 主应用 ===== */
#appView { height:100vh; height:100dvh; display:flex; flex-direction:column; overflow:hidden; }
.app-header { display:flex; align-items:center; justify-content:space-between; padding:14px 18px; background:#fff; box-shadow:0 2px 8px rgba(0,0,0,.04); position:sticky; top:0; z-index:20; }
.app-title { font-size:19px; font-weight:700; color:#8a5a23; }
/* 今日食单顶栏：左侧「私房食忆簿」logo + 中间标题居中 */
.order-header { justify-content:center; }
.order-header .logo-link { position:absolute; left:18px; top:50%; transform:translateY(-50%); font-size:14px; font-weight:600; color:#8a5a23; text-decoration:none; }
.order-header .app-title { display:flex; align-items:center; }
.content { flex:1; min-height:0; max-height:100%; overflow-y:auto; padding:14px 16px 16px; -webkit-overflow-scrolling:touch; box-sizing:border-box; }
.tabbar { display:flex; background:#fff; border-top:1px solid #eee4d3; padding-bottom:env(safe-area-inset-bottom); }
.tab-btn { flex:1; background:none; border:none; padding:10px 0 8px; display:flex; flex-direction:column; align-items:center; gap:2px; color:#999; cursor:pointer; }
.tab-btn .tab-ico { font-size:20px; }
.tab-btn.active { color:#d4822f; font-weight:600; }

/* ===== 菜谱库 ===== */
.toolbar { display:flex; gap:8px; margin-bottom:12px; }
.search-input { flex:1; padding:10px 14px; border:1.5px solid #e5d9c5; border-radius:12px; background:#fff; }
.cat-row { display:flex; flex-wrap:wrap; gap:8px 8px; padding:4px 0 10px; }
.cat-chip { flex-shrink:0; padding:8px 14px; border-radius:20px; background:#fff; border:1.5px solid #e5d9c5; color:#7a6a55; cursor:pointer; display:inline-flex; align-items:center; gap:6px; }
.cat-chip .cc-count { font-size:11px; background:#f5efe2; color:#a5753a; border-radius:10px; padding:1px 6px; min-width:16px; text-align:center; }
.cat-chip.active { background:#d4822f; border-color:#d4822f; color:#fff; font-weight:600; }
.cat-chip.active .cc-count { background:#fff; color:#d4822f; }
.func-row { display:flex; gap:8px; margin-bottom:10px; flex-wrap:wrap; }
.func-chip { padding:6px 12px; border-radius:16px; border:1.5px solid #e5d9c5; background:#fff; color:#7a6a55; font-size:13px; cursor:pointer; }
.func-chip.active { background:#f3a44e; border-color:#f3a44e; color:#fff; }
.tag-row { display:flex; gap:6px; overflow-x:auto; padding:2px 0 10px; border-bottom:1px dashed #e3d7c3; margin-bottom:12px; }
.tag-chip { flex-shrink:0; padding:5px 11px; border-radius:14px; background:#fdf3e3; border:1px solid #ecd9b5; color:#a5753a; font-size:12px; cursor:pointer; }
.tag-chip.active { background:#d4822f; color:#fff; border-color:#d4822f; }
.tag-picker { display:flex; flex-wrap:wrap; gap:8px; padding:10px 0 2px; }
.tag-new-row { display:flex; gap:10px; margin-top:10px; }
.tag-new-row .text-input { flex:1; }

.dish-list { display:grid; grid-template-columns:repeat(auto-fill, minmax(150px,1fr)); gap:12px; }
.dish-card { background:#fff; border-radius:16px; overflow:hidden; box-shadow:0 3px 12px rgba(0,0,0,.05); cursor:pointer; }
.dish-card .thumb { width:100%; height:130px; object-fit:cover; background:#f0e9dc; display:block; }
.dish-card.noimg .thumb { display:flex; align-items:center; justify-content:center; font-size:44px; }
.dish-card .d-body { padding:10px 12px; }
.dish-card .d-name { font-size:16px; font-weight:700; }
.dish-card .d-cat { font-size:12px; color:#b58a55; margin:2px 0; }
.dish-card .d-tags { font-size:11px; color:#a5753a; }
.dish-card .d-last { font-size:11px; color:#c8b394; margin-top:4px; }
.empty { text-align:center; color:#b9a98d; padding:60px 0; }

/* 详情 */
.detail-img { width:100%; height:200px; object-fit:cover; background:#f0e9dc; border-radius:16px; }
.detail-name { font-size:22px; font-weight:800; margin:12px 0 4px; }
.detail-cat { color:#b58a55; font-size:14px; }
.detail-tags { margin:8px 0; }
.detail-tag { display:inline-block; background:#fdf3e3;color:#a5753a;padding:3px 10px;border-radius:12px;font-size:12px;margin:2px; }
.section-title { font-size:15px; font-weight:700; color:#8a5a23; margin:16px 0 8px; }
.ingre-box, .recipe-box { background:#fff; border-radius:12px; padding:12px 14px; line-height:1.7; white-space:pre-wrap; }
.recipe-box { min-height:80px; }
.source-tag { display:inline-block; padding:4px 10px; border-radius:10px; font-size:13px; margin-bottom:8px; }
.source-1{background:#e8f5ec;color:#2f9e5a;} .source-2{background:#fff3e0;color:#d4822f;} .source-3{background:#f0e9dc;color:#8a7a66;}
.detail-actions { display:flex; gap:10px; margin-top:18px; }
.action-btn { flex:1; padding:12px; border:none; border-radius:12px; cursor:pointer; font-weight:600; }
.btn-eat{background:#e8f5ec;color:#2f9e5a;} .btn-edit{background:#fff4e0;color:#d4822f;} .btn-del{background:#fdeaea;color:#d44;}
.notice-inspire { text-align:center; color:#c8b394; font-size:12px; padding:14px 0; border-bottom:1px dashed #e3d7c3; margin-bottom:12px; }

/* ===== 今日食单(点单+采买) ===== */
.app-header .header-right { display:flex; align-items:center; gap:12px; }
.link { color:#d4822f; font-weight:600; text-decoration:none; }
.sub-tabs { display:flex; background:#fff; border-bottom:1px solid #eee4d3; position:relative; z-index:20; flex-shrink:0; }
.sub-tab { flex:1; background:none; border:none; padding:15px 0 13px; font-size:16px; font-weight:700; color:#999; cursor:pointer; }
.sub-tab.active { color:#d4822f; border-bottom:2.5px solid #d4822f; }

/* 左分类 右菜 双栏 */
.order-content { padding:0; }
.order-layout { display:flex; gap:0; padding:0; height:100%; overflow:hidden; }
.shopping-pane { display:none; padding:14px 16px 20px; max-width:520px; margin:0 auto; width:100%; box-sizing:border-box; }
.order-side { width:92px; flex-shrink:0; overflow:hidden; background:#faf6ee; border-right:1px solid #eee4d3; padding:10px 0; }
.os-cat { display:block; width:100%; background:none; border:none; padding:14px 8px; font-size:14px; color:#7a6a55; cursor:pointer; text-align:center; }
.os-cat.active { background:#d4822f; color:#fff; font-weight:600; border-radius:8px; }
.order-main { flex:1; overflow-y:auto; padding:12px 12px 12px 3px; -webkit-overflow-scrolling:touch; }
.order-grid { display:grid; grid-template-columns:1fr; gap:3px; min-width:0; }
.og-card { position:relative; display:flex; align-items:center; width:100%; min-width:0; max-width:100%; overflow:hidden; box-sizing:border-box; background:transparent; border-radius:12px; cursor:pointer; border:2px solid transparent; }
.og-card .og-img { width:110px; height:110px; flex-shrink:0; border-radius:10px; object-fit:cover; background:#f0e9dc; display:block; }
.og-card .og-img img { width:100%; height:100%; object-fit:cover; display:block; border-radius:10px; }
.og-card .og-img.emoji { display:flex; align-items:center; justify-content:center; font-size:50px; width:110px; height:110px; border-radius:10px; }
.og-card .og-body { flex:1; min-width:0; padding:8px 0 0 10px; align-self:stretch; }
.og-card .og-name { font-size:18px; font-weight:500; line-height:1.25; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.og-card .og-made { font-size:12px; color:#b58a55; margin-top:4px; font-weight:400; }
.og-card .og-cat { font-size:11px; color:#b58a55; margin-top:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.og-card .og-add { flex-shrink:0; align-self:flex-end; margin:0 10px 8px 10px; width:22px; height:22px; border-radius:50%; background:#d4822f; color:#fff; font-size:13px; font-weight:700; border:none; display:flex; align-items:center; justify-content:center; cursor:pointer; line-height:1; padding:0; box-shadow:0 1px 4px rgba(0,0,0,.18); }
.og-card.sel { border-color:#d4822f; }
.og-card.sel .og-add { background:#fff; color:#d4822f; border:2px solid #d4822f; box-shadow:0 1px 4px rgba(0,0,0,.12); }
.order-detail { position:fixed; top:0; left:0; right:0; bottom:0; z-index:999; background:#fff; display:flex; flex-direction:column; transform:translateY(100%); will-change:transform; }
.od-scroll { flex:1; min-height:0; overflow-y:auto; -webkit-overflow-scrolling:touch; padding:calc(14px + env(safe-area-inset-top)) 16px 28px; }
/* 打开详情时，物理隐藏顶部标题栏、tab、底部栏，确保被全屏详情盖住 */
body.order-detail-open .app-header,
body.order-detail-open .sub-tabs,
body.order-detail-open .today-bar { visibility:hidden; }

/* 底部已点汇总条 */
.today-bar { position:relative; z-index:30; flex-shrink:0; margin:0 10px 10px; background:#fff; border:1px solid #f0e4cf; border-radius:16px; box-shadow:0 -2px 16px rgba(176,134,66,.14); padding:12px 16px; padding-bottom:calc(12px + env(safe-area-inset-bottom)); display:flex; align-items:center; gap:12px; justify-content:flex-end; }
.today-bar .tb-count { font-size:17px; margin-right:auto; display:flex; align-items:center; gap:6px; }
.today-bar .tb-count b { color:#d4822f; font-size:26px; font-weight:800; }
.today-bar .tb-clear { color:#b9a98d; font-size:15px; cursor:pointer; padding:10px 14px; border-radius:10px; }
.today-bar .tb-clear:active { background:#f5efe2; }
.today-bar .btn { padding:12px 22px; font-size:16px; border-radius:12px; }
.today-bar .btn.dim { opacity:.4; }
.today-bar .tb-arrow { display:inline-flex; align-items:center; justify-content:center; width:18px; height:20px; cursor:pointer; padding:4px 2px; }
.today-bar .tb-arrow::after { content:""; width:8px; height:8px; border-right:1.8px solid #d4822f; border-bottom:1.8px solid #d4822f; transform:rotate(225deg); margin-top:4px; transition:transform .2s; }
.today-bar .tb-arrow.open::after { transform:rotate(45deg); margin-top:-4px; }
.today-list { position:absolute; left:10px; right:10px; bottom:calc(100% + 8px); background:#fff; border:1px solid #f0e4cf; border-radius:14px; box-shadow:0 -4px 20px rgba(0,0,0,.12); max-height:40vh; overflow-y:auto; z-index:31; -webkit-overflow-scrolling:touch; }
.today-list .tl-head { display:flex; align-items:center; justify-content:space-between; padding:8px 12px 4px 16px; border-bottom:1px solid #f0e6d4; position:sticky; top:0; background:#fff; }
.today-list .tl-title { font-size:15px; font-weight:700; color:#8a5a23; }
.today-list .tb-clear { color:#b9a98d; font-size:14px; cursor:pointer; padding:6px 10px; border-radius:8px; }
.today-list .tb-clear:active { background:#f5efe2; }
.today-list .tl-item { display:flex; align-items:center; padding:9px 16px; font-size:16px; color:#5a4632; border-bottom:1px dashed #f0e6d4; }
.today-list .tl-item:last-child { border-bottom:none; }
.today-list .tl-name { flex:1; min-width:0; }
.today-list .tl-del { flex-shrink:0; width:26px; height:26px; border-radius:50%; border:1.5px solid #e0cfa7; background:#fff; color:#b58a55; font-size:20px; line-height:1; display:flex; align-items:center; justify-content:center; cursor:pointer; padding:0; }
.today-list .tl-del:active { background:#f5efe2; }
.today-list .tl-empty { padding:14px 16px; text-align:center; color:#b9a98d; font-size:14px; }

/* 采买录 */
.shopping-wrap { padding-bottom:20px; }
.shop-cat { font-weight:700; color:#8a5a23; margin:16px 0 6px; }
.shop-item { display:flex; justify-content:flex-start; background:#fff; padding:10px 14px; border-radius:10px; margin-bottom:6px; align-items:center; gap:10px; cursor:pointer; }
.shop-item .si-name { font-weight:600; }
.shop-item .si-from { font-size:11px; color:#c8b394; max-width:60%; text-align:right; margin-left:auto; }
.shop-item .si-check { width:19px; height:19px; accent-color:#d4822f; flex-shrink:0; cursor:pointer; }
.shop-item.done { background:#faf6ec; }
.shop-item.done .si-name { text-decoration:line-through; color:#b9a98d; }
.shop-pick { display:flex; gap:8px; overflow-x:auto; padding:4px 0 8px; }
.shop-pick-chip { flex-shrink:0; padding:8px 14px; border-radius:18px; background:#fff; border:1.5px solid #e5d9c5; font-size:13px; cursor:pointer; }
.shop-pick-chip.active { background:#d4822f; color:#fff; }

/* ===== 弹层 ===== */
.mask { position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:40; }
.sheet { position:fixed; left:0; right:0; top:0; bottom:auto; background:#fff; border-radius:0 0 20px 20px; z-index:1000; height:100vh; height:100dvh; max-height:100dvh; display:flex; flex-direction:column; box-shadow:0 6px 30px rgba(0,0,0,.15); }
  .sheet .sheet-head { padding-top: calc(10px + env(safe-area-inset-top)); }
.sheet-head { display:flex; align-items:center; justify-content:space-between; padding:16px 18px; border-bottom:1px solid #f0e9dc; font-size:17px; font-weight:700; }
.sheet-body { flex:1; min-height:0; padding:16px 18px 28px; overflow-y:auto; }
.field-label { display:block; font-size:13px; color:#8a7a66; margin:10px 0 2px; font-weight:600; }
.img-upload-row { display:flex; align-items:center; gap:10px; margin:6px 0; }
.img-preview { width:80px; height:80px; object-fit:cover; border-radius:12px; }