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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #fff0f3;
  color: #333;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

/* 通用卡片样式 */
.card {
  background: #ffffff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
  text-align: center;
}

/* 1. 置顶计时器 */
.top-header {
  width: 100%;
  max-width: 900px;
  margin-bottom: 20px;
}

.timer-card h2 {
  color: #e63946;
  margin-bottom: 8px;
}

.timer-text {
  font-size: 1.4rem;
  font-weight: bold;
  color: #e76f51;
  margin-top: 6px;
}

/* 2. 主体布局：左侧边 + 右侧内容 */
.main-container {
  display: flex;
  width: 100%;
  max-width: 900px;
  gap: 20px;
}

/* 左侧边栏 */
.sidebar {
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

.nav-btn {
  padding: 14px 16px;
  background-color: #ffffff;
  border: 2px solid transparent;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.nav-btn:hover {
  background-color: #ffe5ec;
}

.nav-btn.active {
  background-color: #ff4d6d;
  color: #ffffff;
}

/* 右侧内容区 */
.content-area {
  flex-grow: 1;
}

.page-content {
  display: none;
}

.page-content.active {
  display: block;
}

.placeholder-text {
  color: #888;
  margin-top: 15px;
}

/* 今天吃什么功能块 */
.food-card button {
  margin-top: 15px;
  padding: 10px 20px;
  background-color: #e63946;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}

.food-result-text {
  margin-top: 15px;
  font-weight: bold;
  color: #2b2d42;
}

/* 我们的照片相册布局 */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
  margin-top: 15px;
}

.gallery img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 12px;
}

/* 响应式：手机端自动改为上下布局 */
@media (max-width: 600px) {
  .main-container {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    flex-direction: row;
  }
  .nav-btn {
    flex: 1;
    text-align: center;
    font-size: 0.85rem;
    padding: 10px 5px;
  }
}
/* ================= 备忘录样式 ================= */
.memo-card {
  padding: 20px;
  text-align: left;
}

.memo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  border-bottom: 2px solid #ffe5ec;
  padding-bottom: 10px;
}

.search-btn {
  background: #ff4d6d;
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
}

.memo-container {
  display: flex;
  gap: 15px;
  min-height: 350px;
}

/* 笔记列表 */
.memo-list-sidebar {
  width: 180px;
  border-right: 1px solid #f0f0f0;
  padding-right: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.new-btn {
  background-color: #ffccd5;
  color: #c9184a;
  border: none;
  padding: 8px;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
}

.memo-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow-y: auto;
  max-height: 300px;
}

.memo-item {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  background-color: #f8f9fa;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.memo-item.active {
  background-color: #ffccd5;
  color: #c9184a;
  font-weight: bold;
}

/* 笔记编辑器 */
.memo-editor {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.editor-header {
  display: flex;
  gap: 10px;
}

#memo-title-input {
  flex-grow: 1;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: bold;
}

#memo-content-input {
  flex-grow: 1;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.95rem;
  resize: none;
  min-height: 250px;
  font-family: inherit;
}

.delete-btn {
  background: #e63946;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

/* ================= 搜索弹窗样式 ================= */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  width: 90%;
  max-width: 500px;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.close-btn {
  font-size: 1.5rem;
  cursor: pointer;
  color: #888;
}

#search-input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin-bottom: 15px;
}

.search-results {
  max-height: 250px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-result-item {
  padding: 10px;
  background: #fff0f3;
  border-radius: 8px;
  cursor: pointer;
}

.search-result-item h5 {
  color: #c9184a;
  margin-bottom: 4px;
}

.search-result-item p {
  font-size: 0.85rem;
  color: #555;
}

.highlight {
  background-color: #ffb703;
  font-weight: bold;
}


/* ================= 手机端响应式适配 (屏幕宽度 <= 768px) ================= */
@media (max-width: 768px) {
  /* 1. 整体边距优化 */
  body {
    padding: 10px;
  }

  .main-container {
    flex-direction: column;
    gap: 15px;
  }

  .card {
    padding: 15px;
  }

  /* 2. 顶部导航按钮自适应等宽 */
  .sidebar {
    display: flex;
    gap: 6px;
    width: 100%;
  }

  .nav-btn {
    flex: 1;
    padding: 8px 4px;
    font-size: 0.85rem;
    text-align: center;
    white-space: nowrap;
  }

  /* 3. 备忘录核心修复：从左右并排改为上下排列 */
  .memo-container {
    flex-direction: column;
    min-height: auto;
  }

  /* 笔记列表变全宽，限制最大高度避免遮挡编辑区 */
  .memo-list-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 2px dashed #ffe5ec;
    padding-right: 0;
    padding-bottom: 12px;
  }

  .memo-list {
    max-height: 120px;
  }

  /* 编辑区充满全屏 */
  .memo-editor {
    width: 100%;
  }

  .editor-header {
    display: flex;
    gap: 8px;
    align-items: center;
  }

  #memo-title-input {
    min-width: 0; /* 允许标题框自动收缩，防止挤出屏外 */
    flex: 1;
  }

  .delete-btn {
    white-space: nowrap; /* 保证删除按钮不换行 */
    padding: 8px 10px;
    font-size: 0.85rem;
  }

  #memo-content-input {
    min-height: 200px;
  }

  /* 4. 搜索弹窗手机端宽度自适应 */
  .modal-content {
    width: 92%;
    padding: 15px;
  }
}
