:root {
  --bg: #eaf6f4;
  --primary: #2fa4a9;
  --primary-dark: #1f7a80;
  --accent: #6fcf97;
  --accent-dark: #4caf7d;
  --card: #ffffff;
  --text: #1f3a3d;
  --text-soft: #5b7a7d;
  --danger: #e0684f;
  --border: #d7ece9;
  --shadow: 0 10px 30px rgba(31, 90, 90, 0.12);
  --radius: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Quicksand', -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg);
}

button, input, select, textarea { font-family: inherit; }

.hidden { display: none !important; }

/* ---------- Buttons & inputs ---------- */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; box-shadow: 0 4px 14px rgba(47,164,169,0.35); }
.btn-accent { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: white; box-shadow: 0 4px 14px rgba(111,207,151,0.35); }
.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: rgba(31,90,90,0.06); }
.btn-danger { background: #fdeeea; color: var(--danger); }
.btn-danger:hover { background: #fbe0d9; }
.btn-block { width: 100%; }

.text-input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--text);
  background: #fbfffe;
  outline: none;
  transition: border-color 0.15s ease;
}
.text-input:focus { border-color: var(--primary); }

.field-label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 0.9rem; color: var(--text-soft); }
.field-check { display: flex; align-items: center; gap: 8px; margin-top: 16px; font-weight: 600; cursor: pointer; }

/* ---------- Login screen ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at 20% 20%, #dcf4ef, transparent 55%),
              radial-gradient(circle at 85% 80%, #d7f0e3, transparent 55%),
              linear-gradient(160deg, #eaf6f4, #dff3ee);
}
.login-card {
  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand-emoji { font-size: 2.6rem; }
.login-brand h1 { margin: 6px 0 4px; color: var(--primary-dark); }
.login-brand p { margin: 0; color: var(--text-soft); font-size: 0.9rem; }

.login-error {
  background: #fdeeea;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 16px;
  text-align: center;
}

.persona-select { display: flex; gap: 12px; margin-bottom: 6px; }
.persona-option { flex: 1; cursor: pointer; }
.persona-option input { position: absolute; opacity: 0; pointer-events: none; }
.persona-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.15s ease;
}
.persona-emoji { font-size: 2rem; }
.persona-name { font-weight: 700; color: var(--text-soft); }
.persona-option input:checked + .persona-card {
  border-color: var(--primary);
  background: #eafaf7;
  box-shadow: 0 4px 14px rgba(47,164,169,0.2);
}
.persona-option input:checked + .persona-card .persona-name { color: var(--primary-dark); }

/* ---------- Map page layout ---------- */
.map-body { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: var(--card);
  box-shadow: 0 2px 12px rgba(31,90,90,0.08);
  z-index: 1000;
  position: relative;
}
.topbar-brand { font-weight: 700; font-size: 1.15rem; color: var(--primary-dark); white-space: nowrap; }

.search-wrap { flex: 1; max-width: 420px; position: relative; }
.search-input { padding: 9px 14px; }
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  overflow: hidden;
  max-height: 280px;
  overflow-y: auto;
  z-index: 1200;
}
.search-result-item { padding: 10px 14px; cursor: pointer; font-size: 0.9rem; border-bottom: 1px solid var(--border); }
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: #eafaf7; }

.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #eafaf7;
  color: var(--primary-dark);
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
}
.user-emoji { font-size: 1.1rem; }

.map-area { position: relative; flex: 1; min-height: 0; }
#map { width: 100%; height: 100%; z-index: 1; }

/* ---------- Filters panel ---------- */
.filters-panel {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 900;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  max-width: 240px;
  max-height: calc(100% - 28px);
  overflow-y: auto;
}
.filters-toggle {
  width: 100%;
  border: none;
  background: transparent;
  padding: 12px 16px;
  font-weight: 700;
  color: var(--primary-dark);
  cursor: pointer;
  text-align: left;
}
.filters-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.filters-group { display: flex; flex-direction: column; gap: 8px; }
.filters-divider { height: 1px; background: var(--border); margin: 8px 0; }
.filters-radio, .filters-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
}
.cat-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ---------- Place detail panel ---------- */
.place-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 92vw;
  background: var(--card);
  box-shadow: -6px 0 24px rgba(31,90,90,0.15);
  z-index: 1100;
  overflow-y: auto;
  padding: 20px;
}
.panel-close {
  position: absolute;
  top: 14px;
  right: 14px;
  border: none;
  background: rgba(31,90,90,0.08);
  color: var(--text-soft);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  z-index: 5;
}
.panel-close:hover { background: rgba(31,90,90,0.16); }

.place-photos { display: flex; gap: 8px; overflow-x: auto; margin: 8px 0 16px; border-radius: var(--radius-sm); }
.place-photos img { height: 180px; border-radius: var(--radius-sm); flex-shrink: 0; object-fit: cover; }
.place-cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  margin-bottom: 10px;
}
.place-title { margin: 4px 0 6px; font-size: 1.3rem; color: var(--primary-dark); }
.place-visited-badge { font-weight: 700; font-size: 0.85rem; margin-bottom: 10px; }
.place-visited-badge.visited { color: var(--accent-dark); }
.place-visited-badge.wishlist { color: #d19a1e; }
.place-desc { white-space: pre-wrap; line-height: 1.5; color: var(--text); margin-bottom: 18px; }
.place-meta { font-size: 0.8rem; color: var(--text-soft); margin-bottom: 18px; }
.place-actions { display: flex; gap: 10px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 50, 50, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}
.modal {
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.modal h2 { margin: 0 0 6px; color: var(--primary-dark); }
.coords-hint { font-size: 0.8rem; color: var(--text-soft); margin-bottom: 6px; }
.modal-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 22px; gap: 10px; }
.modal-actions-right { display: flex; gap: 10px; margin-left: auto; }
.existing-photos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.existing-photo { position: relative; }
.existing-photo img { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius-sm); }
.existing-photo button {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  cursor: pointer;
}

/* ---------- Leaflet marker tweaks ---------- */
.visitmap-marker {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
.visitmap-marker.wishlist {
  background: white !important;
  border-width: 3px;
  border-style: dashed;
}
.visitmap-marker.visited {
  border: 2px solid white;
}
.leaflet-popup-content-wrapper { border-radius: var(--radius-sm); }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
  .topbar-brand { order: 1; font-size: 1.05rem; }
  .topbar-actions {
    order: 2;
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }
  .search-wrap { order: 3; max-width: none; width: 100%; }
  .btn { white-space: nowrap; padding: 8px 14px; font-size: 0.88rem; }
  .user-badge { padding: 8px 10px; }
  .place-panel { width: 100%; }
  .filters-panel { max-width: calc(100vw - 28px); }
}
