* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

body { display: flex; flex-direction: column; }

#app-header {
  flex: none;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 16px;
  background: #6d1f1f;
  color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
  position: relative;
  z-index: 1200;
}

.brand { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.brand-title { font-size: 20px; font-weight: 700; color: #ffd27a; text-decoration: none; }
.brand-title:hover { color: #ffe6b8; text-decoration: none; }
.brand-tagline { font-size: 13px; opacity: .9; }
.brand-impressum { font-size: 12px; color: #ffd27a; text-decoration: none; margin-top: 1px; }
.brand-impressum:hover { color: #ffe6b8; text-decoration: none; }

.map-chooser { flex: none; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.map-chooser label {
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  opacity: .85;
}
.map-chooser select {
  font: 14px/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, .55);
  background: #fff;
  color: #3a1313;
  font-weight: 600;
  cursor: pointer;
  min-width: 210px;
}

#map-area { position: relative; flex: 1 1 auto; min-height: 0; }
#map { position: absolute; inset: 0; background: #eaeaea; }

/* Info-Bereich links in der Kartenmitte (je Themenkomplex) */
.map-info-panel {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1000;
  width: 260px;
  max-width: calc(100% - 32px);
  max-height: calc(100% - 32px);
  overflow-y: auto;
  background: rgba(255, 255, 255, .96);
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .3);
  padding: 16px 18px;
  color: #2a2a2a;
}
.map-info-panel[hidden] { display: none; }
.map-info-panel h2 { margin: 0 0 6px; font-size: 18px; color: #6d1f1f; }
.map-info-desc { margin: 0 0 12px; font-size: 12.5px; line-height: 1.45; color: #444; }
.map-info-stats { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 14px; }
.map-info-stats .stat { display: inline-flex; align-items: center; gap: 8px; }
.map-info-stats b { font-size: 16px; font-weight: 700; }
.map-info-stats .dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .2);
}
.map-info-stats .dot.hoard { background: #dc0000; }
.map-info-stats .dot.coin { background: #ff8c00; }

.map-info-total {
  margin: 0 0 14px;
  padding-top: 11px;
  border-top: 1px solid #e2d4d4;
  font-size: 14px;
  color: #444;
}
.map-info-total b { font-size: 19px; font-weight: 700; color: #6d1f1f; margin-right: 2px; }

.map-info-btn {
  display: inline-block;
  background: #6d1f1f;
  color: #fff;
  padding: 9px 16px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background .15s;
}
.map-info-btn:hover { background: #8a2a2a; }

/* Info-Panel per Ziehleisten verschiebbar (oben/unten), analog zu den Popups */
.panel-drag {
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: move;
  border-radius: 4px;
  background: #f3ebeb;
  touch-action: none;
  user-select: none;
}
.panel-drag:hover { background: #ecdede; }
.panel-drag span {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: #b48a8a;
}
.panel-drag-top { margin: -6px -8px 12px; }
.panel-drag-bottom { margin: 14px -8px -6px; }
.map-info-panel.panel-dragging {
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  cursor: move;
}

@media (max-width: 720px) {
  .brand-title { font-size: 18px; }
  .brand-tagline { font-size: 12px; }
  .map-chooser select { min-width: 150px; }
  .map-info-panel { width: 220px; }
}

/* Legende */
.legend {
  background: rgba(255, 255, 255, .92);
  padding: 8px 10px;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
  font-size: 12px;
  line-height: 1.5;
  color: #222;
}

.legend h4 {
  margin: 0 0 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #555;
}

.legend hr { border: none; border-top: 1px solid #ddd; margin: 6px 0; }
.legend .legend-note { max-width: 190px; color: #444; }

.legend .dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  vertical-align: -1px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .2);
}

.legend .dot.hoard { background: #dc0000; }
.legend .dot.coin { background: #ff8c00; }

.leaflet-control-layers { font-size: 13px; }

/* Popup */
.fund-popup .leaflet-popup-content { margin: 12px 14px; }

/* Ziehleisten zum Verschieben des Popups */
.fund-drag {
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: move;
  border-radius: 4px;
  background: #f3ebeb;
  touch-action: none;
  user-select: none;
}
.fund-drag:hover { background: #ecdede; }
.fund-drag-top { margin: -6px -8px 8px; padding-right: 18px; }
.fund-drag-bottom { margin: 10px -8px -6px; position: relative; }
.fund-drag span {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: #b48a8a;
}
.fund-close {
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: transparent;
  color: #6d1f1f;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
}
.fund-close:hover { background: rgba(109, 31, 31, .14); }
.leaflet-popup.fund-dragging .leaflet-popup-content-wrapper {
  box-shadow: 0 8px 26px rgba(0, 0, 0, .35);
}

.fund h3 { margin: 0 0 6px; font-size: 15px; color: #6d1f1f; }

.type-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  padding: 1px 8px;
  border-radius: 10px;
  margin-bottom: 8px;
  background: #777;
}

.type-badge.hoard { background: #dc0000; }
.type-badge.coin { background: #ff8c00; }

.fund-dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 3px 10px;
  margin: 0;
  max-height: 320px;
  overflow: auto;
}

.fund-dl dt { font-weight: 600; color: #555; }
.fund-dl dd { margin: 0; color: #222; word-break: break-word; }
.fund-dl dd a { color: #1a5fb4; }

.fund-msg { font-size: 13px; color: #333; max-width: 240px; }
.fund-msg code { background: #f0f0f0; padding: 1px 4px; border-radius: 3px; }

/* Mehrere Funde an derselben Koordinate */
.fund-multi {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 -8px 8px;
  padding: 6px 10px;
  background: #f6ecec;
  border: 1px solid #e0c9c9;
  border-radius: 5px;
}
.fund-multi-info {
  font-size: 12px;
  font-weight: 700;
  color: #6d1f1f;
  line-height: 1.25;
}
.fund-multi-nav { display: flex; align-items: center; gap: 4px; flex: none; }
.fund-multi-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid #cc9999;
  border-radius: 5px;
  background: #fff;
  color: #6d1f1f;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.fund-multi-btn:hover { background: #6d1f1f; border-color: #6d1f1f; color: #fff; }
.fund-multi-count {
  font-size: 12px;
  font-weight: 600;
  color: #6d1f1f;
  min-width: 42px;
  text-align: center;
}

/* Dauerhafte Markierung: mehrere Funde an einer Koordinate */
.fund-cluster {
  pointer-events: none !important; /* Klick/Hover fallen auf die Karte durch */
  background: transparent !important;
  border: none !important;
}
.fund-cluster-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 11px;
  background: #6d1f1f;
  color: #fff;
  font: 700 12px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  border: 2px solid #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, .45);
}

/* Hover-Tooltip mit Toponym */
.fund-tip.leaflet-tooltip {
  background: #6d1f1f;
  color: #fff;
  border: none;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .35);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 4px;
}
.fund-tip.leaflet-tooltip-top::before { border-top-color: #6d1f1f; }
.fund-tip.leaflet-tooltip-bottom::before { border-bottom-color: #6d1f1f; }

/* Bereichs-Export */
.export-ctl {
  background: #fff;
  padding: 9px 11px;
  border-radius: 7px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .3);
  width: 196px;
  font: 13px/1.35 system-ui, -apple-system, sans-serif;
  color: #333;
}
.export-title { font-weight: 700; color: #6d1f1f; margin-bottom: 7px; }
.export-btn {
  display: block;
  width: 100%;
  margin: 5px 0;
  padding: 8px 9px;
  border: 1px solid #c3b9a8;
  border-radius: 5px;
  background: #f6f2ea;
  color: #333;
  font: inherit;
  cursor: pointer;
  text-align: center;
  transition: background .15s, border-color .15s;
}
.export-btn:hover:not(:disabled) { background: #ece4d6; }
.export-btn.active { background: #6d1f1f; border-color: #6d1f1f; color: #fff; }
.export-btn:disabled { opacity: .5; cursor: default; }
.export-run { font-weight: 600; }
.export-hint { margin-top: 5px; font-size: 11px; color: #7d7669; }
.export-rect { cursor: crosshair; }

/* Besucher-Präsenz (links unten) */
.presence-ctl {
  background: #fff;
  padding: 8px 11px;
  border-radius: 7px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .3);
  font: 12px/1.4 system-ui, -apple-system, sans-serif;
  color: #333;
  min-width: 150px;
}
.presence-title {
  font-weight: 700;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #6d1f1f;
  margin-bottom: 5px;
}
.presence-online { display: flex; align-items: center; gap: 6px; }
.presence-online b { color: #1a7f34; font-weight: 700; font-size: 14px; }
.presence-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #23c552;
  box-shadow: 0 0 0 rgba(35, 197, 82, .6);
  animation: presence-pulse 1.8s ease-out infinite;
}
@keyframes presence-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(35, 197, 82, .55); }
  70%  { box-shadow: 0 0 0 7px rgba(35, 197, 82, 0); }
  100% { box-shadow: 0 0 0 0 rgba(35, 197, 82, 0); }
}
.presence-sub { margin-top: 4px; font-size: 11px; color: #6b6b6b; }
.presence-sub b { color: #444; font-weight: 700; }

/* Button im Popup: enthaltene Münzen eines Hortes anzeigen */
.fund-coins-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: #6d1f1f;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.fund-coins-btn:hover { background: #8a2a2a; }

/* Overlay mit der Münzliste eines Hortes */
.coins-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, .5);
}
.coins-modal {
  display: flex;
  flex-direction: column;
  width: 960px;
  max-width: 100%;
  max-height: 84vh;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .4);
  overflow: hidden;
}
.coins-modal-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #6d1f1f;
  color: #fff;
}
.coins-modal-title { margin: 0; font-size: 16px; font-weight: 700; }
.coins-modal-close {
  flex: none;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
}
.coins-modal-close:hover { background: rgba(255, 255, 255, .18); }
.coins-modal-body { padding: 14px 16px; overflow: auto; }
.coins-loading, .coins-empty { padding: 20px 4px; color: #555; font-size: 14px; }
.coins-empty code { background: #f0f0f0; padding: 1px 4px; border-radius: 3px; }
.coins-count {
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6d1f1f;
}

.coins-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.coins-table thead th {
  position: sticky;
  top: 0;
  background: #f6ecec;
  color: #6d1f1f;
  text-align: left;
  font-weight: 700;
  padding: 7px 10px;
  border-bottom: 2px solid #e0c9c9;
  white-space: nowrap;
}
.coins-table tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid #eee;
  color: #222;
  vertical-align: top;
}
.coins-table tbody tr:nth-child(even) { background: #faf6f6; }
.coins-table .coins-key {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  color: #444;
  white-space: nowrap;
}
.coins-table a { color: #1a5fb4; white-space: nowrap; }

@media (max-width: 720px) {
  .coins-table { font-size: 12px; }
  .coins-table thead th, .coins-table tbody td { padding: 5px 7px; }
}

/* Münzsuche im Info-Panel */
.coin-search {
  margin: 0 0 14px;
  padding-top: 12px;
  border-top: 1px solid #e2d4d4;
}
.coin-search-title {
  margin: 0 0 9px;
  font-size: 14px;
  font-weight: 700;
  color: #6d1f1f;
}
.coin-search-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 8px;
}
.coin-search-field span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: #6b5a5a;
}
.coin-search-field select,
.coin-search-field input {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid #c9bcbc;
  border-radius: 6px;
  background: #fff;
  color: #2a2a2a;
  font: 13px/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.coin-search-field select:focus,
.coin-search-field input:focus {
  outline: none;
  border-color: #6d1f1f;
  box-shadow: 0 0 0 2px rgba(109, 31, 31, .15);
}
.coin-search-actions { display: flex; gap: 8px; margin-top: 2px; }
.coin-search-btn {
  flex: 1 1 auto;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: #6d1f1f;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.coin-search-btn:hover:not(:disabled) { background: #8a2a2a; }
.coin-search-btn:disabled { opacity: .6; cursor: default; }
.coin-search-reset {
  flex: none;
  padding: 8px 12px;
  border: 1px solid #c9bcbc;
  border-radius: 6px;
  background: #f6f2f2;
  color: #555;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.coin-search-reset:hover { background: #ece0e0; }
.coin-search-result {
  margin-top: 9px;
  font-size: 12.5px;
  line-height: 1.4;
  color: #444;
  min-height: 0;
}
.coin-search-result.cs-ok { color: #1f5f2a; font-weight: 600; }
.coin-search-result.cs-warn { color: #8a2a2a; }

/* Treffer-Popup der Münzsuche */
.cs-pop h3 { margin: 0 0 6px; font-size: 15px; color: #6d1f1f; }
.cs-pop-count {
  margin: 4px 0 2px;
  font-size: 13px;
  font-weight: 600;
  color: #333;
}

/* Größen-Legende der Münzsuche (Punktgröße = Trefferzahl) */
.coin-search-legend {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px dashed #e2d4d4;
}
.coin-search-legend[hidden] { display: none; }
.cs-legend-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
  color: #6b5a5a;
  margin-bottom: 10px;
}
.cs-legend-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
  padding: 0 4px 2px;
}
.cs-legend-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.cs-legend-dot {
  display: block;
  border-radius: 50%;
  background: #1565c0;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
}
.cs-legend-lbl {
  font-size: 10px;
  line-height: 1;
  color: #666;
}

