/* === 主题变量（默认：番茄红食欲调） === */
:root,
[data-theme="warm"] {
  --primary: #e85d4a;
  --primary-dark: #c93e2b;
  --primary-light: #fdebe6;
  --bg: #fffaf5;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #f0e6dc;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --shadow: 0 1px 3px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 24px rgba(232,93,74,.12);
}

[data-theme="fresh"] {
  --primary: #2d6a4f;
  --primary-dark: #1b4332;
  --primary-light: #e6f1eb;
  --bg: #f4ede0;
  --surface: #fffbf3;
  --border: #e0d6c3;
  --shadow-lg: 0 8px 24px rgba(45,106,79,.12);
}

[data-theme="bright"] {
  --primary: #f4a300;
  --primary-dark: #c98300;
  --primary-light: #fff4d6;
  --bg: #fffbf0;
  --surface: #ffffff;
  --border: #f3e8c8;
  --shadow-lg: 0 8px 24px rgba(244,163,0,.15);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background .25s, color .25s;
}
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); font-size: .9em; }

/* === 按钮 === */
.btn, .btn-primary, button {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  transition: all .15s;
  font-family: inherit;
}
.btn:hover { background: var(--primary-light); text-decoration: none; }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); text-decoration: none; }
.btn-primary.small { padding: 5px 12px; font-size: 13px; }
.link-btn {
  background: none; border: none; color: var(--primary-dark);
  cursor: pointer; padding: 0 4px; font-size: inherit; font-family: inherit;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.ok { color: var(--success); }
.link-btn.no { color: var(--danger); }

/* === Header / 导航 === */
.site-header {
  background: var(--surface);
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 10;
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 64px;
}
.brand {
  font-size: 20px; font-weight: bold;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.brand:hover { color: var(--primary-dark); text-decoration: none; }
.main-nav {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow: hidden;
}
.main-nav a {
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  white-space: nowrap;
  font-size: 14px;
}
.main-nav a:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
  text-decoration: none;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.user-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-link {
  color: var(--primary-dark);
  font-weight: 500;
  max-width: 120px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* === 主题切换器 === */
.theme-switcher {
  position: relative;
}
.theme-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  transition: all .15s;
}
.theme-btn:hover { background: var(--primary-light); border-color: var(--primary); }
.theme-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  min-width: 180px;
  display: none;
  z-index: 20;
}
.theme-switcher.open .theme-menu { display: block; }
.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
}
.theme-option:hover { background: var(--primary-light); }
.theme-option.active { color: var(--primary-dark); font-weight: 500; }
.theme-dots {
  display: inline-flex;
  gap: 3px;
}
.theme-dots span {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.08);
}

/* === Hero === */
.hero {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--surface) 100%);
  padding: 56px 0;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.hero h1 { margin: 0 0 8px; font-size: 38px; color: var(--primary-dark); }
.hero p { color: var(--muted); margin: 0 0 24px; }
.search-bar {
  display: inline-flex;
  max-width: 520px;
  width: 100%;
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.search-bar input {
  flex: 1; padding: 12px 16px; border: none;
  font-size: 15px; outline: none; background: transparent;
  color: var(--text);
}
.search-bar button {
  background: var(--primary); color: white; border: none;
  padding: 0 28px; font-size: 15px; border-radius: 0;
}
.search-bar button:hover { background: var(--primary-dark); }

/* === 主体布局 === */
main.container {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  padding-top: 28px;
  padding-bottom: 56px;
  align-items: start;
}

/* === 侧栏 === */
.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  position: sticky;
  top: 84px;
}
.sidebar h3 { margin: 0 0 12px; font-size: 16px; color: var(--text); }
.cat-list { list-style: none; padding: 0; margin: 0; }
.cat-list li a {
  display: block; padding: 8px 12px; border-radius: 6px;
  color: var(--text); font-size: 14px;
  transition: all .12s;
}
.cat-list li a:hover { background: var(--primary-light); color: var(--primary-dark); text-decoration: none; }
.cat-list li a.active { background: var(--primary); color: white; }

