:root {
  --bg: #f4f6f5; --card: #ffffff; --text: #17201c; --muted: #66726c; --line: #e2e8e5;
  --accent: #2f9e6f; --accent-ink: #ffffff;
  --ok: #2f9e6f; --warn: #d98a00; --bad: #d64545;
  --ok-bg: #e3f4ec; --warn-bg: #fdf0d5; --bad-bg: #fbe4e4; --none-bg: #eceff0;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412; --card: #19211e; --text: #e8efeb; --muted: #94a39b; --line: #27322e;
    --accent: #3cc08a; --accent-ink: #06150e;
    --ok: #3cc08a; --warn: #f0b13a; --bad: #f07070;
    --ok-bg: #173226; --warn-bg: #3a2d10; --bad-bg: #3d1b1b; --none-bg: #222b28;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0; }
.sub { color: var(--muted); margin: 4px 0 12px; }

input, select, button, textarea { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button { border: 0; border-radius: 10px; padding: 11px 14px; background: var(--none-bg); cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.ghost { background: transparent; color: var(--muted); }
button.small { padding: 6px 8px; font-size: 14px; }
button:active { opacity: .7; }

#auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 360px; display: grid; gap: 10px; }
.err { color: var(--bad); min-height: 1.2em; margin: 0; font-size: 14px; }

header { position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  display: flex; justify-content: space-between; align-items: center; }
.who { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
main { padding: 4px 16px calc(90px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }

nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
nav button { flex: 1; background: none; border-radius: 0; padding: 8px 0 7px; font-size: 12px; color: var(--muted); }
nav button span { display: block; font-size: 22px; line-height: 1.2; }
nav button.on { color: var(--accent); font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.add { display: grid; gap: 8px; }
.row { display: grid; grid-template-columns: 1fr 1fr 1.6fr; gap: 8px; }
.row.two { grid-template-columns: 1fr 1fr; }

.item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 8px; display: flex; align-items: center; gap: 10px; }
.item.dim { opacity: .5; }
.item.done b { text-decoration: line-through; color: var(--muted); }
.grow { flex: 1; min-width: 0; }
.grow b { display: block; overflow-wrap: anywhere; }
.sub, .item .sub { color: var(--muted); font-size: 13px; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.none { background: var(--none-bg); color: var(--muted); }
.qty { display: flex; align-items: center; gap: 6px; font-size: 14px; white-space: nowrap; }
.qty button { width: 32px; height: 32px; padding: 0; }
.x { background: none; color: var(--muted); padding: 6px; }
.check { width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 2px solid var(--line); background: none; flex: none; }
.check.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.prio-2 { border-left: 4px solid var(--bad); }
.prio-1 { border-left: 4px solid var(--warn); }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 4px 8px; }

.recipe summary { cursor: pointer; list-style: none; }
.recipe summary::-webkit-details-marker { display: none; }
.recipe h3 { margin: 0 0 4px; font-size: 16px; }
.recipe p { margin: 8px 0 0; }
.tag { font-size: 12px; padding: 1px 7px; border-radius: 99px; margin: 2px 4px 0 0; display: inline-block; }
.tag.have { background: var(--ok-bg); color: var(--ok); }
.tag.miss { background: var(--none-bg); color: var(--muted); }
.tag.exp { background: var(--warn-bg); color: var(--warn); font-weight: 600; }

.habit-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.habit-count { font-size: 34px; font-weight: 700; line-height: 1; }
.habit-count small { font-size: 15px; color: var(--muted); font-weight: 400; }
.habit-count.over { color: var(--bad); }
.habit-btns { display: flex; gap: 8px; align-items: center; }
.habit-btns .primary { font-size: 20px; padding: 10px 22px; }
.bars { display: flex; gap: 6px; height: 80px; align-items: flex-end; margin-top: 14px; }
.bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.bar i { display: block; width: 100%; max-width: 28px; background: var(--accent); border-radius: 5px 5px 2px 2px; min-height: 2px; opacity: .85; }
.bar i.over { background: var(--bad); }
.bar small { font-size: 11px; color: var(--muted); margin-top: 3px; }
.bar em { font-style: normal; font-size: 11px; color: var(--muted); position: absolute; top: 0; }

#toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; z-index: 20; }
#toast.show { opacity: 1; }

.back { display: block; text-align: center; text-decoration: none; font-size: 14px; padding: 6px; }
