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

html {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: #0f172a;
  background: #f8fafc;
  -webkit-font-smoothing: antialiased;
}

/* ── Nav ── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 60px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}
.nav-brand { font-weight: 700; font-size: 1.05rem; color: #0f172a; letter-spacing: -0.02em; white-space: nowrap; }
.nav-links { display: flex; gap: 4px; }
.nav-link { padding: 6px 12px; border-radius: 5px; font-size: 0.875rem; color: #64748b; text-decoration: none; cursor: pointer; transition: all 0.15s; }
.nav-link:hover { background: #f1f5f9; color: #0f172a; }
.nav-link.active { background: #f1f5f9; color: #0f172a; font-weight: 500; }

/* ── Layout ── */
.app-layout {
  display: flex;
  min-height: calc(100vh - 60px);
}
.main-content {
  flex: 1;
  padding: 36px 40px;
  max-width: 1100px;
  transition: margin-right 0.3s ease;
}
.main-content.ai-open { margin-right: 380px; }

/* ── Views ── */
.view { display: none; }
.view.active { display: block; }

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}
.view-header h1 { font-size: 1.8rem; font-weight: 700; letter-spacing: -0.03em; color: #0f172a; }
.view-header p { color: #64748b; margin-top: 4px; font-size: 0.9rem; }
.header-controls { display: flex; gap: 10px; align-items: center; }

/* ── Search ── */
.search-input {
  padding: 9px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.875rem;
  font-family: inherit;
  background: #fff;
  color: #0f172a;
  width: 240px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

/* ── Filter Bar ── */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.filter-btn {
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid #e2e8f0;
  background: #fff;
  font-size: 0.8rem;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.filter-btn:hover { border-color: #94a3b8; color: #0f172a; }
.filter-btn.active { background: #0f172a; color: #fff; border-color: #0f172a; }

/* ── Recipes Grid ── */
.recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

/* ── Recipe Card ── */
.recipe-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  position: relative;
}
.recipe-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  border-color: #cbd5e1;
}
.recipe-card-emoji {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}
.recipe-card-body { padding: 18px; }
.recipe-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 6px;
  line-height: 1.3;
}
.recipe-card-desc {
  font-size: 0.82rem;
  color: #64748b;
  line-height: 1.5;
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.recipe-card-meta {
  display: flex;
  gap: 12px;
  align-items: center;
}
.meta-tag {
  font-size: 0.75rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 4px;
}
.difficulty-badge {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 99px;
  margin-left: auto;
}
.difficulty-badge.Lätt { background: #dcfce7; color: #15803d; }
.difficulty-badge.Medel { background: #fef3c7; color: #b45309; }
.difficulty-badge.Svår { background: #fee2e2; color: #b91c1c; }

.fav-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,0.9);
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.15s;
  backdrop-filter: blur(4px);
}
.fav-btn:hover { transform: scale(1.15); background: #fff; }
.fav-btn.active { background: #fff0f0; }

/* ── Recipe Detail ── */
.back-btn {
  margin-bottom: 24px;
  color: #64748b;
  font-size: 0.875rem;
}
.recipe-detail {
  max-width: 720px;
}
.recipe-detail-hero {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-bottom: 32px;
  padding: 28px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}
.recipe-detail-emoji { font-size: 5rem; }
.recipe-detail-info h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}
.recipe-detail-info p { color: #64748b; margin-bottom: 14px; font-size: 0.9rem; }
.recipe-meta-row { display: flex; gap: 20px; flex-wrap: wrap; }
.recipe-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.recipe-meta-item .label {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
}
.recipe-meta-item .value { font-size: 0.95rem; font-weight: 600; color: #0f172a; }

.detail-sections {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 20px;
}
.detail-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 24px;
}
.detail-card h3 {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 16px;
}
.ingredient-list { list-style: none; }
.ingredient-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.875rem;
}
.ingredient-list li:last-child { border-bottom: none; }
.ingredient-name { color: #0f172a; font-weight: 500; }
.ingredient-amount { color: #64748b; }

.steps-list { list-style: none; counter-reset: steps; }
.steps-list li {
  counter-increment: steps;
  display: flex;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.875rem;
  color: #334155;
  line-height: 1.6;
}
.steps-list li:last-child { border-bottom: none; }
.steps-list li::before {
  content: counter(steps);
  min-width: 26px;
  height: 26px;
  background: #0f172a;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ── Ingredient Search ── */
.ingredient-search-box {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 24px;
  max-width: 640px;
}
.ingredient-input-row { display: flex; gap: 10px; margin-bottom: 12px; }
.ingredient-input-row .search-input { flex: 1; width: auto; }

.ingredient-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  min-height: 0;
}
.suggestion-chip {
  padding: 4px 12px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 99px;
  font-size: 0.8rem;
  cursor: pointer;
  color: #334155;
  transition: all 0.15s;
  font-family: inherit;
}
.suggestion-chip:hover { background: #e2e8f0; border-color: #94a3b8; }

.selected-ingredients {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.selected-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: #0f172a;
  color: #fff;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 500;
}
.selected-chip button {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
}
.selected-chip button:hover { color: #fff; }

/* ── AI Panel ── */
.ai-panel {
  position: fixed;
  top: 60px;
  right: 0;
  width: 370px;
  height: calc(100vh - 60px);
  background: #fff;
  border-left: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 90;
}
.ai-panel.open { transform: translateX(0); }

.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 600;
  font-size: 0.9rem;
  color: #0f172a;
}
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ai-message {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.6;
}
.ai-message--assistant {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  align-self: flex-start;
  color: #334155;
}
.ai-message--user {
  background: #0f172a;
  color: #fff;
  align-self: flex-end;
  border-radius: 10px 10px 2px 10px;
}
.ai-status {
  padding: 0 20px 8px;
  font-size: 0.78rem;
  color: #94a3b8;
  min-height: 20px;
}
.ai-input-row {
  display: flex;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid #e2e8f0;
}
.ai-input {
  flex: 1;
  padding: 9px 13px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: inherit;
  color: #0f172a;
  background: #f8fafc;
  transition: border-color 0.15s;
}
.ai-input:focus { outline: none; border-color: #3b82f6; background: #fff; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 17px;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn-primary { background: #0f172a; color: #fff; border-color: #0f172a; }
.btn-primary:hover { background: #1e293b; }
.btn-secondary { background: #fff; color: #0f172a; border-color: #e2e8f0; }
.btn-secondary:hover { background: #f1f5f9; }
.btn-ghost { background: transparent; color: #64748b; border-color: transparent; }
.btn-ghost:hover { background: #f1f5f9; color: #0f172a; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* ── States ── */
.loading-state, .empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 80px 20px;
  color: #94a3b8;
  font-size: 0.9rem;
}
.empty-icon { font-size: 3rem; }
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e2e8f0;
  border-top-color: #0f172a;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tags ── */
.recipe-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.tag {
  padding: 3px 10px;
  background: #f1f5f9;
  border-radius: 99px;
  font-size: 0.75rem;
  color: #64748b;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .main-content { padding: 20px 16px; }
  .main-content.ai-open { margin-right: 0; }
  .ai-panel { width: 100%; }
  .detail-sections { grid-template-columns: 1fr; }
  .recipe-detail-hero { flex-direction: column; text-align: center; }
  .nav-links { display: none; }
}
