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

:root {
  --cream: #FAF7F2;
  --warm-white: #FFFDF9;
  --ink: #1A1208;
  --ink-soft: #4A3F2F;
  --ink-muted: #8C7B65;
  --orange: #E8541A;
  --orange-light: #FFF0E9;
  --orange-mid: #F4845A;
  --green: #2D6A4F;
  --green-light: #E8F5EF;
  --border: rgba(26,18,8,0.10);
  --radius: 16px;
  --radius-sm: 10px;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--warm-white);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 60px rgba(0,0,0,0.08);
}

/* HEADER */
.header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--warm-white);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
}
.logo-dot {
  width: 8px;
  height: 8px;
  background: var(--orange);
  border-radius: 50%;
  display: inline-block;
}
.time-badge {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  background: var(--cream);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.02em;
}
.header-sub {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-muted);
  font-weight: 300;
}

/* SCREENS */
.screen { display: none; flex-direction: column; flex: 1; }
.screen.active { display: flex; }

/* FRIDGE INPUT SCREEN */
.fridge-hero {
  padding: 28px 20px 12px;
  background: var(--orange-light);
  border-bottom: 1px solid rgba(232,84,26,0.12);
}
.fridge-title {
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
  margin-bottom: 6px;
}
.fridge-title em { font-style: italic; color: var(--orange); }
.fridge-desc {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.5;
  font-weight: 300;
}

.input-area {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ingredient-input-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}
.ingredient-input {
  flex: 1;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  background: var(--warm-white);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}
.ingredient-input:focus { border-color: var(--orange); }
.ingredient-input::placeholder { color: var(--ink-muted); }

.add-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--orange);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
.add-btn:active { transform: scale(0.95); background: #c4411a; }

.chips-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.chips-area {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 40px;
}
.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 14px;
  color: var(--ink-soft);
  animation: popIn 0.18s ease;
}
@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.chip-remove {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--border);
  border: none;
  cursor: pointer;
  color: var(--ink-muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
.chip-remove:hover { background: var(--orange); color: white; }

.quick-adds { display: flex; flex-direction: column; gap: 8px; }
.quick-adds-row { display: flex; flex-wrap: wrap; gap: 6px; }
.quick-chip {
  background: transparent;
  border: 1px dashed rgba(26,18,8,0.2);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.12s;
  font-family: 'DM Sans', sans-serif;
}
.quick-chip:hover { background: var(--orange-light); border-color: var(--orange); color: var(--orange); }

.cook-btn {
  margin: 0 20px 20px;
  padding: 16px;
  background: var(--ink);
  color: var(--warm-white);
  border: none;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.cook-btn:hover { background: var(--orange); }
.cook-btn:active { transform: scale(0.98); }
.cook-btn:disabled { background: var(--ink-muted); cursor: not-allowed; transform: none; }

/* LOADING */
.loading-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px;
}
.loading-text {
  font-family: 'Fraunces', serif;
  font-size: 20px;
  color: var(--ink);
  text-align: center;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
.loading-sub {
  font-size: 13px;
  color: var(--ink-muted);
  text-align: center;
}
.spinner-ring {
  width: 48px;
  height: 48px;
  border: 3px solid var(--cream);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* RESULTS */
.results-header {
  padding: 20px 20px 12px;
  background: var(--green-light);
  border-bottom: 1px solid rgba(45,106,79,0.12);
}
.results-title {
  font-family: 'Fraunces', serif;
  font-size: 13px;
  font-weight: 400;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.results-headline {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}
.results-headline em { font-style: italic; color: var(--green); }
.results-ingredients-used {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-muted);
}
.results-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* RECIPE CARDS */
.recipe-card {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.recipe-card:hover { border-color: var(--orange-mid); transform: translateY(-1px); }
.recipe-card-top {
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.recipe-name {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}
.recipe-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.meta-pill {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--cream);
  color: var(--ink-soft);
}
.meta-pill.time { background: var(--orange-light); color: var(--orange); }
.meta-pill.effort { background: var(--green-light); color: var(--green); }
.recipe-emoji { font-size: 36px; flex-shrink: 0; }
.recipe-desc {
  font-size: 13px;
  color: var(--ink-soft);
  padding: 0 16px 14px;
  line-height: 1.5;
  font-weight: 300;
}
.recipe-ingredients-bar {
  padding: 10px 16px;
  background: var(--cream);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.uses-badge {
  background: var(--green-light);
  color: var(--green);
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
}

/* EXPANDED RECIPE */
.recipe-expand {
  display: none;
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--cream);
  flex-direction: column;
  gap: 14px;
}
.recipe-expand.open { display: flex; }
.expand-section-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.steps-list { display: flex; flex-direction: column; gap: 10px; list-style: none; }
.step-item { display: flex; gap: 10px; align-items: flex-start; }
.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--orange);
  color: white;
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.step-text { font-size: 13px; color: var(--ink-soft); line-height: 1.5; font-weight: 300; }
.ing-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.ing-tag {
  font-size: 12px;
  background: var(--warm-white);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 20px;
  color: var(--ink-soft);
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 16px 20px 4px;
  background: none;
  border: none;
  color: var(--ink-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}
.back-btn:hover { color: var(--orange); }

.error-box {
  margin: 16px;
  padding: 14px 16px;
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  color: #991b1b;
  font-size: 13px;
  line-height: 1.5;
}
