:root {
  --paper: #f7f2e8;
  --card: #fffdf8;
  --ink: #2b2925;
  --muted: #7b746a;
  --line: #e6dccb;
  --terra: #d9653b;
  --terra-d: #b4492a;
  --sea: #2a7f7f;
  --sun: #f2b544;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(60, 40, 20, .12);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.45 var(--sans); color: var(--ink); background: var(--paper); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--terra-d); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* buttons */
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 16px; cursor: pointer; transition: background .15s, transform .1s; white-space: nowrap; }
.btn:hover { background: #fff; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--terra); border-color: var(--terra); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--terra-d); }
.btn.primary:disabled { opacity: .6; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,.05); }
.btn.icon { padding: 6px 10px; font-size: 18px; line-height: 1; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { color: #b3261e; }

input:not([type=checkbox]):not([type=radio]):not([type=color]), select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--terra); box-shadow: 0 0 0 3px rgba(217,101,59,.15); }
input[type=color] { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 2px; background: #fff; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
label > input, label > select, label > textarea, label > .search-row { margin-top: 4px; font-weight: 400; color: var(--ink); font-size: 15px; }
.stack > * + * { margin-top: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; color: var(--ink); font-size: 14px; }

/* auth pages */
body.auth { display: grid; place-items: center; min-height: 100%; padding: 20px;
  background: radial-gradient(circle at 20% 10%, #fde7d3, transparent 50%), radial-gradient(circle at 90% 90%, #d6ece9, transparent 50%), var(--paper); }
.auth-card { width: 100%; max-width: 380px; background: var(--card); padding: 32px; border-radius: 20px; box-shadow: var(--shadow); text-align: center; }
.auth-card form { text-align: left; margin-top: 20px; }
.auth-card .btn { width: 100%; margin-top: 20px; padding: 11px; }
.auth-logo { font-size: 48px; }
.alert { background: #fdecea; color: #8c1d18; padding: 10px 12px; border-radius: 10px; text-align: left; font-size: 14px; }
.ok { background: #e7f4ec; color: #1e5b35; padding: 10px 12px; border-radius: 10px; font-size: 14px; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 18px; background: var(--card); border-bottom: 1px solid var(--line); position: relative; z-index: 1000; }
.brand { font-family: var(--serif); font-size: 22px; font-weight: 600; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.stats { display: flex; gap: 22px; margin: 0 auto; }
.stat { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.stat b { font-family: var(--serif); font-size: 22px; color: var(--terra-d); }
.stat span { font-size: 12px; color: var(--muted); }
.top-actions { display: flex; gap: 6px; align-items: center; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); min-width: 220px; padding: 6px; z-index: 2000; }
.menu-pop button, .menu-pop a { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-decoration: none; color: var(--ink); }
.menu-pop button:hover, .menu-pop a:hover { background: var(--paper); }
.menu-me { padding: 8px 12px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }

/* layout */
.layout { display: grid; grid-template-columns: 1fr 390px; height: calc(100vh - 63px); height: calc(100dvh - 63px); }
.map-wrap { position: relative; }
#map { position: absolute; inset: 0; background: #dfe9ec; }
.sidebar { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--paper); }

.people-filter { position: absolute; z-index: 500; top: 12px; left: 56px; right: 12px; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; }
.pchip { pointer-events: auto; display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: rgba(255,253,248,.95); border: 1px solid var(--line); cursor: pointer; font-size: 13px; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.pchip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.pchip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.legend { position: absolute; z-index: 500; bottom: 22px; left: 12px; background: rgba(255,253,248,.95); border-radius: 10px; padding: 6px 10px; font-size: 12px; display: flex; gap: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.sw.been { background: rgba(217,101,59,.55); border: 1px solid var(--terra-d); }
.sw.wish { background: rgba(42,127,127,.2); border: 1px dashed var(--sea); }

/* pins */
.pin-wrap { background: none; border: 0; }
.pin { width: 100%; height: 100%; border-radius: 50%; background: var(--terra); border: 3px solid #fff; box-shadow: 0 3px 10px rgba(0,0,0,.3); display: grid; place-items: center; color: #fff; font-size: 12px; transition: transform .15s; }
.pin.wish { background: var(--sea); }
.pin.has-img { overflow: hidden; padding: 0; }
.pin.has-img.wish { border-color: #cfe7e4; }
.pin img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pin-wrap:hover .pin { transform: scale(1.15); }
.popup-list strong { display: block; font-family: var(--serif); font-size: 15px; margin-bottom: 4px; }
.popup-list button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 5px 2px; cursor: pointer; border-top: 1px solid var(--line); }
.popup-list button:hover { color: var(--terra-d); }

/* sidebar */
.tabs { display: flex; padding: 10px 12px 0; gap: 4px; border-bottom: 1px solid var(--line); }
.tab { flex: 1; border: 0; background: none; padding: 10px 6px; cursor: pointer; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 600; font-size: 14px; }
.tab b { font-weight: 600; background: var(--line); color: var(--ink); border-radius: 999px; padding: 0 7px; font-size: 12px; margin-left: 2px; }
.tab b:empty { display: none; }
.tab.active { color: var(--ink); border-bottom-color: var(--terra); }
.list { overflow-y: auto; padding: 8px 14px 30px; flex: 1; }
.year h3 { font-size: 26px; color: var(--terra-d); margin: 18px 2px 8px; }
.trip-card { display: flex; gap: 12px; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: var(--radius); padding: 10px; margin-bottom: 10px; cursor: pointer; transition: transform .12s, box-shadow .12s; }
.trip-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.trip-card.wish { border-style: dashed; border-color: #b9d8d5; }
.thumb { width: 78px; height: 78px; flex: none; border-radius: 10px; overflow: hidden; background: var(--paper); display: grid; place-items: center; font-size: 34px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.tc-body { min-width: 0; flex: 1; }
.tc-title { font-family: var(--serif); font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-meta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.dots { display: flex; }
.dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--card); margin-right: -4px; }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty-icon { font-size: 44px; margin-bottom: 8px; }
.country-list { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.country-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; background: none; border-radius: 10px; cursor: pointer; text-align: left; }
.country-row:hover { background: var(--card); }
.country-row .flag { font-size: 22px; }
.country-row .cname { flex: 1; font-weight: 600; }

/* dialogs */
.dlg { border: 0; border-radius: 20px; padding: 0; background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); }
.dlg.wide { width: min(940px, calc(100vw - 24px)); }
.dlg.narrow { width: min(400px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(40, 30, 20, .45); backdrop-filter: blur(2px); }
.dlg-body { padding: 22px 24px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.dlg-head h2 { font-size: 26px; }
.dlg-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.dlg-foot .spacer, .dlg-foot #formHint { margin-right: auto; }
.card { background: var(--paper); border-radius: var(--radius); padding: 16px; }

.trip-meta { color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--line); color: var(--ink); margin-left: 6px; }
.badge.been { background: #fbe3d8; color: var(--terra-d); margin-left: 0; }
.badge.wish { background: #d9eeeb; color: #1d5d5d; margin-left: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips.static .pchip { cursor: default; box-shadow: none; }
.story { white-space: pre-wrap; font-family: var(--serif); font-size: 17px; line-height: 1.6; margin: 16px 0 6px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 16px; }
.g-item { position: relative; aspect-ratio: 1; padding: 0; border: 0; border-radius: 10px; overflow: hidden; cursor: zoom-in; background: var(--paper); }
.g-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.g-item:hover img { transform: scale(1.04); }
.g-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 8px 6px; font-size: 12px; color: #fff; text-align: left; background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.g-add { aspect-ratio: 1; border: 2px dashed var(--line); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; color: var(--muted); font-weight: 600; }
.g-add:hover { border-color: var(--terra); color: var(--terra-d); }
.g-add .big { font-size: 32px; line-height: 1; }
.upload-status { color: var(--sea); font-weight: 600; margin-top: 8px; min-height: 1em; }

/* form */
.seg { display: inline-flex; background: var(--paper); border-radius: 999px; padding: 4px; margin-bottom: 14px; }
.seg label { margin: 0; }
.seg input { display: none; }
.seg label { padding: 6px 14px; border-radius: 999px; cursor: pointer; color: var(--ink); font-weight: 600; font-size: 14px; }
.seg label:has(input:checked) { background: var(--card); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.form-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; }
.form-grid .col > * + * { margin-top: 12px; }
.search-row { display: flex; gap: 6px; }
.search-results { display: flex; flex-direction: column; max-height: 160px; overflow-y: auto; }
.search-results:empty { display: none; }
.search-results button { text-align: left; border: 0; background: var(--paper); padding: 7px 10px; border-radius: 8px; margin-bottom: 3px; cursor: pointer; font-size: 13px; }
.search-results button:hover { background: #fbe3d8; }
#formMap { height: 320px; border-radius: 12px; border: 1px solid var(--line); cursor: crosshair; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0; }
.pchip.toggle { box-shadow: none; font-weight: 400; font-size: 14px; color: var(--ink); }
.pchip.toggle input { margin: 0; accent-color: var(--terra); }
.pchip.toggle:has(input:checked) { background: #fbe3d8; border-color: #f0c2ad; }

/* family */
.family-list { list-style: none; padding: 0; margin: 0 0 16px; }
.family-list li { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.family-list .dot { width: 14px; height: 14px; border-radius: 50%; }
.family-list .fname { flex: 1; font-weight: 600; }
.card h3 { font-size: 18px; }

/* lightbox */
.lightbox { width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; border-radius: 0; background: rgba(15, 12, 10, .96); display: none; }
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox::backdrop { background: #000; }
#lbImg { max-width: calc(100vw - 120px); max-height: calc(100dvh - 110px); object-fit: contain; border-radius: 6px; user-select: none; }
.lb-close { position: absolute; top: 12px; right: 16px; background: none; border: 0; color: #fff; font-size: 26px; cursor: pointer; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12); border: 0; color: #fff; font-size: 40px; width: 52px; height: 72px; border-radius: 12px; cursor: pointer; }
.lb-nav:hover { background: rgba(255,255,255,.25); }
.lb-nav.prev { left: 12px; } .lb-nav.next { right: 12px; }
.lb-bar { position: absolute; bottom: 0; left: 0; right: 0; padding: 12px 16px; display: flex; gap: 10px; align-items: center; background: linear-gradient(transparent, rgba(0,0,0,.7)); }
.lb-bar input { flex: 1; background: rgba(255,255,255,.12) !important; border-color: transparent !important; color: #fff; }
.lb-bar input::placeholder { color: rgba(255,255,255,.6); }
.lb-count { color: rgba(255,255,255,.75); font-size: 13px; }

/* toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow); z-index: 9999; max-width: calc(100vw - 32px); }
.toast.error { background: #8c1d18; }

.leaflet-container { font: inherit; }
.leaflet-tooltip { font-size: 13px; }

/* mobiel */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .brand { font-size: 18px; }
  .stats { order: 3; width: 100%; justify-content: space-around; gap: 6px; }
  .top-actions { margin-left: auto; }
  .layout { display: block; height: auto; }
  .map-wrap { height: 58vh; height: 58dvh; }
  .sidebar { border-left: 0; }
  .list { overflow: visible; }
  .form-grid { grid-template-columns: 1fr; }
  #formMap { height: 240px; }
  .dlg-body { padding: 18px; }
  .dlg-head h2 { font-size: 22px; }
  #lbImg { max-width: 100vw; }
  .lb-nav { display: none; }
  .lb-bar { flex-wrap: wrap; }
  .people-filter { left: 52px; }
}
