/* ==========================================================================
   Walter & Amy 的厨房 —— 设计系统
   暖奶油底 + 番茄陶土橙主色 + 罗勒绿辅助，卡片化、圆角、移动端优先
   ========================================================================== */

:root {
  --bg: #FBF7F1;
  --bg-soft: #F5EEE4;
  --surface: #FFFFFF;
  --surface-soft: #FDFAF6;
  --line: #EFE6D9;
  --line-strong: #E3D7C5;

  --text: #2F2A25;
  --text-2: #5F564C;
  --muted: #9A8F82;

  --brand: #C8673F;
  --brand-deep: #A44F2C;
  --brand-soft: #FBEDE5;
  --brand-line: #F0D6C6;

  --green: #6E9B58;
  --green-soft: #EDF4E7;
  --green-line: #D7E5CC;

  --accent: #C9973F;
  --accent-soft: #FBF1DF;

  --danger: #BE5B4C;
  --danger-soft: #FAEAE5;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 26px;
  --radius-full: 999px;

  --shadow-1: 0 1px 2px rgba(47, 42, 37, .04), 0 6px 18px rgba(47, 42, 37, .05);
  --shadow-2: 0 14px 36px rgba(47, 42, 37, .14);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bar-h: 52px;
  --tab-h: 58px;

  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
body { overflow: hidden; }

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; }
input, textarea, select { -webkit-appearance: none; appearance: none; }
a { color: inherit; text-decoration: none; }

/* ---------------------------------------------------------------- 启动页 */

