:root {
  --bg: #fbf7f0;
  --card: #ffffff;
  --ink: #3a2f28;
  --ink-soft: #7a6f66;
  --accent: #e8602c;
  --accent-soft: #f8dfd2;
  --border: #ece3d8;
  --danger: #d3402f;
  --radius: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  min-height: 100vh;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 20px 100px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.app-header h1 {
  font-size: 20px;
  margin: 0;
  font-weight: 700;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ---------- Home screen ---------- */
.hero-card {
  background: linear-gradient(160deg, #fff 0%, var(--accent-soft) 100%);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  margin-bottom: 20px;
}

.hero-card h2 {
  font-size: 22px;
  margin: 0 0 18px;
}

.manual-btn {
  display: block;
  width: 100%;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(232,96,44,0.3);
  transition: transform 0.15s ease;
}
.manual-btn:active { transform: scale(0.98); }

.current-ingredients {
  margin-top: 18px;
  text-align: left;
}
.current-ingredients .label {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
}
.chip.ng { background: #fdecea; border-color: #f3c6c0; color: var(--danger); }

.staples-box {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
}
.chip-removable {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip-x {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1;
}

.quick-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}
.quick-group { margin-bottom: 12px; }
.chip-select { transition: background 0.1s ease, color 0.1s ease, border-color 0.1s ease; }
.chip-select.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.chip-select.chip-edit {
  background: #fdecea;
  border-color: #f3c6c0;
  color: var(--danger);
}
.chip-add {
  background: #fff;
  border: 1px dashed var(--border);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
}
.quick-add-form {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.quick-add-input {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  background: #fff;
  color: var(--ink);
  width: 120px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  margin: 26px 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.recipe-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  gap: 14px;
  align-items: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  margin-bottom: 12px;
}
.recipe-card .photo {
  width: 76px;
  height: 76px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  flex-shrink: 0;
}
.recipe-card .info { flex: 1; min-width: 0; }
.recipe-card .name { font-size: 17px; font-weight: 700; margin: 0 0 4px; }
.recipe-card .meta { font-size: 13px; color: var(--ink-soft); }

.recommend-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
}
.recommend-card .photo {
  width: 100%;
  height: 160px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  margin-bottom: 14px;
}
.recommend-card .name { font-size: 21px; font-weight: 700; margin: 0 0 6px; }
.recommend-card .why { font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; }
.missing-note { font-size: 13px; color: var(--accent); margin-bottom: 14px; }
.need-badge {
  display: inline-block;
  font-size: 11px;
  color: var(--accent);
  border: 1px solid var(--accent-soft);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--ink); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.action-grid .btn { width: 100%; }

/* ---------- Bottom nav ---------- */
.tab-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(251,247,240,0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 50;
}
.tab-bar button {
  flex: 1;
  padding: 10px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--ink-soft);
}
.tab-bar button.active { color: var(--accent); font-weight: 700; }
.tab-bar .tab-icon { font-size: 20px; }

/* ---------- Modal / sheet ---------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(30,20,10,0.4);
  display: flex; align-items: flex-end;
  z-index: 100;
}
.overlay.center { align-items: center; padding: 20px; }
.sheet {
  background: var(--bg);
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 22px 22px 0 0;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
}
.overlay.center .sheet {
  border-radius: var(--radius);
  max-width: 420px;
}
.sheet-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 16px;
}

.field-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.field-row input, .field-row select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 15px;
  background: #fff;
  color: var(--ink);
}
.field-row .fi-name { flex: 2; min-width: 0; }
.field-row .fi-amount { flex: 1; min-width: 0; }
.field-row .fi-unit { flex: 1; min-width: 0; }
.field-row .fi-remove {
  width: 40px;
  color: var(--ink-soft);
  font-size: 20px;
}
.fi-mustuse {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
  flex-shrink: 0;
}
.fi-mustuse input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.empty-state {
  text-align: center;
  color: var(--ink-soft);
  padding: 30px 10px;
  font-size: 14px;
}

.text-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 15px;
  background: #fff;
  color: var(--ink);
}

.confirm-list {
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 12px 0;
}
.confirm-list .row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.confirm-list .row:last-child { border-bottom: none; }

/* iPad / wide layout */
@media (min-width: 720px) {
  .app { padding: 32px 40px 110px; }
  .home-grid {
    display: grid;
    grid-template-columns: 1fr 1.1fr;
    gap: 24px;
    align-items: start;
  }
  .action-grid { grid-template-columns: 1fr 1fr 1fr 1fr; }
}

.rating-stars {
  display: flex;
  gap: 4px;
  font-size: 26px;
  justify-content: center;
  margin: 10px 0;
}
.rating-stars span { color: #d9cfc3; }
.rating-stars span.filled { color: var(--accent); }

.history-item {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.history-item .meta { font-size: 12px; color: var(--ink-soft); }

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.step-list { padding-left: 20px; }
.step-list li { margin-bottom: 10px; line-height: 1.5; }

.recipe-detail-photo {
  width: 100%;
  height: 200px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
  margin-bottom: 16px;
}

.ingredient-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}
.ingredient-table td {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.ingredient-table td:last-child { text-align: right; color: var(--ink-soft); }
