:root {
  --sidebar: #222e3c;
  --sidebar-text: #ced4da;
  --sidebar-muted: #869099;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active: rgba(255, 255, 255, 0.1);
  --brand: #e5534b;
  --primary: #3b7ddd;
  --primary-hover: #326abc;
  --warning: #f0ad4e;
  --success: #1cbb8c;
  --body: #f7f9fc;
  --card: #ffffff;
  --ink: #212529;
  --ink-soft: #6c757d;
  --line: #e9ecef;
  --shadow: 0 0.1rem 0.2rem rgba(0, 0, 0, 0.05);
  --shadow-card: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --radius: 0.5rem;
  --sidebar-w: 260px;
  --sans: Inter, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

html[data-theme="dark"] {
  --body: #1a1d21;
  --card: #22262a;
  --ink: #e9ecef;
  --ink-soft: #adb5bd;
  --line: #343a40;
  --shadow: 0 0.1rem 0.2rem rgba(0, 0, 0, 0.35);
  --shadow-card: 0 0.125rem 0.35rem rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body.app-body, body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--body);
  line-height: 1.5;
}
a { color: inherit; }
button, input, textarea, select { font: inherit; }
img { max-width: 100%; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.icon { width: 18px; height: 18px; flex: 0 0 auto; }

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  color: var(--sidebar-text);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  flex: 0 0 var(--sidebar-w);
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1.15rem 1.35rem 1rem;
  text-decoration: none;
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
}
.brand-mark .icon { width: 18px; height: 18px; }
.brand-text { font-size: 1.15rem; }

.side-nav { padding: 0 0 2rem; }
.side-label {
  margin: 1.1rem 1.35rem 0.35rem;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  font-weight: 600;
}
.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.55rem 1.35rem;
  text-decoration: none;
  color: var(--sidebar-text);
  font-size: 0.95rem;
}
.side-link:hover { background: var(--sidebar-hover); color: #fff; }
.side-link.is-active {
  background: var(--sidebar-active);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--primary);
}
.side-locales, .side-theme {
  display: flex;
  gap: 8px;
  padding: 0.75rem 1.35rem 0.25rem;
}
.locale-btn, .ghost-btn {
  border: 1px solid rgba(255,255,255,0.12);
  background: transparent;
  color: var(--sidebar-text);
  border-radius: 999px;
  padding: 4px 10px;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
}
.locale-btn.is-active, .ghost-btn[aria-pressed="true"] {
  background: #fff;
  color: var(--sidebar);
  border-color: #fff;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 2rem 2rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 1.25rem;
  align-items: flex-start;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.page-header h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.page-header h1 .icon { color: var(--ink-soft); width: 22px; height: 22px; }
.page-sub { margin: 0.25rem 0 0; color: var(--ink-soft); }
.page-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.search-form { display: flex; align-items: center; gap: 0.5rem; }
.search-field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  padding: 0.4rem 0.7rem;
  min-width: 220px;
  color: var(--ink-soft);
}
.search-field input {
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  width: 100%;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--card);
  color: var(--ink);
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover { background: rgba(59, 125, 221, 0.08); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.alert {
  background: #cfe2ff;
  color: #084298;
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-bottom: 1.25rem;
}
html[data-theme="dark"] .alert {
  background: #16324f;
  color: #cfe2ff;
}
.alert-title { margin: 0 0 0.25rem; font-size: 1.05rem; }
.alert p { margin: 0; }

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}
.recipe-card-wrap { min-width: 0; }
.recipe-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--line);
}
.recipe-card:hover { box-shadow: 0 0.35rem 0.75rem rgba(0, 0, 0, 0.08); }
.recipe-card-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  background: #e9eef5;
}
.recipe-card-img.placeholder {
  display: grid;
  place-items: center;
  font-size: 2.4rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #3b7ddd, #1a1d21);
}
.recipe-card-body { padding: 0.85rem 1rem 1rem; }
.recipe-card-title {
  margin: 0 0 0.35rem;
  font-size: 0.98rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recipe-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.8rem;
}
.difficulty .stars, .stars { color: var(--warning); letter-spacing: 0.04em; }
.recipe-card-cal { color: var(--ink-soft); display: inline-flex; align-items: center; gap: 0.2rem; }
.recipe-card-desc {
  margin: 0.4rem 0 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pager {
  display: flex;
  justify-content: center;
  padding: 1.5rem 0 0;
}
.empty-state, .empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--ink-soft);
}

