:root {
  --bg: #f6f5f0;
  --paper: #ffffff;
  --ink: #1d2620;
  --ink-soft: #5b6660;
  --line: #e3e0d6;
  --primary: #0f766e;
  --primary-soft: #d6efeb;
  --accent: #e8a838;
  --yes: #2c8a4a;
  --yes-soft: #e3f3e8;
  --maybe: #d39024;
  --maybe-soft: #fbf1dd;
  --no: #c0413a;
  --no-soft: #fbe3e1;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 18px rgba(0,0,0,.06);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  padding-bottom: 84px;
  min-height: 100vh;
}

[hidden] { display: none !important; }
svg { width: 22px; height: 22px; flex-shrink: 0; }

/* HEADER */
.app-header {
  position: sticky; top: 0; z-index: 30;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  padding-top: max(14px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { width: 28px; height: 28px; color: var(--primary); }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: .2px; font-weight: 700; }
.who {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--primary-soft); color: var(--primary);
  border: 0; border-radius: 999px;
  padding: 5px 14px 5px 5px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.who #who-avatar { display: inline-flex; }
.who .swap { opacity: .55; width: 14px; height: 14px; }

main { padding: 18px; max-width: 720px; margin: 0 auto; }

/* SECTIONS */
.section {
  background: var(--paper); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.section.intro { background: linear-gradient(135deg, #fff 0%, #faf7ec 100%); }
.section h2 { margin: 0 0 4px; font-size: 18px; }
.section .sub, p.sub { color: var(--ink-soft); font-size: 13px; margin: 0 0 14px; line-height: 1.45; }
.section .sub b { color: var(--ink); font-weight: 600; }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 10px;
  background: var(--primary); color: white;
  padding: 11px 16px; font-size: 15px; font-weight: 600;
  cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--paper); color: var(--ink); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.danger { background: transparent; color: var(--no); border: 1px solid transparent; padding: 8px; }
.btn.icon { width: 38px; height: 38px; padding: 0; }
.btn.full { width: 100%; }
.btn.small { padding: 8px 12px; font-size: 13px; }

input[type="text"], input[type="date"] {
  -webkit-appearance: none; appearance: none;
  border: 1px solid var(--line); background: var(--paper);
  border-radius: 10px; padding: 11px 14px; font-size: 16px; font-family: inherit;
  color: var(--ink); width: 100%;
}
input[type="text"]:focus, input[type="date"]:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

label.lbl { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.row { display: flex; gap: 8px; }
.row > input { flex: 1; min-width: 0; }
.muted { color: var(--ink-soft); font-size: 13px; }

/* AVATAR */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: white;
  border-radius: 50%; font-weight: 700;
  flex-shrink: 0; overflow: hidden;
}
.avatar.img { padding: 0; background: var(--line); }
.avatar.img img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* RSVP HERO (na keuze) */
.rsvp-hero {
  background: var(--paper);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.rsvp-banner {
  background: linear-gradient(135deg, var(--primary) 0%, #0d6660 100%);
  color: white;
  padding: 22px 20px 24px;
  text-align: center;
}
.rsvp-eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; opacity: .85; font-weight: 600; margin-bottom: 4px; }
.rsvp-date { font-size: 24px; font-weight: 700; letter-spacing: .3px; }
.rsvp-body { padding: 18px 18px 20px; }
.rsvp-question { font-size: 16px; font-weight: 700; margin-bottom: 10px; }
.rsvp-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rsvp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 2px solid var(--line); background: var(--paper);
  border-radius: 12px; padding: 14px 8px;
  font-size: 15px; font-weight: 700; color: var(--ink-soft);
  cursor: pointer; font-family: inherit;
}
.rsvp-btn svg { width: 18px; height: 18px; }
.rsvp-btn.yes.on { background: var(--yes); color: white; border-color: var(--yes); }
.rsvp-btn.no.on { background: var(--no); color: white; border-color: var(--no); }
.rsvp-extra { margin-top: 12px; padding: 12px; background: var(--bg); border-radius: 12px; }
.rsvp-extra .meal-row { flex-wrap: wrap; }
.rsvp-extra .allergie-in { margin-top: 10px; }

.other-dates { margin-top: 14px; }
.other-dates-list { margin-top: 12px; }

/* MINI date cards (pre keuze) */
.date-mini {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.date-mini-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.date-mini-day { font-size: 15px; font-weight: 700; }
.date-mini .counts { display: flex; gap: 4px; }
.date-mini .counts .pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 24px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
}
.date-mini .counts .pill.yes { background: var(--yes-soft); color: #1d6435; }
.date-mini .counts .pill.maybe { background: var(--maybe-soft); color: #8a5e10; }
.date-mini .counts .pill.no { background: var(--no-soft); color: #7c2421; }

/* (legacy) DATES big cards still referenced via class fallback - now unused */
.date-big {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.date-big.chosen { border-color: var(--primary); border-width: 2px; }
.date-big-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--primary-soft) 0%, #ecf6f4 100%);
  border-bottom: 1px solid var(--line);
}
.date-big.chosen .date-big-head { background: linear-gradient(135deg, var(--primary) 0%, #0d6660 100%); color: white; }
.date-big-day { font-size: 17px; font-weight: 700; letter-spacing: .2px; }
.chosen-pill { background: rgba(255,255,255,.25); color: white; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.date-big-body { padding: 14px 18px; }

.vote-block { margin-bottom: 14px; }
.vote-label { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; font-weight: 600; }
.vote-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.vote-buttons.mini { display: flex; gap: 4px; }
.vote-buttons.mini .vote-btn { padding: 6px 10px; font-size: 13px; }
.vote-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border: 1px solid var(--line); background: var(--paper);
  border-radius: 10px; padding: 10px 8px;
  font-size: 14px; font-weight: 600;
  color: var(--ink-soft); cursor: pointer;
}
.vote-btn svg { width: 16px; height: 16px; }
.vote-btn.yes.on { background: var(--yes); color: white; border-color: var(--yes); }
.vote-btn.maybe.on { background: var(--maybe); color: white; border-color: var(--maybe); }
.vote-btn.no.on { background: var(--no); color: white; border-color: var(--no); }

.meal-block { margin-top: 12px; padding: 10px 12px; background: var(--bg); border-radius: 10px; }
.meal-row { display: flex; gap: 8px; }
.check-pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--paper);
  border-radius: 999px; padding: 6px 12px 6px 6px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  user-select: none;
}
.check-pill .cb {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  color: white;
}
.check-pill .cb svg { width: 14px; height: 14px; display: none; }
.check-pill.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.check-pill.on .cb { background: var(--primary); border-color: var(--primary); }
.check-pill.on .cb svg { display: block; }
.allergie-in { margin-top: 10px; }

.people-grid-wrap { margin-top: 14px; }
.grid-label { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; margin-bottom: 6px; }
.people-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.avatar-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 12px 4px 4px;
  cursor: pointer; font-size: 13px; font-weight: 600;
  color: var(--ink);
}
.avatar-chip:hover { border-color: var(--primary); }
.avatar-chip .chip-name { white-space: nowrap; }

/* TASKS */
.task-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.task-tabs button {
  flex: 1; border: 1px solid var(--line); background: var(--paper);
  border-radius: 10px; padding: 8px 10px; font-size: 14px; font-weight: 600;
  color: var(--ink-soft); cursor: pointer;
}
.task-tabs button.active { background: var(--ink); color: white; border-color: var(--ink); }

.task { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; background: #fbfaf6; }
.task.done { background: #f1f4f1; }
.task-head { display: flex; align-items: flex-start; gap: 12px; }
.task-check {
  flex-shrink: 0; width: 26px; height: 26px;
  border: 2px solid var(--ink-soft); border-radius: 8px;
  background: white; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  color: white; margin-top: 2px;
}
.task.done .task-check { background: var(--primary); border-color: var(--primary); }
.task.done .task-check svg { width: 18px; height: 18px; }
.task:not(.done) .task-check svg { display: none; }
.task-body { flex: 1; min-width: 0; }
.task-text { font-weight: 600; font-size: 15px; word-wrap: break-word; }
.task.done .task-text { text-decoration: line-through; color: var(--ink-soft); }
.task-meta { font-size: 12px; color: var(--ink-soft); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.task-meta .who-tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--primary-soft); color: var(--primary);
  padding: 2px 10px 2px 2px;
  border-radius: 999px; font-weight: 600;
}
.task-meta .who-tag svg { width: 14px; height: 14px; }
.task-meta .who-tag.unassigned { background: #f1ede0; color: var(--ink-soft); padding: 2px 10px; }
.who-mini { display: inline-flex; }
.who-mini .avatar { width: 18px !important; height: 18px !important; font-size: 10px !important; }

.task-actions { display: flex; align-items: flex-start; gap: 0; }
.task-photos { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.photo-thumb { position: relative; width: 70px; height: 70px; border-radius: 10px; overflow: hidden; background: var(--line); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer; }
.photo-thumb .x {
  position: absolute; top: 3px; right: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: white;
  border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.photo-thumb .x svg { width: 14px; height: 14px; }
.photo-add {
  width: 70px; height: 70px;
  border-radius: 10px; border: 2px dashed var(--line);
  background: white;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-soft);
}
.photo-add svg { width: 26px; height: 26px; }
.photo-add input { display: none; }

/* PEOPLE */
.people-list { display: grid; gap: 10px; }
.person-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border: 1px solid var(--line); background: #fbfaf6;
  border-radius: 12px;
}
.person-card.me { border-color: var(--primary); background: var(--primary-soft); }
.person-info { flex: 1; min-width: 0; }
.person-name { font-weight: 700; font-size: 15px; }
.person-name .you { font-weight: 500; color: var(--primary); font-size: 13px; }
.person-tags { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--accent); background: #fdf3df; color: #8a5e10;
  border: 1px solid #ecd9a8;
  border-radius: 999px; padding: 3px 10px;
  font-size: 12px; font-weight: 500;
}
.tag-chip.mini { padding: 2px 8px; font-size: 11px; }
.tag-x { background: transparent; border: 0; color: inherit; cursor: pointer; padding: 0; display: inline-flex; }
.tag-x svg { width: 12px; height: 12px; }

/* TABS */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--paper); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(3, 1fr);
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  background: none; border: 0; padding: 10px 0 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--ink-soft); font-size: 12px; font-weight: 600;
}
.tabs button.active { color: var(--primary); }

/* MODAL */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(20, 25, 22, .55);
  z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-back.center { align-items: center; }
.modal {
  background: var(--paper);
  width: 100%; max-width: 480px;
  border-radius: 18px 18px 0 0;
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  max-height: 90vh; overflow-y: auto;
  animation: slideUp .25s ease;
}
.modal-back.center .modal { border-radius: 18px; animation: pop .2s ease; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes pop { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h2 { margin: 0 0 4px; }

.name-list { display: grid; gap: 8px; margin-bottom: 14px; max-height: 50vh; overflow-y: auto; }
.name-list button {
  text-align: left; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: white;
  font-size: 16px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  color: var(--ink);
}
.name-list button:hover { border-color: var(--primary); background: var(--primary-soft); }
.name-list button .ck {
  width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; color: white;
  flex-shrink: 0;
}
.name-list button .ck svg { width: 14px; height: 14px; display: none; }
.name-list button.sel { border-color: var(--primary); background: var(--primary-soft); }
.name-list button.sel .ck { background: var(--primary); border-color: var(--primary); }
.name-list button.sel .ck svg { display: block; }

.divider { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: 13px; margin: 14px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.empty { color: var(--ink-soft); text-align: center; padding: 18px 8px; font-size: 14px; }

/* PROFILE SETUP */
.profile-photo-row { display: flex; justify-content: center; margin: 16px 0 18px; }
.avatar-upload {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer;
}
.avatar-preview {
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--bg); border: 2px dashed var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-soft); overflow: hidden;
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-preview .avatar { width: 100% !important; height: 100% !important; font-size: 36px !important; border-radius: 0; }
.avatar-preview svg { width: 32px; height: 32px; }
.avatar-upload-hint { font-size: 12px; color: var(--ink-soft); font-weight: 600; }

.tag-suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.sug-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px 6px 6px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  color: var(--ink-soft);
  font-family: inherit;
}
.sug-chip .sug-mark {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--line);
  color: var(--ink-soft);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  line-height: 1;
}
.sug-chip .sug-mark svg { width: 12px; height: 12px; color: white; }
.sug-chip.on { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.sug-chip.on .sug-mark { background: var(--primary); border-color: var(--primary); color: white; }

.tag-input-wrap { border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: var(--paper); }
.tag-input-wrap:focus-within { border-color: var(--primary); outline: 2px solid var(--primary-soft); }
.tag-input-wrap input { border: 0; padding: 6px 4px; outline: none; }
.tag-input-wrap input:focus { outline: none; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.tag-list:empty { display: none; }
.hint { font-size: 11px; color: var(--ink-soft); margin: 4px 0 0; }

.profile-head { display: flex; align-items: center; gap: 14px; }

.others-list { display: grid; gap: 8px; margin-top: 6px; max-height: 60vh; overflow-y: auto; }
.oth-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fbfaf6;
}
.oth-name { display: flex; align-items: center; gap: 10px; font-weight: 600; min-width: 0; }
.oth-name span:not(.avatar) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.toast {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%);
  background: var(--ink); color: white; padding: 10px 16px;
  border-radius: 999px; font-size: 14px; z-index: 100;
  box-shadow: var(--shadow);
  animation: toast .25s ease;
}
@keyframes toast { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translate(-50%, 0); } }

.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 80; padding: 20px;
}
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox .close {
  position: absolute; top: 16px; right: 16px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,.15); border: 0; color: white; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

@media (min-width: 600px) {
  .vote-buttons { grid-template-columns: repeat(3, 1fr); }
}
