/* ========= 基础重置 ========= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: "PingFang SC", "Microsoft YaHei", "STHeiti", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: #3d3d3d;
  background-color: #f5f3ee;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; border: none; cursor: pointer; background: transparent; }
input, textarea { font-family: inherit; outline: none; }
img { display: block; max-width: 100%; }

/* ========= 顶部导航栏 ========= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 48px;
  background: linear-gradient(135deg, #3d5c3d 0%, #2c3e2e 100%);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.topbar-title {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 2px;
  text-align: center;
}

.topbar-back {
  width: 32px;
  height: 32px;
  color: #fff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}
.topbar-back:active { background: rgba(255,255,255,0.15); }

.topbar-right { width: 32px; }

/* ========= 主内容区 ========= */
.app-content {
  flex: 1;
  padding: 16px;
  padding-bottom: 80px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ========= 底部 Tab Bar ========= */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: #ffffff;
  display: flex;
  border-top: 1px solid #e8e4dc;
  z-index: 99;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.04);
}

.tabbar.hidden { display: none; }

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #8a8579;
  transition: color 0.2s;
  padding: 6px 0;
}

.tab-item .tab-icon {
  font-size: 22px;
  margin-bottom: 2px;
  filter: grayscale(0.3);
}

.tab-item .tab-text {
  font-size: 12px;
  letter-spacing: 1px;
}

.tab-item.active {
  color: #2c3e2e;
  font-weight: 600;
}
.tab-item.active .tab-icon {
  filter: none;
  transform: scale(1.1);
}
.tab-item:active {
  background: #f5f3ee;
}

/* ========= 通用卡片样式 ========= */
.card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
  border: 1px solid #e8e4dc;
  position: relative;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #3d5c3d, transparent);
  border-radius: 10px 10px 0 0;
  opacity: 0.35;
}

.card-header {
  display: flex;
  align-items: center;
  margin-bottom: 14px;
}

.card-icon {
  font-size: 20px;
  margin-right: 10px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: #2c3e2e;
  letter-spacing: 1px;
}

/* ========= 首页：Hero 区域 ========= */
.hero {
  position: relative;
  height: 170px;
  border-radius: 12px;
  overflow: hidden;
  margin: 0 -16px 14px;
  background: linear-gradient(135deg, #3d5c3d 0%, #2c3e2e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.hero-content {
  text-align: center;
  z-index: 2;
  position: relative;
}

.hero-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 6px;
  margin-bottom: 8px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.hero-subtitle {
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  letter-spacing: 3px;
}

.hero::after {
  content: '🌿';
  position: absolute;
  right: -10px;
  top: -10px;
  font-size: 120px;
  opacity: 0.15;
}

/* ========= 时间线 ========= */
.timeline {
  padding-left: 16px;
  border-left: 2px solid #e8e4dc;
  margin-left: 8px;
}

.timeline-item {
  display: flex;
  margin-bottom: 20px;
  position: relative;
}

.timeline-item:last-child { margin-bottom: 0; }

.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3d5c3d;
  margin-right: 14px;
  margin-top: 6px;
  flex-shrink: 0;
  border: 2px solid #f5f3ee;
  box-shadow: 0 0 0 2px #3d5c3d;
}

.timeline-content { flex: 1; }

.timeline-era {
  font-size: 15px;
  font-weight: 600;
  color: #2c3e2e;
  margin-bottom: 3px;
}

.timeline-time {
  font-size: 11px;
  color: #8a8579;
  margin-bottom: 6px;
}

.timeline-desc {
  font-size: 13px;
  color: #5a5a5a;
  line-height: 1.7;
}

/* ========= 好处网格 ========= */
.benefits-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.benefit-item {
  background: #f8f6f1;
  border-radius: 8px;
  padding: 16px 12px;
  text-align: center;
  border: 1px solid #e8e4dc;
  transition: transform 0.2s;
}
.benefit-item:active { transform: scale(0.97); }

.benefit-icon {
  font-size: 28px;
  margin-bottom: 8px;
  display: block;
}

.benefit-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #2c3e2e;
  margin-bottom: 6px;
}

