:root {
  --bg: #fbf7f0;
  --surface: #ffffff;
  --ink: #2b2622;
  --muted: #8a8079;
  --line: #ece4d8;
  --accent: #e2683c;
  --accent-soft: #fbe7dd;
  --p-high: #e14b3b;
  --p-medium: #e2933c;
  --p-low: #6f8f5e;
  --shadow: 0 6px 24px rgba(60, 44, 30, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding: 0 16px env(safe-area-inset-bottom);
}

.app-header {
  text-align: center;
  padding: 28px 0 14px;
  max-width: 560px;
  margin: 0 auto;
}
.app-header h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.02em;
}
.logo { filter: saturate(1.1); }
.tagline {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.categories {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 2px 14px;
  max-width: 560px;
  margin: 0 auto;
  -webkit-overflow-scrolling: touch;
}
.cat {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}
.cat.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(226, 104, 60, 0.3);
}
.cat.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.cat .soon {
  font-size: 10px;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}

main {
  max-width: 560px;
  margin: 0 auto;
}

.camera-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--line);
}
.viewport {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #2b2622;
  display: flex;
  align-items: center;
  justify-content: center;
}
.viewport video,
.viewport img {
  width: 100%;
  height: 100%;
  display: block;
}
.viewport video { object-fit: cover; }
/* 撮影プレビューは contain で、AIに送る画像と同じ範囲を表示（切り取らない） */
.viewport img { object-fit: contain; background: #2b2622; }
.cam-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 999px;
  text-align: center;
  max-width: 90%;
}

.genre-pick { padding: 14px 16px 0; }
.genre-pick-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 7px;
}
.gbtns { display: flex; flex-wrap: wrap; gap: 7px; }
.gbtn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.gbtn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 16px;
}
button, .upload-btn {
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  border: none;
}
.primary {
  flex: 1 1 auto;
  background: var(--accent);
  color: #fff;
  padding: 14px 18px;
  box-shadow: 0 4px 14px rgba(226, 104, 60, 0.3);
}
.primary:active { transform: translateY(1px); }
.upload-btn {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 13px 16px;
}
.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 13px 16px;
}

.results {
  margin: 18px 0 40px;
}
.scene {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  font-size: 15px;
}
.scene-label {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 9px;
  border-radius: 999px;
  margin-right: 10px;
  vertical-align: middle;
}
.scene .error { color: var(--p-high); font-weight: 600; }

.task-list {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: grid;
  gap: 12px;
}
.task {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid var(--p-low);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.task.p-high { border-left-color: var(--p-high); }
.task.p-medium { border-left-color: var(--p-medium); }
.task.p-low { border-left-color: var(--p-low); }
.task-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.badge {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
}
.p-high .badge { background: var(--p-high); }
.p-medium .badge { background: var(--p-medium); }
.p-low .badge { background: var(--p-low); }
.time { font-size: 12px; color: var(--muted); }
.task h3 { margin: 2px 0 4px; font-size: 17px; }
.task p { margin: 0; font-size: 14px; color: #5c534b; }
.empty {
  list-style: none;
  text-align: center;
  color: var(--muted);
  padding: 26px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 14px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 38, 34, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: #fff;
  z-index: 10;
  backdrop-filter: blur(2px);
}
.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.app-footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 20px 0 30px;
}

[hidden] { display: none !important; }

/* ── モード説明 ───────────────────────────── */
.mode-desc {
  max-width: 560px;
  margin: -4px auto 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 0 4px;
}

/* ── 献立カード ───────────────────────────── */
.menu-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 18px 16px;
}
.card-title { margin: 0; font-size: 18px; }
.card-sub { margin: 4px 0 14px; color: var(--muted); font-size: 13px; }
.slots { display: grid; gap: 10px; }
.slot-row { display: flex; gap: 8px; align-items: center; }
.slot-time-in {
  flex: 0 0 auto;
  font-family: inherit;
  font-size: 15px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
.slot-label-in {
  flex: 1 1 auto;
  min-width: 0;
  font-family: inherit;
  font-size: 15px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
.slot-del {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 14px;
}
.add-slot {
  width: 100%;
  margin: 12px 0;
  padding: 11px;
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--accent);
  font-size: 15px;
}
.menu-request {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  margin-bottom: 12px;
}
.primary.block { width: 100%; }

/* ── セクション見出し・食材チップ ─────────── */
.section-label,
.chips-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin: 18px 2px 8px;
}
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
}

