:root {
  --bg: #f7f5fb;
  --surface: #ffffff;
  --surface-2: #f0edf7;
  --text: #1f1b2d;
  --muted: #6b6680;
  --border: #e3dfee;
  --primary: #6c5ce7;
  --primary-ink: #ffffff;
  --primary-soft: #ece9fd;
  --success: #1f9d61;
  --success-soft: #e3f6ec;
  --danger: #d63a4a;
  --danger-soft: #fde8ea;
  --warn: #b7791f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 27, 45, .06), 0 4px 16px rgba(31, 27, 45, .06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15131c;
    --surface: #1f1c29;
    --surface-2: #2a2637;
    --text: #f0eef6;
    --muted: #a39fb4;
    --border: #353046;
    --primary: #8f83f0;
    --primary-ink: #15131c;
    --primary-soft: #2e2a4a;
    --success: #4cc98b;
    --success-soft: #1d3329;
    --danger: #f06b78;
    --danger-soft: #3a2026;
    --warn: #e0a84b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

a { color: var(--primary); }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }

.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: .875rem; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

#topnav { display: flex; align-items: center; gap: .5rem; min-width: 0; }
#topnav .who { color: var(--muted); font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 16px 4rem;
}

/* ---------- buttons & forms ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: .55rem .95rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.small { padding: .3rem .65rem; font-size: .875rem; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.field { margin-bottom: 1rem; }
.field .hint { font-weight: 400; color: var(--muted); font-size: .8rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="date"], textarea, select {
  width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
textarea { min-height: 80px; resize: vertical; }

.row { display: flex; gap: .75rem; flex-wrap: wrap; }
.row > .field { flex: 1 1 160px; }

.error {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 10px;
  padding: .6rem .8rem;
  margin: 0 0 1rem;
  font-size: .9rem;
}

/* emoji + kleur kiezers */
.picker { display: flex; flex-wrap: wrap; gap: .35rem; }
.picker input { position: absolute; opacity: 0; pointer-events: none; }
.picker label {
  margin: 0;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 2px solid var(--border);
  font-size: 1.3rem;
  cursor: pointer;
  background: var(--surface);
}
.picker input:checked + label { border-color: var(--primary); background: var(--primary-soft); }
.picker input:focus-visible + label { outline: 3px solid var(--primary); outline-offset: 2px; }
.picker.colors label { border-radius: 50%; width: 34px; height: 34px; }
.picker.colors input:checked + label { box-shadow: 0 0 0 3px var(--surface) inset; border-color: var(--text); }

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.auth-card { max-width: 420px; margin: 2rem auto; }
.auth-card .hero { text-align: center; font-size: 3rem; margin-bottom: .25rem; }

.tabs { display: flex; gap: .25rem; background: var(--surface-2); padding: .25rem; border-radius: 12px; margin: 1rem 0 1.25rem; }
.tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: .5rem;
  border-radius: 9px;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.crumbs { font-size: .9rem; margin-bottom: .5rem; }
.crumbs a { text-decoration: none; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.family-card, .member-card {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease;
}
.family-card:hover, .member-card:hover { transform: translateY(-2px); }

.member-card { text-align: center; position: relative; }
.member-card .badge { position: absolute; top: .75rem; right: .75rem; }

.avatar {
  --c: var(--primary);
  width: 64px; height: 64px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 2rem;
  background: color-mix(in srgb, var(--c) 22%, var(--surface));
  border: 3px solid var(--c);
  flex: none;
}
.avatar.lg { width: 88px; height: 88px; font-size: 2.8rem; }
.avatar.sm { width: 36px; height: 36px; font-size: 1.1rem; border-width: 2px; }

.badge {
  display: inline-block;
  padding: .1rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  background: var(--primary-soft);
  color: var(--primary);
}
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.grey { background: var(--surface-2); color: var(--muted); }

.invite {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  background: var(--primary-soft);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  margin-bottom: 1.5rem;
}
.invite code {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: .15em;
  background: var(--surface);
  padding: .25rem .6rem;
  border-radius: 8px;
}
.invite .text { flex: 1 1 220px; }

.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}
.empty .big { font-size: 2.5rem; }

/* ---------- profiel ---------- */

.profile-head {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.profile-head .info { flex: 1 1 240px; min-width: 0; }
.profile-head .bio { white-space: pre-wrap; margin: .25rem 0 0; }

.notice {
  background: var(--surface-2);
  border-radius: 10px;
  padding: .6rem .9rem;
  font-size: .9rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.items { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }

.item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.item.reserved { background: var(--surface-2); }
.item.reserved .title { text-decoration: line-through; text-decoration-color: var(--muted); }
.item .prio { font-size: 1.1rem; line-height: 1.4; flex: none; width: 1.5rem; text-align: center; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 700; overflow-wrap: anywhere; }
.item .meta { display: flex; gap: .5rem .9rem; flex-wrap: wrap; font-size: .875rem; color: var(--muted); margin-top: .2rem; }
.item .meta a { overflow-wrap: anywhere; }
.item .notes { margin: .4rem 0 0; white-space: pre-wrap; font-size: .925rem; }
.item .side { display: flex; flex-direction: column; gap: .4rem; align-items: flex-end; flex: none; }
.item .reserved-label { font-size: .8rem; color: var(--success); font-weight: 600; text-align: right; }

@media (max-width: 560px) {
  .item { flex-wrap: wrap; }
  .item .side { flex-direction: row; flex-wrap: wrap; width: 100%; align-items: center; justify-content: flex-end; }
  .item .reserved-label { flex: 1; text-align: left; }
  .profile-head { align-items: flex-start; }
}

/* ---------- reserveringen ---------- */

.group { margin-bottom: 1.5rem; }
.group h3 { display: flex; align-items: center; gap: .5rem; }

/* ---------- modal & toast ---------- */

dialog {
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(20, 16, 32, .5); }
dialog form { padding: 1.25rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .5rem; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: .7rem 1.1rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-weight: 600;
  z-index: 100;
  max-width: calc(100vw - 32px);
}
