:root {
  --teal: #2a7f7e;
  --teal-dark: #1f5f5e;
  --orange: #f2994a;
  --orange-dark: #d9772b;
  --bg: #fbf7f0;
  --card-bg: #ffffff;
  --text: #2c2c2c;
  --muted: #767676;
  --border: #e6ddd0;
  --green: #3aa76d;
  --green-bg: #e6f6ee;
  --red: #d1495b;
  --yellow: #e0a800;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overscroll-behavior-y: contain;
}

/* Alle tikbare elementen minimaal 44px hoog, conform mobiele richtlijnen */
button, .btn, input, textarea, select {
  min-height: 44px;
  font-size: 16px; /* voorkomt automatisch inzoomen bij focus op iOS */
}

.hidden { display: none !important; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(14px + var(--safe-top)) 16px 14px;
  background: var(--teal);
  color: white;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-size: 1.25rem;
  font-weight: 700;
}
.brand span { margin-left: 4px; }
.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.15);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
}
.user-badge .link-btn {
  color: white;
  opacity: 0.85;
  font-size: 0.8rem;
}

#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 14px calc(40px + var(--safe-bottom));
}

@media (min-width: 640px) {
  #app { padding: 24px 16px 80px; }
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  border: 1px solid var(--border);
}
@media (min-width: 640px) {
  .card { padding: 28px; }
}
.center-card {
  max-width: 420px;
  margin: 40px auto;
  text-align: center;
}

.user-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 20px;
}
.user-pick-btn {
  padding: 18px 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--teal-dark);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}
.user-pick-btn:active {
  background: var(--teal);
  color: white;
}

.location-line { margin-top: 2px; }
.next-date-line {
  color: var(--teal-dark);
  font-weight: 700;
  margin: 2px 0 6px;
  font-size: 0.95rem;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

h1 { margin: 0 0 8px; color: var(--teal-dark); }
h2 { color: var(--teal-dark); margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

form { display: flex; flex-direction: column; gap: 6px; }
label { font-weight: 600; margin-top: 10px; font-size: 0.9rem; }

input[type=text], input[type=date], textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  width: 100%;
}
textarea { resize: vertical; min-height: 60px; }

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--orange); color: white; }
.btn-primary:hover { background: var(--orange-dark); }
.btn-secondary { background: var(--teal); color: white; }
.btn-secondary:hover { background: var(--teal-dark); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn-danger:hover { background: var(--red); color: white; }
.btn-block { width: 100%; margin-top: 16px; }

.link-btn {
  background: none;
  border: none;
  color: var(--teal);
  cursor: pointer;
  text-decoration: underline;
  font-size: 0.9rem;
  padding: 0;
}

.error {
  color: var(--red);
  font-weight: 600;
  margin-top: 12px;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}
.list-header h1 { font-size: 1.4rem; }
.list-header .btn { white-space: nowrap; }

.event-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.event-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}
.event-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
.event-card h3 { margin: 0 0 4px; color: var(--teal-dark); }
.event-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 8px;
}
.best-pill {
  display: inline-block;
  background: var(--green-bg);
  color: var(--green);
  border-radius: 999px;
  padding: 2px 10px;
  font-weight: 700;
  font-size: 0.8rem;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  margin-top: 60px;
  font-size: 1.1rem;
}

.date-adder {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.date-adder input { flex: 1; }
.date-adder.compact { max-width: 320px; }

.date-draft-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.date-draft-list li {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.date-draft-list button {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-weight: 700;
}

.back-btn { display: inline-block; margin-bottom: 14px; }

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.detail-header h1 { font-size: 1.35rem; }
@media (max-width: 480px) {
  .detail-header { flex-direction: column; }
  .detail-header .btn-danger { width: 100%; }
}

.detail-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 800px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.dates-panel, .chat-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
@media (min-width: 640px) {
  .dates-panel, .chat-panel { padding: 20px; }
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
}

.date-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-top: 14px;
  position: relative;
}
.date-block.best {
  border-color: var(--green);
  background: var(--green-bg);
}
.date-block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.date-title {
  font-weight: 700;
  font-size: 1.05rem;
}
.date-title .badge {
  margin-left: 8px;
  font-size: 0.75rem;
  background: var(--green);
  color: white;
  border-radius: 999px;
  padding: 2px 8px;
}
.date-actions { display: flex; gap: 8px; align-items: center; }
.remove-date-btn {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: 0.85rem;
}
.score-line {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
}
.my-status-btns {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.my-status-btns button {
  border: 1px solid var(--border);
  background: white;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.9rem;
  min-height: 40px;
  flex: 1 1 auto;
}
.my-status-btns button.active-ja { background: var(--green); color: white; border-color: var(--green); }
.my-status-btns button.active-misschien { background: var(--yellow); color: white; border-color: var(--yellow); }
.my-status-btns button.active-nee { background: var(--red); color: white; border-color: var(--red); }

.response-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.chip {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.chip.ja { background: var(--green-bg); color: var(--green); }
.chip.misschien { background: #fff5df; color: var(--yellow); }
.chip.nee { background: #fbe6e9; color: var(--red); }
.chip .comment-icon { cursor: help; }

.chat-messages {
  max-height: 320px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}
@media (min-width: 800px) {
  .chat-messages { max-height: 420px; }
}
.chat-msg {
  background: var(--bg);
  border-radius: 12px;
  padding: 8px 12px;
  max-width: 90%;
}
.chat-msg .author {
  font-weight: 700;
  color: var(--teal-dark);
  font-size: 0.85rem;
}
.chat-msg .time {
  font-size: 0.7rem;
  color: var(--muted);
  margin-left: 6px;
}
.chat-msg .msg-actions {
  float: right;
}
.chat-msg .msg-actions button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
}
.chat-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  position: sticky;
  bottom: 0;
  background: var(--card-bg);
  padding-top: 6px;
}
.chat-form input { flex: 1; }
.chat-form .btn { flex-shrink: 0; padding: 10px 16px; }
.chat-empty { color: var(--muted); font-size: 0.9rem; text-align: center; padding: 20px 0; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 0;
}
.popover {
  background: white;
  border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(24px + var(--safe-bottom));
  max-width: 480px;
  width: 100%;
}
@media (min-width: 640px) {
  .overlay { align-items: center; padding: 16px; }
  .popover { border-radius: var(--radius); max-width: 360px; padding: 24px; }
}
.popover h3 { margin-top: 0; color: var(--teal-dark); }
.status-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.status-choice {
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  font-size: 0.95rem;
  text-align: left;
}
.status-choice.selected {
  border-color: var(--teal);
  background: #e6f2f2;
  font-weight: 700;
}
.popover-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
}
