:root {
  --paper: #fbf6ee;
  --paper-2: #f4ebdd;
  --card: #fffdf9;
  --ink: #3b2a1e;
  --ink-soft: #7a6553;
  --line: #e6d8c3;
  --cranberry: #7a1f2b;
  --cranberry-2: #9b2c3a;
  --pumpkin: #c8641e;
  --gold: #b8862b;
  --sage: #6b7b4b;
  --plum: #5b3a55;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(59, 42, 30, 0.06), 0 6px 20px rgba(59, 42, 30, 0.06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Lato", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 50% -200px, #f3e2c7 0%, transparent 70%),
    var(--paper);
  line-height: 1.45;
  min-height: 100vh;
}

h1, h2, h3 { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 600; margin: 0; }

/* ---------- Header ---------- */
.hero {
  text-align: center;
  padding: 36px 20px 24px;
}
.leaves { width: min(520px, 90%); height: auto; display: block; margin: 0 auto 8px; }
.eyebrow {
  margin: 0;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--gold);
  font-weight: 700;
}
.hero h1 {
  font-size: clamp(2.8rem, 9vw, 4.6rem);
  line-height: 1;
  color: var(--cranberry);
  margin-top: 6px;
}
.tagline {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-size: 1.35rem;
  margin: 4px 0 16px;
  color: var(--ink-soft);
}
.progress {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.progress .bar {
  width: 140px; height: 6px; border-radius: 99px;
  background: var(--line); overflow: hidden;
}
.progress .bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--pumpkin), var(--cranberry)); transition: width .4s ease; }
.progress button {
  border: 0; background: none; padding: 0; font: inherit;
  color: var(--cranberry); text-decoration: underline; cursor: pointer;
}

/* ---------- Layout ---------- */
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px 40px; }

.toolbar {
  display: flex; flex-wrap: wrap; gap: 12px;
  justify-content: space-between; align-items: center;
  margin-bottom: 18px;
}
.seg {
  display: inline-flex; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: 99px; padding: 3px;
}
.seg button {
  border: 0; background: none; font: inherit; font-weight: 700; font-size: 0.9rem;
  color: var(--ink-soft); padding: 7px 16px; border-radius: 99px; cursor: pointer;
}
.seg button.active { background: var(--cranberry); color: #fff; box-shadow: var(--shadow); }
.filter { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--ink-soft); }

.note {
  margin: 0 0 18px; padding: 10px 14px;
  background: #fff6e6; border: 1px dashed #e7c48f; border-radius: 10px;
  font-size: 0.92rem; color: #7a5420;
}

select, input[type="text"] {
  font: inherit; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; min-height: 40px;
}
select { cursor: pointer; padding-right: 28px; }
select:focus, input:focus, button:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }

/* ---------- Cards / groups ---------- */
.list { display: grid; gap: 18px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.group > header {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--line);
}
.group h2 { font-size: 1.6rem; color: var(--cranberry); display: flex; align-items: center; gap: 10px; }
.group .count { font-size: 0.8rem; color: var(--ink-soft); }
.group.person h2 .dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

.item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center; gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid #f0e6d6;
  transition: background .3s ease;
}
.item:last-child { border-bottom: 0; }
.item.flash { background: #fdf0dc; }
.item .name { font-weight: 700; }
.item .cat { display: block; font-weight: 400; font-size: 0.78rem; color: var(--ink-soft); }
.item.open .name::after {
  content: "Needs someone"; margin-left: 8px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--pumpkin); background: #fdeedd; border-radius: 99px; padding: 2px 8px; vertical-align: 2px;
  display: inline-block; white-space: nowrap;
}
.group.person .item.open .name::after { content: none; }
.add form > * { min-width: 0; width: 100%; }
.item select { min-width: 168px; border-left-width: 5px; }
.item select.p-0 { border-left-color: var(--cranberry); }
.item select.p-1 { border-left-color: var(--pumpkin); }
.item select.p-2 { border-left-color: var(--sage); }
.item select.p-3 { border-left-color: var(--gold); }
.item select.p-none { border-left-color: var(--line); color: var(--ink-soft); font-style: italic; }

.remove {
  border: 0; background: none; cursor: pointer;
  width: 34px; height: 34px; border-radius: 50%;
  color: var(--ink-soft); font-size: 1.1rem; line-height: 1;
}
.remove:hover { background: #f8e4e4; color: var(--cranberry); }
.remove[hidden] { display: inline-block; visibility: hidden; }

.group-note {
  margin: 0; padding: 10px 18px;
  background: #fff6e6; border-bottom: 1px dashed #e7c48f;
  font-size: 0.92rem; color: #7a5420;
}
.empty { padding: 16px 18px; color: var(--ink-soft); font-style: italic; margin: 0; }
.loading { text-align: center; color: var(--ink-soft); font-style: italic; }

.dot.p-0 { background: var(--cranberry); }
.dot.p-1 { background: var(--pumpkin); }
.dot.p-2 { background: var(--sage); }
.dot.p-3 { background: var(--gold); }
.dot.p-none { background: transparent; border: 2px dashed var(--ink-soft); }

/* ---------- Add form ---------- */
.add { margin-top: 26px; padding: 18px; }
.add h2 { font-size: 1.45rem; color: var(--cranberry); margin-bottom: 12px; }
.add form { display: grid; grid-template-columns: 2fr 1.3fr 1.3fr auto; gap: 10px; }
.btn {
  font: inherit; font-weight: 700; cursor: pointer;
  background: var(--cranberry); color: #fff; border: 0; border-radius: 10px;
  padding: 9px 18px; min-height: 40px;
}
.btn:hover { background: var(--cranberry-2); }
.btn:disabled { opacity: .6; cursor: default; }
.hint { margin: 10px 0 0; font-size: 0.82rem; color: var(--ink-soft); }

.foot { text-align: center; color: var(--ink-soft); font-size: 0.8rem; padding: 10px 0 36px; font-style: italic; font-family: "Cormorant Garamond", Georgia, serif; font-size: 1rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 30px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 0.92rem; opacity: 0; pointer-events: none; transition: all .25s ease;
  width: max-content; max-width: calc(100% - 32px); text-align: center; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--cranberry); }

/* ---------- Mobile ---------- */
@media (max-width: 560px) {
  .item { grid-template-columns: 1fr auto; padding: 10px 14px; }
  .item select { grid-column: 1 / 2; min-width: 0; width: 100%; }
  .item .remove { grid-row: 1 / 3; grid-column: 2; width: 42px; height: 42px; }
  .add form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .add form input { grid-column: 1 / -1; }
  .add form .btn { grid-column: 1 / -1; }
  .group > header { padding: 12px 14px 8px; }
  .progress { flex-direction: column; gap: 6px; }
  .progress .bar { width: 200px; }
  .progress button { padding: 8px 6px; margin: -4px 0; }
  .toolbar { justify-content: center; }
  .filter select { min-width: 200px; }
}