.site-footer {
  margin-top: auto;
  padding-top: 2.5rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
}
.site-footer a { color: var(--primary); }
.footer-utility {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--line);
}
.footer-locale {
  display: inline-flex;
  align-items: center;
  margin: 0;
}
.footer-locale select {
  padding: 0.28rem 0.55rem;
  font-size: 0.8rem;
  min-width: 9.5rem;
}
.footer-legal-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.9rem;
}
.footer-legal-links a { text-decoration: none; }
.footer-legal-links a:hover { text-decoration: underline; }

.legal-page .recipe-article p { color: var(--ink); }
.legal-table-wrap { overflow-x: auto; }
.legal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.legal-table th, .legal-table td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 0.55rem 0.45rem;
  vertical-align: top;
}
.legal-table thead th { color: var(--ink-soft); font-weight: 600; }

.detail-top { margin-bottom: 0.75rem; }
.breadcrumb {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0;
  margin: 0 0 0.75rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}
.breadcrumb li:not(:last-child)::after { content: "/"; margin-left: 0.35rem; color: #adb5bd; }
.breadcrumb a { color: var(--primary); text-decoration: none; }

.detail-wrap { max-width: 820px; margin: 0 auto; width: 100%; }
.recipe-article {
  background: var(--card);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-card);
  padding: 2rem 2.25rem 1.5rem;
  border: 1px solid var(--line);
}
.recipe-hero-cover { margin: 0 0 1.25rem; }
.recipe-hero-cover img {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border-radius: 0.6rem;
}
.recipe-article h1 { margin: 0 0 1rem; font-size: 1.8rem; }
.recipe-lead {
  margin: 0 0 1.25rem;
  color: var(--ink);
  line-height: 1.8;
  font-size: 1.02rem;
}
.related-list { padding-left: 1.35rem; }
.related-list li { margin: 0.3rem 0; line-height: 1.75; }
.related-list a { color: var(--primary); text-decoration: none; }
.related-list a:hover { text-decoration: underline; }
.recipe-section { margin-top: 2rem; }
.recipe-section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--line);
}
.recipe-section ul, .recipe-section ol { padding-left: 1.35rem; }
.recipe-section li { margin: 0.3rem 0; line-height: 1.75; }
.tips-section { background: var(--body); border-radius: 0.75rem; padding: 1rem 1.15rem 0.25rem; }

.stat-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  border-radius: 1rem;
  margin: 0 0 1rem;
  background: var(--body);
  border-left: 4px solid var(--warning);
}
.calorie-card { border-left-color: #dc3545; }
.stat-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 700;
}
.stat-value { margin: 0.15rem 0 0; font-size: 1.6rem; font-weight: 700; }
.stat-value span { font-size: 0.95rem; font-weight: 500; color: var(--ink-soft); }
.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.4rem 1rem;
  background: var(--warning);
  color: #212529;
  font-weight: 700;
}
.banner {
  padding: 0.7rem 0.85rem;
  border-radius: 0.5rem;
  background: #fff3cd;
  color: #664d03;
}
html[data-theme="dark"] .banner { background: #4d3b0f; color: #ffe08a; }
.banner.error { background: #f8d7da; color: #842029; }
.banner.ok { background: #d1e7dd; color: #0f5132; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}
.wrap { max-width: 820px; margin: 0 auto; width: 100%; }
form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-size: 0.92rem; }
input, textarea, select {
  padding: 10px 12px;
  border-radius: 0.5rem;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.job {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.status { font-size: 0.8rem; border-radius: 999px; padding: 3px 8px; background: var(--body); }
.muted { color: var(--ink-soft); font-size: 0.9rem; }

.nav-toggle {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 40;
  border: 0;
  background: var(--sidebar);
  color: #fff;
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  align-items: center;
  gap: 0.4rem;
}
.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 25;
}

@media (max-width: 1200px) {
  .recipe-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .recipe-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; }
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .app-main { padding: 4rem 1rem 1.5rem; }
  .recipe-grid, .row { grid-template-columns: 1fr; }
  .recipe-article { padding: 1.15rem; }
  .page-header { flex-direction: column; }
  .search-field { min-width: 0; width: 100%; }
}

/* Legacy class names still used by submit/admin JS */
.site-header { display: none; }
.hero { display: none; }
.toolbar { display: none; }
.grid { display: contents; }
.card { background: var(--card); }
.primary {
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}
.ghost {
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
}
