:root {
  --green-dark: #1B5E20;
  --green: #2E7D32;
  --green-light: #4CAF50;
  --yellow: #FBC02D;
  --yellow-dark: #F9A825;
  --white: #FFFFFF;
  --gray: #555;
  --gray-light: #EEE;
  --shadow: 0 2px 8px rgba(0,0,0,0.18);
  --shadow-up: 0 -4px 12px rgba(0,0,0,0.18);
  --topbar-h: 60px;
  --bottom-h: 76px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%; width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--green-dark); color: #222;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}

#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  z-index: 1000; padding: 0 12px;
  background: var(--green-dark); color: var(--white);
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow);
  padding-top: env(safe-area-inset-top, 0);
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0));
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .logo { font-size: 26px; flex-shrink: 0; }
.brand-text { min-width: 0; }
.brand strong { display: block; font-size: 14px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { display: block; font-size: 11px; opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#menu-btn {
  background: transparent; border: 0; color: var(--white);
  font-size: 26px; line-height: 1; cursor: pointer; padding: 6px 10px;
  border-radius: 6px;
}
#menu-btn:active { background: rgba(255,255,255,0.15); }

#map {
  position: absolute;
  top: calc(var(--topbar-h) + env(safe-area-inset-top, 0));
  left: 0; right: 0;
  bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom, 0));
  background: #DDE3D3;
}

#bottom-actions {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--bottom-h) + env(safe-area-inset-bottom, 0));
  z-index: 1000;
  background: var(--white); border-top: 3px solid var(--yellow);
  display: flex; gap: 6px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0));
}
.action-btn {
  flex: 1; min-width: 0;
  border: 0; border-radius: 10px;
  background: var(--green-dark); color: var(--white);
  font-size: 12px; font-weight: 600; padding: 6px 4px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; line-height: 1.2;
  transition: transform 0.08s, background 0.15s;
}
.action-btn .icon { font-size: 22px; }
.action-btn:active { background: var(--green); transform: scale(0.96); }
.action-btn.active { background: var(--yellow); color: var(--green-dark); }
.action-btn.active .icon { animation: pulse 1.2s infinite; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.panel {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom, 0));
  z-index: 1100;
  background: var(--white); padding: 16px;
  box-shadow: var(--shadow-up);
  border-top: 4px solid var(--yellow);
  border-radius: 14px 14px 0 0;
  max-height: 65vh; overflow-y: auto;
  animation: slideUp 0.25s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.hidden { display: none !important; }

.panel h3 { color: var(--green-dark); margin-bottom: 10px; font-size: 15px; font-weight: 700; }
.panel h3:not(:first-child) { margin-top: 14px; }

.poi-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-bottom: 10px;
}
.poi-grid button {
  border: 2px solid var(--green-dark); border-radius: 10px;
  background: var(--white); color: var(--green-dark);
  padding: 10px 4px; font-size: 11px; font-weight: 700;
  cursor: pointer; line-height: 1.3;
  transition: background 0.15s, transform 0.08s;
}
.poi-grid button span { font-size: 22px; display: block; margin-bottom: 2px; }
.poi-grid button:active { transform: scale(0.95); }
.poi-grid button.selected { background: var(--yellow); border-color: var(--yellow-dark); }

.hint { font-size: 12px; color: var(--gray); margin: 8px 0 12px; line-height: 1.4; }

.panel button.secondary, #poi-cancel, #menu-close {
  width: 100%; padding: 11px; border: 0; border-radius: 8px;
  background: #888; color: var(--white); font-weight: 600; font-size: 14px;
  cursor: pointer; margin-top: 10px;
}

.menu-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.menu-actions button {
  padding: 10px; border: 0; border-radius: 8px;
  background: var(--green-dark); color: var(--white);
  font-weight: 600; font-size: 13px; cursor: pointer;
}
.menu-actions button:active { background: var(--green); }

#trail-list, #poi-list { list-style: none; }
#trail-list li, #poi-list li {
  padding: 10px 4px; border-bottom: 1px solid var(--gray-light); font-size: 13px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
#trail-list li span, #poi-list li span {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#trail-list li button, #poi-list li button {
  border: 0; background: var(--yellow); color: var(--green-dark);
  padding: 6px 14px; border-radius: 6px; font-size: 12px; font-weight: 700; cursor: pointer;
  flex-shrink: 0;
}
#trail-list li em, #poi-list li em { color: var(--gray); font-style: italic; }

#progress-bar {
  position: fixed;
  top: calc(var(--topbar-h) + env(safe-area-inset-top, 0));
  left: 0; right: 0; z-index: 1500;
  background: var(--green-dark); color: var(--white);
  padding: 10px 14px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.progress-track {
  flex: 1; height: 8px; background: rgba(255,255,255,0.2);
  border-radius: 4px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--yellow); width: 0%;
  transition: width 0.2s ease;
}
.progress-text { font-size: 12px; min-width: 80px; text-align: right; font-weight: 600; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom, 0) + 16px);
  z-index: 2000;
  background: rgba(27,94,32,0.95); color: var(--white);
  padding: 10px 18px; border-radius: 24px;
  font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow);
  animation: toastIn 0.25s;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

.poi-marker { background: transparent !important; border: 0 !important; }
.poi-pin-admin {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border: 3px solid var(--white);
  border-radius: 9px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
  font-size: 18px;
  color: var(--white);
}

.filter-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid var(--gray-light);
  font-size: 14px; cursor: pointer;
}
.filter-row input[type="checkbox"] {
  width: 20px; height: 20px;
  accent-color: var(--green-dark);
  cursor: pointer;
}
.filter-row span { flex: 1; }
.filter-row:active { background: rgba(251,192,45,0.15); }

.leaflet-popup-content { font-size: 13px; line-height: 1.4; min-width: 140px; }
.leaflet-popup-content strong { color: var(--green-dark); }
.popup-btn {
  margin-top: 8px; background: #D32F2F; color: var(--white);
  border: 0; padding: 5px 10px; border-radius: 4px; cursor: pointer;
  font-size: 12px; font-weight: 600;
}
.leaflet-control-zoom { border: 0 !important; box-shadow: var(--shadow) !important; }
.leaflet-control-zoom a {
  background: var(--white) !important; color: var(--green-dark) !important;
  border-radius: 6px !important; margin-bottom: 4px;
}
.leaflet-control-attribution { font-size: 10px !important; }

@media (min-width: 768px) {
  .panel {
    left: auto; right: 12px;
    bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom, 0) + 8px);
    max-width: 380px;
    border-radius: 14px;
  }
  .action-btn { font-size: 13px; }
  .action-btn .icon { font-size: 24px; }
}
