:root {
  --cream: #FBF7F0;
  --cream-2: #F4ECDD;
  --gold: #C8902E;
  --gold-deep: #A9761E;
  --gold-soft: #F6EBD3;
  --rose: #BD5E6E;
  --ink: #3A3330;
  --muted: #9A8F86;
  --line: #ECE3D6;
  --white: #FFFFFF;
  --shadow: 0 6px 18px rgba(120, 90, 40, 0.10);
  --shadow-soft: 0 2px 8px rgba(120, 90, 40, 0.06);
  --radius: 18px;
  --serif: 'Noto Serif SC', 'Songti SC', serif;
  --sans: 'Noto Sans SC', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: linear-gradient(160deg, #efe6d6, #e6d8c2);
  font-family: var(--sans);
  color: var(--ink);
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
img { display: block; max-width: 100%; }
[contenteditable] { outline: none; }
[contenteditable][data-empty="true"]::before {
  content: attr(data-ph); color: var(--muted); font-weight: 400;
}

/* ---------- 全屏容器（无边框、无假状态栏） ---------- */
.app {
  position: relative; width: 100%; height: 100dvh;
  background: var(--cream); display: flex; flex-direction: column;
  overflow: hidden;
}
/* 桌面预览时收成一列居中阅读，手机上自然铺满 */
@media (min-width: 600px) {
  .app { max-width: 480px; margin: 0 auto; }
}
.viewport { position: relative; flex: 1; overflow: hidden; }

.screen {
  position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  padding-bottom: 96px; display: none; background: var(--cream);
}
.screen.active { display: block; }

/* ---------- 顶部栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(14px + env(safe-area-inset-top)) 18px 8px;
  position: sticky; top: 0; background: var(--cream); z-index: 20;
}
.topbar h1 { font-family: var(--serif); font-size: 22px; margin: 0; font-weight: 700; }
.topbar .back { font-size: 22px; width: 34px; height: 34px; border-radius: 50%;
  background: var(--white); box-shadow: var(--shadow); display: grid; place-items: center; }
.topbar .spacer { flex: 1; }

/* ---------- 通用卡片/按钮 ---------- */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 14px; border: 1px solid rgba(236,227,214,.7); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px;
  background: var(--cream-2); color: var(--ink); font-size: 13px; border: 1px solid transparent;
}
.chip.on { background: var(--gold); color: #fff; border-color: var(--gold-deep); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 18px; border-radius: 14px; background: var(--gold); color: #fff;
  font-size: 15px; font-weight: 600; box-shadow: var(--shadow); width: 100%;
}
.btn.ghost { background: var(--white); color: var(--gold); border: 1px solid var(--line); box-shadow: none; }
.btn.sm { width: auto; padding: 8px 14px; font-size: 13px; border-radius: 12px; }
.btn:active { transform: translateY(1px); }
.section-title { font-family: var(--serif); font-size: 17px; font-weight: 700; margin: 18px 18px 8px;
  position: relative; padding-left: 12px; }
.section-title::before { content: ''; position: absolute; left: 0; top: 2px; bottom: 2px; width: 4px;
  border-radius: 4px; background: linear-gradient(var(--gold), var(--gold-deep)); }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }

