* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f0;
  color: #1a1a1a;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Top bar ── */
.topbar {
  background: #e8522a;
  padding: 0 16px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.logo {
  color: #fff;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.logo span { color: #ffd0a0; }

.topbar-right { margin-left: auto; display: flex; gap: 8px; }

.topbar-btn {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

.topbar-btn:hover { background: rgba(255, 255, 255, 0.28); }

/* ── Main layout ── */
.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: 280px;
  background: #fff;
  border-right: 1px solid #e8e8e3;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid #e8e8e3;
}

.sidebar-title {
  font-size: 12px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 8px;
}

.search-wrap { position: relative; }

.search-wrap input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  background: #f5f5f0;
  color: #1a1a1a;
  outline: none;
  transition: border-color 0.15s;
}

.search-wrap input:focus { border-color: #e8522a; }

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #aaa;
  font-size: 15px;
  pointer-events: none;
}

/* ── Ingredient categories ── */
.cats {
  overflow-y: auto;
  flex: 1;
  padding: 4px 0;
}

.cats::-webkit-scrollbar { width: 4px; }
.cats::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

.cat-section { border-bottom: 1px solid #f0f0eb; }

.cat-header {
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  color: #555;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  transition: background 0.1s;
}

.cat-header:hover { background: #faf9f6; }

.cat-arrow {
  font-size: 10px;
  color: #bbb;
  transition: transform 0.15s;
  display: inline-block;
}

.cat-arrow.open { transform: rotate(90deg); }

.ing-list {
  padding: 2px 0;
  display: none;
}

.ing-list.open { display: block; }

.ing-item {
  padding: 7px 16px 7px 28px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #333;
  transition: background 0.1s;
}

.ing-item:hover { background: #faf9f6; }

.ing-check {
  width: 17px;
  height: 17px;
  border-radius: 4px;
  border: 1.5px solid #ccc;
  background: #fff;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, border-color 0.1s;
}

.ing-check.checked {
  background: #e8522a;
  border-color: #e8522a;
}

.ing-check.checked::after {
  content: '';
  display: block;
  width: 4px;
  height: 8px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
}

/* ── Chips bar ── */
.chips-bar {
  padding: 10px 16px;
  border-bottom: 1px solid #e8e8e3;
  background: #fff;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 46px;
  align-items: center;
}

.chips-label {
  font-size: 13px;
  color: #aaa;
}

.chip {
  background: #fff3ee;
  border: 1px solid #f5b49a;
  color: #c03a10;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chip-x {
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: #c03a10;
  margin-left: 2px;
  transition: color 0.1s;
}

.chip-x:hover { color: #8a2005; }

/* ── Recipes area ── */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.recipes-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.recipes-area::-webkit-scrollbar { width: 5px; }
.recipes-area::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }

.recipes-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.recipes-count {
  font-size: 15px;
  font-weight: 500;
  color: #333;
}

.recipes-count span { color: #e8522a; }

.filter-tabs { display: flex; gap: 4px; flex-wrap: wrap; }

.filter-tab {
  padding: 5px 13px;
  font-size: 13px;
  border: 1px solid #ddd;
  border-radius: 20px;
  cursor: pointer;
  background: #fff;
  color: #666;
  transition: background 0.1s, color 0.1s;
}

.filter-tab.active {
  background: #e8522a;
  color: #fff;
  border-color: #e8522a;
}

.filter-tab:hover:not(.active) { background: #f5f5f0; }

/* ── Recipe grid ── */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.recipe-card {
  background: #fff;
  border: 1px solid #e8e8e3;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}

.recipe-card:hover {
  border-color: #e8522a;
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(232, 82, 42, 0.12);
}

.recipe-img {
  width: 100%;
  height: 120px;
  background: #faf0eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}

.recipe-body { padding: 10px 12px 12px; }

.recipe-name {
  font-size: 14px;
  font-weight: 500;
  color: #1a1a1a;
  line-height: 1.3;
  margin-bottom: 6px;
}

.recipe-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  flex-wrap: wrap;
}

.recipe-match {
  font-size: 12px;
  color: #e8522a;
  font-weight: 500;
}

.recipe-miss { font-size: 11px; color: #999; }
.recipe-miss.none { color: #2e8a47; font-weight: 500; }

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 320px;
  gap: 12px;
  text-align: center;
}

.empty-icon { font-size: 52px; }

.empty-title {
  font-size: 18px;
  font-weight: 500;
  color: #333;
}

.empty-sub {
  font-size: 14px;
  color: #999;
  max-width: 300px;
  line-height: 1.6;
}

/* ── Recipe Modal ── */
.recipe-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
}

.recipe-modal.open {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.modal-content {
  position: relative;
  background: #fff;
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  position: relative;
  padding: 16px;
  border-bottom: 1px solid #e8e8e3;
  display: flex;
  justify-content: flex-end;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s, color 0.2s;
}

.modal-close:hover {
  background: #f5f5f0;
  color: #333;
}

.modal-body {
  padding: 20px;
}

.recipe-detail-img {
  width: 100%;
  height: 300px;
  background: #faf0eb;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
  margin-bottom: 20px;
  object-fit: cover;
}

.recipe-detail-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

.recipe-detail-info h1 {
  font-size: 28px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 12px;
}

.recipe-detail-meta {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
  font-size: 14px;
  color: #666;
}

.detail-section {
  margin-bottom: 24px;
}

.detail-section h3 {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 12px;
  border-bottom: 2px solid #e8522a;
  padding-bottom: 8px;
}

.ingredients-list {
  list-style: none;
  padding: 0;
}

.ingredients-list li {
  padding: 8px 0;
  padding-left: 24px;
  position: relative;
  font-size: 14px;
  color: #333;
  line-height: 1.6;
}

.ingredients-list li:before {
  content: '○';
  position: absolute;
  left: 0;
  color: #e8522a;
  font-weight: bold;
}

.ingredients-list li span.available {
  color: #2e8a47;
  font-weight: 500;
}

.ingredients-list li span.missing {
  color: #c03a10;
}

.instructions-list {
  padding-left: 20px;
}

.instructions-list li {
  padding: 12px 0;
  font-size: 14px;
  color: #333;
  line-height: 1.8;
}

.detail-footer {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e8e8e3;
}

.btn-primary, .btn-secondary {
  flex: 1;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: #e8522a;
  color: #fff;
}

.btn-primary:hover {
  background: #d43f1f;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(232, 82, 42, 0.2);
}

.btn-secondary {
  background: #f5f5f0;
  color: #333;
  border: 1px solid #ddd;
}

.btn-secondary:hover {
  background: #efefea;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .sidebar { width: 220px; }
  .recipe-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
