:root {
  --bg: #f7f7fa;
  --surface: #ffffff;
  --text: #1a1a1c;
  --muted: #6b6b73;
  --accent: #0b6dff;
  --accent-soft: #e6efff;
  --danger: #d92d2d;
  --joel: #1d8a4c;
  --lea: #b5359c;
  --amelie: #d97706;
  --all: #6b6b73;
  --border: #e3e3e8;
  --packed: #b5b5bd;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom);
  --safe-top: env(safe-area-inset-top);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e10;
    --surface: #1c1c1f;
    --text: #f1f1f3;
    --muted: #9a9aa3;
    --accent: #4a90ff;
    --accent-soft: #1c2a44;
    --danger: #ff5a5a;
    --joel: #4ac88a;
    --lea: #e07ecf;
    --amelie: #fbbf24;
    --all: #9a9aa3;
    --border: #2a2a30;
    --packed: #5a5a63;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font: 16px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(220px + var(--safe-bottom));
}

.top {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: calc(12px + var(--safe-top)) 16px 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.top h1 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.progress {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

#bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.25s ease;
}

.stats {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

main {
  padding: 12px 12px 4px;
}

.filter {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.filter button {
  flex: 1;
  min-width: 60px;
  padding: 9px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.filter button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cat {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 14px 6px 6px;
}

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.item.packed {
  opacity: 0.55;
}

.item.packed .name {
  text-decoration: line-through;
  color: var(--packed);
}

.check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  color: transparent;
  transition: all 0.15s ease;
}

.item.packed .check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.check svg {
  width: 16px;
  height: 16px;
}

.body {
  flex: 1;
  min-width: 0;
}

.name {
  font-size: 16px;
  font-weight: 500;
  word-break: break-word;
}

.meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tag.joel { background: color-mix(in srgb, var(--joel) 20%, transparent); color: var(--joel); }
.tag.lea { background: color-mix(in srgb, var(--lea) 20%, transparent); color: var(--lea); }
.tag.amelie { background: color-mix(in srgb, var(--amelie) 22%, transparent); color: var(--amelie); }
.tag.all { background: color-mix(in srgb, var(--all) 18%, transparent); color: var(--all); }

.qty {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.del {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 22px;
  padding: 6px 8px;
  cursor: pointer;
  line-height: 1;
}

.del:active {
  color: var(--danger);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  font-size: 14px;
}

.add {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(56px + var(--safe-bottom));
  padding: 10px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9;
}

.add input,
.add select {
  font: inherit;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}

.add input:focus,
.add select:focus {
  outline: none;
  border-color: var(--accent);
}

.add .row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
}

.add .row select {
  padding-right: 28px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path fill='%236b6b73' d='M6 8L2 4h8z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 10px;
}

.add #quantity {
  width: 58px;
  text-align: center;
}

.add button[type="submit"] {
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 22px;
  font-weight: 600;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  cursor: pointer;
}

.actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 8px;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 8;
}

.actions button {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.actions .danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
}
