:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface2: #1f2b4d;
  --primary: #0f3460;
  --accent: #e94560;
  --ok: #3f9d5a;
  --text: #eee;
  --text-muted: #a8adbd;
  --radius: 12px;
  --sheet-h: 42dvh;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; overflow: hidden; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

a { color: #7fb2ff; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---- Bovenbalk ---- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 8px;
  background: rgba(26, 26, 46, 0.92);
  backdrop-filter: blur(6px);
}
.brand { font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.version { font-weight: 400; font-size: 11px; color: var(--text-muted); }

.chip {
  border: 1px solid #34406a; background: var(--surface); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.chip.travel[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }

/* ---- Kaart ---- */
#map { position: fixed; inset: 0 0 var(--sheet-h) 0; }
.sheet.collapsed ~ #map, body.sheet-collapsed #map { bottom: 76px; }

.fab {
  position: fixed; right: 12px; bottom: calc(var(--sheet-h) + 12px); z-index: 15;
  width: 46px; height: 46px; border-radius: 50%; border: none;
  background: var(--surface); font-size: 22px; box-shadow: 0 2px 8px rgba(0,0,0,.4); cursor: pointer;
}
body.sheet-collapsed .fab { bottom: 88px; }

.status {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top, 0px) + 56px);
  z-index: 25; background: var(--surface); padding: 6px 14px; border-radius: 999px; font-size: 13px;
  box-shadow: 0 2px 8px rgba(0,0,0,.4); max-width: calc(100% - 32px);
}

/* ---- Paneel onderin ---- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  height: var(--sheet-h); display: flex; flex-direction: column;
  background: var(--bg); border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 16px rgba(0,0,0,.35);
  padding-bottom: var(--safe-b);
  transition: height .2s;
}
body.sheet-collapsed .sheet { height: calc(76px + var(--safe-b)); }
body.sheet-expanded { --sheet-h: 78dvh; }

.sheet-handle { display: flex; justify-content: center; padding: 8px 0 4px; cursor: pointer; }
.sheet-handle span { width: 40px; height: 5px; border-radius: 3px; background: #445; }

.tabs { display: flex; gap: 4px; padding: 0 12px 6px; }
.tab {
  flex: 1; padding: 8px; border: none; border-radius: 8px; background: transparent;
  color: var(--text-muted); cursor: pointer;
}
.tab.active { background: var(--surface2); color: var(--text); font-weight: 600; }

.tab-panel { flex: 1; overflow-y: auto; padding: 4px 12px 16px; -webkit-overflow-scrolling: touch; }

.row { display: flex; gap: 8px; margin: 8px 0; }
.row.wrap { flex-wrap: wrap; }
.muted { color: var(--text-muted); font-size: 13px; margin: 6px 0; }
.small { font-size: 12px; }

.btn {
  border: 1px solid #34406a; background: var(--surface); border-radius: 10px;
  padding: 10px 14px; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; }
#nearby-btn { flex: 1; }

/* ---- Lijsten ---- */
.list { list-style: none; }
.list li {
  display: flex; align-items: center; gap: 10px; padding: 10px 4px;
  border-bottom: 1px solid #262c48; cursor: pointer;
}
.list li:active { background: var(--surface); }
.dot { flex: 0 0 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 17px; }
.li-main { flex: 1; min-width: 0; }
.li-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-sub { font-size: 12px; color: var(--text-muted); }
.li-ai { font-size: 12.5px; line-height: 1.4; color: var(--text); margin-top: 4px; white-space: normal; }
.li-ai::before { content: '✨ '; }
.ai-box { background: var(--surface); border-radius: 10px; padding: 10px 12px; margin: 12px 0; line-height: 1.5; }
.ai-box .muted { margin: 6px 0 0; }
#place-form input { flex: 1; }
.li-side { text-align: right; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--surface2); }
.badge.open { background: #24533a; }
.badge.closed { background: #5a2530; }

/* ---- Formulieren ---- */
.form { display: flex; flex-direction: column; gap: 10px; margin: 8px 0; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-muted); }
.form label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
input, select, textarea {
  background: var(--surface); border: 1px solid #34406a; border-radius: 8px; padding: 9px 10px; width: 100%;
}
input[type="checkbox"] { width: 20px; height: 20px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---- Profiel ---- */
.cats { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 16px; }
.cat {
  background: var(--surface); border-radius: var(--radius); padding: 10px 12px;
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
}
.cat-name { font-weight: 600; }
.cat-controls { grid-column: 1 / -1; display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 8px; }
.cat-controls label { font-size: 11px; color: var(--text-muted); display: flex; flex-direction: column; gap: 2px; }
.cat-controls input, .cat-controls select { padding: 6px 8px; }

/* ---- Melding ---- */
.toast {
  position: fixed; left: 12px; right: 12px; top: calc(env(safe-area-inset-top, 0px) + 60px); z-index: 30;
  background: var(--surface2); border-left: 5px solid var(--accent); border-radius: var(--radius);
  padding: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.5);
  display: flex; flex-direction: column; gap: 10px; animation: slide .25s ease-out;
}
@keyframes slide { from { transform: translateY(-20px); opacity: 0; } }
.toast-title { font-weight: 700; font-size: 16px; }
.toast-sub { color: var(--text-muted); font-size: 13px; }
.toast-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---- Detailkaart ---- */
.detail {
  position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.detail-card {
  position: relative; width: 100%; max-width: 640px; max-height: 88dvh; overflow-y: auto;
  background: var(--bg); border-radius: 16px 16px 0 0; padding: 18px 16px calc(20px + var(--safe-b));
}
.detail .close { position: absolute; right: 8px; top: 8px; }
.detail h2 { font-size: 20px; margin: 4px 40px 4px 0; }
.detail .meta { color: var(--text-muted); font-size: 13px; margin-bottom: 10px; }
.detail .extract { line-height: 1.5; margin: 12px 0; }
.detail figure { margin: 10px 0; }
.detail figure img { width: 100%; max-height: 260px; object-fit: cover; border-radius: 10px; background: var(--surface); }
.detail figcaption { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.detail .source { font-size: 12px; color: var(--text-muted); border-top: 1px solid #262c48; padding-top: 10px; margin-top: 12px; }
.detail .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.detail .actions .btn { flex: 1 1 auto; }

/* ---- Kaartmarkers ---- */
.me-marker {
  width: 18px; height: 18px; border-radius: 50%; background: #2d8cff; border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(45, 140, 255, .25);
}

@media (min-width: 900px) {
  :root { --sheet-h: 100dvh; }
  .sheet { right: auto; width: 400px; top: 56px; height: auto; border-radius: 0; }
  #map { inset: 56px 0 0 400px; }
  .fab { bottom: 20px; }
  .sheet-handle { display: none; }
  .toast { left: auto; width: 380px; }
}