.boot {
  position: fixed; inset: 0; z-index: 90;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; background: var(--bg);
}
.boot-mark { opacity: .95; }
.boot-name { margin: 14px 0 0; font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.boot-sub { margin: 0; font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------- 骨架 */

#app {
  height: 100%; display: flex; flex-direction: column;
  max-width: 520px; margin: 0 auto; position: relative;
  background: var(--bg);
}
@media (min-width: 560px) {
  #app { box-shadow: 0 0 0 1px var(--line), 0 20px 60px rgba(47, 42, 37, .08); }
}

.app-bar {
  flex: none; height: calc(var(--bar-h) + var(--safe-top));
  padding-top: var(--safe-top);
  background: rgba(251, 247, 241, .92);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 5;
}
.app-bar-inner {
  height: var(--bar-h); display: flex; align-items: center; gap: 6px; padding: 0 8px;
}
.app-bar-title {
  flex: 1; text-align: center; font-size: 16px; font-weight: 650; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-bar-actions { display: flex; align-items: center; gap: 2px; min-width: 40px; justify-content: flex-end; }
.app-bar-left { min-width: 40px; display: flex; justify-content: flex-start; }

.view {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 14px 14px calc(24px + var(--tab-h) + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
}
.view.is-plain { padding: 0; }

.tab-bar {
  flex: none; display: flex; align-items: stretch;
  height: calc(var(--tab-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
  position: relative; z-index: 5;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--muted); font-size: 11px; position: relative;
}
.tab.is-active { color: var(--brand); font-weight: 600; }
.tab-dot {
  position: absolute; top: 6px; left: 50%; margin-left: 6px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--brand); color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ---------------------------------------------------------------- 基础件 */

.icon-btn {
  width: 36px; height: 36px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2); flex: none;
}
.icon-btn:active { background: var(--bg-soft); }
.icon-btn.is-brand { color: var(--brand); }

.btn {
  height: 42px; padding: 0 18px; border-radius: var(--radius-full);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 15px; font-weight: 600; background: var(--surface);
  border: 1px solid var(--line-strong); color: var(--text);
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-accent { background: var(--green); border-color: var(--green); color: #fff; }
.btn-ghost { background: var(--surface-soft); }
.btn-danger { background: var(--danger-soft); border-color: #EFCFC7; color: var(--danger); }
.btn-sm { height: 34px; padding: 0 13px; font-size: 13.5px; }
.btn-xs { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 28px; padding: 0 11px; border-radius: var(--radius-full);
  background: var(--surface); border: 1px solid var(--line-strong);
  font-size: 13px; color: var(--text-2); white-space: nowrap;
}
.chip.is-on { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-deep); font-weight: 600; }
.chip-green.is-on { background: var(--green-soft); border-color: var(--green-line); color: #4E7A3C; }
.chip-row { display: flex; gap: 7px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-1);
  overflow: hidden; margin-bottom: 12px;
}
.card-pad { padding: 14px; }
.card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px 0;
}
.card-title { font-size: 15px; font-weight: 650; flex: 1; display: flex; align-items: center; gap: 7px; }
.card-sub { font-size: 12.5px; color: var(--muted); font-weight: 500; }

.section-title {
  display: flex; align-items: center; gap: 7px;
  margin: 18px 2px 10px; font-size: 13.5px; font-weight: 650; color: var(--text-2);
}
.section-title .muted { color: var(--muted); font-weight: 500; }
.section-title .spacer { flex: 1; }

.empty {
  padding: 34px 20px; text-align: center; color: var(--muted); font-size: 13.5px;
}
.empty-icon { margin-bottom: 8px; opacity: .5; }
.empty-title { color: var(--text-2); font-weight: 600; font-size: 14px; margin-bottom: 4px; }

.divider { height: 1px; background: var(--line); margin: 0 14px; }

.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.small { font-size: 13px; }
.strong { font-weight: 650; }
.brand-text { color: var(--brand); }
.green-text { color: var(--green); }
.danger-text { color: var(--danger); }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- 输入 */

.field { margin-bottom: 12px; }
.field-label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; font-weight: 600; }
.input, .select, .textarea {
  width: 100%; height: 44px; padding: 0 13px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); outline: none;
}
.textarea { height: auto; min-height: 84px; padding: 11px 13px; line-height: 1.55; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239A8F82' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9.5 12 15.5 18 9.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px;
}
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; margin-bottom: 12px; }

/* ---------------------------------------------------------------- 列表行 */

.row-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
}
.row-item:last-child { border-bottom: 0; }
.row-item:active { background: var(--surface-soft); }
.row-item-main { flex: 1; min-width: 0; }
.row-item-title { font-size: 14.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.row-item-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px;
  border-radius: 6px; background: var(--bg-soft); color: var(--text-2);
  font-size: 11.5px; font-weight: 600;
}
.tag-brand { background: var(--brand-soft); color: var(--brand-deep); }
.tag-green { background: var(--green-soft); color: #4E7A3C; }
.tag-warn { background: var(--accent-soft); color: #96702A; }
.tag-danger { background: var(--danger-soft); color: var(--danger); }

/* ---------------------------------------------------------------- 首页 */

.hero {
  background: linear-gradient(140deg, #C8673F 0%, #B4562F 62%, #A44F2C 100%);
  border-radius: var(--radius-lg); padding: 18px; color: #fff;
  box-shadow: 0 12px 28px rgba(164, 79, 44, .22); margin-bottom: 14px; position: relative; overflow: hidden;
}
.hero::after {
  content: ''; position: absolute; right: -30px; top: -40px;
  width: 150px; height: 150px; border-radius: 50%;
  background: rgba(255, 255, 255, .10);
}
.hero-date { font-size: 12.5px; opacity: .85; }
.hero-title { font-size: 20px; font-weight: 700; margin: 4px 0 12px; letter-spacing: .3px; }
.hero-meals { display: flex; flex-direction: column; gap: 8px; position: relative; }
.hero-meal {
  background: rgba(255, 255, 255, .16); border-radius: 14px; padding: 10px 12px;
  display: flex; gap: 10px; align-items: center;
}
.hero-meal-label { font-size: 12px; opacity: .85; width: 34px; flex: none; }
.hero-meal-list { flex: 1; font-size: 14.5px; font-weight: 600; min-width: 0; }
.hero-empty { opacity: .7; font-weight: 500; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 10px; text-align: center; box-shadow: var(--shadow-1);
}
.stat-num { font-size: 20px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.dish-mini {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.dish-mini:last-child { border-bottom: 0; }
.dish-mini-name { font-size: 14.5px; font-weight: 600; }
.dish-mini-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* ---------------------------------------------------------------- 计划页 */

.week-strip { display: flex; gap: 6px; margin-bottom: 12px; }
.week-day {
  flex: 1; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 8px 2px; text-align: center; color: var(--text-2);
}
.week-day.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }
.week-day.is-today .week-day-num { font-weight: 700; }
.week-day.has-plan::after {
  content: ''; display: block; width: 4px; height: 4px; border-radius: 2px;
  background: var(--brand); margin: 3px auto 0;
}
.week-day.is-on.has-plan::after { background: #fff; }
.week-day-w { font-size: 11px; opacity: .9; }
.week-day-num { font-size: 15px; font-weight: 600; margin-top: 1px; }

.meal-block { margin-bottom: 12px; }
.meal-head { display: flex; align-items: center; gap: 8px; padding: 2px 2px 8px; }
.meal-head-title { font-size: 14.5px; font-weight: 650; display: flex; align-items: center; gap: 6px; }

.plan-dish {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.plan-dish:last-child { border-bottom: 0; }
.plan-dish-main { flex: 1; min-width: 0; }
.plan-dish-name { font-size: 14.5px; font-weight: 600; }
.plan-dish-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

.add-slot {
  width: 100%; padding: 11px; border-top: 1px dashed var(--line-strong);
  color: var(--brand); font-size: 13.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.add-slot:active { background: var(--brand-soft); }

/* ---------------------------------------------------------------- 采购页 */

.shop-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
}
.shop-item:last-child { border-bottom: 0; }
.check {
  width: 22px; height: 22px; border-radius: 7px; flex: none; margin-top: 1px;
  border: 1.6px solid var(--line-strong); background: var(--surface);
  display: flex; align-items: center; justify-content: center; color: transparent;
}
.check.is-on { background: var(--green); border-color: var(--green); color: #fff; }
.shop-item.is-done .shop-item-name { color: var(--muted); text-decoration: line-through; }
.shop-item-name { font-size: 14.5px; font-weight: 600; }
.shop-item-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.shop-item-qty { font-size: 14px; font-weight: 700; color: var(--brand-deep); white-space: nowrap; }
.shop-item-qty .sub { font-weight: 500; color: var(--muted); font-size: 11.5px; }

.group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}
.group-dot { width: 8px; height: 8px; border-radius: 4px; flex: none; }
.group-title { font-size: 13px; font-weight: 650; }
.group-count { margin-left: auto; font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- 冰箱页 */

.fridge-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.fridge-item:last-child { border-bottom: 0; }
.fridge-qty { font-size: 14.5px; font-weight: 700; white-space: nowrap; }
.fridge-name { font-size: 14.5px; font-weight: 600; }
.fridge-meta { font-size: 12px; margin-top: 2px; }

/* ---------------------------------------------------------------- 菜谱页 */

.dish-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dish-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 4px;
}
.dish-card:active { transform: scale(.985); }
.dish-card-name { font-size: 14.5px; font-weight: 650; }
.dish-card-ing { font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.dish-card-meta { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-2); margin-top: 2px; }

.search-bar {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-full); margin-bottom: 10px; color: var(--muted);
}
.search-bar input { flex: 1; border: 0; outline: none; background: none; height: 100%; }

.search-bar input::placeholder { color: var(--muted); }

/* ---------------------------------------------------------------- 弹层 */

.overlay { position: fixed; inset: 0; z-index: 60; display: flex; }
.overlay-mask { position: absolute; inset: 0; background: rgba(47, 42, 37, .38); opacity: 0; transition: opacity .22s ease; }
.overlay.is-in .overlay-mask { opacity: 1; }

.overlay-panel {
  position: relative; background: var(--bg); display: flex; flex-direction: column;
  max-height: 100%; width: 100%;
}
.overlay-sheet { align-items: flex-end; }
.overlay-sheet .overlay-panel {
  max-width: 520px; margin: 0 auto; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  max-height: 88%; transform: translateY(100%); transition: transform .26s cubic-bezier(.32, .72, 0, 1);
}
.overlay-sheet.is-in .overlay-panel { transform: translateY(0); }

.overlay-dialog { align-items: center; justify-content: center; padding: 20px; }
.overlay-dialog .overlay-panel {
  max-width: 340px; border-radius: var(--radius-lg); box-shadow: var(--shadow-2);
  transform: scale(.94); opacity: 0; transition: transform .2s ease, opacity .2s ease;
}
.overlay-dialog.is-in .overlay-panel { transform: scale(1); opacity: 1; }

.overlay-full { align-items: stretch; }
.overlay-full .overlay-panel {
  max-width: 520px; margin: 0 auto; height: 100%;
  transform: translateY(14px); opacity: 0; transition: transform .2s ease, opacity .2s ease;
}
.overlay-full.is-in .overlay-panel { transform: translateY(0); opacity: 1; }

.overlay-grab { width: 36px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 8px auto 2px; }
.overlay-head-simple { padding: 8px 18px 6px; text-align: center; }
.overlay-head {
  display: flex; align-items: center; gap: 4px;
  height: calc(var(--bar-h) + var(--safe-top)); padding: var(--safe-top) 8px 0;
  border-bottom: 1px solid var(--line);
}
.overlay-title { flex: 1; text-align: center; font-size: 16px; font-weight: 650; }
.overlay-head-right { min-width: 36px; }
.overlay-desc { font-size: 13px; color: var(--muted); margin-top: 4px; }
.overlay-body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.overlay-foot {
  flex: none; display: flex; gap: 10px; padding: 12px 16px calc(14px + var(--safe-bottom));
  border-top: 1px solid var(--line); background: var(--surface);
}
.overlay-foot .btn { flex: 1; }

/* ---------------------------------------------------------------- toast */

.toast-root {
  position: fixed; left: 0; right: 0; bottom: calc(84px + var(--safe-bottom));
  z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  max-width: 76%; padding: 10px 16px; border-radius: var(--radius-full);
  background: rgba(47, 42, 37, .92); color: #fff; font-size: 13.5px;
  box-shadow: var(--shadow-2); opacity: 0; transform: translateY(8px);
  transition: opacity .22s ease, transform .22s ease; text-align: center;
}
.toast.is-in { opacity: 1; transform: translateY(0); }
.toast-error { background: var(--danger); }
.toast-ok { background: var(--green); }

/* ---------------------------------------------------------------- 杂项 */

.fab {
  position: absolute; right: 16px;
  bottom: calc(var(--tab-h) + var(--safe-bottom) + 16px);
  width: 52px; height: 52px; border-radius: 26px;
  background: var(--brand); color: #fff; box-shadow: 0 8px 20px rgba(164, 79, 44, .3);
  display: flex; align-items: center; justify-content: center; z-index: 4;
}
.fab:active { transform: scale(.94); }

.swipe-hint { font-size: 12px; color: var(--muted); text-align: center; padding: 4px 0 2px; }

.avatar-pair { display: flex; align-items: center; gap: 6px; }
.avatar {
  width: 30px; height: 30px; border-radius: 15px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; background: var(--brand);
}
.avatar.amy { background: var(--green); }

.ing-line { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.ing-line:last-child { border-bottom: 0; }
.ing-line-name { flex: 1; font-size: 14px; }
.ing-line-qty { font-size: 13.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }

.kv-list { display: flex; flex-direction: column; gap: 0; }
.kv {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.kv:last-child { border-bottom: 0; }
.kv-label { font-size: 14px; flex: 1; }
.kv-value { font-size: 13.5px; color: var(--muted); }

.steps-text { font-size: 14px; line-height: 1.75; color: var(--text-2); white-space: pre-wrap; }
