/* ========================================
   铅笔的生活小记 - 主样式文件
   ======================================== */

/* CSS 变量 */
:root {
  --color-primary: #5d4e37;
  --color-secondary: #8b7355;
  --color-accent: #c4936a;
  --color-bg: #faf8f5;
  --color-card: #ffffff;
  --color-text: #3d3d3d;
  --color-text-light: #666666;
  --color-muted: #a0937d;
  --color-border: #eee;
  --color-tag-bg: #faf0e6;
  --color-highlight: #fcb69f;
  --shadow-sm: 0 2px 8px rgba(93, 78, 55, 0.06);
  --shadow-md: 0 6px 20px rgba(93, 78, 55, 0.08);
  --radius: 12px;
  --max-width: 1100px;
  --sidebar-width: 240px;
}

/* 深色模式 */
[data-theme="dark"] {
  --color-primary: #d4c5a9;
  --color-secondary: #b8a88a;
  --color-accent: #e0b08a;
  --color-bg: #1a1a2e;
  --color-card: #252540;
  --color-text: #e0ddd5;
  --color-text-light: #a0a0a0;
  --color-muted: #8a7d6d;
  --color-border: #3a3a50;
  --color-tag-bg: #2a2a45;
  --color-highlight: #c4795a;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, #2a2a45 25%, #353560 50%, #2a2a45 75%);
}

[data-theme="dark"] .main-nav {
  background: var(--color-card);
  border-bottom-color: var(--color-border);
}

[data-theme="dark"] .recipe-card,
[data-theme="dark"] .ingredient-card,
[data-theme="dark"] .category-card,
[data-theme="dark"] .meal-plan-card,
[data-theme="dark"] .favorite-card,
[data-theme="dark"] .related-recipe-card {
  background: var(--color-card);
  border-color: var(--color-border);
}

[data-theme="dark"] .recipe-card:hover,
[data-theme="dark"] .ingredient-card:hover {
  box-shadow: var(--shadow-md);
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: #2a2a45;
  color: var(--color-text);
  border-color: var(--color-border);
}

[data-theme="dark"] .search-box input {
  background: #2a2a45;
  color: var(--color-text);
  border-color: var(--color-border);
}

[data-theme="dark"] .tag {
  background: var(--color-tag-bg);
  color: var(--color-text-light);
}

[data-theme="dark"] .btn-primary {
  background: var(--color-accent);
  color: #1a1a2e;
}

[data-theme="dark"] .btn-secondary {
  background: #3a3a50;
  color: var(--color-text);
  border-color: var(--color-border);
}

[data-theme="dark"] .sidebar {
  background: var(--color-card);
  border-color: var(--color-border);
}

[data-theme="dark"] .breadcrumb {
  color: var(--color-text-light);
}

[data-theme="dark"] .breadcrumb a {
  color: var(--color-accent);
}

[data-theme="dark"] .stat-card,
[data-theme="dark"] .info-card {
  background: var(--color-card);
  border-color: var(--color-border);
}

[data-theme="dark"] .section-title {
  color: var(--color-text);
}

[data-theme="dark"] .step-item {
  background: var(--color-card);
  border-color: var(--color-border);
}

[data-theme="dark"] .timer-modal-content {
  background: var(--color-card);
  color: var(--color-text);
}

[data-theme="dark"] .modal-overlay {
  background: rgba(0, 0, 0, 0.6);
}

/* 重置样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s;
}

/* ========================================
   导航栏
   ======================================== */
nav {
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  padding: 10px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

nav .inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

nav .brand {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-primary);
  flex-shrink: 0;
}

.nav-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
}

nav .links {
  display: flex;
  align-items: center;
  gap: 16px;
}

nav .links a {
  color: var(--color-secondary);
  font-size: 14px;
  position: relative;
}

nav .links a:hover {
  color: var(--color-primary);
}

nav .links a.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-accent);
  border-radius: 1px;
}

