:root {
  --app-bg: white;
  --app-content-bg: white;
  --app-border-color: #ccc;
  --text-color: #502379;
  --text-inverse-color: white;
  --bar-text-color: black;
  --bar-selected-color: #FDC220;
  --bar-bg: white;
  --color-fab: #502379;
  --input-bg: white;
  --input-border: #ccc;
  --input-text-color: black;
  --focus-color: black;
  --spinner-size: 64px;
  --spinner-thickness: 6px;
  --spinner-track: rgba(0,0,0,0.18);
  --spinner-accent: var(--bar-selected-color);
  --spinner-scrim: rgba(0,0,0,0.28);
}

.mobile-only { display: none !important;
}

html, body {
  height: 100%;
  margin: 0;
  font-family: system-ui, sans-serif;
  background: var(--app-bg);
  color: var(--text-color);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#map {
  height: calc(var(--vh, 1vh) * 100);
  touch-action: none;
  overscroll-behavior: contain;
}


button, input, select {
  font-family: inherit;
  background-color: var(--input-bg);
  color: var(--text-color);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

button:focus,
input:focus,
select:focus,

button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),

.leaflet-bar a:focus { outline: 2px solid var(--focus-color) !important; outline-offset: 2px;
}
.leaflet-bar a:focus:not(:focus-visible) { outline: none !important;
}
.leaflet-bar a .flag-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  box-sizing: border-box;
}

#find-me, #reset-marker {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 14px;
  font-size: 17px;
  cursor: pointer;
  z-index: 1000;
  background-color: var(--app-content-bg);
  border: 1px solid var(--app-border-color);
  box-shadow: 0 0 4px rgba(0,0,0,0.2);
}

#wahlkreis-filter {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 8px 14px;
  font-size: 17px;
  box-shadow: 0 0 4px rgba(0,0,0,0.2);
}

#search-box {
  position: absolute;
  bottom: 90px;
  left: 10px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: var(--app-content-bg);
  padding: 18px 20px;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  border: 1px solid var(--app-border-color);
  width: 340px;
  gap: 10px;
}

#search-box label {
  font-weight: bold;
  margin-bottom: -4px;
  font-size: 18px;
}

#search-box input {
  padding: 10px;
  font-size: 18px;
  border-radius: 8px;
}

#search-box button {
  padding: 8px;
  font-size: 17px;
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text-color);
  border: 1px solid var(--app-border-color);
  cursor: pointer;
}

#search-box input,
#search-box button {
  width: 100%;
  box-sizing: border-box;
}

.suggestions-box {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--app-content-bg);
  color: var(--text-color);
  border: 1px solid var(--app-border-color, #ccc);
  z-index: 1100;
  max-height: 200px;
  overflow-y: auto;
  width: 100%;
  display: none;
  font-size: 17px;
  box-shadow: 0 6px 12px rgba(0,0,0,0.2);
  border-radius: 8px;
}

.suggestions-box div {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--app-border-color);
}

.suggestions-box div:last-child {
  border-bottom: none;
}

.suggestions-box div:hover {
  background-color: var(--hover-bg, rgba(255,255,255,0.1));
}

.suggestions-box button.suggestion-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.suggestions-box button.suggestion-item:hover,
.suggestions-box button.suggestion-item:focus-visible {
  background-color: var(--hover-bg, rgba(255,255,255,0.1));
  outline: none;
}

.desktop-feedback {
  font-size: 16px;
  color: #a00;
  margin-top: -6px;
  margin-bottom: 2px;
  display: none;
}

.landesliste-container {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  z-index: 1000;
  gap: 10px;
}

.volt-logo {
  width: 100px;
  height: auto;
}

.landesliste-counter {
  background: var(--app-content-bg);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 17px;
  font-weight: bold;
  max-width: 280px;
  box-shadow: 0 0 4px rgba(0,0,0,0.2);
  line-height: 1.4;
}

.landesliste-counter small {
  font-weight: normal;
  font-size: 16px;
  color: var(--text-color);
  margin-top: 6px;
  display: block;
}

.legend {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: var(--app-content-bg);
  padding: 14px;
  border-radius: 8px;
  box-shadow: 0 0 5px rgba(0,0,0,0.2);
  font-size: 17px;
  z-index: 1000;
  line-height: 1.4;
  width: 380px;
  border: 1px solid var(--app-border-color);
}

