:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-alt: #f3efe9;
  --text: #1f1d1a;
  --text-muted: #6e675f;
  --primary: #e0533c;
  --primary-hover: #c8412b;
  --primary-soft: #fdece9;
  --accent: #2a7b62;
  --accent-soft: #e6f4ef;
  --border: #e6e0d6;
  --shadow-sm: 0 2px 8px rgba(31, 29, 26, 0.06);
  --shadow-md: 0 10px 25px rgba(31, 29, 26, 0.09);
  --shadow-lg: 0 20px 45px rgba(31, 29, 26, 0.16);
  --radius: 16px;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: 4rem;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Hero / Header */
.hero {
  background: linear-gradient(135deg, #241f1c 0%, #3a2d27 100%);
  color: #fff;
  padding: 2.25rem 0 2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.brand-icon {
  font-size: 2.5rem;
  background: rgba(255, 255, 255, 0.1);
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
}

.brand h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 2rem;
  letter-spacing: -0.02em;
}

.subtitle {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.95rem;
}

.extract-bar {
  display: flex;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.5rem;
  border-radius: 14px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 10px;
  padding: 0 0.85rem;
}

.input-icon {
  margin-right: 0.6rem;
  font-size: 1.1rem;
}

.input-wrapper input {
  width: 100%;
  border: none;
  outline: none;
  padding: 0.8rem 0;
  font-size: 0.95rem;
  color: var(--text);
  background: transparent;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 1.4rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: wait;
}

.extract-status {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.12);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Controls & Filters */
.controls-section {
  background: var(--surface);
  margin-top: 1.5rem;
  padding: 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 1rem;
  margin-bottom: 1rem;
}

.search-icon {
  margin-right: 0.65rem;
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  padding: 0.75rem 0;
  font-size: 0.95rem;
  color: var(--text);
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: center;
  justify-content: space-between;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.filter-group label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.pills-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.pill {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.pill:hover {
  border-color: var(--primary);
}

.pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.select-filter {
  padding: 0.45rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1.25rem 0 0.85rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

/* Grid & Cards */
.recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.recipe-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

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

.card-media {
  position: relative;
  height: 210px;
  background: #2b2623;
  overflow: hidden;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.recipe-card:hover .card-media img {
  transform: scale(1.04);
}

.card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  background: linear-gradient(135deg, #f3efe9 0%, #e5dec9 100%);
}

.badge-category {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: rgba(31, 29, 26, 0.82);
  color: #fff;
  backdrop-filter: blur(4px);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-appliance {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  padding: 0.28rem 0.65rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.card-body {
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-title {
  font-size: 1.12rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  line-height: 1.35;
}

.card-author {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: auto;
}

.tag-chip {
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 0.74rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-weight: 500;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 15, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 1000;
}

.modal-card {
  background: var(--surface);
  width: 100%;
  max-width: 840px;
  max-height: 90vh;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: sticky;
  top: 1rem;
  float: right;
  margin: 1rem 1rem 0 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(31, 29, 26, 0.75);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  z-index: 10;
}

.modal-header-hero {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
  padding: 1.75rem;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}

.modal-thumb {
  width: 100%;
  height: 240px;
  object-fit: cover;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.modal-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.75rem;
  line-height: 1.25;
  margin-bottom: 0.5rem;
}

.modal-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.modal-badge {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.3rem 0.7rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.5rem 0.9rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  color: #b91c1c;
}

.btn-danger:hover {
  border-color: #b91c1c;
  background: #fef2f2;
  color: #b91c1c;
}

.modal-content-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 2rem;
  padding: 1.75rem;
}

.section-heading {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ingredients-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.ingredient-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.9rem;
  cursor: pointer;
}

.ingredient-item input {
  margin-top: 0.25rem;
  accent-color: var(--accent);
}

.ingredient-item.checked span {
  text-decoration: line-through;
  color: var(--text-muted);
}

.steps-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.step-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.step-num {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

.step-chips {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.step-chip {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.18rem 0.55rem;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.tips-box {
  margin: 0 1.75rem 1.75rem;
  background: var(--accent-soft);
  border: 1px solid #bce3d6;
  border-radius: 12px;
  padding: 1.15rem;
}

.tips-box ul {
  margin-left: 1.2rem;
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}

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

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #1f1d1a;
  color: #fff;
  padding: 0.85rem 1.25rem;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
  z-index: 2000;
}

.hidden {
  display: none !important;
}

/* Edit Form inside Modal */
.edit-form-container {
  padding: 1.75rem;
}

.edit-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.edit-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.edit-field.full-width {
  grid-column: 1 / -1;
}

.edit-field label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.edit-input,
.edit-textarea {
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
}

.edit-input:focus,
.edit-textarea:focus {
  border-color: var(--primary);
  background: #fff;
}

.edit-tags-box {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  align-items: center;
}

.edit-tag-chip {
  background: var(--primary-soft);
  color: var(--primary-hover);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.edit-tag-chip button {
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
}

.edit-tag-input {
  border: none;
  outline: none;
  background: transparent;
  flex: 1;
  min-width: 160px;
  font-size: 0.88rem;
  padding: 0.25rem;
}

.edit-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
  .extract-bar {
    flex-direction: column;
  }
  .btn-primary {
    padding: 0.85rem;
  }
  .modal-header-hero,
  .modal-content-grid,
  .edit-form-grid {
    grid-template-columns: 1fr;
  }
}
