:root {
  --bg: #fbf8f4;
  --surface: #ffffff;
  --text: #2b2520;
  --muted: #7a6f66;
  --line: #e9e2d9;
  --accent: #e8590c;
  --accent-text: #ffffff;
  --accent-soft: #fff0e6;
  --danger: #c92a2a;
  --inferred-bg: #fff3bf;
  --inferred-text: #7a5a00;
  --tabs-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1815;
    --surface: #26221e;
    --text: #f1ebe4;
    --muted: #a99d92;
    --line: #3a342e;
    --accent: #ff8a4c;
    --accent-text: #1b1815;
    --accent-soft: #3a2a1f;
    --danger: #ff8787;
    --inferred-bg: #4a3f12;
    --inferred-text: #ffe066;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2 { line-height: 1.3; margin: 0; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; margin-top: 28px; margin-bottom: 8px; }

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 24px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; }
.back { text-decoration: none; font-weight: 600; padding: 8px 0; }
.state { color: var(--muted); text-align: center; padding: 32px 0; margin: 0; }
.state.error, .card-error { color: var(--danger); }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0; }

/* 入力 */
input, textarea {
  width: 100%;
  font: inherit;            /* 16px 以上にして、iPhone で入力時に勝手に拡大されないようにする */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  appearance: none;
}
textarea { resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.btn {
  display: block;
  width: 100%;
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  min-height: 48px;
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); background: transparent; }
.btn.big { font-size: 1.1rem; padding: 16px; }
.btn:disabled { opacity: 0.55; }
.link { font: inherit; color: var(--accent); background: none; border: 0; padding: 8px 0; cursor: pointer; }

