:root {
  --bg: #ffffff; --fg: #1b1f1d; --muted: #6b726e; --line: #e3e6e4; --card: #f4f6f5; --accent: #2f7d4f; --accent-fg: #ffffff; --danger: #c0392b;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121413; --fg: #e8ebe9; --muted: #9aa29e; --line: #2a2e2c; --card: #1c1f1e; --accent: #4caf78; --accent-fg: #0d1a12; --danger: #e57368; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 0 0 calc(64px + env(safe-area-inset-bottom));
}
main { max-width: 720px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); }
h1 { font-size: 24px; margin: 0; flex: 1; overflow-wrap: anywhere; }
h2 { font-size: 19px; margin: 24px 0 8px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 4px; }
header { display: flex; align-items: center; gap: 8px; min-height: 60px; position: sticky; top: 0; background: var(--bg); z-index: 2; padding-top: env(safe-area-inset-top); }
button, .btn, input, select, textarea { font: inherit; color: inherit; }
button, .btn {
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.danger { color: var(--danger); }
.wide { width: 100%; margin-top: 12px; }
.icon { min-width: 44px; padding: 0; font-size: 24px; background: none; border: none; color: var(--accent); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; }
.back { font-size: 36px; text-decoration: none; padding: 0 10px 4px 0; line-height: 1; }
input, select, textarea { width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); }
textarea { resize: vertical; }
label { display: block; font-size: 14px; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--fg); font-size: 17px; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { border-bottom: 1px solid var(--line); }
.row { display: flex; align-items: center; min-height: 56px; color: inherit; text-decoration: none; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.count { color: var(--muted); }
.item { display: flex; align-items: center; }
.tap { flex: 1; display: flex; align-items: center; gap: 14px; text-align: left; background: none; border: none; border-radius: 0; padding: 10px 0; min-height: 56px; justify-content: flex-start; }
.tap small { display: block; color: var(--muted); font-size: 14px; }
.box { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--muted); flex: none; }
.done .box { background: var(--accent); border-color: var(--accent); }
.done .name { text-decoration: line-through; color: var(--muted); }
.qty { color: var(--muted); }
.item .icon { font-size: 18px; color: var(--muted); }
.add { display: flex; gap: 8px; margin: 4px 0 8px; }
details { margin-top: 20px; }
summary { min-height: 44px; display: flex; align-items: center; color: var(--muted); cursor: pointer; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }
.search { display: flex; gap: 8px; margin-bottom: 12px; }
.search select { width: 40%; }
.cards { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; background: var(--card); border-radius: 12px; overflow: hidden; }
.card a { display: block; color: inherit; text-decoration: none; flex: 1; }
.card img, .noimg { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--line); }
.card span { display: block; padding: 8px 10px; font-size: 15px; line-height: 1.3; }
.card small { color: var(--muted); font-size: 13px; padding: 0 10px 8px; }
.cardacts { display: flex; gap: 6px; padding: 0 8px 8px; }
.cardacts button { flex: 1; min-height: 36px; padding: 0 8px; font-size: 14px; background: var(--bg); }
.plan.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.seg { display: flex; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; border: none; border-radius: 0; background: var(--card); font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--accent); color: var(--accent-fg); }
.hero { width: 100%; max-height: 50vh; object-fit: cover; border-radius: 12px; }
.meta, .muted { color: var(--muted); }
.tags a { display: inline-block; padding: 4px 10px; margin: 0 6px 6px 0; border-radius: 999px; background: var(--card); text-decoration: none; font-size: 14px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.btns > * { flex: 1; }
.note { white-space: pre-wrap; }
.ings { list-style: none; padding: 0; margin: 0; }
.ings li:not(.heading) { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); min-height: 48px; }
.pick li { padding: 4px 0; }
.heading { list-style: none; font-weight: 600; margin: 12px 0 0; }
.add1 { flex: none; min-height: 36px; width: 36px; padding: 0; border-radius: 50%; font-size: 20px; color: var(--accent); background: none; transition: background .2s, color .2s; }
.add1.added { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.kebab { font-size: 22px; color: var(--muted); }
#menu { position: absolute; z-index: 5; min-width: 160px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 6px 24px rgb(0 0 0 / .18); padding: 4px; display: flex; flex-direction: column; }
#menu button { border: none; background: none; justify-content: flex-start; border-radius: 8px; }
.leaving { animation: leave 2s linear forwards; }
@keyframes leave { from { opacity: 1; } to { opacity: .3; } }
.steps { padding-left: 24px; }
.steps li { padding: 8px 4px; }
.steps.cooking li { font-size: 20px; padding: 14px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.steps.cooking li.done { color: var(--muted); text-decoration: line-through; }
pre { white-space: pre-wrap; font: inherit; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 12px; padding-bottom: 16px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
dialog { width: min(92vw, 520px); max-height: 85vh; border: none; border-radius: 16px; background: var(--bg); color: var(--fg); padding: 16px; }
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog h2 { margin: 0; }
.pick { list-style: none; padding: 0; margin: 0; }
.pick .heading { margin: 8px 0 0; }
.pick label { display: flex; align-items: center; gap: 10px; color: var(--fg); font-size: 16px; min-height: 40px; }
.pick input { width: 22px; min-height: 22px; flex: none; margin: 0; }
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--bg); border-top: 1px solid var(--line); z-index: 3;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { flex: 1; text-align: center; padding: 14px 0; color: var(--muted); text-decoration: none; font-weight: 600; }
.tabs a.on { color: var(--accent); }
#toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--fg); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 4; max-width: 90vw;
}
#toast.show { opacity: 1; }
#toast.actionable { pointer-events: auto; display: flex; align-items: center; gap: 12px; }
#toast .undo { min-height: 36px; padding: 0 12px; background: none; border: none; color: inherit; font-weight: 700; text-decoration: underline; }
.login { padding-top: 20vh; max-width: 360px; }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.bad { color: var(--danger); margin: 0; }