/* ---------- 封面图（统一组件） ---------- */
.cover { position: relative; overflow: hidden; background: var(--gold-soft); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .ph {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-family: var(--serif); font-size: 30px; color: #fff;
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
}

/* ---------- 美食大图卡 ---------- */
.hero {
  margin: 14px; border-radius: 22px; overflow: hidden; position: relative; height: 220px;
  box-shadow: var(--shadow); transition: transform .25s ease;
}
.hero:active { transform: scale(.99); }
.hero .scrim {
  position: absolute; inset: 0; background: linear-gradient(180deg, transparent 35%, rgba(40,28,18,.72));
  display: flex; flex-direction: column; justify-content: flex-end; padding: 18px; color: #fff;
}
.hero .scrim .tag { align-self: flex-start; background: rgba(255,255,255,.22); backdrop-filter: blur(4px);
  padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; margin-bottom: 8px; }
.hero .scrim .t { font-family: var(--serif); font-size: 23px; font-weight: 700; letter-spacing: .5px; }
.hero .scrim .s { font-size: 13px; opacity: .92; margin-top: 5px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- 列表卡 / 菜谱卡 ---------- */
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; padding: 0 14px; }
.rcard { position: relative; background: var(--white); border-radius: 16px; overflow: hidden;
  box-shadow: var(--shadow); transition: transform .2s ease, box-shadow .2s ease; }
.rcard:active { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(120,90,40,.16); }
.rcard .cover { height: 116px; }
.rcard .badge { position: absolute; top: 8px; right: 8px; background: rgba(40,28,18,.55); backdrop-filter: blur(3px);
  color: #fff; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.rcard .meta { padding: 11px 13px 13px; }
.rcard .meta .t { font-family: var(--serif); font-size: 15px; font-weight: 700; line-height: 1.3; }
.rcard .meta .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- 首页暖心 motto ---------- */
.motto { text-align: center; font-family: var(--serif); font-size: 15px; color: var(--gold-deep);
  line-height: 1.8; padding: 22px 24px 6px; letter-spacing: 1px; opacity: .92; }

/* ---------- 评分星 ---------- */
.stars { display: inline-flex; gap: 4px; }
.stars .st { font-size: 22px; color: #E4D7C2; transition: transform .1s; }
.stars .st.on { color: var(--rose); }
.stars .st:active { transform: scale(1.25); }

/* ---------- 分段切换 ---------- */
.seg { display: flex; background: var(--cream-2); border-radius: 14px; padding: 4px; margin: 14px; }
.seg button { flex: 1; padding: 10px; border-radius: 11px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--white); color: var(--gold); box-shadow: var(--shadow); }

/* ---------- 表单 ---------- */
.field {
  background: var(--cream-2); border-radius: 12px; padding: 10px 12px; min-height: 44px;
  font-size: 14px; line-height: 1.5;
}
.field.title { font-family: var(--serif); font-size: 18px; font-weight: 700; background: transparent; padding-left: 0; }
.stepbox, .ingbox {
  display: flex; align-items: flex-start; gap: 8px; background: var(--cream-2); border-radius: 12px;
  padding: 10px 12px; margin-bottom: 8px; font-size: 14px; line-height: 1.5;
}
.stepbox .n { flex: 0 0 22px; height: 22px; border-radius: 50%; background: var(--gold); color: #fff;
  font-size: 12px; display: grid; place-items: center; margin-top: 1px; }
.stepbox [contenteditable], .ingbox [contenteditable] { flex: 1; }
.x { margin-left: auto; color: var(--muted); font-size: 16px; padding: 0 4px; }
.addlink { color: var(--gold); font-weight: 600; font-size: 14px; padding: 8px 4px; display: inline-block; }

/* ---------- 记录菜谱：上传封面 ---------- */
.cover-upload {
  display: grid; place-items: center; position: relative; overflow: hidden;
  height: 120px; border: 2px dashed var(--gold); border-radius: 14px;
  background: var(--gold-soft); cursor: pointer;
}
.cover-upload .cover-ph { color: var(--gold); font-weight: 600; font-size: 14px; }
.cover-upload img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-upload.has .cover-ph { display: none; }

/* ---------- 库存 ---------- */
.card input { min-width: 0; box-sizing: border-box; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 12px; font-size: 14px; background: var(--white); color: var(--ink); width: 100%; }
.card input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200,144,46,.15); }
.inv { display: flex; align-items: center; gap: 10px; background: var(--white); border-radius: 14px;
  padding: 12px 14px; margin: 8px 14px; box-shadow: var(--shadow);
  border-left: 3px solid var(--gold); }
.inv .nm { flex: 1; font-weight: 600; min-width: 0; word-break: break-word; }
.inv .ct { display: flex; align-items: baseline; justify-content: flex-end; gap: 5px; min-width: 64px; }
.inv .ct .num { color: var(--gold); font-weight: 700; }
.inv .ct .unit { color: var(--muted); font-weight: 600; font-size: 13px; }
.inv .ct [contenteditable] { display: inline; }
.inv .ct .num:empty::before, .inv .ct .unit:empty::before { content: '?'; color: var(--muted); }
.inv .x { margin-left: 4px; color: var(--muted); font-size: 16px; padding: 4px 6px; border-radius: 8px; }
.inv .x:active { background: var(--cream-2); color: var(--rose); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 14px; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: absolute; left: 14px; right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom)); height: 58px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-radius: 30px;
  display: flex; align-items: center; box-shadow: 0 10px 30px rgba(80,60,30,.2); z-index: 25;
  padding: 0 8px;
}
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--muted); padding: 6px 0; border-radius: 16px; }
.tabbar button .ic { font-size: 20px; }
.tabbar button.on { color: var(--gold); }
.tabbar button.on .ic { transform: translateY(-1px); }

/* ---------- 设置/备份屏 ---------- */
.setrow { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px;
  border-bottom: 1px solid var(--line); background: var(--white); }
.setrow:first-child { border-radius: 16px 16px 0 0; }
.setrow:last-child { border-radius: 0 0 16px 16px; border-bottom: none; }
.setcard { border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); margin: 14px; }
.note { font-size: 12px; color: var(--muted); line-height: 1.6; padding: 0 16px; }

/* ---------- Toast ---------- */
.toast { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  background: rgba(40,30,20,.9); color: #fff; padding: 12px 20px; border-radius: 12px; font-size: 14px;
  z-index: 50; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 80%; text-align: center; }
.toast.show { opacity: 1; }

.hide { display: none !important; }
