:root {
  --bg: #0f1115;
  --surface: #181c23;
  --surface-2: #222833;
  --border: #2c3442;
  --text: #f3f5f8;
  --muted: #9aa4b2;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --danger: #ef4444;
  --success: #10b981;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  padding-bottom: 48px;
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 17, 21, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon { font-size: 28px; }
.brand h1 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.subtitle { font-size: 0.78rem; color: var(--muted); }

/* Buttons */
.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #111; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: #2c3442; }
.btn-danger { background: rgba(239, 68, 68, 0.16); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.35); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.28); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Controls */
.controls { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }

.search-wrap input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 16px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}
.search-wrap input:focus { border-color: var(--accent); }

.category-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}

.cat-pill {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cat-pill .count {
  background: var(--surface-2);
  color: var(--muted);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.75rem;
}
.cat-pill.active {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}
.cat-pill.active .count {
  background: rgba(0, 0, 0, 0.2);
  color: #111;
}

.status-bar {
  margin: 14px 0 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Recipe Grid */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }

.card-thumb {
  height: 150px;
  background: linear-gradient(135deg, #1f2530, #2a241a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 46px;
  position: relative;
  overflow: hidden;
}
.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
}
.badge-muted { background: var(--surface-2); color: var(--muted); }

.card-title { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.card-desc {
  font-size: 0.85rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 20px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}

/* Pagination */
.pagination-bar {
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
}

.modal-box {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.icon-close {
  background: var(--surface-2);
  color: var(--text);
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Detail View */
.detail-hero {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 16px;
}
.detail-title { font-size: 1.45rem; margin-bottom: 6px; }
.detail-desc { color: var(--muted); margin-bottom: 16px; font-size: 0.95rem; }

.meta-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.meta-item {
  background: var(--surface-2);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.meta-label { display: block; font-size: 0.72rem; color: var(--muted); }
.meta-val { font-size: 0.9rem; font-weight: 700; }

.detail-section { margin-bottom: 22px; }
.detail-section h3 {
  font-size: 1.05rem;
  margin-bottom: 10px;
  color: var(--accent);
}

.check-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.check-list li label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface-2);
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.92rem;
}
.check-list input:checked + span {
  text-decoration: line-through;
  color: var(--muted);
}

.step-list { list-style: none; display: flex; flex-direction: column; gap: 12px; counter-reset: step; }
.step-list li {
  counter-increment: step;
  display: flex;
  gap: 12px;
  background: var(--surface-2);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.93rem;
}
.step-list li::before {
  content: counter(step);
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #111;
  font-weight: 800;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chef-tips {
  background: rgba(245, 158, 11, 0.1);
  border-left: 4px solid var(--accent);
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 0.92rem;
}

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 0.84rem; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
}

.photo-preview-wrap {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.photo-preview-wrap img {
  width: 96px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  border: 1px solid var(--accent);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  z-index: 100;
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .brand h1 { font-size: 1rem; }
  .subtitle { display: none; }
}