/* === 列表头 === */
.content-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 8px;
}
.content-head h2 { margin: 0; font-size: 22px; }

/* === 菜谱卡片 === */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}
.recipe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: all .2s;
  display: block;
  color: inherit;
}
.recipe-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
  border-color: var(--primary);
  text-decoration: none;
}
.cover {
  aspect-ratio: 4/3;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.no-cover { font-size: 72px; opacity: .5; }
.info { padding: 14px; }
.info h3 {
  margin: 0 0 6px; font-size: 16px; line-height: 1.4;
  max-height: 2.8em; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.desc {
  font-size: 13px; color: var(--muted);
  margin: 0 0 10px; height: 2.6em; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  font-size: 12px; margin-bottom: 8px;
}
.tag {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}
.author { font-size: 12px; color: var(--muted); }

/* === 分页 === */
.pagination {
  display: flex; gap: 4px;
  margin-top: 32px; justify-content: center;
  flex-wrap: wrap;
}
.pagination a {
  padding: 6px 14px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text); font-size: 14px;
  min-width: 36px; text-align: center;
}
.pagination a:hover { background: var(--primary-light); text-decoration: none; }
.pagination a.active { background: var(--primary); color: white; border-color: var(--primary); }

/* === 详情页 === */
.recipe-detail article {
  background: var(--surface);
  padding: 36px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  grid-column: 1 / -1;
}
.recipe-detail h1 { margin: 0 0 14px; font-size: 30px; line-height: 1.3; }
.meta-bar {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center;
  color: var(--muted); font-size: 14px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.meta-bar button {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  color: var(--primary-dark);
  padding: 4px 14px;
}
.meta-bar button.liked {
  background: var(--primary);
  color: white;
}
.cover-full {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 20px;
}
.description {
  background: var(--bg);
  padding: 16px 20px;
  border-radius: 8px;
  white-space: pre-wrap;
  margin-bottom: 20px;
  border-left: 3px solid var(--primary);
}
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 24px; }

.section { margin-top: 36px; }
.section h2 {
  font-size: 20px;
  margin: 0 0 18px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary);
  display: inline-block;
}
.ing-table { width: 100%; border-collapse: collapse; }
.ing-table tr { border-bottom: 1px dashed var(--border); }
.ing-table tr:last-child { border-bottom: none; }
.ing-table td { padding: 10px 12px; }
.ing-table td:last-child { color: var(--muted); text-align: right; }
.steps { padding-left: 0; list-style: none; counter-reset: step; }
.steps li {
  margin-bottom: 24px;
  padding-left: 56px;
  position: relative;
  counter-increment: step;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 0;
  width: 36px; height: 36px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: bold;
}
.step-content { white-space: pre-wrap; }
.step-img {
  width: 100%; max-width: 600px;
  border-radius: 8px;
  margin-top: 12px;
}