/* ── 料理カード ───────────────────────────── */
.dish-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 12px; }
.dish {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.dish-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dish-top h3 { margin: 0; font-size: 17px; }
.dish p { margin: 8px 0 0; font-size: 14px; color: #5c534b; }
.dish-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}
.genre {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  padding: 2px 9px;
  border-radius: 999px;
}
.g-wa { background: #6f8f5e; }
.g-yo { background: #e2933c; }
.g-chu { background: #d9534f; }
.g-eth { background: #9b6fb0; }
.g-oth { background: #8a8079; }
.badge-soft {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 2px 9px;
  border-radius: 999px;
}
.badge-soft.ok { color: #fff; background: var(--p-low); border-color: var(--p-low); }

/* ── 買い足しリスト ───────────────────────── */
.shop-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.shop {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
}
.shop-item { font-weight: 700; font-size: 15px; display: block; }
.shop-reason { font-size: 13px; color: var(--muted); }

/* ── 献立（時間帯つき料理） ───────────────── */
.menu-dish { border-left: 5px solid var(--accent); }
.slot-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.slot-time { font-size: 18px; font-weight: 800; color: var(--accent); }
.slot-label { font-size: 13px; font-weight: 700; color: var(--muted); }
.total {
  margin-top: 14px;
  text-align: center;
  font-weight: 700;
  color: var(--ink);
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 12px;
}

/* ── 複数写真サムネイル ───────────────────── */
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px 0; }
.thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}
/* 見た目は小さいまま、当たり判定を広げる（誤タップ防止） */
.thumb-del::before { content: ""; position: absolute; inset: -9px; }

/* ── 料理カード（タップでレシピ） ─────────── */
.dish[data-dish] { cursor: pointer; transition: transform 0.05s; }
.dish[data-dish]:active { transform: scale(0.99); }
.recipe-link { margin-top: 8px; font-size: 13px; font-weight: 700; color: var(--accent); }

/* ── もっと提案 ───────────────────────────── */
.more-btn {
  width: 100%;
  margin-top: 14px;
  padding: 13px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  background: transparent;
  border: 1px dashed var(--accent);
  border-radius: 12px;
  color: var(--accent);
  cursor: pointer;
}

/* ── レシピモーダル（下からのシート） ─────── */
.recipe-modal {
  position: fixed;
  inset: 0;
  z-index: 15;
  background: rgba(43, 38, 34, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.recipe-card {
  position: relative;
  background: var(--surface);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow);
}
.recipe-card #recipeBody {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 18px calc(28px + env(safe-area-inset-bottom));
}
.recipe-close {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 2;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
}
.recipe-title { margin: 0 44px 8px 0; font-size: 20px; }
.recipe-loading { text-align: center; color: var(--muted); padding: 30px; }
.recipe-loading .spinner { margin: 0 auto 12px; border: 4px solid var(--line); border-top-color: var(--accent); }
.recipe-ings { list-style: none; padding: 0; margin: 6px 0 0; }
.recipe-ings li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.recipe-ings .amt { color: var(--muted); font-weight: 600; white-space: nowrap; }
.recipe-steps { margin: 8px 0 0; padding-left: 22px; }
.recipe-steps li { margin-bottom: 10px; font-size: 15px; line-height: 1.7; }
.recipe-tips {
  margin-top: 14px;
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  color: #5c534b;
}

/* ── トースト通知 ─────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 30;
  background: rgba(43, 38, 34, 0.92);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 999px;
  max-width: 90%;
  text-align: center;
  box-shadow: var(--shadow);
}

/* ── 食材モードの要望入力 ─────────────────── */
.req-wrap { padding: 12px 16px 0; }

/* ── お気に入りボタン ─────────────────────── */
.dish-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.fav-btn {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
}

/* ── レシピ内アクション（後勝ちで .ract が見た目を上書き） ── */
.ract {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 13px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.recipe-actions { display: flex; gap: 8px; margin: 10px 0 4px; flex-wrap: wrap; }
.ract.fav-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ── 買い足しに ＋ ────────────────────────── */
.shop { display: flex; align-items: center; gap: 10px; }
.shop-text { flex: 1 1 auto; min-width: 0; }
.add-shop {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

/* ── 買い物リスト ─────────────────────────── */
.shop-check { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.shop-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
}
.shop-row .check {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}
.shop-row.done .check { background: var(--p-low); border-color: var(--p-low); }
.shop-row .label { flex: 1 1 auto; font-size: 15px; }
.shop-row.done .label { text-decoration: line-through; color: var(--muted); }
.shop-del {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

/* ── ログイン ─────────────────────────────── */
.login {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 22px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-card h2 { margin: 0 0 6px; font-size: 22px; }
.login-card p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.login-card input {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  margin-bottom: 12px;
}
.login-err {
  color: var(--p-high);
  font-size: 14px;
  min-height: 20px;
  margin-top: 8px;
}
.logout {
  margin-left: 10px;
  font-size: 12px;
  font-weight: 600;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
}