/* 一覧 */
.cards { display: flex; flex-direction: column; gap: 10px; }
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  color: inherit;
  text-decoration: none;
}
.card-title { font-weight: 700; font-size: 1.05rem; }
.card-title.url { font-weight: 500; font-size: 0.9rem; word-break: break-all; }
.card-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.card-error { font-size: 0.85rem; margin: 6px 0 0; }
.made { color: var(--accent); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font: inherit;
  font-size: 0.8rem;
  color: var(--text);
  background: var(--accent-soft);
  border: 0;
  border-radius: 999px;
  padding: 3px 10px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.panel h2 { margin: 0; }

/* 詳細 */
.title { font-size: 1.6rem; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); margin: 0; font-size: 0.9rem; }
.source { font-weight: 600; text-decoration: none; }
.inferred {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--inferred-text);
  background: var(--inferred-bg);
  border-radius: 6px;
  padding: 0 6px;
  margin-left: 6px;
  vertical-align: middle;
  white-space: nowrap;
}
.unknown { color: var(--muted); }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.section-head h2 { margin-bottom: 0; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 44px; height: 44px;
  font-size: 1.4rem; line-height: 1;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
}
.stepper-value { min-width: 4.5em; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.ingredients { list-style: none; margin: 0; padding: 0; }
.ingredients li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.ing-name small { display: block; color: var(--muted); font-size: 0.8rem; }
.ing-amount { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ing-amount.unknown { font-weight: 400; }
.steps { margin: 0; padding-left: 1.6em; }
.steps li { padding: 8px 0; }
.memo { white-space: pre-wrap; margin: 0; }
.made-box { display: flex; flex-direction: column; gap: 4px; margin-top: 20px; }

/* 編集 */
.field { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.field > span { font-size: 0.85rem; color: var(--muted); }
.field-pair { display: flex; gap: 12px; }
.rows { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; flex-direction: column; gap: 6px; }
.row-main { display: flex; align-items: center; gap: 6px; }
.row-sub { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 6px; padding-right: 50px; }
.row-no { width: 1.5em; text-align: center; color: var(--muted); font-weight: 700; flex: none; }
.row-del {
  flex: none;
  width: 44px; height: 44px;
  font-size: 1rem;
  color: var(--muted);
  background: transparent;
  border: 0;
}

/* 下のタブ */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1;
  height: var(--tabs-h);
  display: flex; align-items: center; justify-content: center; gap: 4px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}
.tabs a.active { color: var(--accent); }
.badge {
  min-width: 18px;
  font-size: 0.7rem;
  line-height: 18px;
  text-align: center;
  color: var(--accent-text);
  background: var(--accent);
  border-radius: 9px;
  padding: 0 5px;
}

.toast {
  position: fixed;
  left: 16px; right: 16px;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px);
  max-width: 608px;
  margin: 0 auto;
  background: var(--text);
  color: var(--bg);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.9rem;
  z-index: 20;
}

/* 調理モード */
.page.cook {
  height: 100dvh;
  padding-bottom: calc(env(safe-area-inset-bottom) + 16px);
}
.cook-top { display: flex; align-items: center; justify-content: space-between; }
.cook-count { font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.cook-title { color: var(--muted); font-size: 0.9rem; }
.lock-note { font-size: 0.75rem; margin-left: 6px; }
.cook-text {
  flex: 1;
  margin: 0;
  overflow-y: auto;
  font-size: clamp(1.6rem, 7.5vw, 2.4rem);
  font-weight: 600;
  line-height: 1.5;
  display: block;
  padding: 8px 0;
}
.cook-nav { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.sheet {
  position: fixed; inset: 0;
  background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 16px);
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  z-index: 10;
}
.sheet h2 { margin-top: 0; }
.sheet .ingredients { flex: 1; font-size: 1.15rem; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }

.guide { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; }
.guide img { width: 150px; height: auto; flex: none; }
.bubble { position: relative; margin: 0; padding: 10px 12px; background: #fff; border: 1px solid #f0e2d0; border-radius: 14px; font-size: 14px; line-height: 1.5; }
.bubble::before { content: ''; position: absolute; left: -7px; top: 50%; width: 12px; height: 12px; margin-top: -6px; background: #fff; border-left: 1px solid #f0e2d0; border-bottom: 1px solid #f0e2d0; transform: rotate(45deg); }

/* レシピの絵(写真 or イラスト) */
.card.with-thumb { display: flex; gap: 12px; align-items: flex-start; }
.card-body { flex: 1; min-width: 0; }
.thumb { width: 84px; height: 84px; flex: none; border-radius: 14px; object-fit: cover; background: #fff3e0; }
.thumb.hero { display: block; width: 120px; height: 120px; margin: 4px auto 12px; border-radius: 24px; }
.thumb.hero.photo { width: 100%; height: auto; max-height: 360px; aspect-ratio: 4 / 3; border-radius: 18px; }

/* 調理モード: ごま・のあ のイラストつき */
.cook-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.cook-body .cook-text { flex: none; overflow: visible; font-size: clamp(1.45rem, 6.6vw, 2.1rem); padding: 0; }
.cook-stage { position: relative; }
.cook-art { display: block; width: 100%; height: auto; aspect-ratio: 400 / 230; border-radius: 22px; }
.cook-say {
  position: absolute; left: 12px; bottom: 10px; margin: 0; padding: 6px 12px;
  background: #fff; border-radius: 999px; font-size: 0.9rem; font-weight: 700; color: #6b4a32;
  box-shadow: 0 2px 6px rgba(120, 80, 40, 0.15);
}
.cook-used { display: flex; flex-wrap: wrap; gap: 8px; }
.used-chip { display: inline-flex; gap: 8px; align-items: baseline; padding: 8px 12px; background: #fff; border: 1px solid #f0e2d0; border-radius: 12px; font-size: 1rem; }
.used-chip b { color: var(--accent); }
.cook-dots { display: flex; justify-content: center; gap: 6px; padding: 4px 0; flex-wrap: wrap; }
.cook-dots span { width: 8px; height: 8px; border-radius: 50%; background: #e6d8c6; }
.cook-dots span.on { width: 22px; border-radius: 999px; background: var(--accent); }

.brand img.cutlery { width: 28px; height: 28px; border-radius: 0; margin-left: -2px; }

/* 天気に合わせたおすすめ */
.weather { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 12px; padding: 12px; background: #fff; border: 1px solid #f0e2d0; border-radius: 16px; }
.weather-face { width: 44px; height: auto; flex: none; }
.weather-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.weather-now { margin: 0; font-weight: 700; font-size: 0.95rem; }
.weather-text { margin: 0; font-size: 0.95rem; line-height: 1.5; }
.weather-ask, .weather-pick { border: 0; border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 0.9rem; font-weight: 700; cursor: pointer; }
.weather-ask { background: #fff3e0; color: #b4541a; }
.weather-pick { background: var(--accent); color: #fff; }

/* トップページ: ふわふわ浮かぶ料理とお酒 */
.hero { position: relative; padding-top: 48px; display: flex; flex-direction: column; gap: 12px; }
.hero > .top, .hero > .guide { position: relative; z-index: 1; }
.hero > .guide { margin: 0; }
.floaties { position: absolute; inset: 0; pointer-events: none; }
.floaties img { position: absolute; width: 38px; height: 38px; transform: rotate(var(--tilt)); animation: floaty 5s ease-in-out infinite; }
.floaties img.wide-only { display: none; }
@media (min-width: 560px) {
  .floaties img { width: 44px; height: 44px; }
  .floaties img.wide-only { display: block; }
}
@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(var(--tilt)); }
  50% { transform: translateY(-7px) rotate(calc(var(--tilt) + 5deg)); }
}
@media (prefers-reduced-motion: reduce) { .floaties img { animation: none; } }
.card-meta .time.unknown { opacity: 0.6; }

/* 難易度の目安 */
.level { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 700; }
.level-1 { background: #dff3df; color: #23783a; }
.level-2 { background: #dcefff; color: #1f66a8; }
.level-3 { background: #ffe9c7; color: #a85d0a; }
.level-4 { background: #ffdada; color: #b3261e; }

/* 旬の食材 */
.season { width: 100%; margin-top: 4px; padding-top: 8px; border-top: 1px dashed #f0e2d0; }
.season-title { margin: 0 0 6px; font-size: 0.85rem; font-weight: 700; color: #6b4a32; }
.season-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.season-chip { border: 1px solid #cfe6c2; background: #f1f9ea; color: #2f6b2a; border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
