:root {
  color-scheme: dark;
  --bg: #152019;
  --bg-2: #1c2a22;
  --card: #24332a;
  --ink: #f3ece0;
  --muted: #b7c0b4;
  --line: #3a4c40;
  --pine: #6fbf7a;
  --pine-dim: #3d7a4a;
  --ember: #d9834f;
  --danger: #d96a5a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 500px at 10% -10%, #2b4334 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  line-height: 1.4;
}

.hidden { display: none !important; }
button, input, select { font: inherit; color-scheme: dark; }
button { cursor: pointer; }

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card, .card, .meal, .person {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.gate-card { width: min(420px, 100%); padding: 28px 24px 24px; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  color: var(--pine);
  margin: 0 0 6px;
}
h1 { margin: 0 0 8px; font-size: 28px; letter-spacing: -0.03em; }
h2 { margin: 0 0 12px; font-size: 18px; }
.lede, .hint { color: var(--muted); font-size: 14px; }
.hint { margin: 8px 0 0; }
code { color: var(--pine); }

#login-form, .dialog-form, .card { display: grid; gap: 12px; }
input, select {
  width: 100%;
  margin-top: 6px;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink);
}
select option,
select optgroup {
  background: var(--card);
  color: var(--ink);
}
button[type="submit"], .edit-only, #item-save {
  background: var(--pine);
  color: #102016;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 700;
}
.ghost, .danger {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 14px;
}
.danger { color: var(--danger); border-color: #6a3a34; }
.error { color: var(--danger); font-size: 14px; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  padding: 18px 16px 8px;
}
.top h1 { font-size: 24px; }
.top-actions { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }
.lock-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}
.lock-btn svg { width: 16px; height: 16px; }
.lock-btn svg,
.dock svg,
.chooser svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.badge {
  background: #314a38;
  color: var(--pine);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.badge.edit { background: #4a3828; color: var(--ember); }

.day-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 16px;
  scroll-snap-type: x mandatory;
}
.day-strip button {
  flex: 1 0 3.15rem;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 3.5rem;
  padding: 6px 4px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--muted);
  line-height: 1.1;
}
.day-strip .dow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.day-strip .dom { font-size: 16px; font-weight: 750; color: var(--ink); }
.day-strip button.on {
  background: var(--pine);
  border-color: var(--pine);
  color: #102016;
}
.day-strip button.on .dom { color: #102016; }
.segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.segment button {
  padding: 14px 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-weight: 750;
}
.segment button.on {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.chooser { display: grid; gap: 8px; margin-bottom: 14px; }
.chooser button {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
}
.chooser .mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--bg-2);
}
.chooser svg { width: 24px; height: 24px; }
.chooser .copy { display: flex; flex-direction: column; min-width: 0; }
.chooser .name { font-size: 17px; font-weight: 750; letter-spacing: -0.02em; }
.chooser .blurb { color: var(--muted); font-size: 13px; font-weight: 500; }
.chooser .count { font-size: 22px; font-weight: 750; color: var(--pine); letter-spacing: -0.03em; }
.chooser button[data-list="food"] .mark { color: var(--pine); }
.chooser button[data-list="booze"] .mark { color: var(--ember); }
.chooser button[data-list="supplies"] .mark { color: #e4d2b0; }
.chooser button.on { border-color: var(--pine); box-shadow: inset 0 0 0 1px var(--pine); }
.chooser button.on .mark { background: #314a38; }
.dock {
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(18, 28, 22, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.dock button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 0 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.02em;
}
.dock-mark {
  width: 44px;
  height: 32px;
  border-radius: 12px;
  display: grid;
  place-items: center;
}
.dock svg { width: 22px; height: 22px; }
.dock button.on { color: var(--pine); }
.dock button.on .dock-mark { background: #314a38; }

main { padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
.meal, .person, .card { padding: 16px; margin: 0 0 14px; }
.meal-head, .person-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.meal-head h2, .person-head h2 { margin: 0; }
.head-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.head-actions .ghost,
.head-actions .danger {
  padding: 6px 10px;
  font-size: 13px;
}
.meal.missing .meal-head { margin-bottom: 0; }
.count { color: var(--muted); font-size: 13px; }
.who {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.chip {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 14px;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.roster-head h2 { margin-bottom: 0; }
.roster {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}
.roster .person { margin: 0; min-width: 0; padding: 12px; }
.person-id { flex: 1 1 8rem; min-width: 0; }
.person-id h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.person-id .hint { margin: 4px 0 0; }
.person-tools {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.person-head { align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.person-head .ghost { padding: 6px 10px; font-size: 13px; }
.person .confirm-line { font-size: 13px; font-weight: 600; white-space: nowrap; }
.person.unconfirmed { border-style: dashed; }
.named-counts, .day-toggles, .day-checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(2rem, 1fr));
  gap: 4px;
}
.day-checks { grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr)); gap: 6px; }
.day-count {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 0;
  background: var(--bg-2);
  border-radius: 10px;
  padding: 6px 2px;
  line-height: 1.1;
}
.day-count .dow { color: var(--muted); }
.day-count .dow,
.day-toggle .dow {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.day-count .dom { font-size: 12px; color: var(--ink); }
.day-count strong { font-size: 15px; color: var(--pine); }
.day-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 0;
  min-height: 2.7rem;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 4px 0;
  line-height: 1.1;
}
.day-toggle .dom { font-size: 13px; font-weight: 700; color: var(--ink); }
.day-toggle.on {
  background: var(--pine);
  border-color: var(--pine);
  color: #102016;
  font-weight: 700;
}
.day-toggle.on .dom { color: #102016; }
body.readonly .day-toggle { cursor: default; pointer-events: none; }
.days-field {
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 0;
  padding: 10px 12px 12px;
}
.days-field legend { padding: 0 6px; color: var(--muted); font-size: 13px; }
.check-day {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
}
.check-day input { width: auto; margin: 0; }
.confirm-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
}
.confirm-line input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--pine);
}
.person.unconfirmed h2 { color: var(--muted); }
.headcount {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
}
.headcount strong { color: var(--ink); }
.headcount input { width: 55px; margin: 0 5px; padding: 8px 10px; }
.total-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.total-line strong { font-size: 15px; }
.total-line span { text-align: right; }
select#summary-person, select#set-year { margin-top: 6px; }
body.readonly .confirm-line input { pointer-events: none; }
.table-wrap { overflow-x: auto; }
.meal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.meal-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
  padding: 8px 8px 6px 0;
}
.meal-table td {
  padding: 10px 8px 10px 0;
  border-top: 1px solid var(--line);
  vertical-align: top;
}
.meal-table .col-qty,
.meal-table .col-unit { white-space: nowrap; }
.meal-table .col-camper { color: var(--ember); }
.meal-table .col-action { width: 1%; text-align: right; padding-right: 0; }
.meal-table .empty-row { color: var(--muted); }
body:not(.readonly) .meal-table .col-item { cursor: pointer; }
.item-remove {
  padding: 6px 10px;
  font-size: 13px;
}
.grocery-edit, .meal-only, .year-only { display: grid; gap: 12px; }
.grocery-edit[hidden], .meal-only[hidden], .year-only[hidden], #grocery-readout[hidden],
.grocery-name[hidden], .grocery-pick[hidden], #choose-existing[hidden], #new-grocery-hint[hidden] { display: none; }
.text-link {
  justify-self: start;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--pine);
  font-weight: 650;
}
.grocery-pick .meal-head { margin-bottom: 0; }
.grocery-pick .meal-head span { font-weight: 650; }
.use-table select,
.use-table input { margin: 0; padding: 6px 8px; font-size: 13px; }
.camper-picker { position: relative; }
.camper-picker-label {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--ink);
}
.camper-picker select {
  display: none;
  position: absolute;
  z-index: 5;
  left: 0;
  min-width: 11rem;
  margin-top: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.camper-picker.open select { display: block; }
.grocery-pick { display: grid; }
.grocery-picker-label,
.grocery-picker-option {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--ink);
  font-weight: 500;
}
.grocery-picker-label { margin-top: 6px; }
.grocery-picker-list {
  display: none;
  max-height: 16rem;
  overflow: auto;
  margin-top: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.grocery-picker.open .grocery-picker-list { display: block; }
.grocery-picker-search {
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 10px 10px 0 0;
  background: var(--bg-2);
}
.grocery-picker-empty {
  margin: 0;
  padding: 12px 10px;
  color: var(--muted);
  font-size: 13px;
}
.grocery-picker-group {
  margin: 0;
  padding: 8px 10px 4px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.grocery-picker-option {
  background: transparent;
  border: 0;
  border-radius: 0;
}
.grocery-picker-option.on { background: #314a38; color: var(--pine); }
.meal-only .table-wrap { overflow: visible; }
.use-table .col-qty input { width: 72px; }

.title { font-weight: 650; }
.meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.add {
  width: 100%;
  margin-top: 8px;
  background: transparent;
  color: var(--pine);
  border: 1px dashed var(--pine-dim);
  border-radius: 12px;
  padding: 10px;
}

.day-hero { margin: 4px 0 14px; }
.day-hero h2 { font-size: 22px; margin: 0; }
.day-hero p { margin: 4px 0 0; color: var(--muted); }

.row { display: flex; gap: 8px; }
.row button { flex: 1; }

dialog {
  border: 0;
  border-radius: 18px;
  padding: 0;
  background: transparent;
  width: min(720px, calc(100vw - 24px));
}
dialog::backdrop { background: rgba(8, 12, 10, 0.72); }
.dialog-form { background: var(--card); padding: 20px; border-radius: 18px; border: 1px solid var(--line); }

.readonly .edit-only,
.readonly .add { display: none !important; }

@media (min-width: 720px) {
  .roster { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 800px) {
  #app { max-width: 820px; margin: 0 auto; }
  .dock {
    width: min(820px, 100%);
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    border-radius: 20px 20px 0 0;
  }
}
