/* ===== 极简食谱 PWA 样式（移动优先） ===== */

:root {
  --brand: #D26B49;
  --brand-dark: #B05538;
  --brand-light: #F2E3D8;
  --cream: #FAF5EF;
  --bg: #F2F1F6;
  --card: #FFFFFF;
  --text: #1C1C1E;
  --secondary: #8E8E93;
  --tertiary: #C7C7CC;
  --radius: 16px;
  --nav-h: 52px;
  --tab-h: 58px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

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

html, body {
  margin: 0; padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Helvetica Neue", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
}

#app { height: 100%; }

.hidden { display: none !important; }

/* ===== 页面 ===== */

.page {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-top: var(--safe-top);
}

.content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  padding-bottom: calc(var(--tab-h) + var(--safe-bottom) + 24px);
}

/* ===== 顶部导航栏 ===== */

.nav-bar {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: var(--cream);
}
.nav-bar h1 { font-size: 20px; margin: 0; font-weight: 700; }
.nav-actions { display: flex; gap: 10px; align-items: center; }

.icon-btn {
  border: none; background: transparent;
  color: var(--text);
  padding: 6px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn.accent { color: var(--brand); }

/* ===== 分段控件 ===== */

.segmented {
  display: flex;
  margin: 8px 14px;
  background: rgba(120, 120, 128, 0.12);
  border-radius: 9px;
  padding: 2px;
}
.seg {
  flex: 1;
  border: none; background: transparent;
  padding: 7px 0;
  font-size: 14px;
  border-radius: 7px;
  color: var(--text);
  cursor: pointer;
}
.seg.active {
  background: #fff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}

/* ===== 搜索 ===== */

.search-wrap {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 14px 8px;
  background: rgba(118, 118, 128, 0.12);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--secondary);
}
.search-wrap input {
  border: none; background: transparent; outline: none;
  flex: 1; font-size: 15px; color: var(--text);
}

/* ===== 分类 chips ===== */

.chip-bar {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 4px 14px 10px;
  scrollbar-width: none;
}
.chip-bar::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  border: none;
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(120,120,128,.14);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.chip.active { background: var(--brand); color: #fff; }

/* ===== 卡片 ===== */

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

/* 食谱行 */
.recipe-row {
  display: flex; gap: 12px; align-items: center;
}
.thumb {
  width: 76px; height: 76px;
  border-radius: 12px;
  background: var(--brand-light);
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.thumb img, .thumb video {
  width: 100%; height: 100%; object-fit: cover;
}
.thumb .emoji { font-size: 26px; }
.recipe-meta { flex: 1; min-width: 0; }
.recipe-meta .title { font-size: 16px; font-weight: 600; margin-bottom: 3px; }
.recipe-meta .sub { font-size: 12px; color: var(--secondary); margin-bottom: 4px; }
.recipe-meta .summary {
  font-size: 11px; color: var(--secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.tag-line { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 4px; }
.tag-pill {
  font-size: 10px; padding: 2px 7px; border-radius: 10px;
  background: rgba(120,120,128,.14); color: var(--secondary);
}
.tag-pill.hot { background: var(--brand); color: #fff; }

/* 网格视图 */
.recipe-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.recipe-grid .grid-cell .thumb { width: 100%; height: 130px; }
.grid-cell .title { font-size: 14px; margin: 6px 0 2px; }
.grid-cell .sub { font-size: 11px; color: var(--secondary); }

/* ===== 周计划 ===== */

.week-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 16px;
}
.week-title { text-align: center; }
.week-title #week-label { font-size: 15px; font-weight: 600; }
.link-btn {
  border: none; background: none; color: var(--brand);
  font-size: 12px; cursor: pointer; padding: 2px;
}

.day-card .day-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.day-card .day-title { font-size: 14px; font-weight: 600; }
.day-card .day-title.today { color: var(--brand); }
.meal-line {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 13px; padding: 3px 0;
}
.meal-line .meal-name {
  color: var(--brand); font-size: 12px;
  width: 36px; flex: 0 0 auto;
}
.meal-line .meal-dishes { flex: 1; }
.meal-line .empty { color: var(--tertiary); }

/* ===== 购物清单 ===== */

.shop-add {
  display: flex; gap: 8px; margin-bottom: 12px;
}
.shop-add input {
  border: none; border-radius: 10px; padding: 10px;
  background: var(--card); font-size: 14px; outline: none;
}
.shop-add input[name="name"] { flex: 1; }
.shop-add input[name="qty"] { width: 64px; }

.shop-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0,0,0,.05);
}
.shop-check {
  width: 24px; height: 24px; flex: 0 0 auto;
  border: none; background: none; cursor: pointer;
  color: var(--secondary);
}
.shop-check.done { color: var(--brand); }
.shop-item.done .shop-text { text-decoration: line-through; color: var(--secondary); }
.shop-item.athome .shop-text { color: var(--secondary); }
.shop-text { flex: 1; font-size: 14px; }
.shop-source { font-size: 10px; color: var(--tertiary); }
.section-title {
  font-size: 13px; font-weight: 700; color: var(--brand);
  margin: 14px 0 6px;
}

/* ===== 表单 ===== */

.form-group { margin-bottom: 12px; }
.form-group label {
  display: block; font-size: 13px; color: var(--secondary); margin-bottom: 5px;
}
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="search"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
  width: 100%;
  border: 1px solid rgba(0,0,0,.1);
  border-radius: 10px;
  padding: 10px;
  font-size: 15px;
  background: var(--card);
  outline: none;
  font-family: inherit;
}
.form-group textarea { min-height: 70px; resize: vertical; }
.form-row { display: flex; gap: 8px; }
.form-row > * { flex: 1; }

.btn {
  border: none; border-radius: 12px;
  padding: 12px; font-size: 15px; font-weight: 600;
  cursor: pointer; width: 100%;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-secondary { background: rgba(120,120,128,.14); color: var(--text); }
.btn:active { opacity: .8; }
.btn[disabled] { opacity: .5; }

.btn-inline {
  border: 1px solid var(--brand);
  color: var(--brand); background: transparent;
  border-radius: 8px; padding: 4px 10px;
  font-size: 12px; cursor: pointer;
}
.btn-inline.filled { background: var(--brand); color: #fff; }

.list-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(0,0,0,.05);
}
.list-row .grow { flex: 1; }

/* 开关 */
.toggle {
  position: relative; width: 48px; height: 28px;
  flex: 0 0 auto;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute; inset: 0;
  background: rgba(120,120,128,.32);
  border-radius: 16px; transition: .2s;
}
.toggle .slider::before {
  content: ""; position: absolute;
  width: 24px; height: 24px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle input:checked + .slider { background: var(--brand); }
.toggle input:checked + .slider::before { transform: translateX(20px); }

/* ===== 统计 ===== */

.stat-row { display: flex; gap: 10px; }
.stat-box {
  flex: 1; text-align: center;
  background: var(--card); border-radius: 12px; padding: 12px 6px;
}
.stat-box .num { font-size: 20px; font-weight: 700; }
.stat-box .lbl { font-size: 11px; color: var(--secondary); margin-top: 2px; }
.chart-box { background: var(--card); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.chart-box canvas { max-height: 220px; }
.chart-box .chart-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; }

/* ===== 模态 ===== */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--cream);
  width: 100%;
  max-height: 92vh;
  border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column;
  padding-bottom: var(--safe-bottom);
  animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
}
.modal-header .modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 0 16px 16px; overflow-y: auto; }

.modal-center { align-items: center; }
.modal-center .modal { border-radius: 20px; max-width: 340px; }

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--tab-h) + var(--safe-bottom) + 20px);
  left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.8); color: #fff;
  padding: 10px 18px; border-radius: 20px;
  font-size: 14px; z-index: 200;
  max-width: 84%; text-align: center;
}

/* ===== 底部标签栏 ===== */

.tab-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--tab-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: rgba(250,245,239,.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid rgba(0,0,0,.12);
  z-index: 50;
}
.tab {
  flex: 1;
  border: none; background: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  font-size: 10px;
  color: var(--secondary);
  cursor: pointer;
}
.tab.active { color: var(--brand); }

/* ===== 空状态 ===== */

.empty-state {
  text-align: center; color: var(--secondary);
  padding: 60px 24px;
}
.empty-state .big { font-size: 40px; margin-bottom: 12px; }
.empty-state .t { font-size: 16px; color: var(--text); margin-bottom: 6px; }
.empty-state .d { font-size: 13px; }

/* ===== 进度 ===== */
.progress-line { display: flex; align-items: center; gap: 12px; padding: 12px; }
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(0,0,0,.15);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 打印（PDF 食谱册） */
@media print {
  .tab-bar, .nav-bar, .chip-bar, .search-wrap, .segmented,
  .week-header, .btn, .shop-add, .no-print { display: none !important; }
  .page, .content { height: auto; overflow: visible; padding: 0; }
  .card, .print-page { break-inside: avoid; page-break-inside: avoid; }
  .print-page { page-break-after: always; }
  body { background: #fff; }
}
