#splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  background: #0f172a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease-out;
}

#splash-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

#splash-screen img {
  max-width: 200px;
  max-height: 200px;
  margin-bottom: 24px;
}

.splash-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #7dd3fc;
  border-radius: 50%;
  animation: splash-spin 0.8s linear infinite;
}

@keyframes splash-spin {
  to { transform: rotate(360deg); }
}

html, body {
  margin: 0;
  height: 100%;
  font-family: Arial, "Microsoft JhengHei", sans-serif;
  background: #f3f3f3;
}

#app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#toolbar {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 8px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  box-sizing: border-box;
  flex-wrap: wrap;
}

#toolbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 5px;
}

#search-icon-btn {
  display: none;
}

#mobile-menu-btn {
  display: none;
}

#about-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  background: none;
  border: none;
  color: #0f172a;
  text-decoration: none;
  cursor: pointer;
  margin-right: 4px;
  order: -1;
  height: 24px;
  box-sizing: border-box;
}

#about-btn:hover {
  opacity: 0.8;
}

.navbar-icon {
  height: 20px;
  width: auto;
}

.navbar-text {
  font-size: 12px;
  font-weight: 500;
}

#search-box {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 1 auto;
}

#tags {
  width: 220px;
  flex: 0 0 220px;
  min-width: initial;
  padding: 0 6px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 12px;
  line-height: 20px;
  height: 24px;
  box-sizing: border-box;
}

#toolbar label {
  display: none;
}

button,
select {
  padding: 0 6px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a;
  font-size: 12px;
  line-height: 20px;
  height: 24px;
  box-sizing: border-box;
  margin: 0;
}

button.active {
  background: #89c1da;
  border-color: #0234c0;
  color: #0f172a;
  cursor: pointer;
}

button.disable {
  opacity: 0.5;
  filter: grayscale(60%);
}

#filter-menu-wrap {
  position: relative;
}

#filter-menu {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  min-width: 260px;
  padding: 6px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.22);
}

#filter-menu.hidden {
  display: none;
}

.marker-filter-toggle {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 999px;
  cursor: pointer;
}

#marker-label-toggle-btn,
#marker-filter-all-btn {
  grid-column: 1 / -1;
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 999px;
  cursor: pointer;
}

select {
  font-family: "Microsoft JhengHei", sans-serif;
}

input[type="range"] {
  width: 100px;
  accent-color: #0ea5e9;
}

#map-wrap {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 400px;
}

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

#drop-container {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  padding: 20px;
  background-color: rgba(100, 100, 100, 0.5);
  box-sizing: border-box;
}

#drop-silhouette {
  width: 100%;
  height: 100%;
  border: 8px dashed white;
  border-radius: 8px;
  box-sizing: border-box;
}

#layer-controls {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 15;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  padding: 2px;
}

#layer-controls label {
  display: none;
}

#layer-controls select {
  max-width: 115px;
  font-size: 11px;
  padding: 2px 3px;
  height: 30px;
  box-sizing: border-box;
}

#layer-controls input[type="range"] {
  width: 64px;
}

.ol-zoom {
  top: auto;
  right: 10px;
  bottom: 10px;
  left: auto;
}

.ol-zoom .ol-zoom-in,
.ol-zoom .ol-zoom-out {
  width: 32px;
  height: 32px;
  font-size: 18px;
}

#buttons {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 2px;
}

#compass-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
  cursor: pointer;
  overflow: hidden;
}

#compass-btn:hover {
  background: #e2e8f0;
}

#compass-btn:active {
  background: #cbd5e1;
}

#compass-btn canvas {
  display: block;
}

#fullscreen-btn {
  position: absolute;
  top: 54px;
  right: 10px;
  z-index: 15;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
  color: #0f172a;
  cursor: pointer;
}

#fullscreen-btn:hover {
  background: #e2e8f0;
}

#fullscreen-btn:active {
  background: #cbd5e1;
}

#geolocate-btn {
  position: absolute;
  top: 98px;
  right: 10px;
  z-index: 15;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
  color: #0f172a;
  cursor: pointer;
}

#geolocate-btn:hover {
  background: #e2e8f0;
}

#geolocate-btn:active {
  background: #cbd5e1;
}

#buttons.hidden {
  display: none;
}

#buttons button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #0f172a;
  cursor: pointer;
}

#buttons button:hover {
  background: #e2e8f0;
}

#buttons button.disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

