:root {
  --brand-green: #1B8A3D;
  --brand-green-bright: #22C55E;
  --brand-green-dark: #146030;
  --brand-yellow: #FFDA00;
  --brand-black: #111111;
  --panel-bg: #ffffff;
  --text-muted: #5f6b63;
  --shadow: 0 2px 10px rgba(0,0,0,.18);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--brand-black);
  overscroll-behavior: none;
}

#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: var(--brand-green);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: block;
}

.brand-name {
  color: #fff;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.header-actions {
  display: flex;
  gap: 6px;
}

.header-btn {
  position: relative;
  border: none;
  background: rgba(255,255,255,.18);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.header-btn:active { background: rgba(255,255,255,.32); }

.saved-count {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--brand-yellow);
  color: var(--brand-black);
  font-size: .68rem;
  font-weight: 800;
  min-width: 17px;
  height: 17px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.search-bar {
  position: fixed;
  top: calc(58px + var(--safe-top));
  left: 12px;
  right: 12px;
  z-index: 20;
  display: flex;
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.search-bar input {
  flex: 1;
  border: none;
  padding: 12px 14px;
  font-size: 1rem;
  outline: none;
  min-width: 0;
}

.search-bar button {
  border: none;
  background: transparent;
  color: var(--brand-green);
  width: 46px;
  cursor: pointer;
}

.fab {
  position: fixed;
  right: 16px;
  z-index: 20;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--brand-black);
  color: #fff;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.fab-secondary {
  background: #fff;
  color: var(--brand-green);
  bottom: calc(24px + var(--safe-bottom));
}

.fab-primary {
  bottom: calc(24px + var(--safe-bottom));
  background: var(--brand-green);
  font-size: 1.8rem;
  line-height: 1;
}

/* Leaflet popup styling */
.leaflet-popup-content-wrapper {
  border-radius: 14px;
}

.pin-popup {
  min-width: 220px;
  max-width: 260px;
}

.pin-popup .pin-category {
  display: inline-block;
  background: var(--brand-yellow);
  color: var(--brand-black);
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 8px;
  border-radius: 20px;
  margin-bottom: 6px;
}

.pin-popup h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.pin-popup p {
  margin: 0 0 10px;
  font-size: .88rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.pin-popup .pin-photo {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 8px;
}

.pin-actions {
  display: flex;
  gap: 6px;
}

.pin-actions button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid #e2e2e2;
  background: #fafafa;
  border-radius: 10px;
  padding: 8px 6px;
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--brand-black);
}

.pin-actions button.active {
  background: var(--brand-green);
  border-color: var(--brand-green);
  color: #fff;
}

.pin-actions button svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.marker-cluster-custom {
  background: var(--brand-green);
  border: 3px solid rgba(255,255,255,.9);
  border-radius: 50%;
  color: #fff;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--brand-black);
  color: #fff;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: .88rem;
  font-weight: 600;
  z-index: 40;
  box-shadow: var(--shadow);
  animation: toast-in .18s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 29;
}

.panel {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: min(380px, 92vw);
  background: var(--panel-bg);
  z-index: 30;
  box-shadow: -4px 0 20px rgba(0,0,0,.25);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid #eee;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.panel-header .header-btn {
  background: #f1f1f1;
  color: var(--brand-black);
}

.saved-list {
  overflow-y: auto;
  padding: 8px;
  flex: 1;
}

.suggest-form {
  overflow-y: auto;
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.form-label {
  font-weight: 700;
  font-size: .85rem;
  margin: 14px 0 6px;
}

.form-label:first-child {
  margin-top: 0;
}

.form-hint {
  font-size: .78rem;
  color: var(--text-muted);
  margin: 4px 0 8px;
}

.suggest-form input[type="text"],
.suggest-form textarea {
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: .95rem;
  font-family: inherit;
  resize: vertical;
}

.suggest-form input[type="file"] {
  font-size: .85rem;
}

.mini-map-wrap {
  position: relative;
  height: 180px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #ddd;
}

#suggestMap {
  height: 100%;
  width: 100%;
}

.mini-map-pin {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -100%);
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.4));
}

.text-btn {
  align-self: flex-start;
  border: none;
  background: none;
  color: var(--brand-green);
  font-weight: 700;
  font-size: .85rem;
  padding: 8px 0;
  cursor: pointer;
}

.photo-preview {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 10px;
  margin-top: 8px;
}

.primary-btn {
  margin-top: 20px;
  background: var(--brand-green);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 13px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.primary-btn:disabled {
  opacity: .6;
}

.saved-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.saved-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid transparent;
}

.saved-item:hover, .saved-item:active {
  background: #f5f9f6;
  border-color: #e5efe8;
}

.saved-item .saved-item-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.saved-item h4 {
  margin: 0 0 2px;
  font-size: .95rem;
}

.saved-item p {
  margin: 0;
  font-size: .78rem;
  color: var(--text-muted);
}

.saved-item .remove-btn {
  border: none;
  background: transparent;
  color: #bbb;
  cursor: pointer;
  padding: 4px;
}

@media (min-width: 640px) {
  .search-bar { left: 16px; max-width: 420px; right: auto; }
}
