:root {
  --bg: #f6ecdc; --paper: #fffaf1; --ink: #3b2a1e; --sub: #7a6250; --line: #e3d2b8;
  --accent: #b5532f; --accent-ink: #fff; --mustard: #d9a441; --herb: #5d7a3a; --miss: #b5532f;
  --chip: #fffaf1; --chip-on: #f3d9b8; --shadow: 0 2px 0 #e3d2b8;
  --mincho: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  --gothic: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #241a13; --paper: #2f241b; --ink: #f2e6d6; --sub: #c4ab93; --line: #4a3a2c;
    --accent: #e07a52; --accent-ink: #241a13; --mustard: #e3b55a; --herb: #9cbf73; --miss: #f0936e;
    --chip: #2f241b; --chip-on: #5a3a26; --shadow: 0 2px 0 #1a120c; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--gothic); line-height: 1.7; }
.app { max-width: 720px; margin: 0 auto; padding: calc(20px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(110px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--mustard); outline-offset: 2px; }

.mast { display: flex; align-items: center; gap: 14px; }
.pot { width: 52px; height: 52px; color: var(--accent); flex: none; }
.kicker { margin: 0; font-size: 13px; color: var(--sub); letter-spacing: .1em; }
h1 { margin: 0; font-family: var(--mincho); font-size: 34px; letter-spacing: .08em; line-height: 1.2; }
.lead { margin: 14px 0 22px; color: var(--sub); }

.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-bottom: 2px solid var(--ink); padding-bottom: 6px; margin: 30px 0 10px; }
h2 { margin: 0; font-family: var(--mincho); font-size: 22px; display: flex; align-items: center; gap: 10px; }
.num { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 15px; }
.link { background: none; border: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; padding: 8px 4px; cursor: pointer; font-size: 14px; }
.hint { margin: 6px 0 12px; font-size: 13px; color: var(--sub); }

.group { border: 0; margin: 0 0 14px; padding: 0; min-width: 0; }
.group legend { font-family: var(--mincho); font-weight: 700; font-size: 15px; padding: 0; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }
.group legend::before { content: ""; width: 14px; height: 3px; background: var(--mustard); border-radius: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span { display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 8px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--chip); box-shadow: var(--shadow); font-size: 15px; cursor: pointer; transition: background .15s, border-color .15s; }
.chip span::before { content: ""; width: 14px; height: 14px; border: 1.5px solid var(--sub); border-radius: 4px; flex: none; }
.chip input:checked + span { background: var(--chip-on); border-color: var(--accent); }
.chip input:checked + span::before { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--chip-on); }
.chip input:focus-visible + span { outline: 3px solid var(--mustard); outline-offset: 2px; }

.dock { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px calc(16px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); background: linear-gradient(transparent, var(--bg) 30%); z-index: 5; }
.go { display: block; width: 100%; max-width: 688px; margin: 0 auto; min-height: 56px; border: 0; border-radius: 16px; background: var(--accent); color: var(--accent-ink); font-size: 17px; font-weight: 700; letter-spacing: .05em; cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,.18); }
.go:disabled { background: var(--line); color: var(--sub); box-shadow: none; cursor: default; }
.go:not(:disabled):active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }

.empty { border: 2px dashed var(--line); border-radius: 16px; padding: 22px 18px; text-align: center; color: var(--sub); }
.empty p { margin: 0 0 12px; }
.sample { border: 1.5px solid var(--accent); background: transparent; color: var(--accent); border-radius: 999px; padding: 10px 16px; cursor: pointer; font-size: 14px; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: 6px 6px 18px 18px; padding: 18px 18px 14px; margin: 0 0 16px; position: relative; box-shadow: 0 6px 18px rgba(80,50,20,.08); }
.card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 6px; border-radius: 6px 6px 0 0; background: repeating-linear-gradient(90deg, var(--accent) 0 12px, transparent 12px 20px); opacity: .7; }
.card h3 { font-family: var(--mincho); font-size: 22px; margin: 6px 0 2px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; color: var(--sub); }
.tag { background: var(--mustard); color: #3b2a1e; border-radius: 6px; padding: 0 8px; font-weight: 700; }
.score { color: var(--herb); font-weight: 700; }
.ing { list-style: none; padding: 0; margin: 12px 0 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 14px; font-size: 14px; }
.ing li { display: flex; gap: 6px; align-items: baseline; }
.ing .mk { flex: none; width: 1.2em; font-weight: 700; }
.ing .have .mk { color: var(--herb); }
.ing .need .mk, .ing .need .nm { color: var(--miss); }
.ing .opt { color: var(--sub); }
.ing .amt { color: var(--sub); font-size: 12px; }
.season { font-size: 13px; color: var(--sub); margin: 0 0 6px; }
details { border-top: 1px dashed var(--line); margin-top: 8px; }
summary { cursor: pointer; padding: 10px 0 4px; font-weight: 700; color: var(--accent); list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "＋ "; }
details[open] summary::before { content: "－ "; }
.steps { margin: 6px 0 4px; padding-left: 1.6em; }
.steps li { margin-bottom: 6px; }

.memo { list-style: none; margin: 0; padding: 14px 16px; background: var(--paper); border-radius: 4px; border-left: 6px solid var(--mustard); }
.memo li { min-height: 46px; display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.memo li:last-child { border-bottom: 0; }
.memo label { display: flex; gap: 10px; align-items: center; width: 100%; cursor: pointer; }
.memo input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.memo .for { margin-left: auto; font-size: 12px; color: var(--sub); text-align: right; }
.memo input:checked ~ .nm { text-decoration: line-through; color: var(--sub); }
.memo .none { color: var(--herb); font-weight: 700; }

.foot { margin-top: 40px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--sub); text-align: center; }
.foot p { margin: 2px 0; }
.foot a { color: var(--accent); }

@media (min-width: 900px) { h1 { font-size: 40px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (prefers-reduced-motion: no-preference) { .card { animation: up .35s ease both; } .card:nth-child(2) { animation-delay: .06s; } .card:nth-child(3) { animation-delay: .12s; } }
@keyframes up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 改行のととのえ */
h1, h2, h3, .sample { text-wrap: balance; }
p, li { text-wrap: pretty; }
.try { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 16px; padding: 12px 14px; border-radius: 14px; background: var(--paper); border: 1.5px dashed var(--mustard); }
.try[hidden] { display: none; }
.try p { margin: 0; font-size: 14px; flex: 1 1 14em; }
.try .sample { min-height: 44px; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.memo.all-done { border-left-color: var(--herb); }
.ln { display: inline-block; }
.try .sample { padding: 10px 22px; }

/* 食材の入力 */
.finder { position: relative; margin: 4px 0 14px; }
.f-label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.f-row { display: flex; gap: 8px; }
.f-row input { flex: 1; min-width: 0; min-height: 50px; padding: 10px 14px; font: inherit; font-size: 16px; color: var(--ink); background: var(--paper); border: 2px solid var(--ink); border-radius: 14px; }
.f-row input::placeholder { color: var(--sub); opacity: .8; }
.f-row input:focus-visible { outline: 3px solid var(--mustard); outline-offset: 1px; }
.add { flex: none; min-width: 72px; min-height: 50px; border: 0; border-radius: 14px; background: var(--ink); color: var(--bg); font-weight: 700; cursor: pointer; }
.sugg { position: absolute; left: 0; right: 0; top: 82px; z-index: 8; list-style: none; margin: 0; padding: 6px; background: var(--paper); border: 1.5px solid var(--line); border-radius: 14px; box-shadow: 0 10px 28px rgba(60,35,15,.18); max-height: 340px; overflow-y: auto; }
.opt { display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.opt[aria-selected="true"], .opt:hover { background: var(--chip-on); }
.o-name { font-weight: 700; }
.o-via { font-size: 12px; color: var(--sub); }
.o-via::before { content: "「"; } .o-via::after { content: "」"; }
.o-cat { margin-left: auto; font-size: 12px; color: var(--sub); white-space: nowrap; }
.o-free .o-name { font-weight: 400; }
.o-season .o-name { font-weight: 400; color: var(--sub); }
.say { margin: 4px 0 0; min-height: 0; font-size: 14px; color: var(--herb); font-weight: 700; }
.say:empty { display: none; }

.picked-wrap { margin: 0 0 16px; padding: 12px 14px; border-radius: 14px; background: var(--paper); border: 1px solid var(--line); }
.picked-wrap[hidden] { display: none; }
.picked-head { margin: 0 0 8px; font-weight: 700; font-size: 14px; }
.picked-head span { color: var(--sub); font-weight: 400; margin-left: 4px; }
.picked { display: flex; flex-wrap: wrap; gap: 6px; }
.pick { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 8px 6px 12px; border-radius: 999px; border: 1.5px solid var(--accent); background: var(--chip-on); cursor: pointer; font-size: 14px; }
.pick .x { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 13px; line-height: 1; }
.pick.free { border-style: dashed; background: transparent; }
.pick.free .x { background: var(--sub); }
.picked-wrap .hint { margin: 8px 0 0; }
.list-head { margin: 4px 0 10px; font-size: 13px; color: var(--sub); font-weight: 700; letter-spacing: .05em; }

.more-btn { margin-top: 8px; border: 0; background: none; color: var(--accent); font-size: 14px; min-height: 40px; padding: 4px 2px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.more-btn[data-on]:not([data-on=""])::after { content: "　" attr(data-on); color: var(--herb); text-decoration: none; font-weight: 700; }
.more-items { margin-top: 8px; }
.chips[hidden] { display: none; }

/* 絞り込み */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.genres { display: flex; flex-wrap: wrap; gap: 6px; }
.fchip { min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--paper); cursor: pointer; font-size: 14px; }
.fchip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.fchip.quick::before { content: "⏱ "; }
.filters .quick { border-color: var(--mustard); }
#pick-msg:empty { display: none; }

.uses { margin: 4px 0 0; font-size: 13px; color: var(--herb); font-weight: 700; }
.score.need { color: var(--sub); }
.tag.t-副菜 { background: #b7c98f; } .tag.t-汁物 { background: #e9c39b; } .tag.t-主食 { background: #e3d2b8; }

/* ほかの候補 */
.ltabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px; scrollbar-width: none; }
.ltab { flex: none; min-height: 40px; padding: 6px 9px; border: 0; border-bottom: 3px solid transparent; background: none; cursor: pointer; font-size: 14px; color: var(--sub); }
.ltab[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 700; }
.ltab:disabled { opacity: .45; cursor: default; }
.clist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.cand { border-bottom: 1px solid var(--line); }
.cand details { border: 0; margin: 0; }
.cand summary { display: block; padding: 12px 2px; color: var(--ink); font-weight: 400; }
.cand summary::before { content: none; }
.c-top { display: flex; gap: 10px; align-items: baseline; }
.c-name { font-family: var(--mincho); font-weight: 700; font-size: 17px; }
.c-buy { margin-left: auto; flex: none; font-size: 12px; color: var(--herb); font-weight: 700; }
.c-buy.need { color: var(--sub); }
.c-sub { display: block; font-size: 12px; color: var(--sub); margin-top: 2px; }
.cand details[open] summary .c-name { color: var(--accent); }
.c-body { padding: 0 2px 14px; }
.c-body .how { border-top: 1px dashed var(--line); }
.use { margin-top: 6px; min-height: 44px; padding: 8px 18px; border-radius: 12px; border: 1.5px solid var(--accent); background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; }
.c-none { padding: 14px 2px; color: var(--sub); font-size: 14px; }
.lmore { display: block; width: 100%; margin-top: 10px; min-height: 46px; border-radius: 12px; border: 1.5px dashed var(--line); background: none; color: var(--accent); cursor: pointer; }
.lmore[hidden], .cands[hidden] { display: none; }
.shop-n { margin-left: auto; font-size: 13px; color: var(--sub); }
.shop .sec-head .link { margin-left: 0; }
/* 自分で入れた食材 */
.chip.free span { border-style: dashed; }
.fc-item { display: inline-flex; align-items: stretch; }
.fc-item .chip span { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: 0; }
.fc-x { min-width: 38px; border: 1.5px dashed var(--line); border-left-style: dotted; border-radius: 0 12px 12px 0; background: var(--chip); color: var(--sub); box-shadow: var(--shadow); cursor: pointer; font-size: 15px; }
.fc-x:hover { color: var(--accent); }
.fc-add { min-height: 42px; padding: 8px 14px; border: 1.5px dashed var(--accent); border-radius: 12px; background: none; color: var(--accent); font-size: 15px; font-weight: 700; cursor: pointer; }
.fc-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; margin-top: 8px; }
.fc-form[hidden] { display: none; }
.fc-row { display: flex; gap: 6px; align-items: center; }
.fc-in { flex: 1; min-width: 0; min-height: 46px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); padding: 8px 12px; font-size: 16px; font-family: inherit; }
.fc-in[aria-invalid=true] { border-color: var(--miss); }
.fc-ok { min-height: 46px; padding: 0 16px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; flex: none; font-family: inherit; }
.fc-no { min-height: 46px; border: 0; background: none; color: var(--sub); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; flex: none; font-size: 14px; font-family: inherit; }
.fc-err { margin: 0; color: var(--miss); font-size: 13px; }
.fc-err:empty { display: none; }

/* iPhone (WebKit) keeps a fieldset at least as wide as its content; let it shrink so nothing overflows narrow screens */
fieldset{min-width:0;min-inline-size:0}
input,select,textarea{max-width:100%}