.legend h3 {
  margin: 0 0 2px 0;
  font-size: 18px;
  line-height: 1.2;
}

.legend-sub {
  margin: 0 0 8px 0;
  font-size: 14px;
  opacity: 0.9;
}

.legend-scale {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-top: 4px;
}

.legend-facts {
  margin: 10px 0 6px 0;
  font-size: 16px;
  line-height: 1.3;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.legend-facts p {
  margin: 0;
}

.legend-meta {
  font-size: 12px;
  font-style: italic;
  opacity: 0.8;
  margin: 6px 0;
}

.legend-links {
  display: flex;
  gap: 12px;
  margin-top: 6px;
  font-size: 14px;
}
.legend-links a { text-decoration: underline; }

html[data-theme="light"] .legend-links a {
  color: #502379;
}

.legend-bar {
  height: 15px;
  background: linear-gradient(to right, rgb(231,76,60), rgb(241,196,15), rgb(46,204,113));
  margin-top: 5px;
}

.timestamp {
  font-size: 14px;
  color: #666;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  width: 100%;
}

.info-small {
  font-size: 14px;
}

.info-muted {
  font-size: 14px;
  font-style: italic;
  color: #666;
  margin-top: 6px;
}

.footer-links,
.footer-note {
  position: absolute;
  left: 10px;
  background: var(--footer-bg, rgba(255, 255, 255, 0.8));
  padding: 4px 8px;
  border-radius: 5px;
  max-width: 95%;
  font-size: 14px;
  z-index: 1000;
  line-height: 1.4;
}

.footer-links { bottom: 50px; }
.footer-note { bottom: 20px; }

html[data-theme="light"] .footer-links a,
html[data-theme="light"] .footer-links a:visited {
  color: #502379;
}

.wahlkreis-tooltip {
  font-weight: bold;
  font-size: 12px;
  color: var(--text-inverse-color);
  background: rgba(192, 169, 215, 1);
  padding: 3px 8px;
  border-radius: 4px;
  border: none;
  text-shadow: none;
  pointer-events: none;
  white-space: nowrap;
  transform: translate3d(0, 0, 0);
}

.leaflet-bar a {
  width: 36px;
  height: 36px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 22px;
  background: var(--app-content-bg);
  color: var(--text-color);
  text-decoration: none;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
  .mobile-only { display: block; }
  .desktop-only { display: none; }

  #fab-container {
    position: fixed;
    bottom: 95px;
    left: 20px;
    z-index: 1100;
  }

  #fab-main {
    background-color: var(--color-fab);
    color: var(--bar-bg);
    border: none;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    font-size: 26px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.4s ease, box-shadow 0.3s ease;
  }

  #fab-main:hover {
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4);
  }

  #fab-main.open {
    transform: rotate(90deg);
  }

  #fab-menu {
    background: var(--app-content-bg);
    border: 1px solid var(--app-border-color);
    border-radius: 16px;
    padding: 16px;
    margin-top: 12px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
    display: none;
    flex-direction: column;
    gap: 16px;
    max-width: 320px;
    color: var(--text-color);
    transition: opacity 0.3s ease;
  }

  #fab-menu.show {
    display: flex;
    animation: fadeIn 0.3s ease-out;
  }

  .fab-section {
    font-size: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .fab-section input {
    padding: 10px;
    font-size: 16px;
    border-radius: 8px;
    border: 1px solid var(--input-border);
    background-color: var(--input-bg);
    color: var(--input-text-color);
  }
  
   .fab-section input::placeholder {
      color: var(--input-text-color);
      opacity: 0.6;
    }
    
  .fab-section button {
    padding: 10px;
    font-size: 15px;
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--input-text-color);
    border: 1px solid var(--app-border-color);
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  #fab-legend {
    padding: 6px 8px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,.18);
    font-size: 15px;
    line-height: 1.25;
    border: 1px solid var(--app-border-color);
    background: var(--app-content-bg);
  }
  
  #fab-legend h3 { margin: 0 0 1px; font-size: 16px; }
  #fab-legend .legend-sub { margin: 0 0 1px; font-size: 12px; }
  #fab-legend .legend-bar { height: 6px; margin: 1px 0; }
  #fab-legend .flex-between { font-size: 11px; margin: 0; }
  #fab-legend .legend-facts { margin: 1px 0; font-size: 13px; gap: 1px; }
  #fab-legend .legend-facts p { margin: 0; }
  #fab-legend .legend-meta { font-size: 11px; margin-top: 1px; }
  #fab-legend .legend-links { font-size: 12px; margin-top: 0; gap: 4px; }

  .fab-section button, .fab-section select { font-size: 16px; }

  #fab-timestamp { font-size: 11px; margin-top: 2px; }

  @media (hover: hover) {
    .fab-section button:hover {
      background-color: var(--bar-selected-color);
      color: var(--bar-text-color);
      box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    }
  }

  .fab-section button:active,
  .fab-section button:focus {
    background-color: var(--input-bg);
    color: var(--input-text-color);
    box-shadow: none;
    outline: none;
  }
  
  .fab-section strong {
    font-weight: bold;
    margin-bottom: 6px;
    color: var(--text-color);
  }
  
  .fab-feedback {
    font-size: 13px;
    color: #a00;
    margin-top: 4px;
    display: none;
  }
  
  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