/* === 表单/认证 === */
.auth-page {
  display: flex; justify-content: center; align-items: center;
  min-height: calc(100vh - 64px - 60px);
  padding: 24px 16px;
}
.auth-card {
  background: var(--surface);
  padding: 36px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  width: 100%; max-width: 420px;
}
.auth-card.admin { max-width: 380px; }
.auth-card h1 { margin: 0 0 24px; text-align: center; font-size: 26px; color: var(--primary-dark); }
.auth-card label {
  display: block; margin-bottom: 16px;
  font-size: 14px; color: var(--text);
}
.auth-card input, .auth-card select, .auth-card textarea {
  display: block; width: 100%;
  padding: 11px 14px; margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px; font-family: inherit;
  background: var(--bg);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.auth-card input:focus, .auth-card textarea:focus, .auth-card select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: var(--surface);
}
.auth-card button {
  width: 100%; padding: 12px;
  margin-top: 8px;
  font-size: 15px;
}
.auth-card .alt {
  text-align: center; margin-top: 18px;
  color: var(--muted); font-size: 14px;
}

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary-dark);
  margin-bottom: 16px;
  border-left: 3px solid var(--primary);
}
.alert.error { background: #fef2f2; color: var(--danger); border-left-color: var(--danger); }

/* === 发布表单 === */
.page-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px;
  grid-column: 1 / -1;
  flex-wrap: wrap; gap: 12px;
}
.page-head h1 { margin: 0; font-size: 26px; }
.recipe-form {
  background: var(--surface);
  padding: 32px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  grid-column: 1 / -1;
}
.recipe-form label {
  display: block; margin-bottom: 16px;
  font-size: 14px; font-weight: 500;
  color: var(--text);
}
.recipe-form input, .recipe-form select, .recipe-form textarea {
  display: block; width: 100%;
  padding: 10px 12px; margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px; font-family: inherit;
  background: var(--bg); color: var(--text);
}
.recipe-form input:focus, .recipe-form textarea:focus, .recipe-form select:focus {
  outline: none; border-color: var(--primary); background: var(--surface);
}
.recipe-form textarea { resize: vertical; }
.recipe-form h3 {
  margin: 24px 0 12px;
  font-size: 16px;
  color: var(--primary-dark);
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.upload-row {
  display: flex; gap: 8px;
  align-items: center; flex-wrap: wrap;
}
.upload-row input { flex: 1; min-width: 200px; margin-top: 0; }
.cover-preview, .step-preview {
  max-width: 120px; max-height: 90px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.list-edit {
  display: flex; flex-direction: column;
  gap: 8px; margin-bottom: 12px;
}
.list-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
}
.step-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 12px;
  padding: 14px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.step-num {
  width: 32px; height: 32px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: bold;
}
.step-body textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  margin-bottom: 8px;
  background: var(--surface);
  color: var(--text);
}
.btn-icon {
  width: 32px; height: 32px;
  padding: 0;
  border: 1px solid var(--danger);
  color: var(--danger);
  background: var(--surface);
  border-radius: 6px;
  align-self: start;
}
.btn-icon:hover { background: var(--danger); color: white; }
.form-actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
#msg { margin-top: 12px; }

/* === 表格 === */
.data-table {
  width: 100%;
  background: var(--surface);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-collapse: collapse;
  grid-column: 1 / -1;
}
.data-table th, .data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  background: var(--bg);
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: var(--bg); }
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 12px;
}
.badge.status-0 { background: #fef3c7; color: #92400e; }
.badge.status-1 { background: #d1fae5; color: #065f46; }
.badge.status-2 { background: #fee2e2; color: #991b1b; }
.reason { font-size: 12px; color: var(--muted); margin-top: 4px; }

.empty {
  text-align: center; padding: 60px 16px;
  color: var(--muted);
  background: var(--surface);
  border-radius: 10px;
  border: 1px dashed var(--border);
  grid-column: 1 / -1;
}

/* === Footer === */
.site-footer {
  background: var(--surface);
  color: var(--muted);
  padding: 28px 0;
  margin-top: 48px;
  text-align: center;
  border-top: 1px solid var(--border);
}

/* === 响应式 === */
@media (max-width: 900px) {
  main.container { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    order: -1;
  }
  .cat-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }
  .cat-list li a { padding: 6px 12px; }
}
@media (max-width: 640px) {
  .header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 12px 0;
    gap: 10px;
  }
  .brand { font-size: 18px; }
  .main-nav {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .main-nav::-webkit-scrollbar { display: none; }
  .header-right { gap: 6px; }
  .user-actions { gap: 6px; }
  .user-actions .btn-primary { padding: 4px 10px; font-size: 12px; }
  .hero { padding: 36px 0; }
  .hero h1 { font-size: 26px; }
  .recipe-detail article { padding: 20px; }
  .recipe-detail h1 { font-size: 22px; }
  .list-row { grid-template-columns: 1fr; }
  .form-actions .btn-primary { width: 100%; }
}