:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-fg: #ffffff;
  --warn-fg: #7c2d12;
  --warn-bg: #fef3c7;
  --tab-height: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111827;
    --fg: #f3f4f6;
    --muted: #9ca3af;
    --line: #374151;
    --accent: #60a5fa;
    --accent-fg: #111827;
    --warn-fg: #fef3c7;
    --warn-bg: #78350f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tab-height) + env(safe-area-inset-bottom));
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 1.5rem 0 0.25rem;
}

h2:first-of-type { margin-top: 0.5rem; }

.count { float: right; text-transform: none; letter-spacing: 0; }

.banner {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0.6rem 1rem;
  background: var(--warn-bg);
  color: var(--warn-fg);
  font-size: 0.9rem;
}

/* Rows */
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--line);
}

.row input[type="checkbox"] {
  width: 1.4rem;
  height: 1.4rem;
  flex: none;
  accent-color: var(--accent);
}

/* A native checkbox is only about 22px, too small to hit reliably while
   packing one-handed. The label carries the tap target instead, so tapping
   the item name toggles it. Controls that are not the checkbox – the bag
   picker, rename, delete – stay outside the label, or tapping them would
   toggle it too. A quantity item uses the same grouping as a plain span,
   since there's no boolean to tap-toggle, just a number to type into.
   min-width is a floor, not 0: with more controls on a row than fit at
   375px (a quantity item's number input plus its own extra button), a
   floor of 0 let this shrink to nothing and wrapped the name one letter
   per line. A real floor makes the row wrap the *trailing* controls onto
   a second line instead, which is what flex-wrap on .row is there for. */
.row .tap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1 1 auto;
  min-width: 8rem;
  min-height: 44px;
}
.row label.tap { cursor: pointer; }

.row .name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
/* Packed: finished with. */
.row.done .name { color: var(--muted); text-decoration: line-through; }
/* Not owned yet: still outstanding, so muted but deliberately not struck
   through, which would read as cancelled. */
.row.want .name { color: var(--muted); font-style: italic; }
.row .tag { font-size: 0.75rem; color: var(--muted); flex: none; }
.row select { max-width: 9rem; flex: none; }
.row input[type="number"] { width: 4.5rem; flex: none; }

.row button {
  flex: none;
  min-width: 44px;
  min-height: 44px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
}

/* Add form */
form.add {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  margin-bottom: 1rem;
}

form.add .checks {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  font-size: 0.9rem;
}

form.add label { display: flex; align-items: center; gap: 0.4rem; }

input[type="text"], input[type="number"], select {
  font: inherit;
  padding: 0.6rem;
  min-height: 44px;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 0.375rem;
}

form.add button[type="submit"] {
  font: inherit;
  min-height: 44px;
  padding: 0.6rem;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
}

.empty { color: var(--muted); padding: 2rem 0; text-align: center; }

/* Bottom tab bar */
#tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  height: var(--tab-height);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg);
  border-top: 1px solid var(--line);
}

#tabs button {
  flex: 1;
  font: inherit;
  font-size: 0.85rem;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
}

#tabs button.active {
  color: var(--accent);
  box-shadow: inset 0 2px 0 var(--accent);
}