@media (max-width: 768px) {
  .mobile-only {
    display: block !important;
  }

  .desktop-only,
  .legend,
  #find-me,
  #wahlkreis-filter {
    display: none !important;
  }

  #search-box {
    left: 50%;
    transform: translateX(-50%);
    bottom: 120px;
    width: 95%;
    max-width: 300px;
    align-items: center;
  }

  #landesliste-detail {
    display: none;
  }

  .landesliste-counter.tap-detail #landesliste-detail {
    display: block;
  }

  #landesliste-deadline {
    display: none;
  }

  .landesliste-counter.tap-detail #landesliste-deadline {
    display: block;
  }
}

html, body {
  overscroll-behavior: none;
  touch-action: manipulation;
}

.leaflet-bar a {
  width: 40px !important;
  height: 40px !important;
  font-size: 22px !important;
  line-height: 40px !important;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 5000;
}
.overlay.hidden { display: none; }
.overlay-content {
  background: var(--app-content-bg);
  color: var(--text-color);
  padding: 24px;
  border-radius: 12px;
  max-width: 420px;
  width: calc(100% - 48px);
  text-align: center;
  box-shadow: 0 6px 12px rgba(0,0,0,0.3);
  border: 1px solid var(--app-border-color);
}
.overlay-content button {
  margin-top: 16px;
  padding: 10px 18px;
  font-size: 16px;
  cursor: pointer;
  background: var(--input-bg);
  color: var(--input-text-color);
  border: 1px solid var(--input-border);
  border-radius: 8px;
}

.loading-backdrop{
  position: fixed; inset: 0;
  background: var(--spinner-scrim);
  z-index: 4800;
  pointer-events: none;
}

.loading-spinner{
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: var(--spinner-size); height: var(--spinner-size);
  border: var(--spinner-thickness) solid var(--spinner-track);
  border-top-color: var(--spinner-accent);
  border-right-color: var(--spinner-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  z-index: 4900;
  background: transparent;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  pointer-events: none;
}

.hidden { display: none !important; }

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce){
  .loading-spinner{ animation-duration: 1.6s; }
}

.leaflet-marker-icon.bounce {
  animation: lfbounce 600ms ease-out 1;
  transform-origin: bottom center;
}
@keyframes lfbounce {
  0% { transform: translateY(0); }
  30% { transform: translateY(-20px); }
  60% { transform: translateY(0); }
  80% { transform: translateY(-10px); }
  100% { transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .leaflet-marker-icon.bounce { animation: none; }
}

.ll-progress{height:12px;background:rgba(0,0,0,0.08);border-radius:999px;overflow:hidden;margin-top:8px;border:1px solid var(--app-border-color)}
.ll-progress-bar{height:100%;width:0%;background:var(--bar-selected-color);position:relative;transition:width .4s ease}
.ll-progress-bar span{position:absolute;right:6px;top:50%;transform:translateY(-50%);font-size:12px;color:var(--bar-text-color)}
.ll-progress-bar {
  max-width: 100%;
}
.ll-meta{margin-top:8px}
.ll-deadline-badge{display:inline-block;padding:4px 10px;border-radius:999px;border:1px solid var(--app-border-color);background:var(--app-content-bg);font-size:14px}
.ll-deadline-inline {
  font-size: 16px;
  margin-top: 18px;
  color: var(--text-color);
}

.visually-hidden{
  position:absolute !important;
  width:1px;height:1px;
  padding:0;margin:-1px;
  overflow:hidden;clip:rect(0,0,0,0);
  white-space:nowrap;border:0;
}

html, body { height:100%; overflow:hidden; }

#map {
  position: fixed; 
  inset: 0;
  height: calc(var(--vh, 1vh) * 100);
  touch-action: none;
  overscroll-behavior: contain;
}

