:root {
  --bg: #f8f8f6;
  --ink: #1a1410;
  --ink-light: #e8e6e4;
  --muted: #5c767e;
  --accent: #3c6799;
  --border: #79889b;
  --ocean: rgba(188, 218, 223, 0);
  --bg-legend: rgba(238, 242, 245, 0.7);
  --bg-search: rgba(238, 242, 245, 0.7);
  --shadow: rgba(50, 53, 79, 0.3);

  --bg-land: #eef2f5;
  --bg-ausgewaehlt: #0c889a;
  --bg-hover: #941f61;
  --bg-bereist: #2f5170;
  --bg-bereist-link: #366591;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Instrument Sans", sans-serif;
  background: var(--ocean);
  height: 100vh;
  overflow: hidden;
}

#canvas-wrap {
  width: 100vw;
  height: 100vh;
  position: relative;
  cursor: grab;
}

#canvas-wrap:active {
  cursor: grabbing;
}

canvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
}

/* SUCHE – oben rechts */
.search-wrap {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 100;
  width: 210px;
}

.search-wrap input {
  width: 100%;
  background: var(--bg-search);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 8px 14px 8px 32px;
  font-family: "Instrument Sans", sans-serif;
  font-size: 0.82rem;
  border-radius: 2px;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px var(--shadow);
}

.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 2px 14px var(--shadow);
}

.search-wrap input::placeholder {
  color: var(--muted);
}

.s-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  color: var(--muted);
  pointer-events: none;
}

#search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-search);
  border: 1px solid var(--border);
  border-radius: 2px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 9999;
  display: none;
  box-shadow: 0 4px 16px var(--shadow);
}

.sr-item {
  padding: 7px 14px;
  font-size: 0.8rem;
  color: var(--ink);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

.sr-item:last-child {
  border-bottom: none;
}
.sr-item:hover {
  background: var(--accent);
  color: var(--ink-light);
}
.sr-item.active {
  background: var(--accent);
  color: var(--ink-light);
}

/* LEGENDE – unten links */
.legend {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background: var(--bg-legend);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 9px 13px;
  z-index: 100;
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  gap: 5px;
  box-shadow: 0 2px 8px var(--shadow);
}

.leg-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--muted);
}

.leg-dot {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

/* ZOOM – unten rechts */
.zoom-controls {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  z-index: 100;
}

.z-btn {
  width: 32px;
  height: 32px;
  background: var(--bg-legend);
  color: var(--ink);
  border: 1px solid var(--border);
  font-size: 1rem;
  cursor: pointer;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-family: monospace;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 6px var(--shadow);
}

.z-btn:hover {
  background: var(--accent);
  color: var(--ink-light);
  border-color: var(--accent);
}
.z-reset {
  font-size: 0.65rem;
  font-family: "Instrument Sans", sans-serif;
}

/* KOORDINATEN – unten mitte */
.coords-bar {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: var(--muted);
  background: var(--bg-legend);
  padding: 2px 8px;
  border-radius: 2px;
  font-family: monospace;
}

/* TOOLTIP */
#tooltip {
  position: fixed;
  background: var(--ink);
  color: var(--ink-light);
  padding: 5px 10px;
  font-size: 0.75rem;
  border-radius: 2px;
  pointer-events: none;
  display: none;
  z-index: 9999;
  border-left: 3px solid var(--accent);
  font-family: "Instrument Sans", sans-serif;
}
@media (max-width: 768px) {
  #tooltip {
    display: none !important;
  }
  #coords-bar {
    display: none !important;
  }
}

/* INFO POPUP – oben links beim Klick */
#info-popup {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 215px;
  background: var(--bg-search);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 12px 14px;
  z-index: 100;
  display: none;
  box-shadow: 0 4px 20px var(--shadow);
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  backdrop-filter: blur(4px);
}

.popup-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.popup-close:hover {
  color: var(--accent);
}

.c-name {
  font-family: "Instrument Serif", serif;
  font-size: 1.1rem;
  color: var(--accent);
  margin-bottom: 10px;
  padding-bottom: 7px;
  padding-right: 16px;
  border-bottom: 1px solid var(--border);
}

.c-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 0.71rem;
  border-bottom: 1px solid rgba(200, 191, 176, 0.35);
  gap: 8px;
}

.c-key {
  color: var(--muted);
  flex-shrink: 0;
}
.c-val {
  color: var(--ink);
  text-align: right;
  word-break: break-word;
}

::-webkit-scrollbar {
  width: 3px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.leg-toggle {
  transition:
    color 0.15s,
    opacity 0.2s;
}
.leg-toggle:hover {
  color: var(--accent);
}

#toggle-small {
  cursor: pointer;
  user-select: none;
  padding: 3px 6px;
  margin: 2px -6px 0; /* bündig mit Legende */
  border: 1px solid var(--accent);
  border-radius: 2px;
  color: var(--accent);
  transition:
    background 0.15s,
    color 0.15s,
    opacity 0.2s,
    border-color 0.15s;
}

#toggle-small:hover {
  background: var(--accent);
  color: var(--ink-light);
}

#toggle-small:hover .leg-dot {
  border-color: var(--ink-light);
  background: rgba(255, 255, 255, 0.3) !important;
}

#toggle-small.is-off {
  opacity: 0.45;
  border-style: dashed;
  color: var(--muted);
}
