:root {
  --bg: #f6f7f4; --card: #fff; --ink: #1d2420; --muted: #6b766f; --line: #e3e7e1;
  --accent: #2f9e5b; --accent-ink: #fff; --danger: #c2413a;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121614; --card: #1c221e; --ink: #e8eee9; --muted: #8e9a92; --line: #2b332e; --accent: #3fb46d; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) calc(env(safe-area-inset-bottom) + 24px) env(safe-area-inset-left); }
[hidden] { display: none !important; }
button, .button { font: inherit; border: 0; border-radius: 12px; cursor: pointer; }
.ghost { background: none; color: var(--accent); padding: 8px 12px; }
.danger { color: var(--danger); }

header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; max-width: 640px; margin: 0 auto; }
h1 { font-size: 26px; margin: 0; }
#count { color: var(--muted); font-weight: 500; font-size: 18px; }
#menu { font-size: 26px; line-height: 1; padding: 4px 10px; }

#status { max-width: 640px; margin: 4px auto 0; padding: 6px 16px; color: var(--muted); font-size: 14px; }
#status.warn { color: #b7791f; }

main { max-width: 640px; margin: 0 auto; padding: 0 12px; }
#add { position: sticky; top: 0; z-index: 2; display: flex; gap: 8px; padding: 10px 4px; background: var(--bg); }
#add input { flex: 1; min-width: 0; font: inherit; font-size: 18px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); outline: none; }
#add input:focus { border-color: var(--accent); }
#add button { width: 50px; font-size: 28px; line-height: 1; background: var(--accent); color: var(--accent-ink); }

#add-to { display: flex; align-items: center; gap: 8px; padding: 0 6px 10px; color: var(--muted); font-size: 15px; }
#add-to select { font: inherit; font-size: 15px; color: var(--ink); background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px 10px; max-width: 70%; }
#add-to select.picked { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.group + .group { margin-top: 16px; }
.group h3 { margin: 0 0 6px; padding: 0 6px; font-size: 15px; font-weight: 700; color: var(--ink); }
.group.manual h3 { color: var(--accent); }
.items { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: 14px; overflow: hidden; }
.items:empty { display: none; }
.items li { display: flex; align-items: center; border-top: 1px solid var(--line); min-height: 54px; }
.items li:first-child { border-top: 0; }
.items .tick { flex: 1; display: flex; align-items: center; gap: 14px; padding: 12px 6px 12px 14px; background: none;
  color: inherit; text-align: left; border-radius: 0; min-width: 0; }
.items .box { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; }
.items .label { overflow-wrap: anywhere; }
.items .more { flex: none; background: none; color: var(--muted); font-size: 22px; line-height: 1; padding: 10px 16px; letter-spacing: 1px; }
.items li.pending .label::after { content: " ·"; color: var(--muted); }
#done li .label { color: var(--muted); text-decoration: line-through; }
#done li .box { border-color: var(--accent); background: var(--accent); }
#done li .box::after { content: "✓"; color: var(--accent-ink); font-size: 15px; font-weight: 700; }
#empty { text-align: center; color: var(--muted); padding: 28px 0; }

#cart { margin-top: 22px; }
.cart-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 6px; }
h2 { font-size: 16px; margin: 0; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

#signin { display: grid; place-items: center; min-height: 70vh; }
.signin-card { text-align: center; background: var(--card); padding: 32px 26px; border-radius: 18px; max-width: 340px; }
.signin-card .big { font-size: 54px; }
.signin-card h2 { text-transform: none; letter-spacing: 0; font-size: 22px; color: var(--ink); margin: 6px 0; }
.signin-card p { color: var(--muted); }
.button { display: inline-block; text-decoration: none; background: var(--accent); color: var(--accent-ink); padding: 13px 22px; font-weight: 600; }

#sheet, #item-sheet { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; z-index: 5; }
.sheet-card { background: var(--card); width: 100%; max-width: 640px; border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 6px; text-align: center; }
.sheet-card p { color: var(--muted); margin: 0 0 6px; }
#item-title { color: var(--ink); font-weight: 600; font-size: 19px; overflow-wrap: anywhere; }
.sheet-card h2 { text-align: left; margin: 4px 2px 2px; }
#move-to { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; max-height: 50vh; overflow-y: auto; }
#move-to button { background: var(--bg); color: var(--ink); padding: 11px 8px; font-size: 15px; border: 1px solid var(--line); }
#move-to button.current { border-color: var(--accent); color: var(--accent); font-weight: 600; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom));
  background: #222a25; color: #fff; border-radius: 12px; padding: 6px 6px 6px 16px; display: flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 18px rgba(0,0,0,.25); z-index: 6; max-width: calc(100% - 24px); }
#toast .ghost { color: #7fe0a6; font-weight: 600; }
