/* ============ 我家小厨房 · 通用样式（移动端优先 + PC 自适应） ============ */
:root {
  --brand: #ff7a45;
  --brand-dark: #e85f2a;
  --brand-soft: #fff3ec;
  --green: #52c41a;
  --red: #ff4d4f;
  --text: #2b2b2b;
  --text-sub: #8a8a8a;
  --bg: #fdfaf7;
  --card: #ffffff;
  --line: #f0ebe6;
  --radius: 14px;
  --shadow: 0 4px 16px rgba(0, 0, 0, .06);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
input, select, textarea {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 10px 12px; outline: none; width: 100%; color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
textarea { resize: vertical; min-height: 70px; }

/* ---- 通用组件 ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 10px; padding: 10px 16px; cursor: pointer;
  background: #f5f2ef; color: var(--text); font-weight: 500; transition: .15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(.97); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-outline { background: #fff; border: 1px solid var(--line); }
.btn-danger { background: #fff1f0; color: var(--red); }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.on { background: var(--brand); color: #fff; }
.btn.in-cart { background: var(--green); color: #fff; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px;
  background: var(--brand-soft); color: var(--brand-dark);
}
.muted { color: var(--text-sub); font-size: 13px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hidden { display: none !important; }
.empty { text-align: center; padding: 48px 20px; color: var(--text-sub); }

/* ---- 顶部栏 ---- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .95); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); padding: 10px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.logo { font-size: 18px; font-weight: 700; color: var(--brand-dark); display: flex; align-items: center; gap: 6px; }
.search-box { flex: 1; min-width: 140px; position: relative; }
.search-box input { padding-left: 34px; border-radius: 999px; background: #f6f3f0; border-color: transparent; }
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); opacity: .4; }

/* ---- 分类 chips ---- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px; background: #fff;
  border: 1px solid var(--line); cursor: pointer; font-size: 14px; white-space: nowrap;
}
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---- 菜谱网格 ---- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 0 16px 100px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(4, 1fr); gap: 16px; } }
.dish {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); cursor: pointer; transition: .15s; position: relative;
}
.dish:hover { transform: translateY(-2px); }
.dish-cover { width: 100%; aspect-ratio: 4/3; object-fit: cover; background: linear-gradient(135deg, #ffe8db, #fff6ef); }
.dish-cover-ph {
  width: 100%; aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center;
  font-size: 42px; background: linear-gradient(135deg, #ffe8db, #fff6ef);
}
.dish-body { padding: 10px 12px 12px; }
.dish-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dish-meta { font-size: 12px; color: var(--text-sub); display: flex; gap: 8px; flex-wrap: wrap; }
.dish-add {
  position: absolute; right: 8px; bottom: 8px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand); color: #fff; border: none; font-size: 20px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(255,122,69,.4);
}
/* 已在暂存车里：换成绿底对勾，一眼能认出来，右上角小徽章是份数 */
.dish-add.in-cart {
  background: var(--green);
  box-shadow: 0 2px 8px rgba(82,196,26,.4);
  font-size: 16px;
}
.dish-add .cnt {
  position: absolute; top: -6px; right: -6px; min-width: 17px; height: 17px; padding: 0 3px;
  border-radius: 9px; background: #fff; color: var(--green); border: 1.5px solid var(--green);
  font-size: 11px; line-height: 14px; text-align: center; font-weight: 700;
}
/* 已选的菜整张卡片轻轻描个边 + 左上角状态条 */
.dish.picked { box-shadow: 0 0 0 2px var(--green), var(--shadow); }
.dish-picked {
  position: absolute; left: 0; top: 0; background: var(--green); color: #fff;
  font-size: 11px; padding: 2px 8px; border-radius: var(--radius) 0 10px 0; font-weight: 600;
}
/* 选中后把收藏按钮往下挪，给左上角状态条让位 */
.dish.picked .dish-fav { top: 30px; }
.dish-fav { position: absolute; left: 8px; top: 8px; background: rgba(255,255,255,.9); border: none;
  border-radius: 999px; padding: 3px 8px; font-size: 13px; cursor: pointer; }
.dish-off { position: absolute; inset: 0; background: rgba(0,0,0,.35); color: #fff; display: flex;
  align-items: center; justify-content: center; font-size: 13px; }

/* ---- 底部导航（移动端） ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex;
  background: rgba(255,255,255,.97); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
.tabbar button {
  flex: 1; background: none; border: none; padding: 8px 0 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--text-sub); font-size: 11px;
}
.tabbar button.active { color: var(--brand); }
.tabbar .ico { font-size: 20px; line-height: 1; }
.badge {
  position: absolute; margin-left: 16px; margin-top: -4px; background: var(--red); color: #fff;
  font-size: 10px; min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
}

/* ---- 暂存车悬浮条 ---- */
.cart-bar {
  position: fixed; left: 12px; right: 12px; bottom: calc(60px + var(--safe-bottom)); z-index: 35;
  background: #fff; border-radius: 999px; box-shadow: 0 6px 20px rgba(0,0,0,.12);
  padding: 8px 8px 8px 16px; display: flex; align-items: center; justify-content: space-between;
}
@media (min-width: 1024px) { .cart-bar { left: auto; right: 24px; width: 320px; } }
.cart-bar .btn { border-radius: 999px; }

/* ---- 抽屉 ---- */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; opacity: 0;
  pointer-events: none; transition: .2s;
}
.drawer-mask.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; z-index: 51; background: #fff; transition: transform .25s ease;
  display: flex; flex-direction: column; max-height: 100%;
}
.drawer-bottom { left: 0; right: 0; bottom: 0; border-radius: 16px 16px 0 0; transform: translateY(100%); max-height: 82vh; }
.drawer-bottom.show { transform: translateY(0); }
.drawer-right { top: 0; right: 0; bottom: 0; width: 420px; max-width: 100%; transform: translateX(100%); }
.drawer-right.show { transform: translateX(0); }
/* 已选速览：手机上贴底全宽，PC 上收窄居中 */
@media (min-width: 768px) {
  #quickCart {
    left: 50%; right: auto; width: 440px; max-width: calc(100% - 32px);
    bottom: 16px; border-radius: 16px;
    transform: translateX(-50%) translateY(calc(100% + 32px));
    max-height: 76vh;
  }
  #quickCart.show { transform: translateX(-50%) translateY(0); }
  #quickCart .drawer-foot { padding-bottom: 12px; }
}
.drawer-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.drawer-body { padding: 14px 16px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 12px 16px calc(12px + var(--safe-bottom)); border-top: 1px solid var(--line); }