/* 导航右侧区域 */
.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.dark-mode-toggle {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

/* 搜索框 */
.search-box {
  position: relative;
  margin-left: 16px;
}

.search-box input {
  width: 160px;
  padding: 6px 10px 6px 32px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  font-size: 14px;
  background: var(--color-bg);
  transition: all 0.2s;
}

.search-box input:focus {
  outline: none;
  border-color: var(--color-accent);
  width: 220px;
}

.search-box::before {
  content: '🔍';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
}

/* ========================================
   主布局
   ======================================== */
.main-layout {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  gap: 20px;
}

.main-content {
  flex: 1;
  min-width: 0;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
}

/* ========================================
   头部 Hero
   ======================================== */
.hero {
  text-align: left;
  padding: 10px 16px;
  background: linear-gradient(135deg, #fff9f0 0%, #fff 100%);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.hero-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hero h1 {
  font-size: 18px;
  color: var(--color-primary);
  margin-bottom: 1px;
  font-weight: 700;
}

.hero p {
  font-size: 12px;
  color: var(--color-muted);
}

.hero .date {
  margin-top: 0;
  font-size: 12px;
  color: var(--color-muted);
  font-style: italic;
  white-space: nowrap;
}

/* ========================================
   标签样式（菜谱用）
   ======================================== */
.tag {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 12px;
  background: var(--color-tag-bg);
  color: var(--color-muted);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-block;
}

.tag:hover, .tag.active {
  background: var(--color-accent);
  color: #fff;
}

/* ========================================
   侧边栏
   ======================================== */
.sidebar-card {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.sidebar-card h3 {
  font-size: 14px;
  color: var(--color-primary);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
}

/* 关于我 */
.about-me .avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-highlight), var(--color-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto 10px;
}

.about-me .name {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 4px;
}

.about-me .bio {
  text-align: center;
  font-size: 12px;
  color: var(--color-text-light);
  line-height: 1.6;
}

/* 标签云 */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-cloud .tag {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 16px;
  background: var(--color-tag-bg);
  color: var(--color-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.tag-cloud .tag:hover,
.tag-cloud .tag.active {
  background: var(--color-accent);
  color: #fff;
}

/* 最新日记 */
.recent-list {
  list-style: none;
}

.recent-list li {
  padding: 10px 0;
  border-bottom: 1px dashed var(--color-border);
}

.recent-list li:last-child {
  border-bottom: none;
}

.recent-list a {
  display: block;
  font-size: 14px;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-list a:hover {
  color: var(--color-accent);
}

.recent-list .date {
  font-size: 12px;
  color: #b8a898;
  margin-top: 4px;
}

/* 统计 */
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.stats .stat-item {
  text-align: center;
  padding: 8px;
  background: var(--color-bg);
  border-radius: 8px;
}

.stats .stat-num {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-accent);
}

.stats .stat-label {
  font-size: 12px;
  color: var(--color-muted);
  margin-top: 4px;
}

/* ========================================
   分类筛选
   ======================================== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.filter-bar label {
  font-size: 14px;
  color: var(--color-muted);
}

.filter-bar select {
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--color-bg);
  cursor: pointer;
}

.filter-bar select:focus {
  outline: none;
  border-color: var(--color-accent);
}

/* ========================================
   分页
   ======================================== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-card);
  transition: all 0.2s;
}

.pagination a:hover {
  background: var(--color-tag-bg);
}

.pagination .active {
  background: var(--color-accent);
  color: #fff;
}

/* ========================================
   详情页
   ======================================== */
.article-header {
  text-align: center;
  padding: 28px 0 20px;
}

.article-header h1 {
  font-size: 26px;
  color: var(--color-primary);
  margin-bottom: 10px;
}

.article-header .meta {
  font-size: 14px;
  color: var(--color-muted);
}

.article-header .meta span {
  margin: 0 8px;
}

.article-content {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 24px;
  font-size: 15px;
  line-height: 1.8;
  color: var(--color-text);
}

.article-content p {
  margin-bottom: 14px;
}

.article-content h2 {
  font-size: 20px;
  color: var(--color-primary);
  margin: 24px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}

.article-content img {
  max-width: 100%;
  border-radius: 8px;
  margin: 14px 0;
}

.article-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

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

/* ========================================
   归档页
   ======================================== */
.archive-year {
  font-size: 20px;
  color: var(--color-primary);
  margin: 20px 0 12px;
  font-weight: 600;
}

.archive-month {
  margin-left: 20px;
}

.archive-month h4 {
  font-size: 15px;
  color: var(--color-secondary);
  margin: 14px 0 8px;
}

.archive-list {
  list-style: none;
  margin-left: 16px;
}

.archive-list li {
  padding: 8px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.archive-list .date {
  font-size: 13px;
  color: #b8a898;
  min-width: 80px;
}

.archive-list a {
  font-size: 15px;
  color: var(--color-text);
}

.archive-list a:hover {
  color: var(--color-accent);
}

/* ========================================
   底部
   ======================================== */
footer {
  text-align: center;
  padding: 20px 24px;
  color: var(--color-muted);
  font-size: 13px;
  border-top: 1px solid var(--color-border);
  margin-top: 20px;
}

footer a {
  color: var(--color-muted);
}

footer a:hover {
  color: var(--color-accent);
}

/* ========================================
   响应式
   ======================================== */
@media (max-width: 900px) {
  .sidebar {
    display: none;
  }

  .main-layout {
    flex-direction: column;
  }
}

@media (max-width: 600px) {
  nav .inner {
    flex-wrap: wrap;
    gap: 12px;
  }

  .search-box {
    margin-left: 0;
    width: 100%;
    order: 3;
  }

  .search-box input {
    width: 100%;
  }

  .search-box input:focus {
    width: 100%;
  }

  .hero h1 {
    font-size: 18px;
  }

  .hero-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .article-content {
    padding: 16px;
  }

  .article-header h1 {
    font-size: 24px;
  }
}

/* ========================================
   动画
   ======================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 加载状态 */
.loading {
  text-align: center;
  padding: 28px;
  color: var(--color-muted);
}

.loading::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

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

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-muted);
}

.empty-state .icon {
  font-size: 40px;
  margin-bottom: 12px;
}

/* ========================================
   Tab 切换器
   ======================================== */
.tab-switcher { display: flex; gap: 4px; }
.tab-btn {
  padding: 6px 16px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-card);
  font-size: 14px;
  cursor: pointer;
  color: var(--color-text-light);
  transition: all 0.2s;
}
.tab-btn:hover:not(.active) { background: var(--color-bg); color: var(--color-text); }
.tab-btn.active { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
.tab-panel { display: none; }
.tab-panel.active { display: grid; }

/* ========================================
   菜谱卡片
   ======================================== */
.recipe-card {
  background: var(--color-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.3s, transform 0.2s;
  cursor: pointer;
  animation: fadeIn 0.4s ease;
}

.recipe-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.recipe-img {
  height: 100px;
  position: relative;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}

.recipe-card:hover .recipe-img {
  background-size: 115%;
}

.recipe-difficulty {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  color: #fff;
  font-weight: 600;
}

.recipe-info {
  padding: 8px 10px;
}

.recipe-info h3 {
  font-size: 13px;
  color: var(--color-primary);
  margin-bottom: 3px;
  font-weight: 600;
}

.recipe-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--color-muted);
  margin-bottom: 3px;
}

.recipe-summary {
  font-size: 12px;
  color: var(--color-text-light);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 首页菜谱区 */
.recipes-section {
  margin-bottom: 20px;
}

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

.recipes-section .section-header h2 {
  font-size: 16px;
  color: var(--color-primary);
}

.recipes-section .section-header a {
  font-size: 13px;
  color: var(--color-accent);
}

.recipes-grid-home {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

/* ========================================
   多图轮播
   ======================================== */
.carousel {
  position: relative;
  width: 100%;
  max-height: 360px;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
  background: #f5f5f5;
}
.carousel-track {
  display: flex;
  transition: transform 0.4s ease;
}
.carousel-track img {
  width: 100%;
  flex-shrink: 0;
  height: 360px;
  object-fit: cover;
  cursor: pointer;
}
.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.4);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.2s;
  z-index: 2;
}
.carousel-btn:hover { background: rgba(0,0,0,0.6); }
.carousel-btn.prev { left: 12px; }
.carousel-btn.next { right: 12px; }
.carousel-dots {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}
.carousel-dots .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: background 0.2s;
}
.carousel-dots .dot.active { background: #fff; }
.carousel-empty {
  width: 100%;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  color: #ddd;
  background: #fafafa;
  border-radius: var(--radius);
  margin-bottom: 20px;
}

/* ========================================
   小贴士
   ======================================== */
.tips-section {
  background: linear-gradient(135deg, #FFF9F0, #FFF5EE);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  border-left: 4px solid #D4542A;
}
.tips-section h3 {
  font-size: 16px;
  color: #D4542A;
  margin-bottom: 8px;
}
.tips-section ul {
  list-style: none;
  padding: 0;
}
.tips-section li {
  font-size: 14px;
  color: #666;
  line-height: 1.8;
  padding-left: 20px;
  position: relative;
}
.tips-section li::before {
  content: "💡";
  position: absolute;
  left: 0;
}

/* ========================================
   评分星星
   ======================================== */
.rating-section {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.rating-section h3 { font-size: 16px; color: var(--color-primary); margin-bottom: 8px; }
.stars { display: inline-flex; gap: 6px; margin-bottom: 8px; }
.star {
  font-size: 28px;
  cursor: pointer;
  transition: transform 0.2s;
  color: #ddd;
}
.star:hover, .star.active { color: #FFD700; transform: scale(1.2); }
.rating-info { font-size: 14px; color: var(--color-muted); }

/* ========================================
   做菜日志时间线
   ======================================== */
.logs-section {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.logs-section h3 {
  font-size: 16px;
  color: var(--color-primary);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--color-border);
}
.timeline-item {
  position: relative;
  margin-bottom: 18px;
}
.timeline-item:last-child { margin-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -24px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #D4542A;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #D4542A;
}
.timeline-date { font-size: 13px; color: var(--color-muted); margin-bottom: 6px; }
.timeline-rating { color: #FFD700; font-size: 14px; margin-bottom: 6px; }
.timeline-note { font-size: 14px; color: var(--color-text-light); line-height: 1.7; }
.timeline-images { display: flex; gap: 8px; margin-top: 8px; }
.timeline-images img {
  width: 80px; height: 80px; object-fit: cover; border-radius: 8px; cursor: pointer;
  transition: transform 0.2s;
}
.timeline-images img:hover { transform: scale(1.05); }
.add-log-btn {
  display: inline-block;
  margin-top: 16px;
  padding: 8px 20px;
  background: #D4542A;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}
.add-log-btn:hover { background: #c04520; }

/* ========================================
   图片灯箱
   ======================================== */
.lightbox {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
.lightbox.active { display: flex; }
.lightbox img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 8px;
}
.lightbox-close {
  position: absolute;
  top: 20px; right: 24px;
  background: none; border: none;
  color: #fff; font-size: 32px; cursor: pointer;
}
.lightbox-prev, .lightbox-next {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.2);
  border: none; color: #fff;
  width: 48px; height: 48px;
  border-radius: 50%;
  font-size: 20px; cursor: pointer;
  transition: background 0.2s;
}
.lightbox-prev:hover, .lightbox-next:hover { background: rgba(255,255,255,0.4); }
.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }

/* ========================================
   步骤勾选
   ======================================== */
.step-checkbox {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #ddd;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  margin-top: 4px;
  font-size: 12px;
}
.step-checkbox.checked {
  background: #4CAF50;
  border-color: #4CAF50;
  color: #fff;
}

/* ========================================
   相关推荐
   ======================================== */
.related-section {
  margin-bottom: 20px;
}
.related-section h3 {
  font-size: 16px;
  color: var(--color-primary);
  margin-bottom: 12px;
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.related-card {
  background: var(--color-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.related-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.related-card img {
  width: 100%;
  height: 80px;
  object-fit: cover;
}
.related-card .info { padding: 6px 8px; }
.related-card .info h4 {
  font-size: 12px;
  color: var(--color-primary);
  margin-bottom: 2px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.related-card .info .rating {
  font-size: 11px;
  color: #FFD700;
}

/* ========================================
   标签可点击
   ======================================== */
.recipe-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; justify-content: center; }
.recipe-tag {
  padding: 4px 14px;
  background: #FFF5EE;
  color: #D4542A;
  border-radius: 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}
.recipe-tag:hover { background: #D4542A; color: #fff; }

/* ========================================
   菜谱列表视图
   ======================================== */
.recipes-list-view {
  display: none;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}
.recipes-list-view.active { display: flex; }
.recipes-grid.active { display: grid; }
.recipes-grid:not(.active) { display: none; }

.recipe-list-item {
  display: flex;
  background: var(--color-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow 0.3s, transform 0.2s;
}
.recipe-list-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateX(4px);
}
.recipe-list-item .thumb {
  width: 180px;
  min-height: 130px;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}
.recipe-list-item .info {
  flex: 1;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.recipe-list-item .info h3 {
  font-size: 16px;
  color: var(--color-primary);
  margin-bottom: 6px;
}
.recipe-list-item .info .meta {
  font-size: 13px;
  color: var(--color-muted);
  display: flex;
  gap: 16px;
  margin-bottom: 8px;
}
.recipe-list-item .info .summary {
  font-size: 14px;
  color: var(--color-text-light);
  line-height: 1.6;
}
.recipe-list-item .info .rating {
  color: #FFD700;
  font-size: 14px;
  margin-top: 8px;
}

/* ========================================
   分页
   ======================================== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}
.page-btn {
  padding: 8px 14px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-card);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  color: var(--color-text);
}
.page-btn:hover:not(.active):not(:disabled) {
  border-color: #D4542A;
  color: #D4542A;
}
.page-btn.active {
  background: #D4542A;
  color: #fff;
  border-color: #D4542A;
}
.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.page-info {
  font-size: 14px;
  color: var(--color-muted);
  margin: 0 8px;
}

/* ========================================
   视图切换按钮
   ======================================== */
.view-toggle {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}
.view-btn {
  padding: 8px 12px;
  background: var(--color-card);
  border: none;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
  color: var(--color-muted);
}
.view-btn.active {
  background: #D4542A;
  color: #fff;
}
.view-btn:hover:not(.active) {
  background: var(--color-bg);
}

/* ========================================
   响应式：列表视图在小屏幕变为上下布局
   ======================================== */
@media (max-width: 700px) {
  .recipe-list-item {
    flex-direction: column;
  }
  .recipe-list-item .thumb {
    width: 100%;
    height: 150px;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar-right {
    justify-content: center;
  }
}

/* ========================================
   食材库样式
   ======================================== */
.ingredients-hero {
  text-align: center;
  padding: 10px 0 8px;
  background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.ingredients-hero h1 { font-size: 18px; color: #4CAF50; margin-bottom: 2px; }
.ingredients-hero p { font-size: 12px; color: var(--color-muted); }

.category-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.category-tab {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--color-border);
  background: var(--color-card);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--color-text-light);
}
.category-tab:hover { border-color: #4CAF50; color: #4CAF50; }
.category-tab.active { background: #4CAF50; color: #fff; border-color: #4CAF50; }

.ingredients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.ingredient-card {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 10px 8px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.ingredient-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.ingredient-card .emoji {
  font-size: 26px;
  margin-bottom: 4px;
  line-height: 1;
}
.ingredient-card .name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 2px;
}
.ingredient-card .category-label {
  font-size: 11px;
  color: var(--color-muted);
}
.ingredient-card .unit {
  font-size: 11px;
  color: #999;
  margin-top: 2px;
}

/* ===== 食材详情页 ===== */
.ingredient-header {
  text-align: center;
  padding: 20px 20px;
  background: linear-gradient(135deg, #f0f9e8 0%, #fff 100%);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.ingredient-emoji {
  font-size: 56px;
  margin-bottom: 8px;
  line-height: 1;
}
.ingredient-header h1 {
  font-size: 24px;
  color: #5d4e37;
  margin-bottom: 8px;
}
.ingredient-unit {
  font-size: 13px;
  color: var(--color-muted);
  margin-bottom: 6px;
}
.info-item {
  margin-bottom: 12px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.info-label {
  font-size: 13px;
  color: var(--color-muted);
  font-weight: 600;
}
.info-value {
  font-size: 14px;
  color: var(--color-text);
}
.season-tags {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.season-tag {
  padding: 3px 12px;
  background: #E8F5E9;
  color: #4CAF50;
  border-radius: 12px;
  font-size: 13px;
}
.ingredient-description {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  line-height: 1.7;
}
.ingredient-description h3 {
  font-size: 16px;
  color: var(--color-primary);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}
.ingredient-description p {
  font-size: 14px;
  color: var(--color-text-light);
  white-space: pre-wrap;
}
.ingredient-nutrition {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.nutrition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.nutrition-item {
  background: var(--color-bg);
  border-radius: 8px;
  padding: 8px 12px;
  text-align: center;
}
.nutrition-key {
  display: block;
  font-size: 12px;
  color: var(--color-muted);
  margin-bottom: 4px;
}
.nutrition-val {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: #D4542A;
}
.related-recipes-section {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.related-recipes-section h3 {
  font-size: 16px;
  color: var(--color-primary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}
.related-recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.related-recipe-card {
  background: var(--color-bg);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.related-recipe-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.related-recipe-card .recipe-thumb {
  height: 80px;
  background-size: cover;
  background-position: center;
}
.related-recipe-card .recipe-info {
  padding: 6px 8px;
}
.related-recipe-card h4 {
  font-size: 12px;
  color: var(--color-primary);
  margin-bottom: 2px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.related-recipe-card .recipe-meta {
  font-size: 10px;
  color: var(--color-muted);
  display: flex;
  gap: 6px;
}
.related-recipe-card .recipe-amount {
  font-size: 10px;
  color: #999;
  margin-top: 2px;
}

/* ===== 食材链接样式 ===== */
.ing-emoji {
  margin-right: 4px;
  font-size: 15px;
}
.ing-link {
  color: var(--color-accent);
  text-decoration: none;
  transition: color 0.2s;
}
.ing-link:hover {
  color: #D4542A;
  text-decoration: underline;
}
.ingredient-group-label {
  font-size: 13px;
  color: var(--color-muted);
  margin: 12px 0 8px;
  font-weight: 600;
}
.ingredient-group-label:first-of-type {
  margin-top: 0;
}
.ingredient-item.sub .ingredient-name {
  color: var(--color-text-light);
}

/* =======================================
   Skeleton 骨架屏加载动画
   ======================================= */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  background: var(--color-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.skeleton-card .skeleton-img {
  width: 100%;
  height: 100px;
}

.skeleton-card .skeleton-body {
  padding: 10px;
}

.skeleton-line {
  height: 14px;
  margin-bottom: 10px;
  border-radius: 6px;
}

.skeleton-line:last-child {
  margin-bottom: 0;
  width: 60%;
}

.skeleton-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.skeleton-text {
  height: 20px;
  margin-bottom: 12px;
  border-radius: 6px;
}

/* 全局 Loading 指示器 */
.global-spinner {
  position: fixed;
  top: 70px;
  right: 24px;
  width: 32px;
  height: 32px;
  border: 3px solid #f0f0f0;
  border-top: 3px solid #D4542A;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  z-index: 9998;
  display: none;
}

.global-spinner.active {
  display: block;
}

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

/* =======================================
   回到顶部按钮
   ======================================= */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  z-index: 9990;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: opacity 0.3s, transform 0.3s, visibility 0.3s, background 0.2s;
  color: var(--color-primary);
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: #D4542A;
  color: #fff;
  border-color: #D4542A;
}

/* =======================================
   菜谱列表行（紧凑列表视图）
   ======================================= */
.recipe-list-compact {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.recipe-list-row {
  display: flex;
  align-items: center;
  background: var(--color-card);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s;
  text-decoration: none;
  color: inherit;
}
.recipe-list-row:hover {
  box-shadow: var(--shadow-md);
  transform: translateX(3px);
}
.recipe-list-row .row-thumb {
  width: 72px;
  height: 52px;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
  border-radius: 8px 0 0 8px;
}
.recipe-list-row .row-body {
  flex: 1;
  padding: 5px 10px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.recipe-list-row .row-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  min-width: 0;
}
.recipe-list-row .row-meta {
  font-size: 11px;
  color: var(--color-muted);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.recipe-list-row .row-badge {
  position: absolute;
  top: 3px;
  left: 3px;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  color: #fff;
  font-weight: 600;
}
.recipe-list-row .thumb-wrap {
  position: relative;
  flex-shrink: 0;
}

/* 通用标题行（标题+视图切换按钮） */
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}
.section-title-row h3 {
  font-size: 16px;
  color: var(--color-primary);
  margin: 0;
}

/* 迷你视图切换按钮 */
.view-toggle-mini {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow: hidden;
  margin-left: 8px;
  vertical-align: middle;
}
.view-toggle-mini button {
  padding: 3px 8px;
  background: var(--color-card);
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--color-muted);
  transition: all 0.15s;
  line-height: 1;
}
.view-toggle-mini button.active {
  background: #D4542A;
  color: #fff;
}
.view-toggle-mini button:hover:not(.active) {
  background: var(--color-bg);
}

/* 菜谱卡片 Skeleton */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.skeleton-grid .skeleton-card {
  height: 220px;
}

/* =======================================
   Toast 消息提示
   ======================================= */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: translateX(40px);
  transition: all 0.3s ease;
  pointer-events: auto;
  max-width: 320px;
  word-break: break-word;
}

.toast-show {
  opacity: 1;
  transform: translateX(0);
}

.toast-hide {
  opacity: 0;
  transform: translateX(40px);
}

.toast-info { background: #5d4e37; }
.toast-success { background: #4CAF50; }
.toast-error { background: #F44336; }
.toast-warning { background: #FF9800; }

[data-theme="dark"] .toast-info { background: #8b7355; }

/* =======================================
   确认弹窗
   ======================================= */
.confirm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.confirm-dialog {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-md);
}

.confirm-dialog h4 {
  font-size: 16px;
  color: var(--color-primary);
  margin-bottom: 12px;
}

.confirm-dialog p {
  font-size: 14px;
  color: var(--color-text-light);
  margin-bottom: 20px;
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.confirm-actions .btn-primary {
  padding: 8px 20px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: opacity 0.2s;
}

.confirm-actions .btn-primary:hover { opacity: 0.85; }

.confirm-actions .btn-danger {
  padding: 8px 20px;
  background: #F44336;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: opacity 0.2s;
}

.confirm-actions .btn-danger:hover { opacity: 0.85; }

.confirm-actions .btn-secondary {
  padding: 8px 20px;
  background: var(--color-bg);
  color: var(--color-text-light);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}

.confirm-actions .btn-secondary:hover { background: var(--color-border); }

/* =======================================
   导航栏响应式（手机端换行显示菜单）
   ======================================= */
@media (max-width: 768px) {
  nav {
    padding: 8px 0;
  }

  nav .inner {
    flex-wrap: wrap;
    padding: 0 16px;
    gap: 6px;
  }

  .nav-center {
    position: static;
    transform: none;
    width: 100%;
    order: 3;
    justify-content: center;
  }

  nav .links {
    flex-wrap: wrap;
    gap: 4px 12px;
    justify-content: center;
  }

  nav .links a {
    font-size: 13px;
    padding: 2px 0;
  }

  nav .links a.active::after {
    bottom: -2px;
  }

  .nav-right {
    margin-left: auto;
  }
}

/* 骨架屏高度修复 */
.skeleton-card .skeleton-img {
  min-height: 100px;
}

.skeleton-card .skeleton-body {
  min-height: 50px;
}

/* =======================================
   面包屑
   ======================================= */
.breadcrumb-bar {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 8px 24px 0;
  font-size: 12px;
  color: var(--color-muted);
}

.breadcrumb-bar a {
  color: var(--color-muted);
  text-decoration: none;
}

.breadcrumb-bar a:hover {
  color: var(--color-accent);
}

.breadcrumb-bar span {
  margin: 0 8px;
}

/* =======================================
   图片懒加载
   ======================================= */
img[data-src] {
  opacity: 0;
  transition: opacity 0.3s;
}

img.loaded {
  opacity: 1;
}

/* =======================================
   数据导出链接
   ======================================= */
.export-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--color-tag-bg);
  color: var(--color-accent);
  border-radius: 8px;
  font-size: 13px;
  transition: all 0.2s;
  text-decoration: none;
}

.export-link:hover {
  background: var(--color-accent);
  color: #fff;
}
