:root {
  --bg: #fdf8f2;
  --card: #ffffff;
  --text: #2b2b33;
  --muted: #7a7a86;
  --accent: #d9483b;
  --accent-soft: #fbe7e4;
  --line: #ece4da;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }

header {
  text-align: center;
  padding: 24px 16px 8px;
}
h1 { margin: 0; font-size: 1.6rem; }

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 16px 48px;
}

#add-form {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1rem;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: var(--card);
}
input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
button[type="submit"] {
  font: inherit;
  font-weight: 600;
  padding: 12px 18px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:disabled, input:disabled { opacity: 0.6; cursor: progress; }
.status { margin: 4px 4px 12px; color: var(--muted); }
.status.error { color: var(--accent); font-weight: 600; }

#toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin: 8px 0 4px;
}
#toolbar #search { grid-column: 1 / -1; padding: 10px 14px; }
#toolbar #category { grid-column: 1 / -1; }
#toolbar select { width: 100%; min-width: 0; }
@media (min-width: 640px) {
  #toolbar { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) auto; }
  #toolbar #category { grid-column: auto; }
}
select {
  font: inherit;
  font-size: 0.95rem;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
}
.checks { grid-column: 1 / -1; display: flex; gap: 16px; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 6px; font-size: 0.95rem; color: var(--text); white-space: nowrap; }
.check input { flex: none; width: 18px; height: 18px; padding: 0; margin: 0; accent-color: var(--accent); }

#summary { color: var(--muted); margin: 4px 4px 10px; }
#empty { text-align: center; color: var(--muted); padding: 32px 0; }

#items { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
}
.thumb {
  flex: none;
  width: 88px;
  height: 88px;
  border-radius: 10px;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  font-size: 2rem;
  overflow: hidden;
  text-decoration: none;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.body { flex: 1; min-width: 0; display: grid; gap: 6px; }
.title {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
a.title:hover { text-decoration: underline; }
.price { font-size: 1.1rem; font-weight: 700; color: var(--accent); }
.delete {
  flex: none;
  align-self: flex-start;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
}
.delete:hover { background: var(--accent-soft); color: var(--accent); }

.note { font-size: 0.85rem; color: var(--muted); margin-top: -2px; }
.smart {
  display: inline-block;
  font-weight: 700;
  font-size: 0.75rem;
  color: #fff;
  background: #ff5a00;
  padding: 1px 6px;
  border-radius: 6px;
}
.group {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin: 14px 4px 0;
  font-weight: 700;
  font-size: 1.05rem;
}
.group:first-child { margin-top: 4px; }
.group-meta { font-weight: 400; font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.badge {
  justify-self: start;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eee;
  color: var(--muted);
}
.item.ended .thumb img { filter: grayscale(1); opacity: 0.6; }
.item.ended .price { color: var(--muted); text-decoration: line-through; }

@media (max-width: 480px) {
  .thumb { width: 72px; height: 72px; }
}
@media (min-width: 640px) { .checks { grid-column: auto; flex-direction: column; gap: 4px; } }

/* guest entry: birth date instead of a password */
#login { max-width: 360px; margin: 24px auto; padding: 0 16px; }
#login-form { display: grid; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
#login-form label { font-weight: 600; text-align: center; }

/* who is reserving (guests) */
#who { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; padding: 10px 12px;
  background: var(--accent-soft); border-radius: 14px; }
#who label { font-weight: 600; }
#who select { flex: 1; min-width: 180px; }
#who.missing { outline: 2px solid var(--accent); }

.reserve-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.reserve, .unreserve {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 10px;
  cursor: pointer;
}
.reserve { border: 0; background: var(--accent); color: #fff; }
.unreserve { border: 1px solid var(--line); background: var(--card); color: var(--muted); }
.badge.taken { background: #e6f2e6; color: #2f6b34; }
.badge.mine { background: #e6f2e6; color: #2f6b34; }
.item.reserved:not(.mine) .thumb img { opacity: 0.55; }
