* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font-family: -apple-system, "Segoe UI", Roboto, sans-serif; }
body { display: flex; flex-direction: column; background: #14181f; color: #e8e8e8; }

header { padding: 10px 16px 8px; background: #1b202a; border-bottom: 1px solid #2a3140; }
.topbar { display: flex; align-items: center; gap: 16px; justify-content: space-between; }
header h1 { margin: 0; font-size: 1.3rem; letter-spacing: 0.5px; }
header h1 .accent { color: #ff8c42; }
header h1 .claim { font-size: 0.8rem; font-weight: 400; color: #9aa4b5; letter-spacing: 0; }
.language-picker { display: inline-flex; align-items: center; gap: 6px; color: #9aa4b5; font-size: 0.78rem; white-space: nowrap; }
.language-picker select {
  background: #232a38; color: #e8e8e8; border: 1px solid #2a3140;
  border-radius: 6px; padding: 3px 8px; font-size: 0.8rem;
}

.stats { margin: 6px 0 8px; font-size: 0.82rem; color: #c8d0dd; }
.stats .stat { white-space: nowrap; }
.stats i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 3px; vertical-align: -1px; }
.stats b { color: #fff; }

.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 0.85rem; margin-top: 6px; }
.mode-toggle button {
  background: #232a38; color: #e8e8e8; border: 1px solid #2a3140;
  padding: 4px 12px; cursor: pointer; font-size: 0.85rem;
}
.mode-toggle button:first-child { border-radius: 6px 0 0 6px; }
.mode-toggle button:last-child { border-radius: 0 6px 6px 0; margin-left: -1px; }
.mode-toggle button.active { background: #3a4557; border-color: #4a5870; }
.controls select, .controls input {
  background: #232a38; color: #e8e8e8; border: 1px solid #2a3140;
  border-radius: 6px; padding: 4px 8px; font-size: 0.85rem;
}
.controls input { width: 70px; }
.controls label { color: #9aa4b5; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 0.75rem; color: #9aa4b5; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.legend i.ring { background: transparent; border: 2px solid; width: 8px; height: 8px; }
.legend .sep { color: #3a4557; }
.legend .scalebar i { width: 90px; height: 10px; border-radius: 2px; }

/* an/aus als Kippschalter statt nackter Checkbox */
.switch { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .knob {
  width: 32px; height: 18px; border-radius: 9px; background: #2a3140;
  border: 1px solid #3a4557; position: relative; flex-shrink: 0;
  transition: background 0.18s, border-color 0.18s;
}
.switch .knob::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px;
  border-radius: 50%; background: #9aa4b5; transition: transform 0.18s, background 0.18s;
}
.switch input:checked + .knob { background: #b35b1e; border-color: #ff8c42; }
.switch input:checked + .knob::after { transform: translateX(14px); background: #fff; }
.switch:hover .knob { border-color: #4a5870; }

.timeline {
  display: inline-flex; align-items: center; gap: 8px; margin-left: auto;
  background: #1a202b; border: 1px solid #2a3140; border-radius: 8px; padding: 3px 10px;
}
.timeline.tl-past { border-color: #ffd166; }
.timeline input[type=range] {
  -webkit-appearance: none; appearance: none; width: 170px; height: 18px;
  background: transparent; border: none; padding: 0; cursor: pointer;
}
/* der Browser-Fokusring passt nicht zum Custom-Slider; der aktive
   Rückblick ist bereits über den gelben Boxrahmen (.tl-past) erkennbar */
.timeline input[type=range]:focus { outline: none; }
.timeline input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px; background: #3a4557;
}
.timeline input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px;
  border-radius: 50%; background: #ff8c42; border: 2px solid #14181f;
  transition: transform 0.12s;
}
.timeline input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.25); }
.timeline input[type=range]::-moz-range-track {
  height: 4px; border-radius: 2px; background: #3a4557;
}
.timeline input[type=range]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: #ff8c42; border: 2px solid #14181f;
}
.timeline.tl-past input[type=range]::-webkit-slider-thumb { background: #ffd166; }
.timeline.tl-past input[type=range]::-moz-range-thumb { background: #ffd166; }
.tl-caption { color: #9aa4b5; }
.tl-end { color: #6b7688; font-size: 0.75rem; font-variant-numeric: tabular-nums; }
/* fester Platzhalter für Zeitpunkt + Button, sonst springt die rechtsbündige
   Box nach links, sobald beim Schieben das Label eingeblendet wird */
.tl-extra { display: inline-flex; align-items: center; gap: 8px; min-width: 285px; }
@media (max-width: 900px) { .tl-extra { min-width: 0; } }

/* Mobil: Bedienelemente volle Breite, Slider dehnt sich, größere Touchziele */
@media (max-width: 700px) {
  header { padding: 8px 10px 6px; }
  .topbar { align-items: flex-start; }
  header h1 { font-size: 1.15rem; }
  .language-picker span { display: none; }
  .claim { display: none; }
  .stats { font-size: 0.78rem; }
  .controls { gap: 8px; }
  .mode-toggle { display: flex; flex: 1 1 100%; }
  .mode-toggle button { flex: 1; padding: 7px 4px; font-size: 0.8rem; }
  .timeline {
    flex: 1 1 100%; margin-left: 0; flex-wrap: wrap; justify-content: center;
  }
  .timeline input[type=range] { flex: 1 1 120px; width: auto; min-width: 100px; }
  .timeline input[type=range]::-webkit-slider-thumb { width: 20px; height: 20px; margin-top: -8px; }
  .timeline input[type=range]::-moz-range-thumb { width: 18px; height: 18px; }
  .tl-extra { justify-content: center; }
  .tl-extra:empty { display: none; }
  .legend { font-size: 0.68rem; gap: 8px; }
}
#timeline-label {
  color: #ffd166; font-weight: 600; font-variant-numeric: tabular-nums;
}
#timeline-now {
  background: #ff8c42; color: #14181f; font-weight: 600; border: none;
  border-radius: 6px; padding: 3px 10px; cursor: pointer; font-size: 0.8rem;
}
#timeline-now.hidden, #timeline-label.hidden, #filter-records-label.hidden, #filter-years-label.hidden,
#filter-now-missing-label.hidden { display: none; }
#language-select option:disabled { color: #6b7688; }

.badge-near { background: transparent; border: 1.5px solid; }

/* Vollflächiger Hinweis, solange der Datenimport läuft */
#ingest-overlay {
  position: fixed; inset: 0; z-index: 2000; display: flex;
  align-items: center; justify-content: center; text-align: center;
  background: rgba(11, 14, 19, 0.92); padding: 24px;
}
#ingest-overlay.hidden { display: none; }
#ingest-overlay h2 { margin: 18px 0 10px; }
#ingest-overlay p { color: #9aa4b5; max-width: 440px; margin: 0 auto; }
#ingest-overlay .spinner {
  width: 42px; height: 42px; margin: 0 auto; border-radius: 50%;
  border: 4px solid #2a3140; border-top-color: #ff8c42;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#map { flex: 1; background: #14181f; }
#map.hidden { display: none; }
.country-link-label {
  background: rgba(20, 24, 31, 0.82);
  border: 1px solid rgba(138, 180, 248, 0.55);
  border-radius: 6px;
  color: #d8e6ff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  box-shadow: none;
}
.country-link-label::before { display: none; }

#table-view { flex: 1; overflow: auto; padding: 0 16px 16px; }
#table-view.hidden { display: none; }
#stations-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-top: 10px; }
#stations-table th {
  text-align: left; color: #9aa4b5; font-weight: 600; padding: 6px 10px 6px 0;
  border-bottom: 1px solid #2a3140; cursor: pointer; user-select: none;
  position: sticky; top: 0; background: #14181f;
}
#stations-table th.sorted { color: #fff; }
#stations-table td { padding: 4px 10px 4px 0; border-bottom: 1px solid #1e242f; }
#stations-table td.empty { color: #9aa4b5; padding: 14px 0; }
#stations-table td.num { font-variant-numeric: tabular-nums; }
#stations-table tbody tr { cursor: pointer; }
#stations-table tbody tr:hover { background: #1b202a; }

#about {
  padding: 14px 16px; background: #171c25; border-top: 1px solid #2a3140;
  font-size: 0.82rem; color: #b7c0cf; max-height: 30vh; overflow-y: auto;
}
#about h2 { margin: 0 0 6px; font-size: 0.95rem; color: #e8e8e8; cursor: pointer; user-select: none; }
#about.hidden { display: none; }
#about-arrow { float: right; color: #9aa4b5; }
#about p { margin: 0 0 8px; max-width: 75rem; line-height: 1.5; }
#about a { color: #8ab4f8; }

#panel {
  position: absolute; top: 170px; right: 12px; z-index: 1000;
  width: 320px; max-height: calc(100% - 200px); overflow-y: auto;
  background: #1b202a; border: 1px solid #2a3140; border-radius: 10px;
  padding: 14px 16px; box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
#panel.hidden { display: none; }
#panel-close {
  position: absolute; top: 6px; right: 10px; background: none; border: none;
  color: #9aa4b5; font-size: 1.3rem; cursor: pointer;
}
#panel h2 { margin: 0 0 2px; font-size: 1.05rem; }
#panel .meta { font-size: 0.75rem; color: #9aa4b5; margin-bottom: 10px; }
#panel table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
#panel th { text-align: left; color: #9aa4b5; font-weight: 500; padding: 6px 0 2px; }
#panel td { padding: 2px 0; border-bottom: 1px solid #232a38; }
#panel td.val { text-align: right; font-variant-numeric: tabular-nums; }
#panel td.date { text-align: right; color: #9aa4b5; font-size: 0.75rem; }
.today-vals { display: flex; gap: 14px; margin: 8px 0 4px; font-size: 1rem; }
.today-vals .hot { color: #ff8c42; }
.today-vals .cold { color: #6ec6ff; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 0.72rem; margin: 2px 4px 2px 0; }

footer {
  padding: 5px 16px; background: #1b202a; border-top: 1px solid #2a3140;
  font-size: 0.72rem; color: #9aa4b5;
}
footer a { color: #9aa4b5; }

/* Messwert-Labels an den Markern im Nur-Rekorde-Modus der Karte */
.temp-label {
  background: rgba(20, 24, 31, 0.88); border: 1px solid #2a3140; border-radius: 6px;
  color: #e8e8e8; font-size: 0.72rem; font-weight: 600; padding: 1px 5px;
  box-shadow: none;
}
.temp-label::before { display: none; }
.interp-tip { text-align: center; }
/* über der Farbfläche zeigt der Cursor an, dass Werte abgefragt werden können */
.leaflet-container.overlay-crosshair { cursor: crosshair; }
.interp-note { font-weight: 400; font-style: italic; color: #9aa4b5; font-size: 0.65rem; }
