:root {
  --primary: #2EC26E;
  --primary-dark: #23A35B;
  --bg: #F5F9E1;
  --card: #FFFFFF;
  --text: #2B2B28;
  --muted: #7C8468;
  --border: #DFE7C4;
  --danger: #D85A30;
  --warn: #BA7517;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
}

.app-header { padding: 18px 16px 10px; }
.app-header h1 { font-size: 22px; }
.tagline { color: var(--muted); font-size: 13px; margin-top: 2px; }

main { padding: 0 12px; }
.view { padding-bottom: 24px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
}
.card h3 { font-size: 16px; margin-bottom: 8px; }
.hint { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; line-height: 1.6; }

/* buttons */
.btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14.5px;
  cursor: pointer;
  text-align: center;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:active { background: var(--primary-dark); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-wide { width: 100%; margin-top: 10px; }
.btn-icon { border: 1px solid var(--border); background: var(--card); border-radius: 10px; font-size: 18px; padding: 8px 12px; cursor: pointer; }
button:disabled { opacity: .5; pointer-events: none; }

/* register big buttons */
.register-buttons { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.big-btn {
  display: grid;
  grid-template-columns: 44px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  width: 100%;
}
.big-btn:active { background: #F1F6DE; }
.big-btn-icon { grid-row: 1 / 3; font-size: 30px; }
.big-btn-title { font-weight: 700; font-size: 15.5px; }
.big-btn-sub { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* forms */
.form-row { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; flex-wrap: wrap; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  background: #fff;
  flex: 1;
  min-width: 0;
  font-family: inherit;
}
input[type="password"] { width: 100%; margin-bottom: 8px; }
#s-model { width: 100%; margin-bottom: 8px; flex: none; }
.inline-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.toggle-row { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 10px 0; cursor: pointer; }
.setup-guide { margin-top: 14px; font-size: 13px; color: var(--muted); }
.setup-guide summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.setup-guide ol { padding-left: 20px; margin: 8px 0; line-height: 1.9; }

/* stock list */
.stock-summary { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.summary-pill { background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; }
.summary-pill.alert { border-color: var(--danger); color: var(--danger); font-weight: 700; }
.summary-pill.warn { border-color: var(--warn); color: var(--warn); font-weight: 700; }

.stock-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.stock-item.expired { border-left: 4px solid var(--danger); }
.stock-item.soon { border-left: 4px solid var(--warn); }
.stock-emoji { font-size: 22px; }
.stock-info { flex: 1; min-width: 0; }
.stock-name { font-weight: 600; font-size: 14.5px; }
.stock-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.badge { display: inline-block; border-radius: 6px; padding: 1px 6px; font-size: 10.5px; font-weight: 700; margin-right: 4px; }
.badge-expired { background: #FCEBEB; color: var(--danger); }
.badge-today { background: #FCEBEB; color: var(--danger); }
.badge-soon { background: #FAEEDA; color: var(--warn); }
.qty-btn {
  border: 1px solid var(--border);
  background: #F4F8F6;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
.qty-0 { color: var(--muted); background: #F1F1EE; }
.del-btn { border: none; background: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 6px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 14px; line-height: 2; }
.empty-emoji { font-size: 44px; }
.empty-state .btn { margin-top: 12px; display: block; width: 100%; }

/* review */
#review-title { margin: 14px 0 8px; font-size: 15px; }
.review-item {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; margin-bottom: 8px;
}
.review-item .form-row { margin-bottom: 6px; }
.review-item input[type="text"] { font-weight: 600; }
.review-actions { display: flex; gap: 8px; margin: 12px 0; }
.review-actions .btn { flex: 1; }

/* progress */
.progress-card { display: flex; align-items: center; gap: 12px; }
.spinner {
  width: 22px; height: 22px; flex: none;
  border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* recipes */
.mood-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chip {
  border: 1px solid var(--border); border-radius: 999px; background: var(--card);
  padding: 6px 12px; font-size: 12.5px; cursor: pointer; font-family: inherit;
}
.chip.selected { background: var(--primary); color: #fff; border-color: var(--primary); }

.recipe-card { position: relative; }
.recipe-kind { display: inline-block; border-radius: 6px; padding: 2px 8px; font-size: 11.5px; font-weight: 700; margin-bottom: 6px; }
.kind-時短 { background: #E6F1FB; color: #185FA5; }
.kind-節約 { background: #FAEEDA; color: #854F0B; }
.kind-栄養 { background: #EAF3DE; color: #3B6D11; }
.recipe-title { font-size: 16.5px; font-weight: 700; }
.recipe-time { font-size: 12px; color: var(--muted); margin: 2px 0 8px; }
.recipe-uses { font-size: 12.5px; margin-bottom: 8px; line-height: 1.8; }
.recipe-uses .use-tag { background: #F0F8EC; border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; margin-right: 3px; white-space: nowrap; }
.recipe-uses .use-tag.expiring { background: #FAEEDA; border-color: var(--warn); }
.recipe-steps { padding-left: 20px; font-size: 13.5px; line-height: 1.9; margin-bottom: 10px; }
.recipe-point { font-size: 12px; color: var(--muted); margin-bottom: 10px; }

/* tab bar */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 560px; margin: 0 auto;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.tab {
  flex: 1; border: none; background: none;
  padding: 8px 0 6px; font-size: 11px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  cursor: pointer; font-family: inherit;
}
.tab span { font-size: 20px; }
.tab.active { color: var(--primary); font-weight: 700; }

/* toast */
.toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
  background: #2B2B28; color: #fff; border-radius: 10px;
  padding: 10px 18px; font-size: 13.5px; z-index: 20;
  max-width: 90%; text-align: center;
  animation: fadein .2s;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.about { color: var(--muted); font-size: 12px; line-height: 1.8; }

/* qty +/- control */
.qty-ctrl { display: flex; align-items: center; gap: 2px; }
.qty-ctrl button {
  border: 1px solid var(--border); background: #EDF7E4;
  border-radius: 8px; width: 30px; height: 30px;
  font-size: 16px; font-weight: 700; color: var(--primary-dark);
  cursor: pointer; line-height: 1; font-family: inherit;
}
.qty-ctrl button:disabled { opacity: .35; }
.qty-label {
  font-size: 11.5px; min-width: 44px; text-align: center;
  padding: 2px 0; white-space: nowrap;
}
.qty-1 { color: var(--warn); font-weight: 700; }

/* savings meter */
.meter-card {
  background: linear-gradient(0deg, #FFFFFF, #FFFFFF);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 10px 0 4px;
}
.meter-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.meter-title { font-size: 12.5px; font-weight: 700; }
.meter-vals { display: flex; gap: 10px; font-size: 12px; flex-wrap: wrap; }
.meter-good { color: var(--primary-dark); font-weight: 700; }
.meter-bad { color: var(--danger); font-weight: 700; }
.meter-ai { color: #856A00; font-weight: 700; }

/* stock tools + tanaoroshi */
.stock-tools { margin: 8px 0; }
.stock-tools .btn { display: block; }
.tana-sub { font-size: 12.5px; color: var(--muted); margin: 10px 0 6px; }
.tana-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 4px; font-size: 14px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.tana-row input { width: 18px; height: 18px; }

/* shopping list */
.shop-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px;
}
.shop-item.checked .shop-name { text-decoration: line-through; color: var(--muted); }
.shop-check { display: flex; align-items: center; gap: 10px; flex: 1; cursor: pointer; min-width: 0; }
.shop-check input { width: 20px; height: 20px; flex: none; }
.shop-name { font-size: 14.5px; font-weight: 600; }
.shop-tag {
  font-size: 10px; color: var(--muted); border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 6px; white-space: nowrap;
}

/* storage filter chips */
.storage-chips, .mode-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.mode-chips { margin: 12px 0 4px; }

/* recipe star */
.recipe-card { padding-top: 14px; }
.star-btn {
  position: absolute; top: 10px; right: 12px;
  border: none; background: none; font-size: 22px;
  color: #C9C6BA; cursor: pointer; line-height: 1; padding: 4px;
}
.star-btn.faved { color: #EF9F27; }
.recipe-card { position: relative; }

/* week plan */
.week-day-label {
  display: inline-block; background: #E6F1FB; color: #185FA5;
  border-radius: 6px; padding: 2px 8px; font-size: 11.5px; font-weight: 700; margin-bottom: 6px;
}

/* receipt history */
.receipt-row {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 0; margin-bottom: 8px; background: #FDFEF5;
}
.receipt-row summary {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; cursor: pointer; font-size: 13.5px;
  list-style: none; flex-wrap: wrap;
}
.receipt-row summary::-webkit-details-marker { display: none; }
.receipt-date { font-weight: 700; white-space: nowrap; }
.receipt-store { flex: 1; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.receipt-sum { font-weight: 600; white-space: nowrap; }
.receipt-items { list-style: none; padding: 0 12px 6px; }
.receipt-items li {
  display: flex; justify-content: space-between;
  font-size: 12.5px; padding: 4px 0; border-top: 1px dashed var(--border);
}
.receipt-row .btn { margin: 6px 12px 10px; font-size: 12px; padding: 6px 10px; }

/* staples */
.staple-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.staple-chip {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--border); border-radius: 999px; background: #FFF;
  padding: 5px 6px 5px 12px; font-size: 13px;
}
.staple-chip button {
  border: none; background: none; color: var(--muted);
  font-size: 12px; cursor: pointer; padding: 2px 6px;
}

/* edit item */
.edit-item { border-left: 4px solid var(--primary); }
.howto-list { list-style: none; padding: 0; font-size: 13.5px; line-height: 1.8; }
.howto-list li { padding: 6px 0; border-top: 1px dashed var(--border); }

/* AIバッジ（AIが必要な機能の目印） */
.ai-badge {
  display: inline-block; background: #FFE26F; color: #6B4E00;
  font-size: 10px; font-weight: 800; border-radius: 6px;
  padding: 1px 6px; margin-left: 6px; vertical-align: 2px;
  letter-spacing: .5px;
}
.feature-list { list-style: none; padding: 0; font-size: 13.5px; line-height: 1.9; }
.feature-list li { padding: 3px 0; }
.stock-info { cursor: pointer; }
.empty-hint { padding: 12px 8px; text-align: center; }

/* おまかせプラン */
.plan-steps { padding-left: 20px; font-size: 13.5px; line-height: 1.9; margin: 8px 0 12px; }
.btn-link { display: block; text-decoration: none; margin-bottom: 8px; box-sizing: border-box; }