/* ---- 表单 ---- */
.form-item { margin-bottom: 14px; }
.form-item label { display: block; font-size: 13px; color: var(--text-sub); margin-bottom: 6px; }
.form-inline { display: flex; gap: 8px; }
.form-inline > * { flex: 1; }

/* ---- 后台 ---- */
.admin-wrap { display: flex; min-height: 100vh; }
.admin-side {
  width: 200px; flex: 0 0 200px; background: #fff; border-right: 1px solid var(--line);
  padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-side .logo { margin-bottom: 18px; padding: 0 8px; }
.admin-side a {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px;
  color: var(--text-sub); margin-bottom: 4px; font-size: 14px;
}
.admin-side a.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.admin-main { flex: 1; padding: 20px; min-width: 0; }
.admin-title { font-size: 20px; font-weight: 700; margin: 0 0 16px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
@media (min-width: 768px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: #fff; border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat .num { font-size: 24px; font-weight: 700; color: var(--brand-dark); }
.stat .lbl { font-size: 12px; color: var(--text-sub); }

.panel { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.panel h3 { margin: 0 0 12px; font-size: 16px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th, table.tbl td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
table.tbl th { color: var(--text-sub); font-weight: 500; font-size: 13px; }
.table-wrap { overflow-x: auto; }

/* 移动端：后台侧栏变顶部横向导航 */
@media (max-width: 767px) {
  .admin-wrap { flex-direction: column; }
  .admin-side {
    width: 100%; flex: none; height: auto; position: sticky; top: 0; z-index: 20;
    padding: 10px; display: flex; gap: 6px; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line);
  }
  .admin-side .logo { display: none; }
  .admin-side a { margin: 0; white-space: nowrap; }
  .admin-main { padding: 12px; }
}

/* ---- 弹窗 ---- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 60;
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 420px; padding: 20px;
  max-height: 86vh; overflow-y: auto;
}
.modal h3 { margin: 0 0 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ---- 登录页 ---- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(160deg, #fff3ec 0%, #fdfaf7 60%);
}
.login-box { background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 28px; width: 100%; max-width: 380px; }
.login-box h1 { margin: 0 0 4px; font-size: 22px; text-align: center; }
.login-box .sub { text-align: center; color: var(--text-sub); margin-bottom: 20px; font-size: 14px; }
.member-pick { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.member-pick button {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer;
}
.member-pick button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; background: #f6f3f0; padding: 4px; border-radius: 10px; }
.tabs button { flex: 1; border: none; background: none; padding: 8px; border-radius: 8px; cursor: pointer; }
.tabs button.active { background: #fff; font-weight: 600; box-shadow: var(--shadow); }

/* ---- 详情 ---- */
.detail-cover { width: 100%; aspect-ratio: 16/10; object-fit: cover; border-radius: 12px; background: #ffe8db; }
.step-item { display: flex; gap: 12px; margin-bottom: 14px; }
.step-no {
  flex: 0 0 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600;
}
.ing-item { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); }

/* ---- 订单卡片 ---- */
.order-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.order-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.status {
  font-size: 12px; padding: 2px 8px; border-radius: 6px; background: #f5f5f5; color: #666;
}
.status.submitted { background: #fff7e6; color: #d48806; }
.status.accepted { background: #e6f7ff; color: #1890ff; }
.status.cooking { background: #fff1f0; color: #ff4d4f; }
.status.done { background: #f6ffed; color: #52c41a; }
.status.cancelled { background: #f5f5f5; color: #999; }

/* ---- Toast ---- */
#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,.82); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; z-index: 999; opacity: 0; transition: .2s; pointer-events: none; max-width: 80%;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- 购物车行 ---- */
.cart-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cart-row .t { flex: 1; min-width: 0; }
.cart-row .t div:first-child { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qty { display: flex; align-items: center; gap: 8px; }
.qty button {
  width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line);
  background: #fff; cursor: pointer; line-height: 1; font-size: 16px;
}

/* ---- emoji 候选选择器 ---- */
.emoji-picker {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: #fcfaf8;
  max-height: 220px; overflow-y: auto;
}
.emoji-group + .emoji-group { margin-top: 10px; }
.emoji-group-label { font-size: 11px; color: var(--text-sub); margin-bottom: 5px; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 5px; }
.emoji-btn {
  font-size: 21px; line-height: 1; padding: 7px 0; border: 1px solid transparent;
  border-radius: 8px; background: #fff; cursor: pointer; transition: .12s;
}
.emoji-btn:hover { background: #fff3ec; }
.emoji-btn.on { border-color: var(--brand); background: var(--brand-soft); }
.emoji-input { margin-top: 10px; text-align: center; font-size: 18px; }

/* ---- 骨架/加载 ---- */
.loading { text-align: center; padding: 40px; color: var(--text-sub); }

/* ---- 上传预览 ---- */
.uploader {
  border: 2px dashed var(--line); border-radius: 12px; padding: 16px; text-align: center;
  cursor: pointer; color: var(--text-sub); position: relative;
}
.uploader:hover { border-color: var(--brand); }
.thumb-wrap { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumb { position: relative; width: 76px; height: 76px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.thumb .del {
  position: absolute; right: -4px; top: -4px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--red); color: #fff; border: none; font-size: 12px; cursor: pointer; line-height: 1;
}
