/* ============================================================
   Betterway
   Farben aus der deutschen Radwegweisung: grüne Schrift auf
   weißem Grund. Die Routenlinie ist magenta - grün verschwindet
   auf Wald, blau auf Wasser.
   ============================================================ */

:root {
  --ink:        #1C2B24;
  --ink-soft:   #5A6660;
  --paper:      #FBFAF7;
  --panel:      #F4F2EC;
  --paper-edge: #E6E2D8;
  --signal:     #00693E;
  --route:      #C2185B;

  --sheet-peek: 92px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  --shadow: 0 2px 6px rgba(28, 43, 36, .10), 0 8px 24px rgba(28, 43, 36, .10);
  --radius: 13px;

  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-data: ui-monospace, "SF Mono", "Roboto Mono", Menlo, monospace;
}

[data-theme="dark"] {
  --ink:        #E8E6E0;
  --ink-soft:   #9AA39D;
  --paper:      #1A211E;
  --panel:      #232B27;
  --paper-edge: #333C37;
  --signal:     #4CAF7D;
  --route:      #FF4081;
  --shadow: 0 2px 6px rgba(0, 0, 0, .34), 0 8px 24px rgba(0, 0, 0, .30);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  -webkit-tap-highlight-color: transparent;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

#map { position: absolute; inset: 0; }

/* ---------- Kopfzeile ---------- */

.topbar {
  position: absolute;
  top: calc(var(--safe-t) + 10px);
  left: 10px;
  right: 10px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 13px;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  pointer-events: auto;
  flex-shrink: 0;
}

.brand-mark {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 3px rgba(0, 105, 62, .16);
}

.brand-name {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -.01em;
}

/* Kompakt: nur so breit wie der gewählte Profilname */
.profile-select {
  width: auto;
  max-width: 42vw;
  height: 40px;
  padding: 0 30px 0 13px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23888' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 10px;
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  appearance: none;
  pointer-events: auto;
  text-overflow: ellipsis;
}

.icon-btn {
  width: 40px; height: 40px;
  flex-shrink: 0;
  margin-left: auto;
  display: grid; place-items: center;
  background: var(--paper);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  pointer-events: auto;
}

.icon-btn svg {
  width: 19px; height: 19px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ico-moon { display: none; }
[data-theme="dark"] .ico-sun  { display: none; }
[data-theme="dark"] .ico-moon { display: block; }

/* ---------- Kartenwerkzeuge ---------- */

.map-tools {
  position: absolute;
  right: 10px;
  bottom: calc(var(--sheet-peek) + var(--safe-b) + 14px);
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: bottom .28s cubic-bezier(.22, 1, .36, 1);
}

.sheet[data-state="full"] ~ .map-tools { bottom: calc(62vh + 14px); }

.tool {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  background: var(--paper);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .12s;
}

.tool:active { transform: scale(.93); }
.tool:disabled { opacity: .38; }
.tool.is-active svg { stroke: var(--signal); }
.tool.is-active svg .fill { fill: var(--signal); }

.tool svg {
  width: 21px; height: 21px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool svg .fill { fill: var(--ink); stroke: none; }

/* ---------- Meldungen ---------- */

.toast {
  position: absolute;
  top: calc(var(--safe-t) + 62px);
  left: 50%;
  transform: translate(-50%, -8px);
  z-index: 20;
  max-width: calc(100% - 32px);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 550;
  color: var(--paper);
  background: var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: #A02040; color: #fff; }

/* ---------- Bottom Sheet ---------- */

.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  background: var(--paper);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -2px 20px rgba(0, 0, 0, .14);
  padding-bottom: var(--safe-b);
  transition: transform .28s cubic-bezier(.22, 1, .36, 1);
  will-change: transform;
}

.sheet[data-state="peek"] { transform: translateY(calc(100% - var(--sheet-peek) - var(--safe-b))); }
.sheet[data-state="full"] { transform: translateY(0); }

.grip {
  display: block;
  width: 100%;
  padding: 10px 0 6px;
  background: none;
  border: none;
  cursor: pointer;
}

.grip span {
  display: block;
  width: 38px; height: 4px;
  margin: 0 auto;
  background: var(--paper-edge);
  border-radius: 2px;
}

/* ---------- Kennzahlen ---------- */

.readout {
  display: flex;
  padding: 2px 18px 14px;
  gap: 22px;
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 3px;
  position: relative;
  padding-top: 13px;
}

.stat-label {
  position: absolute;
  top: 0; left: 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
}

.stat-value {
  font-family: var(--font-data);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.stat-unit {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}

/* ---------- Höhenprofil ---------- */

.sheet-body { padding: 0 18px 18px; }

.chart-wrap {
  position: relative;
  height: 150px;
  margin-bottom: 14px;
  border-radius: 10px;
  background: var(--panel);
  overflow: hidden;
}

#elevation { display: block; width: 100%; height: 150px; }

.chart-empty {
  position: absolute;
  inset: 0;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 0 26px;
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.chart-cursor {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: var(--ink);
  pointer-events: none;
}

.chart-cursor span {
  position: absolute;
  top: 6px; left: 6px;
  padding: 3px 7px;
  font-family: var(--font-data);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--paper);
  background: var(--ink);
  border-radius: 5px;
}

/* ---------- Varianten ---------- */

.alternatives {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.alt-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.alt-buttons { display: flex; gap: 6px; }

.alt {
  width: 36px; height: 32px;
  font-family: var(--font-data);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--panel);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.alt.is-active { color: #fff; background: var(--signal); }

/* ---------- Aktionen ---------- */

.actions { display: flex; gap: 10px; }

.btn {
  height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .12s, opacity .12s;
}

.btn:active:not(:disabled) { transform: scale(.975); }
.btn:disabled { opacity: .35; cursor: default; }

.btn svg {
  width: 18px; height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-primary { flex: 1; color: #fff; background: var(--signal); }
.btn-ghost { padding: 0 18px; color: var(--ink); background: var(--panel); }

/* ---------- Marker ---------- */

.wp {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  font-family: var(--font-data);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: #33403A;
  border: 2.5px solid var(--paper);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
  cursor: grab;
}

.wp.is-start { background: var(--signal); }
.wp.is-end   { background: var(--route); }

/* Standortpunkt */
.geo-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #1E88E5;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .2), 0 2px 6px rgba(0, 0, 0, .3);
}

.maplibregl-ctrl-attrib {
  font-size: 10px;
  background: rgba(251, 250, 247, .82) !important;
}

[data-theme="dark"] .maplibregl-ctrl-attrib {
  background: rgba(26, 33, 30, .82) !important;
}

[data-theme="dark"] .maplibregl-ctrl-attrib a { color: var(--ink-soft); }

/* Cursor über der Route: Linie ist greifbar */
.maplibregl-canvas-container.route-grab { cursor: grab; }
.maplibregl-canvas-container.route-grabbing { cursor: grabbing; }

/* ---------- Größere Displays ---------- */

@media (min-width: 760px) {
  .sheet {
    left: auto;
    right: 14px;
    bottom: 14px;
    width: 400px;
    border-radius: 18px;
  }
  .sheet[data-state="peek"] { transform: translateY(calc(100% - var(--sheet-peek))); }
  .map-tools { bottom: calc(var(--sheet-peek) + 28px); }
  .sheet[data-state="full"] ~ .map-tools { bottom: 28px; }
  .profile-select { max-width: 260px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; }
}

:focus-visible {
  outline: 2.5px solid var(--signal);
  outline-offset: 2px;
}

/* ============================================================
   Ortssuche und Werkzeugleiste
   ============================================================ */

.search {
  position: absolute;
  top: calc(var(--safe-t) + 58px);
  left: 10px;
  right: 10px;
  z-index: 6;
  max-width: 460px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 42px;
  padding: 0 12px;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.search-field svg {
  width: 17px; height: 17px;
  flex-shrink: 0;
  fill: none;
  stroke: var(--ink-soft);
  stroke-width: 2;
  stroke-linecap: round;
}

.search-field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  font: inherit;
  font-size: 15px;          /* unter 16px zoomt iOS beim Fokus hinein */
  color: var(--ink);
  background: none;
  border: none;
  outline: none;
}

.search-field input::placeholder { color: var(--ink-soft); }
.search-field input::-webkit-search-cancel-button { display: none; }

.search-clear {
  width: 26px; height: 26px;
  flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 20px;
  line-height: 1;
  color: var(--ink-soft);
  background: var(--panel);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.search-results {
  margin: 7px 0 0;
  padding: 6px;
  list-style: none;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 46vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.search-results li {
  padding: 11px 12px;
  font-size: 13.5px;
  line-height: 1.35;
  border-radius: 9px;
  cursor: pointer;
}

.search-results li:hover,
.search-results li[aria-selected="true"] { background: var(--panel); }

.search-results li strong {
  display: block;
  font-weight: 620;
  font-size: 14px;
  margin-bottom: 1px;
}

.search-results li span {
  color: var(--ink-soft);
  font-size: 12px;
}

.search-results.is-empty li {
  color: var(--ink-soft);
  cursor: default;
}

/* ---------- Werkzeugleiste ---------- */

.toolbar {
  position: absolute;
  top: calc(var(--safe-t) + 110px);
  left: 10px;
  right: 10px;
  z-index: 4;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.toolbar::-webkit-scrollbar { display: none; }

.tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  height: 36px;
  padding: 0 13px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--ink);
  background: var(--paper);
  border: none;
  border-radius: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .12s;
}

.tool-chip:active { transform: scale(.95); }

.tool-chip svg {
  width: 15px; height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Noch nicht gebaut: sichtbar, aber erkennbar zurückgenommen */
.tool-chip[data-phase="2"] { color: var(--ink-soft); }

.tool-chip[data-phase="2"]::after {
  content: "bald";
  margin-left: 1px;
  padding: 1px 5px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--ink-soft);
  border-radius: 4px;
}

/* Suche offen: Werkzeugleiste weicht */
body.searching .toolbar { display: none; }

/* ============================================================
   Gespeicherte Routen
   ============================================================ */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 16, 14, .42);
  backdrop-filter: blur(2px);
}

.overlay-card {
  width: 100%;
  max-width: 440px;
  max-height: 76vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
  overflow: hidden;
}

.overlay-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 16px 12px;
  border-bottom: 1px solid var(--paper-edge);
}

.overlay-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.overlay-close {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-soft);
  background: var(--panel);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.routes-list {
  margin: 0;
  padding: 8px;
  list-style: none;
  overflow-y: auto;
}

.routes-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.routes-list li:hover { background: var(--panel); }

.routes-list .route-info { flex: 1; min-width: 0; }

.routes-list .route-name {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.routes-list .route-meta {
  display: block;
  margin-top: 1px;
  font-family: var(--font-data);
  font-size: 11.5px;
  color: var(--ink-soft);
}

.routes-list .route-delete {
  width: 32px; height: 32px;
  flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 19px;
  line-height: 1;
  color: var(--ink-soft);
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.routes-list .route-delete:hover { background: var(--paper-edge); }

.routes-empty {
  padding: 28px 20px;
  text-align: center;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-soft);
}

/* ============================================================
   Sheet: Wischgeste am Handy, dauerhaft offen am Desktop
   ============================================================ */

.sheet-handle-area { cursor: grab; touch-action: none; }
.sheet.is-dragging { transition: none; }

@media (min-width: 760px) {
  /* Am Desktop ist Platz genug - die Kachel bleibt offen. */
  .sheet,
  .sheet[data-state="peek"],
  .sheet[data-state="full"] { transform: translateY(0); }

  .grip { display: none; }
  .sheet { padding-top: 6px; }

  .map-tools,
  .sheet[data-state="peek"] ~ .map-tools,
  .sheet[data-state="full"] ~ .map-tools { bottom: 28px; }
}

.wp.is-ghost {
  background: var(--route);
  opacity: .9;
  cursor: grabbing;
}

/* ============================================================
   [hidden] durchsetzen
   Eigene display-Regeln sind spezifischer als die Browser-Regel
   fuer [hidden]. Ohne diese Zeilen bleibt versteckt sichtbar.
   ============================================================ */

[hidden] { display: none !important; }

/* ============================================================
   Zeitplan
   ============================================================ */

.plan-inputs {
  display: flex;
  gap: 10px;
  padding: 14px 16px 4px;
}

.plan-field { flex: 1; }

.plan-field label {
  display: block;
  margin-bottom: 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.plan-field input {
  width: 100%;
  height: 42px;
  padding: 0 11px;
  font-family: var(--font-data);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid transparent;
  border-radius: 9px;
  outline: none;
}

.plan-field input:focus { border-color: var(--signal); }

.plan-table {
  margin: 0;
  padding: 8px;
  list-style: none;
  overflow-y: auto;
}

.plan-table li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 9px;
}

.plan-table li:nth-child(odd) { background: var(--panel); }

.plan-badge {
  width: 24px; height: 24px;
  flex-shrink: 0;
  display: grid; place-items: center;
  font-family: var(--font-data);
  font-size: 10.5px;
  font-weight: 700;
  color: #fff;
  background: #33403A;
  border-radius: 50%;
}

.plan-badge.is-start { background: var(--signal); }
.plan-badge.is-end   { background: var(--route); }

.plan-km {
  flex: 1;
  font-family: var(--font-data);
  font-size: 13px;
  color: var(--ink-soft);
}

.plan-time {
  font-family: var(--font-data);
  font-size: 16px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.plan-reverse {
  margin: 4px 16px 16px;
  padding: 13px 14px;
  background: var(--panel);
  border-radius: 11px;
}

.plan-reverse h3 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 650;
}

.plan-reverse-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
}

.plan-reverse select,
.plan-reverse input {
  height: 36px;
  padding: 0 9px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  background: var(--paper);
  border: none;
  border-radius: 8px;
  outline: none;
}

.plan-result {
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px solid var(--paper-edge);
  font-size: 13.5px;
  line-height: 1.45;
}

.plan-result strong {
  font-family: var(--font-data);
  font-size: 19px;
  font-weight: 650;
  color: var(--signal);
}

/* ============================================================
   Werkzeugleiste: am Handy senkrecht links, nur Symbole
   ============================================================ */

@media (max-width: 759px) {
  .toolbar {
    top: calc(var(--safe-t) + 112px);
    left: 10px;
    right: auto;
    width: 46px;
    flex-direction: column;
    overflow: visible;
  }

  .tool-chip {
    width: 46px;
    height: 46px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius);
  }

  .tool-chip svg { width: 19px; height: 19px; }
  .chip-label { display: none; }

  .tool-chip[data-phase="2"]::after {
    content: "";
    position: absolute;
    margin: 0;
    padding: 0;
    width: 7px; height: 7px;
    transform: translate(15px, -15px);
    background: var(--ink-soft);
    border-radius: 50%;
  }

  .tool-chip { position: relative; }
}

/* ============================================================
   Wegpunkte: grosszuegige Trefferflaeche
   Sichtbar bleibt der kleine Punkt, klickbar ist deutlich mehr.
   ============================================================ */

.wp-hit {
  width: 46px; height: 46px;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  cursor: grab;
  touch-action: none;
}

.wp-hit:active { cursor: grabbing; }

.wp-dot {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  font-family: var(--font-data);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: #33403A;
  border: 2.5px solid var(--paper);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
  transition: transform .12s;
  pointer-events: none;
}

.wp-hit:active .wp-dot { transform: scale(1.18); }
.wp-dot.is-start { background: var(--signal); }
.wp-dot.is-end   { background: var(--route); }
.wp-dot.is-ghost { background: var(--route); opacity: .9; }

/* Luftbild: Beschriftungen brauchen mehr Kontrast */
body.satellite .maplibregl-ctrl-attrib { background: rgba(0, 0, 0, .55) !important; }
body.satellite .maplibregl-ctrl-attrib,
body.satellite .maplibregl-ctrl-attrib a { color: #EDEDED; }

/* ============================================================
   Punktmenue
   ============================================================ */

.wp-menu {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-b));
  background: rgba(10, 16, 14, .38);
}

.wp-menu-card {
  width: 100%;
  max-width: 380px;
  padding: 7px;
  background: var(--paper);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .32);
}

.wp-menu-title {
  margin: 0;
  padding: 11px 12px 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.wp-action {
  display: block;
  width: 100%;
  height: 48px;
  padding: 0 12px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  color: var(--ink);
  background: none;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}

.wp-action:hover { background: var(--panel); }
.wp-action.is-danger { color: #C62828; }
.wp-action.is-quiet { color: var(--ink-soft); font-weight: 500; }

[data-theme="dark"] .wp-action.is-danger { color: #FF6B6B; }

/* ============================================================
   Suchtreffer: direkt an die Route anhaengen
   ============================================================ */

.search-results li { display: flex; align-items: center; gap: 8px; }
.search-results .hit-text { flex: 1; min-width: 0; }

.search-add {
  width: 34px; height: 34px;
  flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 20px;
  line-height: 1;
  font-weight: 600;
  color: #fff;
  background: var(--signal);
  border: none;
  border-radius: 9px;
  cursor: pointer;
}

/* ============================================================
   Handy: flacher Hoehenstreifen bleibt im eingeklappten Zustand
   ============================================================ */

@media (max-width: 759px) {
  :root { --sheet-peek: 138px; }

  /* Der Streifen sitzt unter den Kennzahlen und bleibt sichtbar. */
  .sheet[data-state="peek"] .chart-wrap {
    height: 44px;
    margin-bottom: 0;
    border-radius: 8px;
  }

  .sheet[data-state="peek"] #elevation { height: 44px; }
  .sheet[data-state="peek"] .chart-empty { font-size: 11.5px; }
  .sheet[data-state="peek"] .alternatives,
  .sheet[data-state="peek"] .actions { display: none; }
  .sheet[data-state="peek"] .sheet-body { padding-bottom: 10px; }
  .sheet[data-state="peek"] .readout { padding-bottom: 10px; }
}

/* ============================================================
   Overlays ueber der Bildschirmtastatur
   Die Karte oeffnet sich oben statt mittig, und die Hoehe folgt
   dem sichtbaren Bereich - sonst liegt die Eingabe unter der Tastatur.
   ============================================================ */

@media (max-width: 759px) {
  .overlay {
    align-items: start;
    padding-top: calc(var(--safe-t) + 12px);
  }

  .overlay-card { max-height: var(--vv-height, 76vh); }
}

/* ============================================================
   Tempo-Regler, Spinner, Rechenzeit
   ============================================================ */

.readout { align-items: flex-start; }

.speed-control {
  margin-left: auto;
  padding-top: 13px;
  position: relative;
  min-width: 108px;
}

.speed-control .stat-label { position: absolute; top: 0; left: 0; }

.speed-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

#speed-slider {
  flex: 1;
  min-width: 62px;
  height: 22px;
  appearance: none;
  background: none;
  cursor: pointer;
}

#speed-slider::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--paper-edge);
  border-radius: 2px;
}

#speed-slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px; height: 18px;
  margin-top: -7px;
  background: var(--signal);
  border: 2px solid var(--paper);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

#speed-slider::-moz-range-track {
  height: 4px;
  background: var(--paper-edge);
  border-radius: 2px;
}

#speed-slider::-moz-range-thumb {
  width: 15px; height: 15px;
  background: var(--signal);
  border: 2px solid var(--paper);
  border-radius: 50%;
}

#speed-out {
  font-family: var(--font-data);
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  min-width: 30px;
  text-align: right;
}

