html, body { margin: 0; height: 100%; }
#map { position: absolute; top: 40px; left: 0; right: 0; bottom: 0; }
.leaflet-control-layers { max-height: 70vh; overflow-y: auto; }

#view-tabs {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 40px;
  z-index: 1000;
  display: flex;
  background: #1c2b3a;
  font-family: sans-serif;
}
#view-tabs button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #9fb1c1;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
}
#view-tabs button svg { width: 20px; height: 20px; }
#view-tabs button:hover { color: #fff; }
#view-tabs button.active {
  color: #fff;
  border-bottom-color: #2b7de9;
  background: rgba(255,255,255,0.05);
}

#user-badge {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  color: #9fb1c1;
  font-size: 12px;
}
#user-badge button {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid #4a5c6e;
  color: #9fb1c1;
  border-radius: 3px;
  width: 26px;
  height: 26px;
  padding: 0;
  cursor: pointer;
}
#user-badge button svg { width: 15px; height: 15px; }
#user-badge button:hover { color: #fff; border-color: #fff; }

/* Help tab: a plain readable page over the map */
#help-panel {
  position: absolute;
  top: 40px; left: 0; right: 0; bottom: 0;
  /* above Leaflet's own control corners, which sit at 1000 */
  z-index: 1100;
  overflow-y: auto;
  background: #f7f9fb;
  font-family: sans-serif;
  color: #2c3e50;
  -webkit-overflow-scrolling: touch;
}
.help-content {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  line-height: 1.5;
  font-size: 14px;
}
.help-content h1 {
  margin: 0 0 4px;
  font-size: 22px;
  color: #1c2b3a;
}
.help-content h2 {
  margin: 24px 0 6px;
  font-size: 15px;
  color: #2b7de9;
}
.help-content ul { margin: 0; padding-left: 20px; }
.help-content li { margin-bottom: 5px; }
.help-content p { margin: 0 0 6px; }
.help-intro { color: #55697c; }
.help-proverb {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid #dde4ea;
  font-style: italic;
  color: #55697c;
}
.help-credit {
  margin-top: 10px;
  font-size: 11px;
  color: #9aa8b4;
}

/* Login / sign-up gate, shown before the map loads */
#auth-overlay {
  position: fixed;
  inset: 0;
  /* The national map, turned into faint lines on navy (tools/topo_bg.py;
     credited under "Sources" in the help panel, as swisstopo's terms allow),
     under a vignette so the edges fall away and the form stays the only
     thing that catches the eye. Plain navy until the image arrives. */
  background:
    radial-gradient(ellipse at center, rgba(20, 33, 48, 0.2) 0%, rgba(11, 19, 28, 0.85) 100%),
    url(../img/login-bg.webp) center / cover no-repeat,
    #1c2b3a;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  font-family: sans-serif;
}
.auth-box {
  background: white;
  border-radius: 8px;
  padding: 24px;
  width: 280px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

.auth-logo {
  display: block;
  width: 56px;
  height: 56px;
  margin: 0 auto 10px;
}
.auth-box h1 {
  margin: 0 0 16px;
  font-size: 20px;
  text-align: center;
  color: #1c2b3a;
}
.auth-tabs { display: flex; margin-bottom: 16px; border-bottom: 1px solid #eee; }
.auth-tabs button {
  flex: 1;
  border: none;
  background: none;
  padding: 8px;
  cursor: pointer;
  color: #888;
  border-bottom: 2px solid transparent;
  font-size: 13px;
}
.auth-tabs button.active { color: #2b7de9; border-bottom-color: #2b7de9; }
.auth-box input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px;
  margin-bottom: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  /* 16px minimum keeps iOS Safari from auto-zooming the page on focus. */
  font-size: 16px;
}
.auth-error { color: #c0392b; font-size: 12px; min-height: 16px; margin-bottom: 8px; }
.auth-error.ok { color: #1e8449; }
.auth-box p { margin: 6px 0 12px; font-size: 13px; line-height: 1.45; color: #55697c; }
.auth-box p.auth-hint {
  background: #fdf6e3;
  border-left: 3px solid #e3b23c;
  border-radius: 0 4px 4px 0;
  padding: 8px 10px;
  color: #6b5a2e;
}
.auth-box > div > b { display: block; margin-bottom: 4px; font-size: 15px; color: #1c2b3a; }
.auth-link {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 4px;
  border: none;
  background: none;
  color: #2b7de9;
  font-size: 12px;
  cursor: pointer;
}
.auth-link:hover { text-decoration: underline; }
.auth-link:disabled { color: #9aa8b4; cursor: default; text-decoration: none; }
.auth-submit {
  width: 100%;
  padding: 8px;
  background: #2b7de9;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}
.auth-submit:hover { background: #1f63c4; }

/* Toolbar for adding points of interest. The container relies on Leaflet's
   own .leaflet-bar class (already applied alongside .poi-toolbar) for the
   box-shadow/rounded corners — no padding/background of our own — and the
   button mirrors .leaflet-bar a's own sizing convention (just at 34px
   instead of 26px), so it lines up exactly with the Leaflet.draw toolbar
   right below it, which uses the same convention. */
.poi-toolbar button {
  display: block;
  width: 34px;
  height: 34px;
  line-height: 34px;
  font-size: 18px;
  background-color: #fff;
  border: none;
  border-bottom: 1px solid #ccc;
  cursor: pointer;
  padding: 0;
  margin: 0;
}
.poi-toolbar button:last-child { border-bottom: none; }
.poi-toolbar button:hover { background-color: #f4f4f4; }
.poi-toolbar button.active { background-color: #e6f0ff; box-shadow: inset 0 0 0 2px #2b7de9; }
.poi-toolbar button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Leaflet's own .leaflet-bar styling gives these two a dark 2px border and
   a heavier shadow than the rest of our icons, which read as an outline
   next to them — match .icon-popup-control instead. */
.leaflet-touch .poi-toolbar,
.leaflet-touch .leaflet-draw-toolbar,
.poi-toolbar,
.leaflet-draw-toolbar {
  border: none;
  box-shadow: 0 1px 5px rgba(0,0,0,0.4);
}

/* Match Leaflet.draw's "draw a polygon" button to the size of our own
   toolbar button above (34x34 instead of Leaflet.draw's default 26x26);
   the +4px position shift keeps the sprite icon centered in the bigger box. */
.leaflet-draw-toolbar a {
  width: 34px !important;
  height: 34px !important;
  line-height: 34px !important;
}
.leaflet-draw-toolbar .leaflet-draw-draw-polygon { background-position: -27px 2px !important; }

/* Bigger, easier-to-hit touch targets for Finish/Delete/Cancel while
   drawing — reduces the chance of a mistap landing on the map instead. */
.leaflet-draw-actions a {
  padding: 0 12px !important;
  line-height: 40px !important;
  height: 40px !important;
}

.emoji-marker-icon {
  font-size: 14px;
  width: 21px;
  height: 21px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
/* Cluster badge, scaled down with the markers it stands for (the plugin's
   own stylesheet sizes it for a 40px icon; ours is 28px — see
   iconCreateFunction in map.js). */
.marker-cluster { border-radius: 14px; }
.marker-cluster div {
  width: 21px;
  height: 21px;
  margin-left: 3.5px;
  margin-top: 3.5px;
  border-radius: 10.5px;
  font-size: 11px;
}
.marker-cluster span { line-height: 21px; }

/* Marker belonging to another user (shown on the main map as a favorite, or
   as the duplicate-avoidance helper while placing a new point). */
.emoji-marker-icon.foreign {
  box-shadow: 0 0 0 2px #2b7de9, 0 1px 4px rgba(0,0,0,0.5);
  opacity: 0.85;
}

.zone-label {
  background: rgba(255,255,255,0.85);
  border: none;
  box-shadow: none;
  font-size: 12px;
  font-weight: bold;
  padding: 1px 4px;
}

#placement-hint {
  position: absolute;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  background: #2b7de9;
  color: white;
  padding: 6px 14px;
  border-radius: 4px;
  font-family: sans-serif;
  font-size: 13px;
  z-index: 1000;
  display: none;
  pointer-events: none;
}

.popup-form, .popup-view { font-family: sans-serif; min-width: 220px; max-width: 70vw; }
.popup-form b, .popup-view b { display: block; margin-bottom: 4px; }
.popup-form input, .popup-form textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 3px 5px;
  margin-bottom: 6px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-family: inherit;
  /* 16px minimum keeps iOS Safari from auto-zooming the page on focus. */
  font-size: 16px;
}
.popup-form textarea { resize: vertical; }
.popup-form .emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
  max-height: 130px;
  overflow-y: auto;
  padding: 2px;
  border: 1px solid #eee;
  border-radius: 3px;
}
.popup-form .emoji-picker button {
  flex: none;
  width: 28px;
  height: 28px;
  font-size: 16px;
  padding: 0;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: #f5f5f5;
  cursor: pointer;
}
.popup-form .emoji-picker-empty {
  font-size: 12px;
  color: #888;
  padding: 4px;
}
.popup-form .emoji-row { display: flex; gap: 6px; }
.popup-form .emoji-input { width: 46px !important; flex: none; text-align: center; font-size: 16px; }
.popup-form .emoji-row input[type="text"]:not(.emoji-input) { flex: 1; }

.popup-form .popup-actions, .popup-view .popup-actions { display: flex; gap: 6px; margin-top: 4px; }
.popup-form button, .popup-view button {
  flex: 1;
  padding: 3px 6px;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: #f5f5f5;
  cursor: pointer;
}
.popup-form button.delete, .popup-view button.delete { color: #c0392b; }

.popup-view .description { margin: 4px 0; white-space: pre-wrap; word-break: break-word; }
.popup-view .description a { color: #2b7de9; }
.popup-view .author { font-size: 11px; color: #888; margin-bottom: 4px; }

.tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.tag-chip {
  background: #eef2f7;
  color: #35506b;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
}

/* Tag picker: checkbox list + "add a new tag" field (points and zones) */
.tag-picker-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  max-height: 100px;
  overflow-y: auto;
  padding: 4px;
  margin-bottom: 6px;
  border: 1px solid #eee;
  border-radius: 3px;
  font-size: 12px;
}
.tag-picker-item { display: flex; align-items: center; gap: 3px; white-space: nowrap; }
.tag-picker-add { display: flex; gap: 6px; margin-bottom: 6px; }
.tag-picker-add input { flex: 1; margin-bottom: 0 !important; }
.tag-picker-add button {
  flex: none;
  width: 26px;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: #f5f5f5;
  cursor: pointer;
}

/* "Others" browsing panel */
.other-users-panel {
  background: white;
  border-radius: 4px;
  box-shadow: 0 1px 5px rgba(0,0,0,0.4);
  padding: 8px;
  font-family: sans-serif;
  width: 190px;
}

/* Generic "collapsed icon square that expands into a floating panel"
   control, shared by the map-style picker and the main-view filter — both
   start out looking exactly like the other 34x34 toolbar icons. */
.icon-popup-control {
  background: white;
  border-radius: 4px;
  box-shadow: 0 1px 5px rgba(0,0,0,0.4);
  font-family: sans-serif;
}
.icon-popup-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  background: #fff;
  border-radius: 4px;
  padding: 0;
  cursor: pointer;
  color: #333;
}
.icon-popup-toggle svg { width: 18px; height: 18px; }
.icon-popup-toggle:hover { background-color: #f4f4f4; }
.icon-popup-toggle.active { background-color: #e6f0ff; box-shadow: inset 0 0 0 2px #2b7de9; }
.icon-popup-body { padding: 8px; border-top: 1px solid #eee; }
/* Avoid a doubled background/shadow when .other-users-panel (its own
   floating-box styling) is nested inside .icon-popup-control's box. */
.icon-popup-body.other-users-panel { background: none; box-shadow: none; border-radius: 0; }

.filter-panel-body { width: 190px; }
.filter-panel-layers {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
  font-size: 12px;
}
.filter-panel-layers label { display: flex; align-items: center; gap: 5px; }

/* Google-Maps-style base layer picker: two image tiles instead of radios */
.layer-picker-body { display: flex; gap: 8px; }
.layer-picker-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 3px;
  background: none;
  cursor: pointer;
  font-size: 11px;
  color: #333;
}
.layer-picker-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 4px;
  overflow: hidden;
}
.layer-picker-thumb img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.layer-picker-option.active { border-color: #2b7de9; }
.layer-picker-option.active span { color: #2b7de9; font-weight: bold; }

/* Location search */
.search-body { width: 220px; }
.search-body input {
  width: 100%;
  box-sizing: border-box;
  padding: 5px 7px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 13px;
}
.search-results { max-height: 220px; overflow-y: auto; }
.search-results:not(:empty) { margin-top: 4px; }
.search-result {
  display: block;
  width: 100%;
  text-align: left;
  padding: 5px 6px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 12px;
  border-radius: 3px;
}
.search-result:hover { background: #eef2f7; }
/* A code match: one of your own places, listed above the place names */
.search-result.local { color: #1f63c4; font-weight: bold; }

/* Three-way season switch in the filter panel */
.season-filter {
  display: flex;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
}
.season-filter button {
  flex: 1;
  padding: 4px 2px;
  border: 1px solid #ccc;
  background: #f5f5f5;
  cursor: pointer;
  font-size: 11px;
}
.season-filter button:first-child { border-radius: 3px 0 0 3px; }
.season-filter button:last-child { border-radius: 0 3px 3px 0; }
.season-filter button + button { border-left: none; }
.season-filter button.active { background: #2b7de9; border-color: #2b7de9; color: #fff; }

/* Shareable code at the foot of a point/zone popup — the code itself is
   the button that copies the link to it. */
.share-row { display: flex; margin: 6px 0 2px; }
.popup-view .share-row button.share-code {
  flex: none;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 1px;
  color: #35506b;
  background: #eef2f7;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 3px 8px;
  cursor: pointer;
}
.popup-view .share-row button.share-code:hover {
  border-color: #2b7de9;
  color: #2b7de9;
}

/* Transient message at the bottom of the map (undo a delete, failed save) */
#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 4000;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  border-radius: 6px;
  background: #1c2b3a;
  color: #fff;
  font-family: sans-serif;
  font-size: 13px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}
#toast.error { background: #a93226; }
#toast button {
  flex: none;
  border: none;
  background: none;
  color: #8ab8f5;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  padding: 0;
}
#toast.error button { color: #ffd9d4; }

/* Round "locate me" button, unlike the square toolbar icons */
.locate-control button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #fff;
  box-shadow: 0 1px 5px rgba(0,0,0,0.4);
  color: #333;
  cursor: pointer;
  padding: 0;
}
.locate-control button svg { width: 20px; height: 20px; }
.locate-control button:hover { background: #f4f4f4; }
.locate-control button.locating svg { color: #2b7de9; animation: locate-pulse 1s ease-in-out infinite; }
.locate-control button.error svg { color: #c0392b; }
@keyframes locate-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.other-users-panel select,
.other-users-panel input {
  width: 100%;
  box-sizing: border-box;
  padding: 3px 5px;
  margin-bottom: 6px;
  border: 1px solid #ccc;
  border-radius: 3px;
}
.other-users-panel button {
  width: 100%;
  padding: 4px 6px;
  margin-bottom: 6px;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: #f5f5f5;
  cursor: pointer;
  font-size: 12px;
}
/* Favoriting from someone else's map: tap an existing tag or emoji to
   follow it, rather than typing it out blind. */
.favorite-section { margin-bottom: 8px; }
.favorite-section > span {
  display: block;
  font-size: 11px;
  color: #888;
  margin-bottom: 4px;
}
.tag-toggles { display: flex; flex-wrap: wrap; gap: 4px; }
.other-users-panel .tag-toggles button {
  width: auto;
  margin: 0;
  padding: 3px 8px;
  border-radius: 10px;
  background: #eef2f7;
  color: #35506b;
  font-size: 11px;
}
.other-users-panel .tag-toggles button.active {
  background: #2b7de9;
  border-color: #2b7de9;
  color: #fff;
}
.other-users-panel .emoji-picker { display: flex; flex-wrap: wrap; gap: 4px; }
.other-users-panel .emoji-picker button {
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 0;
  font-size: 15px;
}
.other-users-panel .emoji-picker button.active { border-color: #2b7de9; background: #e6f0ff; }

/* Photo gallery (points/zones) + full-screen lightbox */
.photo-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}
.photo-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #ccc;
  cursor: pointer;
  flex: none;
}
.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-thumb-remove {
  position: absolute;
  top: 0;
  right: 0;
  width: 16px;
  height: 16px;
  line-height: 14px;
  padding: 0;
  border: none;
  border-radius: 0 0 0 4px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 10px;
  cursor: pointer;
}
.photo-thumb.photo-add {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  border: 1px dashed #999;
  font-size: 22px;
  color: #999;
  cursor: pointer;
}
.photo-thumb.photo-add:hover { background: #ececec; color: #666; }
.photo-thumb.photo-add.loading { opacity: 0.5; pointer-events: none; }
.photo-thumb.photo-add input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

.photo-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 6000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
}
.photo-lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}
.photo-lightbox-close:hover { background: rgba(255,255,255,0.3); }
.photo-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.photo-lightbox-nav:hover { background: rgba(255,255,255,0.3); }
.photo-lightbox-prev { left: 16px; }
.photo-lightbox-next { right: 16px; }