.benefit-desc {
  font-size: 12px;
  color: #7a7a7a;
  line-height: 1.5;
}

/* ========= 快速入口 ========= */
.entry-grid {
  display: flex;
  justify-content: space-around;
}

.entry-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 20px;
  border-radius: 8px;
  transition: background 0.2s;
  flex: 1;
}
.entry-item:active { background: #f5f3ee; }

.entry-icon {
  font-size: 32px;
  margin-bottom: 6px;
}

.entry-text {
  font-size: 13px;
  color: #5a5a5a;
}

/* ========= 筛选/分类标签 ========= */
.filter-tabs {
  display: flex;
  background: #fff;
  border-radius: 10px;
  padding: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
  border: 1px solid #e8e4dc;
  -webkit-overflow-scrolling: touch;
}

.filter-tab {
  padding: 10px 18px;
  border-radius: 6px;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-tab-text {
  font-size: 14px;
  color: #5a5a5a;
  letter-spacing: 1px;
}

.filter-tab.active {
  background: linear-gradient(135deg, #3d5c3d 0%, #2c3e2e 100%);
}
.filter-tab.active .filter-tab-text {
  color: #fff;
  font-weight: 600;
}

/* ========= 食谱列表 ========= */
.recipe-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.recipe-card {
  display: flex;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
  border: 1px solid #e8e4dc;
  cursor: pointer;
  transition: transform 0.15s;
}
.recipe-card:active { transform: scale(0.98); }

.recipe-image {
  width: 110px;
  height: 100px;
  flex-shrink: 0;
  object-fit: cover;
  background: #f5f3ee;
}

.recipe-info {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.recipe-title {
  font-size: 15px;
  font-weight: 600;
  color: #2c3e2e;
  margin-bottom: 6px;
  letter-spacing: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipe-desc {
  font-size: 12px;
  color: #7a7a7a;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.recipe-tags {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.tag {
  font-size: 11px;
  color: #3d5c3d;
  background: #f0ede6;
  padding: 3px 10px;
  border-radius: 4px;
  border: 1px solid #d4cfc4;
}

/* ========= 空状态 ========= */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 0;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.6;
}

.empty-text {
  font-size: 14px;
  color: #8a8579;
  letter-spacing: 2px;
}

/* ========= 食谱详情 ========= */
.detail-header {
  position: relative;
  height: 220px;
  margin: 0 -16px 14px;
  overflow: hidden;
  background: #2c3e2e;
}

.detail-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.9;
}

.detail-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
}

.detail-title {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 3px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.section {
  padding: 8px 0;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: #2c3e2e;
  margin-bottom: 14px;
  letter-spacing: 1px;
}

.ingredients {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ing-item {
  font-size: 13px;
  color: #5a5a5a;
  background: #f5f3ee;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid #e8e4dc;
}

.steps {
  padding-left: 12px;
}

.step-item {
  display: flex;
  margin-bottom: 18px;
}
.step-item:last-child { margin-bottom: 0; }

.step-num {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #3d5c3d 0%, #2c3e2e 100%);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  margin-right: 12px;
  flex-shrink: 0;
}

.step-text {
  font-size: 14px;
  color: #3d3d3d;
  line-height: 1.8;
  padding-top: 3px;
  flex: 1;
}

.benefits-text {
  font-size: 14px;
  color: #3d3d3d;
  line-height: 1.9;
  letter-spacing: 0.5px;
}

/* ========= 登录注册页面 ========= */
.logo-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 0 30px;
}

.logo {
  font-size: 56px;
  margin-bottom: 12px;
  opacity: 0.9;
}

.app-name {
  font-size: 24px;
  font-weight: 700;
  color: #2c3e2e;
  margin-bottom: 10px;
  letter-spacing: 6px;
}

.ink-divider {
  width: 80px;
  height: 3px;
  background: linear-gradient(90deg, transparent, #2c3e2e, transparent);
  margin: 12px 0;
  opacity: 0.5;
}

.app-desc {
  font-size: 13px;
  color: #8a8579;
  letter-spacing: 3px;
}

/* 表单 */
.form-item {
  margin-bottom: 18px;
  position: relative;
}

.form-label {
  font-size: 13px;
  color: #5a5a5a;
  margin-bottom: 8px;
  display: block;
  letter-spacing: 1px;
}

.form-input {
  width: 100%;
  height: 44px;
  border: 1px solid #d4cfc4;
  border-radius: 6px;
  padding: 0 14px;
  font-size: 14px;
  box-sizing: border-box;
  background: #faf9f6;
  color: #3d3d3d;
  transition: border-color 0.2s, background 0.2s;
}

.form-input:focus {
  border-color: #3d5c3d;
  background: #fff;
}

.form-input.disabled {
  background: #f0ede6;
  color: #999;
}

.code-input-wrap {
  position: relative;
}

.code-input-wrap .form-input {
  padding-right: 100px;
}

.code-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: #3d5c3d;
  color: #fff;
  border-radius: 4px;
  padding: 8px 14px;
  font-size: 12px;
  letter-spacing: 1px;
  transition: background 0.2s;
}
.code-btn:active { background: #2c3e2e; }
.code-btn:disabled {
  background: #b8b3a8;
  cursor: not-allowed;
}

/* 复选框/记住我 */
.remember-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  margin-bottom: 16px;
}

.checkbox-wrap {
  display: flex;
  align-items: center;
  font-size: 13px;
  color: #5a5a5a;
  cursor: pointer;
}

.checkbox-wrap input {
  width: 16px;
  height: 16px;
  margin-right: 6px;
  accent-color: #3d5c3d;
}

.link-btn {
  font-size: 13px;
  color: #3d5c3d;
  cursor: pointer;
  text-decoration: underline;
}

/* 主按钮 */
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #3d5c3d 0%, #2c3e2e 100%);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 14px;
  font-size: 15px;
  text-align: center;
  margin-top: 8px;
  letter-spacing: 4px;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(44, 62, 46, 0.2);
  transition: opacity 0.2s, transform 0.15s;
}
.btn-primary:active {
  opacity: 0.85;
  transform: translateY(1px);
}
.btn-primary:disabled {
  background: #b8b3a8;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  width: 100%;
  background: #f5f3ee;
  color: #5a5a5a;
  border: 1px solid #c9c4b8;
  border-radius: 6px;
  padding: 14px;
  font-size: 15px;
  text-align: center;
  margin-top: 10px;
  letter-spacing: 2px;
}
.btn-secondary:active { background: #eae5d8; }

/* 底部提示 */
.tips {
  font-size: 13px;
  color: #8a8579;
  margin-top: 20px;
  text-align: center;
  letter-spacing: 1px;
}

.form-title {
  font-size: 20px;
  font-weight: 700;
  color: #2c3e2e;
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: 4px;
}

/* ========= 个人中心 ========= */
.user-card {
  display: flex;
  align-items: center;
  padding: 24px 20px;
  background: linear-gradient(135deg, #3d5c3d 0%, #2c3e2e 100%);
  border-radius: 10px;
  margin-bottom: 14px;
  color: #fff;
}

.user-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-right: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  flex-shrink: 0;
}

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

.user-name {
  display: block;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
  letter-spacing: 2px;
}

.user-email {
  font-size: 12px;
  color: rgba(255,255,255,0.75);
  word-break: break-all;
}

/* 菜单 */
.menu-list {
  padding: 4px 0;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 18px 0;
  border-bottom: 1px solid #f0ede6;
  cursor: pointer;
  transition: background 0.2s;
}
.menu-item:last-child { border-bottom: none; }
.menu-item:active { background: #f8f6f1; }

.menu-icon {
  font-size: 22px;
  margin-right: 14px;
}

.menu-text {
  flex: 1;
  font-size: 15px;
  color: #3d3d3d;
  letter-spacing: 1px;
}

.menu-arrow {
  font-size: 18px;
  color: #c9c4b8;
}

/* 退出登录 */
.logout-btn {
  width: 100%;
  background: #fff;
  color: #8b4513;
  border: 1px solid #c9c4b8;
  border-radius: 6px;
  padding: 14px;
  font-size: 15px;
  letter-spacing: 4px;
  font-weight: 600;
}
.logout-btn:active { background: #f0ede6; }

/* 版本信息 */
.version-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 0;
  color: #8a8579;
  font-size: 12px;
  letter-spacing: 1px;
}

/* 未登录提示 */
.login-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 20px;
}

.prompt-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.prompt-text {
  font-size: 15px;
  color: #5a5a5a;
  margin-bottom: 20px;
  letter-spacing: 2px;
}

/* ========= AI 聊天页面 ========= */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 48px - 60px);
  margin: -16px;
  background: #f5f3ee;
  position: relative;
}

.chat-list {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.message-item {
  margin-bottom: 16px;
}

.message-content {
  display: flex;
}

.message-content.user {
  flex-direction: row-reverse;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f0ede6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  border: 1px solid #d4cfc4;
}

.message-content.user .avatar {
  background: linear-gradient(135deg, #3d5c3d 0%, #2c3e2e 100%);
  border-color: #3d5c3d;
  color: #fff;
}

.msg-box {
  max-width: 72%;
  padding: 12px 14px;
  border-radius: 10px;
  margin: 0 10px;
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.7;
  font-size: 14px;
}

.message-content.user .msg-box {
  background: linear-gradient(135deg, #3d5c3d 0%, #2c3e2e 100%);
  color: #fff;
  border-top-right-radius: 2px;
}

.message-content.bot .msg-box {
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  border: 1px solid #e8e4dc;
  color: #3d3d3d;
  border-top-left-radius: 2px;
}

/* 输入区 */
.input-area {
  display: flex;
  padding: 12px;
  background: #fff;
  border-top: 1px solid #e8e4dc;
  align-items: center;
}

.msg-input {
  flex: 1;
  height: 40px;
  background: #f8f6f1;
  border: 1px solid #d4cfc4;
  border-radius: 20px;
  padding: 0 16px;
  font-size: 14px;
}
.msg-input:focus {
  border-color: #3d5c3d;
  background: #fff;
}

.send-btn {
  min-width: 64px;
  height: 40px;
  background: linear-gradient(135deg, #3d5c3d 0%, #2c3e2e 100%);
  color: #fff;
  border-radius: 20px;
  font-size: 14px;
  margin-left: 10px;
  letter-spacing: 2px;
  font-weight: 600;
  transition: opacity 0.2s;
}
.send-btn:active { opacity: 0.85; }
.send-btn:disabled {
  background: #c9c4b8;
  cursor: not-allowed;
}

/* ========= Toast ========= */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.78);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  letter-spacing: 1px;
  z-index: 999;
  max-width: 80%;
  text-align: center;
  animation: toastFadeIn 0.2s;
}

@keyframes toastFadeIn {
  from { opacity: 0; transform: translate(-50%, -40%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

/* ========= Loading ========= */
.loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 998;
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  margin-top: 14px;
  color: #fff;
  font-size: 14px;
  letter-spacing: 2px;
}

/* ========= Modal ========= */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 997;
  animation: modalFadeIn 0.2s;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  width: 88%;
  max-width: 340px;
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  border: 1px solid #e8e4dc;
  animation: modalScaleIn 0.2s;
}

@keyframes modalScaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-title {
  display: block;
  font-size: 17px;
  font-weight: 700;
  color: #2c3e2e;
  text-align: center;
  margin-bottom: 20px;
  letter-spacing: 2px;
}

.modal-body {
  font-size: 14px;
  color: #3d3d3d;
  line-height: 1.8;
  margin-bottom: 16px;
  text-align: center;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions .btn-primary,
.modal-actions .btn-secondary {
  margin-top: 0;
  padding: 12px;
  font-size: 14px;
}

/* ========= 响应式（大屏限制宽度） ========= */
@media (min-width: 768px) {
  body {
    max-width: 480px;
    margin: 0 auto;
    background: #eae5d8;
    box-shadow: 0 0 30px rgba(0,0,0,0.1);
  }
  .topbar, .tabbar {
    max-width: 480px;
    margin: 0 auto;
  }
}
