:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --primary: #ff7a59;
  --primary-dark: #e85f3f;
  --primary-soft: #fff1ec;
  --accent: #ffb347;
  --text: #3a2e2a;
  --text-light: #8a7d77;
  --border: #f0e6dd;
  --shadow: 0 6px 20px rgba(58, 46, 42, 0.08);
  --shadow-lg: 0 12px 40px rgba(58, 46, 42, 0.14);
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, button { font-size: 15px; }
.hidden { display: none !important; }

/* 通用按钮 */
.btn {
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-weight: 600;
  transition: all 0.18s ease;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-soft { background: var(--primary-soft); color: var(--primary-dark); }
.btn-soft:hover { background: #ffe4d8; }
.btn-ghost { background: transparent; color: var(--text-light); border: 1px solid var(--border); }
.btn-ghost:hover { background: #fff; color: var(--text); }
.btn-danger { color: #d64545; border: 1px solid #f3d6d6; background: #fff5f5; }
.btn-danger:hover { background: #ffeaea; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ============ 登录注册 ============ */
.auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fff1ec 0%, #ffe9c4 60%, #ffe4d8 100%);
  padding: 24px;
}
.auth-card {
  background: var(--card);
  width: 100%;
  max-width: 400px;
  padding: 36px 32px;
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
}
.auth-logo { text-align: center; margin-bottom: 24px; }
.logo-emoji { font-size: 44px; display: inline-block; }
.logo-emoji.small { font-size: 24px; }
.auth-logo h1 {
  font-size: 30px;
  margin-top: 6px;
  color: var(--primary);
  letter-spacing: 2px;
}
.auth-logo p { color: var(--text-light); font-size: 14px; margin-top: 6px; }

.auth-tabs {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 22px;
}
.auth-tab {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  color: var(--text-light);
  font-weight: 600;
  transition: all 0.2s;
}
.auth-tab.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }

.auth-form .field { display: block; margin-bottom: 16px; }
.auth-form .field > span {
  display: block;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 6px;
  font-weight: 600;
}
.auth-form input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  transition: border-color 0.2s;
}
.auth-form input:focus { outline: none; border-color: var(--primary); }
.auth-form small { display: block; color: var(--text-light); font-size: 12px; margin-top: 4px; }
.auth-form .btn-primary { margin-top: 6px; }
.auth-tip { color: #d64545; font-size: 13px; text-align: center; min-height: 18px; margin-top: 10px; }

/* ============ 主应用布局 ============ */
.app-view { min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 12px rgba(58, 46, 42, 0.04);
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-title { font-size: 22px; font-weight: 700; color: var(--primary); letter-spacing: 1px; }
.header-nav { display: flex; gap: 6px; }
.nav-btn {
  padding: 8px 16px;
  border-radius: 20px;
  color: var(--text-light);
  font-weight: 600;
  transition: all 0.2s;
}
.nav-btn:hover { color: var(--text); background: var(--bg); }
.nav-btn.active { background: var(--primary); color: #fff; }
.header-right { display: flex; align-items: center; gap: 12px; }
.user-info {
  font-size: 13px;
  color: var(--text-light);
  padding: 4px 12px;
  background: var(--primary-soft);
  border-radius: 16px;
  color: var(--primary-dark);
  font-weight: 600;
}

.app-main { flex: 1; padding: 28px; max-width: 1200px; margin: 0 auto; width: 100%; }

.view-panel { display: none; }
.view-panel.active { display: block; animation: fade 0.3s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}
.panel-header h2 { font-size: 22px; }
.date-label { color: var(--text-light); font-size: 14px; }

/* 分类筛选 */
.filter-bar { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-chip {
  padding: 7px 16px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-light);
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s;
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 菜品卡片网格 */
.dish-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.dish-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid var(--border);
}
.dish-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.dish-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}
.dish-name { font-size: 17px; font-weight: 700; }
.dish-actions { display: flex; gap: 4px; }
.dish-cat {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
}
.cat-staple { background: #fff3d6; color: #b8860b; }
.cat-vegetable { background: #e7f6d8; color: #5a8a2a; }
.cat-seafood { background: #d6ecff; color: #2a6ba8; }
.cat-meat { background: #ffd9d9; color: #b03434; }
.cat-soup { background: #f0e0ff; color: #7a3aa8; }
.cat-cold { background: #d6f5f0; color: #2a8a7a; }
.cat-snack { background: #ffe0f0; color: #b0347a; }
.cat-bbq { background: #f0e0d0; color: #8a6a3a; }
.cat-sauce { background: #fff0d6; color: #c87a2a; }
.cat-other { background: #eee; color: #888; }

.dish-ingredients { font-size: 13px; color: var(--text-light); line-height: 1.7; }
.dish-ingredients b { color: var(--text); }
.ingredient-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.ingredient-tag {
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
}

/* 菜品备注 / 做法来源 / 图片 */
.dish-extras {
  margin: 12px 0;
  padding: 10px 12px;
  background: linear-gradient(135deg, #fff9f6 0%, #fff 100%);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.dish-thumb-link {
  flex-shrink: 0;
  width: 66px;
  height: 66px;
  border-radius: 10px;
  overflow: hidden;
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
}
.dish-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.dish-extras-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ex-label {
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 12px;
}
.dish-notes-preview {
  font-size: 12px;
  color: var(--text);
  line-height: 1.55;
  background: #fff;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.dish-recipe-link {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-dark);
  background: var(--primary-soft);
  padding: 4px 8px;
  border-radius: 8px;
  text-decoration: none;
  align-self: flex-start;
  transition: all 0.18s;
}
.dish-recipe-link:hover { background: #ffe0d3; transform: translateY(-1px); }

/* 编辑器分节条 */
.section-sep {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--primary-soft);
  padding: 6px 12px;
  border-radius: 8px;
  margin: 4px 0 14px;
  text-align: center;
  letter-spacing: 1px;
}
.dish-foot {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
}
.dish-author { font-size: 12px; color: var(--text-light); }
.dish-add-today {
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.2s;
}
.dish-add-today:hover { background: var(--primary-soft); }

/* ============ 通用辅助样式 ============ */
.loading {
  text-align: center;
  color: var(--text-light);
  padding: 24px 10px;
  font-size: 14px;
}
.btn-icon {
  padding: 8px 10px;
  font-size: 16px;
  line-height: 1;
}

/* ============ 日期选择器 ============ */
.date-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 4px 6px;
}
.date-picker .btn-sm { padding: 4px 10px; font-size: 16px; line-height: 1; }
.date-input {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  padding: 6px 4px;
  text-align: center;
  min-width: 130px;
}
.date-input:focus { outline: none; }
.date-label { color: var(--text-light); font-size: 13px; font-weight: 600; }

/* ============ 分享弹窗 ============ */
.share-link-box {
  display: flex;
  gap: 8px;
  align-items: center;
}
.share-link-box input {
  flex: 1;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-family: monospace;
  font-size: 13px;
  color: var(--text);
}
.share-link-box input:focus { outline: none; border-color: var(--primary); }

/* ============ 安装引导列表 ============ */
.guide-list {
  margin: 0 0 4px 0;
  padding-left: 22px;
  line-height: 2;
  font-size: 15px;
}
.guide-list li { margin-bottom: 4px; }

/* ============ PWA 安装引导弹窗复用 .modal 样式 ============ */


.empty-hint {
  text-align: center;
  color: var(--text-light);
  padding: 50px 20px;
  font-size: 15px;
}

/* ============ 今日菜单 ============ */
.meal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.meal-col {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  min-height: 200px;
  display: flex;
  flex-direction: column;
}
.meal-col h3 {
  font-size: 16px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 2px dashed var(--border);
}
.meal-list { flex: 1; display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.meal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
}
.meal-item .mi-name { font-weight: 600; }
.meal-item .mi-cat { font-size: 11px; padding: 1px 6px; border-radius: 8px; margin-left: 6px; }
.meal-item .mi-remove {
  color: #d64545;
  font-size: 16px;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  transition: background 0.2s;
}
.meal-item .mi-remove:hover { background: #ffeaea; }
.meal-empty { color: var(--text-light); font-size: 13px; text-align: center; padding: 16px 0; }

/* ============ 购物清单 ============ */
.shopping-list {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px 0;
  border: 1px solid var(--border);
}
.shopping-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px dashed var(--border);
  gap: 12px;
}
.shopping-item:last-child { border-bottom: none; }
.shopping-check {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: all 0.2s;
}
.shopping-check.checked { background: var(--primary); border-color: var(--primary); }
.shopping-check.checked::after {
  content: "✓";
  color: #fff;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 13px;
}
.shopping-name { flex: 1; font-weight: 600; }
.shopping-name.done { text-decoration: line-through; color: var(--text-light); }
.shopping-amount { color: var(--text-light); font-size: 13px; }
.shopping-source { font-size: 12px; color: var(--text-light); }

/* ============ 弹窗 ============ */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-mask { position: absolute; inset: 0; background: rgba(58, 46, 42, 0.45); backdrop-filter: blur(2px); }
.modal-card {
  position: relative;
  background: var(--card);
  border-radius: 18px;
  width: 92%;
  max-width: 460px;
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: pop 0.22s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 18px; }
.modal-close {
  font-size: 26px;
  color: var(--text-light);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  line-height: 1;
  transition: background 0.2s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 22px; overflow-y: auto; }

.modal-body .field { margin-bottom: 16px; }
.modal-body .field > span {
  display: block;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 6px;
  font-weight: 600;
}
.modal-body input, .modal-body select, .modal-body textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  font-family: inherit;
}
.modal-body input:focus, .modal-body select:focus, .modal-body textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.modal-body textarea { resize: vertical; min-height: 70px; }

.ingredient-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.ingredient-input-row input { flex: 1; }
.ingredient-input-row input[name="amount"] { max-width: 120px; }
.ingredient-add-btn {
  padding: 0 14px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 18px;
}
.ingredient-add-btn:hover { background: #ffe4d8; }
.ingredient-edit-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.ingredient-edit-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.ingredient-edit-item button {
  color: #d64545;
  font-size: 16px;
  width: 24px;
  height: 24px;
  border-radius: 6px;
}
.ingredient-edit-item button:hover { background: #ffeaea; }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}
.modal-actions .btn { flex: 1; }

/* 选择菜品加入今日菜单的列表 */
.dish-pick-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.dish-pick-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.18s;
}
.dish-pick-item:hover { border-color: var(--primary); background: var(--primary-soft); }
.dish-pick-item .dpi-info { display: flex; align-items: center; gap: 10px; }
.dish-pick-item .dpi-name { font-weight: 600; }

/* ============ toast ============ */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(58, 46, 42, 0.92);
  color: #fff;
  padding: 10px 22px;
  border-radius: 22px;
  font-size: 14px;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============ 面板操作按钮组 ============ */
.panel-actions { display: flex; gap: 8px; align-items: center; }

/* ============ 分类管理 ============ */
.filter-manage {
  font-size: 13px;
  border-style: dashed;
  opacity: 0.75;
}
.filter-manage:hover { opacity: 1; }

.cat-manager { }
.cat-manager-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 16px;
}
.cat-manager-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.cat-label-input {
  flex: 1;
  border: 1px solid transparent;
  background: transparent;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
}
.cat-label-input:focus { outline: none; border-color: var(--primary); background: #fff; }
.cat-count {
  font-size: 12px;
  color: var(--text-light);
  white-space: nowrap;
}
.cat-color-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 14px;
  flex-shrink: 0;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.18s;
}
.cat-color-dot.selected { border-color: var(--text); transform: scale(1.15); }
.cat-color-preview {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}
.cat-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}
.cat-add-row input { flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.cat-add-row input:focus { outline: none; border-color: var(--primary); }

/* ============ 智能导入 ============ */
.smart-import { }
.import-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 16px;
}
.import-tab {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  color: var(--text-light);
  font-weight: 600;
  transition: all 0.2s;
}
.import-tab.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }
.import-panel { margin-bottom: 12px; }
.import-panel.hidden { display: none; }
.import-tip {
  display: block;
  color: var(--text-light);
  font-size: 12px;
  line-height: 1.6;
  margin-bottom: 12px;
}
.import-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  min-height: 160px;
  margin-bottom: 12px;
  line-height: 1.6;
}
.import-textarea:focus { outline: none; border-color: var(--primary); }
.import-file-label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-light);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 12px;
}
.import-file-label:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.import-img-preview {
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.import-img-preview img { width: 100%; display: block; }
.import-img-preview.hidden { display: none; }
.import-progress {
  text-align: center;
  color: var(--text-light);
  font-size: 13px;
  padding: 8px;
  margin-bottom: 12px;
  background: var(--bg);
  border-radius: 8px;
}
.import-progress.hidden { display: none; }

/* 响应式 */
@media (max-width: 640px) {
  .app-header { flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
  .header-nav { order: 3; width: 100%; justify-content: space-around; }
  .app-main { padding: 16px; }
  .dish-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .meal-grid { grid-template-columns: 1fr; }
  .panel-header { font-size: 14px; }
  .panel-header h2 { font-size: 19px; }
  .panel-actions { flex-wrap: wrap; }
  .panel-actions .btn { font-size: 13px; padding: 8px 12px; }
  .date-picker { flex-wrap: wrap; max-width: 100%; }
  .date-input { min-width: 110px; }
  .header-right .btn-icon { padding: 6px 8px; }
}
