:root {
  --accent: #0f766e;
  --accent-soft: #ccfbf1;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #2dd4bf;
    --accent-soft: #134e4a;
    --bg: #0b1120;
    --card: #1e293b;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --border: #334155;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { background: var(--bg); color: var(--text); -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
button { cursor: pointer; }

header {
  position: sticky; top: 0; z-index: 10;
  background: #0f766e; color: #fff;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 12px;
  display: flex; flex-direction: column; gap: 10px;
}
header h1 { font-size: 1.15rem; }
#search { padding: 11px 14px; border-radius: 12px; border: none; font-size: 1rem; width: 100%; }

main { padding: 14px 12px calc(env(safe-area-inset-bottom) + 150px); max-width: 640px; margin: 0 auto; }

.group { margin-bottom: 16px; }
.group h2 {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 4px 6px 8px;
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; user-select: none; -webkit-user-select: none;
}
.card { background: var(--card); border-radius: 14px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.07); }

.row { display: flex; align-items: center; gap: 10px; padding: 2px 12px; min-height: 54px; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: none; }
.row .name { flex: 1; font-size: 1.02rem; padding: 15px 0; user-select: none; -webkit-user-select: none; }
.row.done .name { text-decoration: line-through; color: var(--muted); }
.row.onlist { background: color-mix(in srgb, var(--accent-soft) 45%, var(--card)); }

.check {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  border: 2px solid var(--muted); background: transparent;
  color: #fff; font-size: .95rem; line-height: 1;
}
.row.done .check { background: var(--accent); border-color: var(--accent); }

.stepper { display: flex; align-items: center; background: var(--bg); border-radius: 10px; flex: none; }
.stepper button { width: 40px; height: 40px; border: none; background: transparent; font-size: 1.35rem; color: var(--accent); }
.stepper .qty { min-width: 26px; text-align: center; font-weight: 600; font-size: 1rem; }

.addbtn {
  width: 40px; height: 40px; border-radius: 12px; border: none; flex: none;
  font-size: 1.3rem; line-height: 1; background: var(--bg); color: var(--accent);
}
.addbtn.on { background: var(--accent); color: #fff; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: var(--card); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab { flex: 1; padding: 15px 0; border: none; background: none; font-size: 1rem; color: var(--muted); }
.tab.active { color: var(--accent); font-weight: 700; }
.badge { background: var(--accent); color: #fff; border-radius: 999px; padding: 2px 8px; font-size: .75rem; margin-left: 6px; }

#fab {
  position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 74px); z-index: 10;
  width: 58px; height: 58px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; font-size: 2rem; line-height: 1;
  box-shadow: 0 4px 14px rgba(0,0,0,.28);
}

.login { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 20px; }
.login form { display: flex; flex-direction: column; gap: 12px; width: min(320px, 88vw); }
.login h1 { text-align: center; margin-bottom: 10px; font-size: 1.5rem; }
.login input { padding: 14px; border-radius: 12px; border: 1px solid var(--border); font-size: 1rem; background: var(--card); color: var(--text); }
.login button { padding: 14px; border-radius: 12px; border: none; background: var(--accent); color: #fff; font-size: 1rem; font-weight: 600; }
.error { color: var(--danger); text-align: center; font-size: .9rem; }

dialog { border: none; border-radius: 16px; padding: 20px; width: min(420px, 92vw); background: var(--card); color: var(--text); margin: auto; }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { display: flex; flex-direction: column; gap: 14px; }
dialog h2 { font-size: 1.1rem; }
dialog label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--muted); }
dialog input, dialog select { padding: 12px; border-radius: 10px; border: 1px solid var(--border); font-size: 1rem; background: var(--bg); color: var(--text); }
.dialog-buttons { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.dialog-buttons .spacer { flex: 1; }
.dialog-buttons button { padding: 11px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: .95rem; }
.dialog-buttons .primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.dialog-buttons .danger { background: transparent; color: var(--danger); border-color: var(--danger); }

.empty { text-align: center; color: var(--muted); padding: 56px 24px; line-height: 1.6; }
.listactions { display: flex; justify-content: center; margin-top: 8px; }
.listactions button { border: none; background: none; color: var(--accent); font-size: .95rem; padding: 12px; font-weight: 600; }
.newfromsearch { display: block; margin: 14px auto 0; border: none; background: var(--accent); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: .95rem; font-weight: 600; }
