:root {
  --bg: #f6f3ee;
  --bg-soft: #fffdf9;
  --card: #ffffff;
  --ink: #24211d;
  --ink-2: #6d6459;
  --line: #e6dfd4;
  --brand: #c8502a;
  --brand-2: #e8763f;
  --green: #3f8a5c;
  --amber: #c98a1e;
  --red: #c0392b;
  --shadow: 0 1px 2px rgba(36, 33, 29, .06), 0 8px 24px -12px rgba(36, 33, 29, .18);
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 208px; flex: 0 0 208px; padding: 18px 12px;
  background: var(--bg-soft); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.logo { display: flex; align-items: center; gap: 9px; padding: 6px 10px 16px; }
.logo .mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-size: 18px;
}
.logo b { font-size: 17px; letter-spacing: .02em; }
.logo small { display: block; color: var(--ink-2); font-size: 11px; font-weight: 400; }

.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 10px;
  color: var(--ink-2); cursor: pointer; border: 0; background: none; width: 100%; text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: #f1ece4; color: var(--ink); }
.nav-item.active { background: #fbe9df; color: var(--brand); font-weight: 600; }
.nav-item .ico { font-size: 16px; width: 20px; text-align: center; }
.nav-item .badge {
  margin-left: auto; background: var(--brand); color: #fff; border-radius: 999px;
  font-size: 11px; padding: 0 6px; line-height: 17px; font-weight: 600;
}
.side-foot { margin-top: auto; font-size: 12px; color: var(--ink-2); padding: 10px; display: flex; justify-content: space-between; align-items: center; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; gap: 10px; align-items: center;
  padding: 12px 22px; background: rgba(246, 243, 238, .86); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.search { flex: 1; max-width: 520px; position: relative; }
.search input {
  width: 100%; padding: 9px 12px 9px 34px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); outline: none;
}
.search input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(232, 118, 63, .12); }
.search .mag { position: absolute; left: 11px; top: 8px; color: var(--ink-2); }
.content { padding: 20px 22px 60px; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.card h3 { font-size: 15px; }
.sub { color: var(--ink-2); font-size: 13px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.stack > * + * { margin-top: 14px; }

.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 13px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  transition: transform .08s, background .15s, border-color .15s;
}
.btn:hover { background: #faf6f0; border-color: #d9cfc0; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border-color: transparent; color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.04); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.danger { color: var(--red); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 12px;
  cursor: pointer; font-size: 13px; color: var(--ink-2); transition: all .15s; user-select: none;
}
.chip:hover { border-color: var(--brand-2); color: var(--brand); }
.chip.on { background: #fdeee6; border-color: var(--brand-2); color: var(--brand); font-weight: 600; }

label.field { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--card); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(232, 118, 63, .12); }
textarea { min-height: 80px; resize: vertical; }
.inline-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inline-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #f2ece3; color: var(--ink-2); }
.pill.hot { background: #fdeaea; color: var(--red); }
.pill.ok { background: #e9f5ec; color: var(--green); }
.pill.warn { background: #fdf3e0; color: var(--amber); }

/* ---------- 菜谱卡片 ---------- */
.recipe-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
  display: flex; flex-direction: column;
}
.recipe-card:hover { transform: translateY(-2px); box-shadow: 0 12px 28px -14px rgba(36, 33, 29, .35); }
.rc-img { aspect-ratio: 4 / 3; position: relative; display: grid; place-items: center; font-size: 44px; }
.rc-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rc-img .cuisine { position: absolute; left: 8px; top: 8px; font-size: 11px; background: rgba(255,255,255,.92); border-radius: 6px; padding: 1px 7px; color: var(--ink); }
.rc-img .spicy { position: absolute; right: 8px; top: 8px; font-size: 11px; background: rgba(255,255,255,.92); border-radius: 6px; padding: 1px 7px; }
.rc-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.rc-body b { font-size: 14.5px; }
.rc-meta { display: flex; gap: 8px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }

/* ---------- 周计划 ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.day { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-height: 180px; }
.day.today { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(232, 118, 63, .1); }
.day header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.day header b { font-size: 13px; }
.day header span { font-size: 11px; color: var(--ink-2); }
.slot { margin-bottom: 8px; }
.slot .meal { font-size: 11px; color: var(--ink-2); margin-bottom: 3px; }
.entry {
  display: flex; align-items: center; gap: 6px; background: #fbf7f1; border: 1px solid #efe7da;
  border-radius: 8px; padding: 5px 7px; margin-bottom: 4px; font-size: 12.5px; cursor: pointer;
}
.entry:hover { background: #fdf2e9; }
.entry .x { margin-left: auto; color: var(--ink-2); font-size: 13px; opacity: .6; }
.entry .x:hover { color: var(--red); opacity: 1; }

/* ---------- 表单弹层 ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(30, 26, 22, .45); z-index: 60;
  display: grid; place-items: center; padding: 20px; backdrop-filter: blur(2px);
}
.modal {
  background: var(--card); border-radius: 16px; width: min(760px, 100%); max-height: 88vh;
  overflow: auto; box-shadow: 0 30px 60px -20px rgba(0,0,0,.4); animation: pop .16s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.99); } }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 2; }
.modal .body { padding: 16px 18px; }
.modal footer { padding: 12px 18px 16px; display: flex; justify-content: flex-end; gap: 8px; }
.close { border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--ink-2); line-height: 1; }

.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #2a2521; color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 13.5px; box-shadow: var(--shadow); animation: pop .16s; }
.toast.err { background: var(--red); }

.empty { text-align: center; padding: 34px 10px; color: var(--ink-2); }
.empty .big { font-size: 34px; display: block; margin-bottom: 8px; }

.hero {
  background: linear-gradient(135deg, #fff6ee, #fdece0); border: 1px solid #f3dccb;
  border-radius: 16px; padding: 18px 20px; display: flex; justify-content: space-between; gap: 16px; align-items: center; flex-wrap: wrap;
}
.hero h2 { font-size: 20px; }
.hero .date { color: var(--brand); font-weight: 600; font-size: 13px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.li { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.li .grow { flex: 1; min-width: 0; }
.li b { font-size: 14px; font-weight: 600; }
.li .meta { font-size: 12px; color: var(--ink-2); }
.li.done { opacity: .55; }
.li.done b { text-decoration: line-through; }
.li.soon { border-color: #f0cf9a; background: #fffbf3; }

.check { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid #cfc4b5; display: grid; place-items: center; cursor: pointer; flex: 0 0 18px; background: #fff; }
.check.on { background: var(--green); border-color: var(--green); color: #fff; font-size: 12px; }

/* 详情弹窗内的菜谱排版 */
.detail-img { width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; object-fit: cover; display: block; }
.detail-hero { aspect-ratio: 16 / 9; border-radius: 12px; display: grid; place-items: center; font-size: 64px; position: relative; overflow: hidden; }
.steps { counter-reset: s; padding: 0; margin: 0; list-style: none; }
.steps li { counter-increment: s; padding: 7px 0 7px 30px; position: relative; border-bottom: 1px dashed #eee5d8; }
.steps li:last-child { border-bottom: 0; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 8px; width: 20px; height: 20px; border-radius: 50%;
  background: #fbe9df; color: var(--brand); font-size: 11px; display: grid; place-items: center; font-weight: 700;
}
table.kv { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.kv td { padding: 6px 0; border-bottom: 1px dashed #eee5d8; }
table.kv td:first-child { color: var(--ink-2); width: 40%; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); }
.login-card .logo { justify-content: center; }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; overflow-x: auto; padding: 10px; }
  .logo, .side-foot { display: none; }
  .nav-item { white-space: nowrap; }
  .content { padding: 14px; }
  .week { grid-template-columns: repeat(7, minmax(140px, 1fr)); }
  .inline-3, .inline-2 { grid-template-columns: 1fr; }
}