.spinner {
  position: absolute;
  top: 14px; right: 18px;
  width: 15px; height: 15px;
  border: 2px solid var(--paper-edge);
  border-top-color: var(--signal);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

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

.calc-time {
  margin: 0 0 10px;
  font-family: var(--font-data);
  font-size: 11px;
  color: var(--ink-soft);
  text-align: right;
}

/* Ziehen im gesamten Profilfeld, nicht nur auf der Linie */
.chart-wrap { touch-action: none; }

/* Etikett darf nicht aus dem Feld laufen */
.chart-cursor span { transform: translateX(0); }
.chart-cursor.is-flipped span { left: auto; right: 6px; }

/* ============================================================
   Desktop: Werkzeuge neben die Kachel statt darunter
   ============================================================ */

@media (min-width: 760px) {
  .map-tools,
  .sheet[data-state="peek"] ~ .map-tools,
  .sheet[data-state="full"] ~ .map-tools {
    right: 428px;
    bottom: 20px;
  }
}

@media (max-width: 759px) {
  .speed-control { min-width: 92px; }
  .readout { gap: 16px; }
}

/* ============================================================
   Kopfbereich neu: Suche oben, Profil darunter
   ============================================================ */

.search.in-topbar {
  top: calc(var(--safe-t) + 10px);
  left: 10px;
  right: 66px;                 /* Platz fuer den Design-Schalter */
  max-width: none;
}

.search.in-topbar .search-field { height: 40px; }

.topbar { pointer-events: none; }
.topbar .brand { display: none; }        /* Platz gehoert der Suche */
.icon-btn { margin-left: auto; }

.profile-row {
  position: absolute;
  top: calc(var(--safe-t) + 58px);
  left: 10px;
  z-index: 5;
}

.profile-select { max-width: 60vw; }

/* ============================================================
   Werkzeugleiste: auch am Desktop links als Symbole,
   die bei Mauskontakt den vollen Text zeigen
   ============================================================ */

@media (min-width: 760px) {
  .toolbar {
    top: calc(var(--safe-t) + 108px);
    left: 10px;
    right: auto;
    width: auto;
    flex-direction: column;
    align-items: flex-start;
    overflow: visible;
  }

  .tool-chip {
    width: 46px;
    height: 46px;
    padding: 0 13px;
    justify-content: flex-start;
    overflow: hidden;
    border-radius: var(--radius);
    transition: width .18s cubic-bezier(.22, 1, .36, 1);
  }

  .tool-chip svg { flex-shrink: 0; margin-left: -1px; }

  .chip-label {
    opacity: 0;
    white-space: nowrap;
    transition: opacity .12s;
  }

  /* Immer nur eine offen: Hover trifft naturgemaess genau eine. */
  .tool-chip:hover,
  .tool-chip:focus-visible {
    width: 172px;
  }

  .tool-chip:hover .chip-label,
  .tool-chip:focus-visible .chip-label { opacity: 1; }

  .tool-chip[data-phase="2"]::after { display: none; }
  .tool-chip:hover[data-phase="2"]::after {
    display: inline;
    position: static;
    transform: none;
    width: auto; height: auto;
    margin-left: 6px;
    padding: 1px 5px;
    content: "bald";
    font-size: 9px;
    border-radius: 4px;
  }
}

/* ============================================================
   Werkzeuge weichen der ausgeklappten Kachel
   Wird per Klasse am body gesteuert - der Geschwister-Selektor
   funktioniert nicht, weil die Kachel im Dokument danach steht.
   ============================================================ */

body.sheet-open .map-tools { bottom: calc(62vh + 14px); }

@media (min-width: 760px) {
  body.sheet-open .map-tools { bottom: 20px; }
}

/* ============================================================
   Tempo-Regler groesser und griffiger
   ============================================================ */

.speed-control { min-width: 132px; }

#speed-slider { height: 30px; }

#speed-slider::-webkit-slider-runnable-track {
  height: 6px;
  background: var(--paper-edge);
  border-radius: 3px;
}

#speed-slider::-webkit-slider-thumb {
  width: 26px; height: 26px;
  margin-top: -10px;
  border-width: 3px;
}

#speed-slider::-moz-range-track { height: 6px; }
#speed-slider::-moz-range-thumb { width: 22px; height: 22px; border-width: 3px; }

#speed-out { font-size: 14px; min-width: 34px; }

@media (max-width: 759px) {
  .speed-control { min-width: 118px; }
}
