/* Motorrad-Tracks – Routenplaner (/planen)
   Ergänzt subpages.css (helles Theme). Nur diese Seite, keine Wirkung auf
   Touren- oder Upload-Seiten. Farben bewusst aus der Palette des Themes. */

.planner { max-width: 1180px; padding: 30px 20px 64px; }

.planner-head { margin-bottom: 20px; }
.planner-head h1 {
  margin: 2px 0 0; font-size: clamp(30px, 5vw, 46px); line-height: 1.1;
  color: #25332f; letter-spacing: -.02em;
}
.planner-head h1::after {
  content: ""; display: block; width: 72px; height: 3px; margin-top: 10px;
  background: #b84927;
}
.planner-head .lead { max-width: 760px; margin: 12px 0 0; color: #42534b; font-size: 15.5px; }
.planner-head .lead a { color: #9a3d20; text-decoration: underline; }
/* Hinweis für Einsteiger: führt zur Hilfeseite mit Schnellstart und Leitlinien. */
.planner-head .planner-help { margin: 10px 0 0; font-size: 14px; color: #64716a; }
.planner-head .planner-help a { color: #9a3d20; text-decoration: underline; font-weight: 600; }

.planner-grid {
  display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(310px, 1fr);
  gap: 22px; align-items: start;
}

/* ---------------- Karte ---------------- */

.planner-map .map-wrap { position: relative; overflow: hidden; }
#planMap { height: min(66vh, 620px); width: 100%; background: #e8ece6; }

/* Hinweisleiste auf der Karte: „Start/Ziel neu setzen – jetzt klicken“.
   Sie liegt bewusst auf der Karte und nicht in der Statuszeile: Im Panel ist
   die Statuszeile oft unterhalb des sichtbaren Bereichs, dann wirkt der Klick
   auf „Start ändern“ wie ohne Wirkung. */
.pick-banner {
  position: absolute; left: 8px; right: 8px; bottom: 30px; margin: 0 auto;
  z-index: 900; display: flex; align-items: center; gap: 12px;
  max-width: 520px; width: fit-content;
  padding: 9px 10px 9px 14px; border-radius: 8px;
  background: #284b3e; color: #fff; font-size: 13.5px; line-height: 1.35;
  box-shadow: 0 10px 26px rgba(20, 30, 26, .32);
}
.pick-banner[hidden] { display: none; }
.pick-banner.route-error { background: #923c2a; }
.pick-banner span { flex: 1 1 auto; }
.pick-banner .mini {
  flex: 0 0 auto; background: #fff; color: #284b3e; border: 0;
  border-radius: 6px; padding: 6px 10px; font-size: 12.5px; cursor: pointer;
}
/* „Route berechnen“ in der Leiste: der nächste sinnvolle Schritt */
.pick-banner .mini.btn-calc { background: #b84927; color: #fff; font-weight: 600; }
.pick-banner .mini.btn-calc:hover { background: #9a3d20; }
#planMap.picking, #planMap.picking .leaflet-pane, #planMap.picking canvas,
#planMap.cutting, #planMap.cutting .leaflet-pane, #planMap.cutting canvas {
  cursor: crosshair;
}

.planner-credit {
  margin: 9px 2px 0; font-size: 12px; line-height: 1.6; color: #64716a;
}
.planner-credit a { color: #9a3d20; text-decoration: underline; }

/* Wegpunkt-Marker (Leaflet-divIcon) */
.wp-pin-wrap { background: none; border: 0; }
.wp-pin {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: #25332f; color: #fff; border: 2px solid #fff;
  font: 600 13px/1 "Segoe UI", system-ui, sans-serif;
  box-shadow: 0 2px 8px rgba(20, 30, 26, .45);
  cursor: grab;
}
.wp-pin.start { background: #284b3e; }
.wp-pin.end { background: #b84927; }
.wp-pin.via { background: #3f5148; }

/* ---------------- Panel ---------------- */

.planner-panel {
  position: sticky; top: 96px;
  /* Eigenständig scrollbar: Die Bedienelemente bleiben erreichbar, ohne dass
     die ganze Seite gescrollt werden muss und die Karte aus dem Bild rutscht. */
  max-height: calc(100vh - 112px); overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 0;
  background: #fff; border: 1px solid #dce1d9; border-radius: 12px;
  box-shadow: 0 5px 18px rgba(37, 51, 47, .05);
}

.planner-block { padding: 18px 20px; border-bottom: 1px solid #edf0ea; }
.planner-block > .planner-actions { margin-top: 18px; }
#gpxControls { margin-top: 8px; }
.planner-mode { margin-top: 12px; }
.planner-mode[hidden] { display: none; }
.template-round { margin-top: 12px; padding: 12px; border-radius: 8px; background: #f5f8f2; }
.template-round[hidden], #endpointFields[hidden] { display: none; }
.template-check, .pub-field .template-check { display: flex; align-items: flex-start; gap: 8px; margin: 10px 0; font-size: 13px; line-height: 1.5; color: #25332f; }
.template-check input[type="checkbox"] { flex: 0 0 auto; width: 16px; height: 16px; padding: 0; margin: 2px 0 0; accent-color: #284b3e; }
#templateAddresses { flex-basis: 100%; }
.template-round .planner-actions { margin-top: 10px; }
.wp-pin.round { width: 36px; border-radius: 12px; background: #284b3e; font-size: 11px; }
.place-item .place-btn.change { width: auto; padding: 6px 10px; }
.planner-block:last-of-type { border-bottom: 0; }
.planner-tools { background: #f5f8f2; }
.planner-tools > .planner-actions { margin-top: 0; }
.avoid-tools { margin-top: 12px; font-size: 13px; color: #42534b; }
.avoid-tools summary { cursor: pointer; padding: 6px 0; }
.avoid-tools .planner-actions { margin-top: 8px; }
.ai-preview { padding: 14px; border-radius: 8px; background: #f0f5ee; }
.ai-preview[hidden] { display: none; }
.ai-preview h3 { margin: 0 0 8px; font-size: 16px; }
.ai-preview li { margin-bottom: 8px; font-size: 13px; overflow-wrap: anywhere; }
.planner-block-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px;
}
.planner-block-head h2 { margin: 0; font-size: 15px; color: #25332f; }
.planner-block-head .mini { padding: 5px 10px; font-size: 12.5px; }

.planner-label {
  display: block; font-size: 12.5px; font-weight: 600; color: #42534b;
  margin-bottom: 8px;
}
.planner-select {
  width: 100%; padding: 9px 10px; font: 14px/1.4 "Segoe UI", system-ui, sans-serif;
  color: #25332f; background: #fff; border: 1px solid #bdcbbc; border-radius: 8px;
}
.planner-select:disabled { color: #8d9a93; background: #f3f6f1; }
.planner-note { margin: 7px 0 0; font-size: 12.5px; line-height: 1.55; color: #64716a; }

/* ---------------- Wegpunktliste ---------------- */

.wp-list { list-style: none; margin: 0 0 12px; padding: 0; }
.wp-empty { color: #64716a; font-size: 13.5px; padding: 4px 0 8px; }
.wp-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0; border-bottom: 1px dashed #e3e8e0;
}
.wp-item:last-child { border-bottom: 0; }
.wp-badge {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font: 600 12px/1 "Segoe UI", system-ui, sans-serif; color: #fff;
  background: #3f5148;
}
.wp-badge.start { background: #284b3e; }
.wp-badge.end { background: #b84927; }
.wp-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.wp-text b { font-size: 13.5px; color: #25332f; }
.wp-coords {
  font-size: 12px; color: #64716a;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.wp-remove {
  margin-left: auto; flex: 0 0 auto; width: 30px; height: 30px;
  border: 1px solid #dce1d9; border-radius: 8px; background: #fff;
  color: #7b8781; font-size: 17px; line-height: 1; cursor: pointer;
}
.wp-remove:hover { color: #a12e23; border-color: #d89e96; background: #fbeae7; }

.planner-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.planner-actions .btn { flex: 1 1 auto; padding: 9px 12px; font-size: 13.5px; }
#calcNow, #download, #share, #publish { width: 100%; flex: 1 1 100%; padding: 11px 14px; font-size: 14.5px; }
#publish { color: #284b3e; }

.planner-link {
  display: inline-block; margin-top: 14px; font-size: 13px; font-weight: 600;
  color: #284b3e; text-decoration: underline;
}
.planner-link:hover { color: #9a3d20; }

/* ---------------- Statistik ---------------- */

.planner-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px;
  background: #f5f8f2;
}
.planner-stats .stat { display: flex; flex-direction: column; line-height: 1.3; }
.planner-stats .stat span {
  font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: #64716a;
}
.planner-stats .stat b { font-size: 18px; color: #25332f; font-variant-numeric: tabular-nums; }

/* ---------------- Status / Hinweis ---------------- */

.planner-status { min-height: 20px; margin: 8px 0 0; font-size: 13px; color: #64716a; }
.planner-status.busy { color: #64716a; }
.planner-status.ok { color: #215830; }
.planner-status.warn { color: #9a5b00; }
.planner-status.err { color: #a12e23; }

/* Ausführlicher Hinweis (z. B. Strecke über dem Längenlimit) */
.planner-warn {
  margin: 8px 0 0; padding: 10px 12px; border-left: 3px solid #c8862a;
  border-radius: 4px; background: #fdf6e6;
  font-size: 12.5px; line-height: 1.55; color: #6b4a06;
}
.planner-warn::before { content: "Hinweis: "; font-weight: 700; }

.planner-hint {
  margin: 0; padding: 14px 18px; background: #f5f8f2;
  font-size: 12.5px; line-height: 1.6; color: #64716a;
}
.planner-hint a { color: #9a3d20; text-decoration: underline; }

.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------------- Vollbild-Umschalter (Kartensteuerung) ---------------- */

.planner-expand {
  background: #f6f7f3f5; border: 1px solid #bdcbbc; border-radius: 8px;
  padding: 4px 6px; box-shadow: 0 6px 18px rgba(20, 30, 26, .12);
}
.planner-expand button {
  border: 0; border-radius: 6px; background: #284b3e; color: #fff;
  font: 600 12.5px/1.2 "Segoe UI", system-ui, sans-serif;
  padding: 7px 10px; cursor: pointer; white-space: nowrap;
}
.planner-expand button:hover { background: #193b2e; }

/* Planer füllt das ganze Browserfenster */
body.planner-expanded { overflow: hidden; }
body.planner-expanded .site-header,
body.planner-expanded .site-footer,
body.planner-expanded .planner-head,
body.planner-expanded .planner-credit { display: none; }
body.planner-expanded .planner {
  position: fixed; inset: 0; z-index: 1200; max-width: none; margin: 0;
  padding: 10px 12px 12px; background: #f6f7f3;
  display: flex; flex-direction: column; gap: 10px;
}
body.planner-expanded .planner-grid {
  flex: 1; min-height: 0; grid-template-columns: minmax(0, 1fr) 340px;
  /* Ohne stretch bleiben die Grid-Zellen auf Inhaltshöhe – die Karte wäre 0 px hoch. */
  align-items: stretch;
}
body.planner-expanded .planner-map { min-height: 0; display: flex; flex-direction: column; }
body.planner-expanded .planner-map .map-wrap { flex: 1; min-height: 0; }
body.planner-expanded #planMap { height: 100%; }
body.planner-expanded .planner-panel {
  position: static; max-height: 100%; overflow-y: auto;
}

/* ---------------- Tour veröffentlichen (Dialog) ---------------- */

.planner-dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: 90vh; padding: 0; margin: auto;
  border: 1px solid #dce1d9; border-radius: 12px; overflow: hidden;
  background: #fff; color: #25332f;
  box-shadow: 0 24px 60px rgba(20, 30, 26, .35);
}
.planner-dialog::backdrop { background: rgba(20, 30, 26, .5); }
.dialog-form { padding: 20px 22px 22px; max-height: 90vh; overflow-y: auto; }

.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog-head h2 { margin: 0; font-size: 20px; color: #25332f; }
.dialog-close {
  border: 0; background: transparent; color: #7b8781; cursor: pointer;
  font-size: 24px; line-height: 1; padding: 0 4px;
}
.dialog-close:hover { color: #a12e23; }
.dialog-lead { margin: 8px 0 16px; font-size: 13.5px; line-height: 1.6; color: #42534b; }

.pub-field { margin-bottom: 14px; }
.pub-field label { display: block; font-size: 12.5px; font-weight: 600; color: #42534b; margin-bottom: 6px; }
.pub-field input, .pub-field textarea {
  width: 100%; padding: 9px 10px; font: 14px/1.4 "Segoe UI", system-ui, sans-serif;
  color: #25332f; background: #fff; border: 1px solid #bdcbbc; border-radius: 8px;
}
.pub-field textarea { min-height: 74px; resize: vertical; }
.pub-field input:focus, .pub-field textarea:focus { outline: none; border-color: #284b3e; box-shadow: 0 0 0 3px rgba(40, 75, 62, .12); }
.pub-field img {
  display: block; max-width: 100%; height: auto; margin-bottom: 8px;
  border: 1px solid #dce1d9; border-radius: 8px; background: #f5f8f2;
}
.pub-field .mini { margin-bottom: 8px; }
.pub-note { margin: 6px 0 0; font-size: 12px; line-height: 1.5; color: #64716a; }
.pub-note.err { color: #a12e23; }

.pub-check {
  display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 16px; padding: 12px;
  font-size: 12.5px; line-height: 1.55; color: #42534b;
  background: #f5f8f2; border: 1px solid #dce1d9; border-radius: 8px;
}
.pub-check input { margin-top: 2px; }
.pub-check a { color: #9a3d20; text-decoration: underline; }

.dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dialog-actions .btn { flex: 1 1 auto; }
.publish-msg, .dialog-msg { min-height: 20px; margin-top: 10px; font-size: 13px; line-height: 1.55; color: #64716a; }
.publish-msg.ok, .dialog-msg.ok { color: #215830; }
.publish-msg.err, .dialog-msg.err { color: #a12e23; }
.publish-receipt {
  margin-top: 12px; padding: 12px 14px; font-size: 12.5px; line-height: 1.6;
  color: #42534b; background: #eaf0e7; border: 1px solid #bdcbbc; border-radius: 8px;
}
.publish-receipt p { margin: 0 0 8px; }

/* ---------------- KI-Wunsch ---------------- */

.ai-dialog textarea { min-height: 86px; }
.ai-mic-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.ai-mic-row .btn { flex: 0 0 auto; }
#aiMic.recording { background: #b84927; color: #fff; border-color: #b84927; }

/* ---------------- Wegpunkte nach Ortsnamen ---------------- */

.place-results {
  list-style: none; margin: 8px 0 0; padding: 0;
  border: 1px solid #dce1d9; border-radius: 8px; overflow: hidden;
}
.place-result {
  display: block; width: 100%; text-align: left; padding: 9px 11px;
  background: #fff; border: 0; border-bottom: 1px solid #edf0ea; cursor: pointer;
  font: 13px/1.45 "Segoe UI", system-ui, sans-serif; color: #25332f;
}
.place-result:last-child { border-bottom: 0; }
.place-result:hover, .place-result:focus { background: #f0f5ee; }
.place-result b { display: block; font-size: 13.5px; }
.place-result span { display: block; color: #64716a; font-size: 12px; }

.place-list-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 2px 0 6px; font-size: 12.5px; font-weight: 600; color: #42534b;
}
.place-list-head span:last-child { font-weight: 400; color: #64716a; }
.place-list { list-style: none; margin: 0 0 12px; padding: 0; }
.place-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 0;
  border-bottom: 1px dashed #e3e8e0;
}
.place-item:last-child { border-bottom: 0; }
.place-num {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #3f5148; color: #fff; font: 600 11.5px/1 "Segoe UI", system-ui, sans-serif;
}
.place-txt { flex: 1 1 auto; min-width: 0; line-height: 1.35; }
.place-txt b { display: block; font-size: 13.5px; color: #25332f; }
.place-txt span {
  display: block; font-size: 12px; color: #64716a;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.place-btn {
  flex: 0 0 auto; width: 26px; height: 26px; padding: 0;
  border: 1px solid #dce1d9; border-radius: 6px; background: #fff;
  color: #4c5a54; font-size: 13px; line-height: 1; cursor: pointer;
}
.place-btn:hover:not(:disabled) { background: #eaf0e7; color: #25332f; border-color: #bdcbbc; }
.place-btn:disabled { opacity: .35; cursor: default; }
.place-btn.del:hover { color: #a12e23; border-color: #d89e96; background: #fbeae7; }
.place-empty { color: #64716a; font-size: 13px; padding: 6px 0 8px; }

/* Rote Linie greifen und auf eine andere Straße ziehen */
.route-line { cursor: grab; }
.route-line:active { cursor: grabbing; }

/* ---------------- Schmale Bildschirme ---------------- */

@media (max-width: 980px) {
  .planner-grid { grid-template-columns: 1fr; }
  .planner-panel { position: static; max-height: none; overflow: visible; }
  #planMap { height: min(52vh, 460px); }
  /* Im Vollbild bleiben Karte UND Werkzeuge erreichbar; das Panel scrollt separat. */
  body.planner-expanded .planner-grid {
    grid-template-columns: 1fr; grid-template-rows: minmax(180px, 1fr) minmax(150px, 38%); gap: 10px;
  }
  body.planner-expanded .planner-panel { display: flex; }
  body.planner-expanded .planner { padding: 8px; }
}
@media (max-width: 560px) {
  .planner { padding: 22px 14px 48px; }
  .planner-block { padding: 14px; }
  .planner-actions .btn { flex: 1 1 100%; }
  .dialog-form { padding: 16px; }
}

/* Straßenarten der berechneten Route */
.road-types{display:flex;flex-wrap:wrap;gap:6px 14px;align-items:center;font-size:13px;color:#3f5049}
.road-types-label{font-family:var(--disp);text-transform:uppercase;font-size:11.5px;letter-spacing:.06em;color:#7d8b83}
.road-types-item{display:inline-flex;align-items:center;gap:5px}
.road-types-item i{width:10px;height:10px;border-radius:2px;background:#b9c3b9;display:inline-block}
.road-types-item i.autobahn{background:#243b53}.road-types-item i.schnellstrasse{background:#3b5c76}
.road-types-item i.bundesstrasse{background:#b84927}.road-types-item i.landesstrasse{background:#c98a3d}
.road-types-item i.kreisstrasse{background:#8a8f52}.road-types-item i.ortsstrasse{background:#5c7a68}
.road-types-item i.weg{background:#8a6d3b}
.road-types-item small{color:#7d8b83}

/* Straßenarten im Planer: Anteile + Verlauf */
.road-types{flex-direction:column;align-items:stretch;gap:6px}
.road-types-row{display:flex;flex-wrap:wrap;gap:6px 14px;align-items:center}
.road-types-list{list-style:none;margin:2px 0 0;padding:0;display:grid;gap:3px;font-size:13px;color:#3f5049}
.road-types-list li{display:flex;align-items:center;gap:8px}
.road-types-list li > span:first-child{min-width:96px;color:#7d8b83;font-size:12px;font-variant-numeric:tabular-nums}
.road-types-list i{width:9px;height:9px;border-radius:2px;display:inline-block;background:#b9c3b9}
.road-types-list i.autobahn{background:#243b53}.road-types-list i.schnellstrasse{background:#3b5c76}
.road-types-list i.bundesstrasse{background:#b84927}.road-types-list i.landesstrasse{background:#c98a3d}
.road-types-list i.kreisstrasse{background:#8a8f52}.road-types-list i.ortsstrasse{background:#5c7a68}
.road-types-list i.weg{background:#8a6d3b}
.road-types-list small{color:#7d8b83}

/* Schalter „Rundtour beibehalten" */
.roundtrip-switch{display:flex;align-items:center;gap:8px;margin:8px 0 2px;font-size:13.5px;color:#3f5049;cursor:pointer}
.roundtrip-switch input{width:17px;height:17px;accent-color:#284b3e;cursor:pointer}

/* Straßenarten: Liste im Panel scrollbar, voller Verlauf im Dialog */
.road-types-list{max-height:190px;overflow-y:auto;padding-right:6px}
.road-types-dialog{width:min(560px,94vw)}
.road-types-dialog-body{max-height:60vh;display:flex;flex-direction:column;gap:10px}
.road-types-dialog-body .road-types-list{max-height:none;overflow:visible}

/* Maut-Hinweis über der Straßenarten-Liste */
.road-types-toll{margin:4px 0 2px;padding:6px 10px;border-radius:6px;background:#fdf3ee;
  border-left:3px solid #b84927;font-size:13px;color:#8d3a1c}
.road-types-toll.free{background:#eef4ea;border-left-color:#284b3e;color:#2f5a44}
