/* 张家大冰箱网页版样式：颜色沿用小程序（绿 #4CAF50、蓝 #007bff、红 #e74c3c、橙 #FF8C00） */
:root {
  --green: #4CAF50;
  --blue: #007bff;
  --red: #e74c3c;
  --orange: #FF8C00;
  --amber: #f39c12;
  --bg: #f7f7f7;
  --card: #ffffff;
  --text: #333333;
  --muted: #999999;
  --line: #eeeeee;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  /* 给底部标签栏留出位置 */
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

button {
  font-family: inherit;
  cursor: pointer;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.welcome-text {
  text-align: center;
  font-size: 16px;
  color: #555;
  margin: 0 0 20px;
  line-height: 1.5;
}

.page-title {
  text-align: center;
  font-size: 22px;
  margin: 0 0 8px;
}

.sub-text {
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 20px;
}

/* ---------- 按钮 ---------- */
.big-button {
  display: block;
  width: 80%;
  margin: 15px auto;
  padding: 14px 0;
  border: none;
  border-radius: 50px;
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.big-button.green { background-color: var(--green); }
.big-button.blue { background-color: var(--blue); }
.big-button.orange { background-color: var(--orange); }

.big-button:active {
  opacity: 0.85;
}

.preview-image {
  display: block;
  width: 80%;
  height: 200px;
  margin: 20px auto;
  border-radius: 15px;
  object-fit: cover;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

/* ---------- 卡片 ---------- */
.card {
  background-color: var(--card);
  border-radius: 15px;
  padding: 20px;
  margin: 20px 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.card-title {
  font-size: 18px;
  text-align: center;
  margin: 0 0 15px;
}

.card-title.left {
  text-align: left;
  margin-bottom: 8px;
}

.empty-text {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
}

/* ---------- 冰箱食材 ---------- */
.food-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

.food-card:last-child {
  border-bottom: none;
}

.member-badge {
  font-size: 22px;
}

.food-info {
  flex: 1;
  min-width: 0;
}

.food-name {
  font-size: 16px;
  font-weight: bold;
  word-break: break-word;
}

.food-details {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 5px;
}

.remaining-days {
  font-size: 14px;
  font-weight: bold;
}

.remaining-days.red { color: var(--red); }
.remaining-days.orange { color: var(--amber); }
.remaining-days.green { color: var(--green); }

.added-by {
  font-size: 13px;
  color: var(--muted);
}

.finish-button {
  flex-shrink: 0;
  background-color: var(--red);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
}

/* ---------- 家庭 ---------- */
.family-id-card {
  background: linear-gradient(135deg, #FFD700, #FFC107);
  border-radius: 15px;
  padding: 25px 20px;
  margin: 20px 0;
  box-shadow: 0 5px 15px rgba(255, 193, 7, 0.4);
  text-align: center;
  color: #fff;
}

.family-id-label {
  font-size: 16px;
  margin-bottom: 8px;
}

.family-id {
  font-size: 24px;
  font-weight: bold;
  letter-spacing: 1px;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.member-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #e0e0e0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.member-name {
  font-size: 16px;
  font-weight: 600;
}

.member-role {
  font-size: 14px;
  color: #666;
}

.add-item-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.add-item-input {
  flex: 1;
  min-width: 0;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 16px; /* 16px 以上，iPhone 点输入框时不会自动放大页面 */
}

.add-item-button {
  flex-shrink: 0;
  background-color: var(--blue);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 14px;
  font-size: 15px;
}

.shopping-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.shopping-item:last-child {
  border-bottom: none;
}

.shopping-item input {
  width: 20px;
  height: 20px;
  accent-color: var(--green);
  flex-shrink: 0;
}

.shopping-item-text {
  font-size: 15px;
}

.bought-item {
  color: #bbb;
  text-decoration: line-through;
}

/* ---------- 营养大盘 ---------- */
.total-card {
  background: linear-gradient(135deg, #66BB6A, var(--green));
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
  color: #fff;
}

.total-item + .total-item {
  margin-top: 18px;
}

.total-label {
  font-size: 15px;
  margin-bottom: 4px;
}

.total-value {
  font-size: 32px;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

.total-unit {
  font-size: 16px;
  font-weight: normal;
}

.progress-bar {
  height: 10px;
  background-color: rgba(255, 255, 255, 0.3);
  border-radius: 5px;
  overflow: hidden;
  margin: 8px 0 4px;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 5px;
  transition: width 0.3s;
}

.kcal-fill { background-color: #FFD54F; }
.protein-fill { background-color: #fff; }

.goal-text {
  font-size: 12px;
  opacity: 0.9;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}

.row:last-child {
  border-bottom: none;
}

.row-name {
  font-size: 15px;
  min-width: 0;
  word-break: break-word;
}

.row-numbers {
  font-size: 14px;
  color: var(--green);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.row-unknown {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.note-text {
  text-align: center;
  font-size: 12px;
  color: #bbb;
}

/* ---------- 底部标签栏 ---------- */
.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  background: #fff;
  border-top: 1px solid #ddd;
  padding-bottom: env(safe-area-inset-bottom);
}

.tab {
  flex: 1;
  border: none;
  background: none;
  padding: 14px 4px;
  font-size: 13px;
  color: var(--muted);
}

.tab.active {
  color: var(--green);
  font-weight: 600;
}

/* ---------- 弹窗和提示 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-mask[hidden],
.toast[hidden],
.preview-image[hidden] {
  display: none;
}

.modal-content {
  background: #fff;
  border-radius: 20px;
  padding: 24px 20px;
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 20px;
  text-align: center;
  margin: 0 0 12px;
}

.recipe-name {
  font-size: 18px;
  font-weight: bold;
  color: var(--orange);
  text-align: center;
  margin: 0 0 6px;
}

.recipe-inspiration {
  font-size: 14px;
  color: #666;
  text-align: center;
  margin: 0 0 16px;
}

.steps-title {
  font-size: 16px;
  margin: 0 0 8px;
}

.recipe-steps {
  margin: 0 0 10px;
  padding-left: 22px;
  line-height: 1.7;
  font-size: 15px;
}

.toast {
  position: fixed;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%);
  z-index: 30;
  max-width: 80%;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 15px;
  text-align: center;
  line-height: 1.5;
  white-space: pre-line;
}

/* ---------- 云端共享 ---------- */
.sync-status {
  margin-top: 8px;
  font-size: 13px;
  opacity: 0.95;
}

.me-tag {
  font-size: 12px;
  color: #fff;
  background: var(--green);
  border-radius: 10px;
  padding: 2px 8px;
}

.who-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
}

.who-option {
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 16px;
}

.who-option:active {
  background: #e8f5e9;
}

.rename-button {
  margin-left: auto;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 13px;
  color: #666;
}

.invite-link {
  background: #f1f8e9;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  word-break: break-all;
  color: #2e7d32;
  margin: 0 0 6px;
}

.big-button[hidden] {
  display: none;
}

.text-button {
  display: block;
  margin: 6px auto 0;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 15px;
  padding: 8px 16px;
}

.switch-family-button {
  margin-top: 12px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 14px;
}

.switch-family-button[hidden] {
  display: none;
}

.or-text {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin: 14px 0;
}

/* ---------- 数量、冷藏/冷冻、改日期 ---------- */
.hint-text {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin: -8px 0 6px;
}

.food-qty {
  font-size: 14px;
  font-weight: normal;
  color: #666;
  background: #f1f1f1;
  border-radius: 8px;
  padding: 1px 6px;
  white-space: nowrap;
}

.storage-tag {
  font-size: 12px;
  color: #1976d2;
  background: #e3f2fd;
  border-radius: 8px;
  padding: 2px 6px;
}

.storage-tag.frozen {
  color: #fff;
  background: #64b5f6;
}

/* 透明的日期选择框盖在"剩几天"上，点它就弹出日期选择 */
label.remaining-days {
  position: relative;
  cursor: pointer;
}

.date-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: none;
  cursor: pointer;
}

.small-button {
  margin-top: 8px;
  border: 1px solid #cfe3f7;
  background: #f5faff;
  color: #1976d2;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 13px;
}

.unit-label {
  align-self: center;
  font-size: 16px;
  color: #666;
}

/* ---------- 一周食谱 ---------- */
.week-switch {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
}

.week-button {
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 16px;
  padding: 6px 18px;
  font-size: 14px;
  color: #666;
}

.week-button.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.day-card {
  padding: 14px 16px;
  margin: 12px 0;
}

.day-card.today {
  box-shadow: 0 0 0 2px var(--green), 0 2px 10px rgba(0, 0, 0, 0.08);
}

.day-card.past {
  opacity: 0.55;
}

.day-title {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 6px;
}

.day-date {
  font-weight: normal;
  color: var(--muted);
  font-size: 14px;
}

.meal-row {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid #f3f3f3;
}

.meal-label {
  flex-shrink: 0;
  font-size: 14px;
  color: #666;
  padding-top: 5px;
  width: 34px;
}

.meal-dishes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.dish-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #e8f5e9;
  color: #2e7d32;
  border-radius: 14px;
  padding: 4px 6px 4px 10px;
  font-size: 14px;
}

.chip-x {
  border: none;
  background: none;
  color: #81c784;
  font-size: 13px;
  padding: 0 4px;
}

.add-dish {
  border: 1px dashed #bbb;
  background: #fff;
  color: #888;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 14px;
}

.add-item-input.full {
  width: 100%;
  margin-bottom: 10px;
}

#dish-options {
  max-height: 40vh;
  overflow-y: auto;
}

.result-title {
  font-weight: 600;
  margin: 10px 0 4px;
}

.result-list {
  margin: 0 0 8px;
  line-height: 1.6;
  color: var(--green);
}

.result-list.muted {
  color: var(--muted);
}

/* 四个标签时字小一点，手机上放得下 */
.tab {
  font-size: 12px;
  padding: 14px 2px;
}

/* ---------- 顶部栏、使用说明 ---------- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: center;
}

.help-button {
  position: absolute;
  right: 12px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 13px;
  color: #666;
}

.help-content h3 {
  font-size: 16px;
  margin: 16px 0 4px;
}

.help-content p {
  font-size: 14px;
  line-height: 1.7;
  color: #444;
  margin: 0;
}

.help-content .note-text {
  margin: 16px 0 4px;
}