#buttons .draw-type {
  display: flex;
  align-items: center;
  gap: 2px;
}

#buttons .draw-type-toggle {
  width: 30px;
  height: 30px;
  font-size: 13px;
  padding: 0;
}

#buttons .draw-type-toggle.active {
  background: #0ea5e9;
  color: #fff;
  border-color: #0ea5e9;
}

#buttons .buttons-sep {
  width: 1px;
  height: 22px;
  background: #cbd5e1;
  margin: 0 4px;
}

#params {
  position: absolute;
  top: 10px;
  right: 54px;
  z-index: 14;
  max-width: 320px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
  font-size: 12px;
  color: #0f172a;
  line-height: 1.6;
}

#params button {
  margin-left: 6px;
  padding: 3px 10px;
  background: #0ea5e9;
  border: 1px solid #0ea5e9;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
}

#areaselect-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 20;
  background: rgba(15, 23, 42, 0.35);
}

#areaselect-modal-overlay.hidden {
  display: none;
}

#inputtitleform {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 21;
  min-width: 260px;
  padding: 16px 20px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.25);
  color: #0f172a;
  font-size: 14px;
}

#inputtitleform.hidden {
  display: none;
}

#inputtitleform input[type="text"],
#inputtitleform select {
  margin: 4px 0;
  padding: 5px 8px;
  border: 1px solid #94a3b8;
  border-radius: 6px;
  font-size: 13px;
}

#inputtitleform input[type="button"] {
  margin: 8px 6px 0 0;
  padding: 5px 14px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

#inputtitleform input[type="button"]:hover {
  background: #e2e8f0;
}

#point-popup {
  position: relative;
  max-width: 340px;
  max-height: min(85vh, 560px);
  overflow: auto;
  scrollbar-width: none;
  padding: 12px 14px;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
  z-index: 20;
  line-height: 1.6;
  font-size: 14px;
  pointer-events: auto;
}

#point-popup::-webkit-scrollbar {
  display: none;
}

#point-popup::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  transform: translateX(-50%) rotate(45deg);
  width: 14px;
  height: 14px;
  background: #ffffff;
  border-right: 1px solid #cbd5e1;
  border-bottom: 1px solid #cbd5e1;
}

#point-popup.hidden {
  display: none;
}

#point-popup a {
  color: #0369a1;
}

#point-popup .popup-header {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  padding-right: 24px;
}

#point-popup .popup-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

#point-popup .popup-close:hover {
  color: #0f172a;
}

#point-popup .popup-measure {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e2e8f0;
}

#point-popup .popup-measure button {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #0369a1;
  border-radius: 4px;
  padding: 2px 8px;
  margin-right: 6px;
  cursor: pointer;
  font-size: 12px;
}

#point-popup .popup-measure button:hover {
  background: #e0f2fe;
  border-color: #0369a1;
}

#point-popup .popup-measure button.measure-active {
  background: #fef3c7;
  border-color: #d97706;
  color: #92400e;
}

#point-popup .popup-meta {
  color: #475569;
  font-size: 12px;
  margin-bottom: 8px;
}

#point-popup .popup-coord {
  color: #0e7490;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
}

#point-popup .popup-story {
  margin: 8px 0;
  color: #1e293b;
  font-size: 13px;
}

#point-popup .popup-story br {
  line-height: 1.8;
}

#point-popup .popup-links {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e2e8f0;
}

#point-popup .popup-links a {
  display: inline-block;
  margin: 0 8px 4px 0;
  color: #0369a1;
  text-decoration: none;
  font-size: 12px;
}

#point-popup .popup-links a:hover {
  text-decoration: underline;
}

#point-popup #los_link {
  color: #0369a1;
  cursor: pointer;
}

#point-popup #los_link.los-running {
  color: #94a3b8;
  cursor: wait;
  pointer-events: none;
}

#point-popup .popup-permalink {
  color: #0369a1 !important;
  text-decoration: none;
  font-size: 14px;
  margin-left: 4px;
  cursor: pointer;
}

#point-popup .popup-wpt {
  color: #b45309;
}

#permalink-dialog {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

#permalink-dialog.hidden {
  display: none;
}

.permalink-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.permalink-dialog-box {
  position: relative;
  background: #1f2937;
  color: #f8fafc;
  border-radius: 10px;
  padding: 16px;
  min-width: 360px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
}

.permalink-dialog-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.permalink-dialog-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}