.rotate-overlay{
  position: fixed; inset: 0;
  display: none;
  flex-direction: column; gap: 16px;
  align-items: center; justify-content: center;
  text-align: center; padding: 24px;
  background: linear-gradient(135deg,#502379 0%, #6B3AA3 60%, #8A5BC0 100%);
  color: white;
  z-index: 99999;
}
.rotate-overlay img{ width: 120px; height: auto; }
.rotate-overlay p{ margin: 0; font-size: 18px; line-height: 1.35; }

@media (orientation: landscape) and (hover: none) and (pointer: coarse) {
  #map, .leaflet-control, .landesliste-container, .legend, #fab-container, #search-box {
    filter: blur(1px);
  }
  .rotate-overlay{ display: flex; }
}



.leaflet-popup-content-wrapper {
  background: var(--app-content-bg);
  color: var(--text-color);
  border: 1px solid var(--app-border-color);
  border-radius: 14px;
  box-shadow: 0 10px 22px rgba(0,0,0,.22);
}

.leaflet-popup-content {
  margin: 14px 16px;
  font-size: 15px;
  line-height: 1.25;
}

.leaflet-popup-tip {
  background: var(--app-content-bg);
  border: 1px solid var(--app-border-color);
}

.wk-popup { min-width: 260px; max-width: 340px; }
.wk-popup__head { margin-bottom: 8px; }
.wk-popup__title { font-weight: 800; font-size: 16px; }
.wk-popup__sub { opacity: .85; margin-top: 2px; }

.wk-popup__section { padding: 10px 0; }
.wk-popup__section-title {
  font-weight: 800;
  font-size: 13px;
  letter-spacing: .02em;
  text-transform: uppercase;
  opacity: .85;
  margin-bottom: 8px;
}

.wk-popup__divider{
  height: 1px;
  background: var(--app-border-color);
  opacity: .7;
  margin: 0;
}

.wk-popup__rows { display: grid; gap: 6px; margin-bottom: 8px; }
.wk-row { display: flex; justify-content: space-between; gap: 12px; }
.wk-row span { opacity: .9; }
.wk-row strong { font-weight: 800; }
.wk-row--muted span, .wk-row--muted strong { opacity: .75; font-weight: 700; }

.wk-progress{
  position: relative;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--app-border-color);
  background: rgba(0,0,0,0.08);
}
.wk-progress__bar{
  height: 100%;
  background: var(--bar-selected-color);
  transition: width .25s ease;
}
.wk-progress__label{
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--bar-text-color);
  font-weight: 800;
}

.wk-link{
  display:inline-flex;
  justify-content:center;
  padding:8px 10px;
  border-radius:10px;
  border:1px solid var(--app-border-color);
  text-decoration:none;
  color: var(--text-color);
  background: var(--input-bg);
}

.landesliste-collected {
  margin-top: 4px;
  font-size: 0.95rem;
  opacity: 0.85;
}

#ll-progress,
.ll-progress,
.ll-progress-bar,
#ll-progress-bar {
  display: none !important;
}

.ll-targets{
  margin-top: 8px;
  display: grid;
  gap: 4px;
}
.ll-target-row{
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.ll-target-label{
  font-weight: 600;
  opacity: 0.9;
}
.ll-target-value{
  font-weight: 800;
}

.landesliste-title{
  font-size: 18px;
  font-weight: bold;
}

#landesliste-counter .ll-targets { display: grid; }
#landesliste-counter #landesliste-deadline { display: block; }

@media (max-width: 768px) {
  #landesliste-counter .ll-targets,
  #landesliste-counter #landesliste-deadline {
    display: none;
  }

  #landesliste-counter.tap-detail .ll-targets { display: grid; }
  #landesliste-counter.tap-detail #landesliste-deadline { display: block; }

  #landesliste-counter { cursor: pointer; -webkit-tap-highlight-color: transparent; }
}
