:root {
  --bg: #fffaf4;
  --surface: #ffffff;
  --surface-soft: #fff3e8;
  --text: #302b28;
  --muted: #7a716b;
  --primary: #f08a5d;
  --primary-dark: #d86f43;
  --secondary: #6a9c78;
  --line: #eadfd5;
  --danger: #bb4d4d;
  --shadow: 0 12px 35px rgba(86, 62, 45, 0.09);
  --radius: 22px;
  font-family: "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 5%, rgba(240, 138, 93, 0.14), transparent 28%),
    radial-gradient(circle at 85% 10%, rgba(106, 156, 120, 0.12), transparent 24%),
    var(--bg);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }

.app-shell { min-height: 100vh; padding-bottom: 98px; }
.topbar {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar h1 { margin: 0; font-size: clamp(2rem, 4vw, 3rem); letter-spacing: 0.02em; }
.eyebrow, .section-kicker {
  margin: 0 0 6px;
  color: var(--secondary);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
main { max-width: 1180px; margin: 0 auto; padding: 10px 24px 38px; }
.view { display: none; animation: fade 0.25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.hero-card {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 34px;
  margin-bottom: 22px;
  border-radius: 30px;
  background: linear-gradient(135deg, #fff1df, #fde1ce);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hero-card h2 { max-width: 760px; margin: 8px 0 10px; font-size: clamp(1.55rem, 3vw, 2.35rem); line-height: 1.35; }
.hero-card p { margin: 0; color: var(--muted); line-height: 1.8; }
.hero-emoji { font-size: clamp(4.3rem, 11vw, 8rem); filter: drop-shadow(0 12px 16px rgba(91, 58, 37, 0.13)); }
.badge {
  display: inline-flex;
  padding: 7px 12px;
  border-radius: 999px;
  color: #8f4e2f;
  background: rgba(255,255,255,0.72);
  font-size: 0.78rem;
  font-weight: 800;
}

.grid { display: grid; gap: 22px; margin-bottom: 22px; }
.grid.two { grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.85fr); }
.panel {
  background: rgba(255,255,255,0.94);
  border: 1px solid rgba(234, 223, 213, 0.9);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.accent-panel { background: linear-gradient(155deg, #fff9f1, #f7fbf7); }
.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}
.panel-title h2, .panel-title h3 { margin: 0; }
.panel-title h2 { font-size: 1.65rem; }
.panel-title h3 { font-size: 1.3rem; }
.header-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
label > span, .field-label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.82rem;
  font-weight: 800;
  color: #5d5550;
}
input, select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 10px 12px;
  background: white;
  color: var(--text);
  outline: none;
}
input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(240, 138, 93, 0.12);
}
.field-block { margin-top: 18px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 9px; }
.toggle-chip input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-chip span {
  margin: 0;
  display: inline-flex;
  align-items: center;
  padding: 9px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-weight: 700;
  transition: 0.2s ease;
}
.toggle-chip input:checked + span {
  color: #7e3f24;
  border-color: #f3a17b;
  background: #fff0e7;
}
.inline-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin: 20px 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.inline-checks input { width: auto; min-height: auto; accent-color: var(--primary); }

.primary-btn, .secondary-btn, .ghost-btn, .text-btn, .danger-btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 15px;
  font-weight: 800;
}
.primary-btn {
  color: white;
  background: linear-gradient(135deg, var(--primary), #ef7e4c);
  box-shadow: 0 10px 20px rgba(240, 138, 93, 0.24);
}
.primary-btn:hover { background: linear-gradient(135deg, var(--primary-dark), #e67242); }
.secondary-btn { color: #416a4c; background: #eaf5ed; }
.ghost-btn { color: var(--muted); background: #f6f1ed; }
.text-btn { color: var(--primary-dark); background: transparent; padding: 7px 4px; }
.danger-btn { color: var(--danger); background: #fff0f0; }
.wide { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 15px 18px; }

.readiness-list { display: grid; gap: 12px; }
.readiness-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 15px;
  background: rgba(255,255,255,0.75);
  border: 1px solid var(--line);
}
.readiness-item span:first-child { font-weight: 800; }
.status-ok { color: var(--secondary); }
.status-warn { color: #b57b2a; }
.tip-box {
  margin-top: 18px;
  padding: 16px;
  border-radius: 16px;
  background: #f2f7f3;
  color: #4d6754;
}
.tip-box p { margin: 6px 0 0; line-height: 1.65; }

.summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.summary-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: #87563d;
  font-weight: 800;
  font-size: 0.85rem;
}

.meal-preview, .plan-grid, .favorites-grid { display: grid; gap: 14px; }
.meal-preview { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.plan-grid { grid-template-columns: repeat(auto-fit, minmax(285px, 1fr)); }
.meal-card, .favorite-card, .history-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  padding: 18px;
}
.meal-card.featured { background: linear-gradient(155deg, #fffdf8, #fff5eb); }
.meal-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.meal-card h3 { margin: 0 0 3px; font-size: 1.08rem; }
.meal-card .date { color: var(--muted); font-size: 0.82rem; }
.meal-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.meta-tag {
  padding: 5px 8px;
  border-radius: 999px;
  background: #f6f2ee;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}
.course-list { display: grid; gap: 10px; }
.course-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.course-label { color: var(--secondary); font-size: 0.76rem; font-weight: 800; }
.course-name { font-weight: 800; line-height: 1.45; }
.course-note { color: var(--muted); font-size: 0.75rem; margin-top: 3px; }
.icon-btn {
  min-width: 38px;
  height: 38px;
  padding: 0 9px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}
.icon-btn.favorite.active { color: #d55353; background: #fff2f2; border-color: #f3cdcd; }
.card-note {
  margin-top: 13px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #eef7f0;
  color: #4b7056;
  font-size: 0.8rem;
  line-height: 1.5;
}

.shopping-list { display: grid; gap: 18px; }
.shopping-group h3 { margin: 0 0 10px; font-size: 1rem; }
.shopping-items { display: grid; gap: 8px; }
.shopping-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
}
.shopping-item input { width: 18px; min-height: auto; accent-color: var(--secondary); }
.shopping-item.checked { opacity: 0.48; }
.shopping-item.checked .shopping-name { text-decoration: line-through; }
.shopping-qty { color: var(--muted); font-size: 0.82rem; }

.stack-form { display: grid; gap: 15px; }
.pantry-list, .family-list, .history-list { display: grid; gap: 10px; }
.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,0.8);
}
.list-row strong { display: block; }
.list-row small { color: var(--muted); line-height: 1.5; }
.expiry-soon { color: #b06439 !important; font-weight: 800; }
.favorites-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.favorite-card h3 { margin: 0 0 8px; }
.favorite-card p { margin: 0 0 12px; color: var(--muted); font-size: 0.84rem; line-height: 1.6; }
.history-card { display: grid; gap: 8px; }
.history-card-head { display: flex; justify-content: space-between; gap: 12px; }
.history-card h3 { margin: 0; font-size: 1rem; }
.history-card p { margin: 0; color: var(--muted); line-height: 1.65; font-size: 0.86rem; }

.empty-state {
  min-height: 150px;
  place-items: center;
  align-content: center;
  text-align: center;
  color: var(--muted);
}
.empty-state .empty-icon { font-size: 2.4rem; margin-bottom: 8px; }
.empty-state p { max-width: 430px; margin: 0; line-height: 1.7; }

.bottom-nav {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(96%, 920px);
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  padding: 8px;
  border: 1px solid rgba(226, 214, 204, 0.9);
  border-radius: 20px;
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(16px);
  box-shadow: 0 18px 40px rgba(75, 54, 40, 0.18);
}
.nav-btn {
  border: 0;
  border-radius: 14px;
  padding: 8px 4px 7px;
  background: transparent;
  color: var(--muted);
  display: grid;
  justify-items: center;
  gap: 2px;
}
.nav-btn span { font-size: 1.15rem; }
.nav-btn small { font-size: 0.68rem; font-weight: 800; }
.nav-btn.active { color: var(--primary-dark); background: var(--surface-soft); }

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 115px;
  transform: translate(-50%, 20px);
  max-width: min(90%, 460px);
  padding: 12px 16px;
  border-radius: 13px;
  color: white;
  background: rgba(48, 43, 40, 0.94);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: 0.22s ease;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.hidden { display: none !important; }

@media (max-width: 820px) {
  .grid.two { grid-template-columns: 1fr; }
  .hero-card { padding: 26px; }
  .hero-emoji { font-size: 5rem; }
  .bottom-nav { overflow-x: auto; grid-template-columns: repeat(7, minmax(72px, 1fr)); }
}
@media (max-width: 560px) {
  .topbar, main { padding-left: 15px; padding-right: 15px; }
  .topbar { align-items: flex-start; }
  .hero-card { padding: 22px; align-items: flex-start; }
  .hero-emoji { font-size: 3.7rem; }
  .form-grid { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
  .panel-title { align-items: flex-start; }
  .header-actions { width: 100%; }
  .course-row { grid-template-columns: 48px minmax(0, 1fr) auto; }
}


.range-field { min-width: 0; }
.range-control {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 118px;
  gap: 12px;
  align-items: center;
}
.range-control input[type="range"] {
  min-height: auto;
  padding: 0;
  border: 0;
  box-shadow: none;
  accent-color: var(--primary);
}
.number-input-wrap {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
}
.number-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(240, 138, 93, 0.12);
}
.number-input-wrap input {
  min-width: 0;
  min-height: 42px;
  padding: 8px 2px;
  border: 0;
  box-shadow: none !important;
  text-align: right;
}
.number-input-wrap > span { color: var(--muted); font-weight: 800; white-space: nowrap; }
.budget-input { grid-template-columns: auto 1fr; }
.field-help { display: block; margin-top: 6px; color: var(--muted); line-height: 1.45; }
.course-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.recipe-btn { min-width: auto; padding: 0 10px; color: var(--primary-dark); }

.recipe-dialog {
  width: min(92vw, 820px);
  max-height: min(88vh, 900px);
  padding: 0;
  border: 0;
  border-radius: 24px;
  color: var(--text);
  background: #fffdf9;
  box-shadow: 0 28px 80px rgba(48, 43, 40, 0.28);
}
.recipe-dialog::backdrop { background: rgba(48, 43, 40, 0.46); backdrop-filter: blur(3px); }
.recipe-dialog-inner { padding: 24px; overflow-y: auto; max-height: 88vh; }
.recipe-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.recipe-dialog-head h2 { margin: 0; font-size: clamp(1.4rem, 4vw, 2rem); }
.dialog-close { font-size: 1.3rem; flex: 0 0 auto; }
.recipe-columns { display: grid; grid-template-columns: minmax(220px, .8fr) minmax(300px, 1.2fr); gap: 24px; }
.recipe-columns section { min-width: 0; }
.recipe-columns h3 { margin: 0 0 10px; }
.recipe-subtitle { margin: -4px 0 12px; color: var(--muted); font-size: .84rem; }
.ingredient-list, .recipe-steps { margin: 0; padding: 0; display: grid; gap: 9px; }
.ingredient-list { list-style: none; }
.ingredient-list li { display: flex; justify-content: space-between; gap: 14px; padding: 10px 12px; border-radius: 12px; background: #f8f4ef; }
.ingredient-list strong { white-space: nowrap; }
.recipe-steps { padding-left: 1.5rem; }
.recipe-steps li { padding-left: 4px; line-height: 1.75; }
.recipe-tip { margin-top: 20px; padding: 13px 15px; border-radius: 14px; background: #eef7f0; color: #4b7056; line-height: 1.6; font-size: .86rem; }

@media (max-width: 680px) {
  .range-control { grid-template-columns: 1fr; gap: 8px; }
  .number-input-wrap { width: 100%; }
  .recipe-columns { grid-template-columns: 1fr; }
  .recipe-dialog-inner { padding: 18px; }
  .course-actions { flex-direction: column; }
  .course-actions .icon-btn { width: 42px; }
}

/* v3: 自由入力欄をスマートフォンでも分かりやすくする */
.number-input-wrap input[type="number"] {
  min-width: 92px;
  font-size: 1.08rem;
  font-weight: 800;
  background: #fffdf9;
  border-radius: 8px;
  padding: 6px 8px;
}
.number-input-wrap input[type="number"]:focus {
  background: #ffffff;
  outline: 2px solid rgba(240, 138, 93, 0.45);
  outline-offset: 1px;
}


/* v5: 収録レシピ一覧 */
.recipe-count-badge {
  flex: 0 0 auto;
  padding: 9px 13px;
  border-radius: 999px;
  background: #eef7f0;
  color: #4b7056;
  font-size: 0.84rem;
  font-weight: 800;
}

.recipe-filter-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(145deg, #fffaf4, #f8fbf8);
}

.recipe-search input {
  min-height: 50px;
  font-size: 1rem;
}

.recipe-filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
}

.recipe-filter-reset {
  justify-self: end;
}

.recipe-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 15px;
}

.recipe-library-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(86, 62, 45, 0.05);
}

.recipe-library-card h3 {
  margin: 10px 0 7px;
  font-size: 1.08rem;
  line-height: 1.5;
}

.recipe-card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.course-badge {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 800;
}

.course-main {
  color: #8a492d;
  background: #fff0e7;
}

.course-side {
  color: #426e4e;
  background: #eaf5ed;
}

.course-soup {
  color: #65538c;
  background: #f0ecfa;
}

.recipe-library-meta {
  margin-top: 4px;
}

.recipe-meals {
  margin: 11px 0 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

.recipe-ingredient-preview,
.recipe-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.recipe-ingredient-preview span {
  padding: 5px 8px;
  border-radius: 9px;
  background: #f7f2ed;
  color: #6d625a;
  font-size: 0.74rem;
}

.recipe-tag-row {
  margin-top: 9px;
}

.recipe-tag-row span {
  color: #4f7258;
  font-size: 0.72rem;
  font-weight: 800;
}

.recipe-detail-btn {
  width: 100%;
  margin-top: auto;
  padding-top: 11px;
  padding-bottom: 11px;
  transform: translateY(12px);
}

@media (max-width: 940px) {
  .recipe-filter-grid {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }
}

@media (max-width: 620px) {
  .recipe-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .recipe-filter-reset {
    width: 100%;
    justify-self: stretch;
  }

  .recipe-library-grid {
    grid-template-columns: 1fr;
  }
}