.permalink-dialog-close:hover {
  color: #f8fafc;
}

#permalink-dialog-url {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid #475569;
  border-radius: 4px;
  background: #0f172a;
  color: #f8fafc;
  font-size: 13px;
  margin-bottom: 10px;
}

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

.permalink-dialog-actions button {
  padding: 5px 14px;
  border-radius: 4px;
  border: 1px solid #475569;
  background: #334155;
  color: #f8fafc;
  font-size: 12px;
  cursor: pointer;
}

.permalink-dialog-actions button:hover {
  background: #475569;
}

#meerkat-wrap {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: 830px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-left: 1px solid #cbd5e1;
  box-shadow: -8px 0 24px rgba(15, 23, 42, 0.25);
  animation: meerkat-in 0.18s ease-out;
}

#meerkat-wrap.hidden {
  display: none;
}

@keyframes meerkat-in {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

.meerkat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 30px;
  background: #ffffff;
  color: #0f172a;
  border-bottom: 1px solid #e2e8f0;
  flex: 0 0 auto;
}

.meerkat-title {
  font-weight: 700;
  font-size: 13px;
}

#meerkat-close {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
}

#meerkat-close:hover {
  color: #93c5fd;
}

#meerkatiframe {
  flex: 1 1 auto;
  width: 100%;
  border: 0;
  background: #ffffff;
}

.ol-control {
  margin: 10px;
}

#msg {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
  font-size: 12px;
  color: #0f172a;
  white-space: nowrap;
}

#map-attribution {
  position: absolute;
  bottom: 8px;
  left: 8px;
  z-index: 20;
  max-width: 60%;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
  font-size: 11px;
  color: #0f172a;
  line-height: 1.5;
}

#map-attribution a {
  color: #1d4ed8;
  text-decoration: none;
}

#map-attribution a:hover {
  text-decoration: underline;
}

@media (max-width: 960px) {
  #layer-controls select {
    max-width: 84px;
  }

  #buttons {
    top: auto;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
  }

  #msg {
    bottom: 64px;
  }

  #map-attribution {
    max-width: 22%;
  }
}

@media (max-width: 600px) {
  #layer-controls select {
    max-width: 70px;
  }

  #buttons {
    bottom: 10px;
    gap: 3px;
    padding: 2px;
  }

  #buttons .draw-type {
    gap: 2px;
  }

  #buttons .draw-type-toggle,
  #buttons button {
    width: 30px;
    height: 30px;
  }

  #buttons .draw-type-toggle {
    font-size: 12px;
  }

  #buttons .buttons-sep {
    height: 18px;
    margin: 0 2px;
  }

  #msg {
    bottom: 66px;
  }

  #map-attribution {
    max-width: 13%;
  }
}

@media (max-width: 760px) {
  #toolbar {
    height: auto;
    min-height: 32px;
  }

  /* Search: show icon, hide input+go by default */
  #search-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 28px;
    background: none;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
  }
  #tags, #goto {
    display: none;
  }
  #search-box.expanded {
    position: absolute;
    top: 32px;
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid #cbd5e1;
    padding: 6px 8px;
    gap: 4px;
    z-index: 90;
  }
  #search-box.expanded #search-icon-btn {
    display: none;
  }
  #search-box.expanded #tags {
    display: block;
    width: 100%;
    flex: 1;
  }
  #search-box.expanded #goto {
    display: inline-block;
  }

  /* Track toggle and filter menu stay visible */
  #track-toggle-btn {
    display: inline-flex;
  }
  #filter-menu-wrap {
    display: inline-flex;
  }

  /* Hide toolbar-right inline, show as dropdown */
  #toolbar-right {
    position: absolute;
    top: 32px;
    right: 8px;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 8px;
    z-index: 100;
    display: none;
    flex-direction: column;
    gap: 6px;
    margin-left: 0;
  }
  #toolbar-right.open {
    display: flex;
  }
  #toolbar-right label {
    display: block;
    font-size: 11px;
    color: #64748b;
    margin-bottom: -2px;
  }
  #toolbar-right select {
    width: 100%;
  }

  /* Show dots button */
  #mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 28px;
    font-size: 20px;
    background: none;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    line-height: 1;
  }

  input[type="range"] {
    flex: 1;
    min-width: 70px;
  }
}

/* Center pin overlay */
#center-pin {
  visibility: hidden;
  pointer-events: none;
}
