:root {
  --bg: #0a0a0c;
  --surface: #16161a;
  --surface-2: #1f1f25;
  --line: #2c2c34;
  --text: #f4f4f6;
  --muted: #9a9aa6;
  --accent: #2ed3a7;
  --accent-2: #3b82f6;
  --danger: #ef4444;
  --warn: #f59e0b;
  --tap: 72px;
  --dock-h: 84px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ---------- Views ---------- */
.view {
  position: absolute;
  inset: 0;
  bottom: calc(var(--dock-h) + var(--safe-b));
  display: none;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: calc(16px + var(--safe-t)) 16px 16px;
}
.view.active { display: flex; }
.view-navi.active { display: block; padding: 0; }

.view-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
}
.view-head h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; flex: 1; }

.hint { color: var(--muted); font-size: 14px; line-height: 1.4; margin: 8px 0; }
.sub { font-size: 18px; margin: 18px 0 10px; color: var(--muted); }

/* ---------- Buttons ---------- */
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }

.btn-big {
  width: 100%; min-height: var(--tap);
  background: var(--accent); color: #04241c;
  font-size: 20px; font-weight: 800; border-radius: 18px;
  margin: 10px 0;
}
.btn-pill {
  min-height: 56px; padding: 0 22px;
  background: var(--surface-2); color: var(--text);
  border-radius: 999px; font-size: 16px; font-weight: 700;
  border: 1px solid var(--line);
}
.btn-pill.btn-primary { background: var(--accent); color: #04241c; border-color: transparent; }
.btn-pill.btn-danger, .btn-danger { background: var(--danger); color: #fff; border-color: transparent; }

/* ---------- Dock ---------- */
.dock {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(var(--dock-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  /* graues Milchglas statt schwarz */
  background: rgba(70,70,80,0.32);
  -webkit-backdrop-filter: blur(26px) saturate(1.6);
  backdrop-filter: blur(26px) saturate(1.6);
  border-top: 1px solid rgba(255,255,255,0.10);
  display: flex; align-items: stretch;
  z-index: 1000;
}
.dock-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 5px;
  color: rgba(255,255,255,0.78); font-size: 12px; font-weight: 600;
  background: none; border: none;
}
.dock-btn .ico { width: 28px; height: 28px; }
.dock-btn .ico svg { width: 100%; height: 100%; display: block; }
.dock-btn.active { color: var(--accent); }

/* ---------- Navi / HUD ---------- */
#map { position: absolute; inset: 0; background: #11161c; z-index: 1; overflow: hidden; }
#mapRot { position: absolute; will-change: transform; }
.leaflet-container { background: #11161c; }
.bike-marker { font-size: 34px; line-height: 1; will-change: transform; filter: drop-shadow(0 0 4px #000); }
.leaflet-control-attribution { background: rgba(10,10,12,0.6) !important; color: #777 !important; font-size: 10px; }
.leaflet-control-attribution a { color: #999 !important; }

.hud-overlay {
  position: absolute; top: calc(12px + var(--safe-t)); left: 12px; right: 12px;
  z-index: 600; display: flex; gap: 12px; align-items: flex-start;
  flex-wrap: nowrap; pointer-events: none;
}
.speed-box {
  background: rgba(10,10,12,0.78); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 20px;
  padding: 10px 18px; text-align: center; min-width: 120px; flex: 0 0 auto;
}
.speed-value { display: block; font-size: 52px; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.speed-box.over .speed-value { color: var(--danger); }
.speed-unit { font-size: 13px; color: var(--muted); letter-spacing: 1px; }

.limit-sign {
  flex: 0 0 auto;
  width: 70px; height: 70px; border-radius: 50%;
  background: #fff; border: 7px solid var(--danger);
  display: flex; align-items: center; justify-content: center;
  color: #111; font-size: 24px; font-weight: 900;
}

.nav-banner {
  flex: 1 1 auto; min-width: 0;
  background: rgba(10,10,12,0.82); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 18px;
  padding: 12px 16px; display: flex; align-items: center; gap: 14px;
}
.nav-text { min-width: 0; }
.nav-arrow { font-size: 40px; font-weight: 900; color: var(--accent); flex: 0 0 auto; }
.nav-distance { font-size: 22px; font-weight: 800; white-space: nowrap; }
.nav-instruction { font-size: 15px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.navi-controls {
  position: absolute; left: 12px; right: 12px;
  bottom: calc(16px); z-index: 600;
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
}
.navi-controls .btn-pill { background: rgba(31,31,37,0.9); backdrop-filter: blur(8px); }

/* ---------- Spotify ---------- */
.spotify-disconnected { text-align: center; padding: 30px 10px; }
.spotify-disconnected p { margin: 10px 0; color: var(--muted); }

.spotify-player {
  position: relative;
  width: 100%; max-width: 940px; margin: 0 auto;
  padding: 18px 16px 28px;
}
/* Vollbild-Cover-Hintergrund wie bei CarPlay – liegt hinter der ganzen App,
   sichtbar nur in der Musik-Ansicht (Views sind transparent). */
.np-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: #0a0a0c center/cover no-repeat;
  filter: blur(60px) brightness(0.40) saturate(1.4);
  transform: scale(1.18);
  opacity: 0; transition: opacity .45s ease;
}
.np-bg::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10,10,12,.30), rgba(10,10,12,.70));
}
body[data-view="music"] .np-bg { opacity: 1; }
.np-row, .np-foot, .playlist-grid { position: relative; z-index: 1; }

.np-row {
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.np-main { width: 100%; max-width: 460px; text-align: center; }

.now-art {
  width: min(280px, 38vh); aspect-ratio: 1; flex: 0 0 auto;
  border-radius: 16px; background: var(--surface-2) center/cover no-repeat;
  box-shadow: 0 14px 44px rgba(0,0,0,.55);
}
.now-title {
  font-size: 30px; font-weight: 900; letter-spacing: -.5px; line-height: 1.15;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.now-artist {
  font-size: 20px; font-weight: 700; margin-top: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.now-album {
  font-size: 16px; font-weight: 700; color: var(--accent); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.now-status { color: var(--warn); font-size: 14px; min-height: 18px; margin-top: 8px; }

.player-controls { display: flex; justify-content: center; align-items: center; gap: 30px; margin: 20px 0 14px; }
.ctrl {
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(255,255,255,.10); border: none; color: var(--text);
  display: flex; align-items: center; justify-content: center;
}
.ctrl-main { width: 100px; height: 100px; background: #fff; color: #000; }
.ctrl svg { width: 46%; height: 46%; display: block; }
.ctrl-main svg { width: 42%; height: 42%; }
.ctrl-sm svg { width: 44%; height: 44%; display: block; }

.np-progress { display: flex; align-items: center; gap: 12px; margin: 2px 0 16px; }
.np-time { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums;
  width: 50px; flex: 0 0 50px; text-align: left; }
.np-time:last-child { text-align: right; }
.np-bar { min-width: 0; }
.np-bar { flex: 1; height: 6px; border-radius: 3px; background: rgba(255,255,255,.20); overflow: hidden; }
.np-fill { height: 100%; width: 0%; background: #fff; border-radius: 3px; transition: width .5s linear; }

.np-extra { display: flex; justify-content: center; align-items: center; gap: 20px; }
.ctrl-sm {
  width: 58px; height: 58px; border-radius: 50%;
  background: rgba(255,255,255,.08); border: none; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.ctrl-sm.active { background: var(--accent); color: #04241c; }

.np-foot { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 12px; }
.np-foot .sub { margin: 0; }

.playlist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.playlist-card {
  background: rgba(255,255,255,.06); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px; min-height: 88px;
  display: flex; flex-direction: column; gap: 8px; text-align: left;
}
.playlist-card .pl-art { width: 100%; aspect-ratio: 1; border-radius: 8px; background: var(--surface-2) center/cover; }
.playlist-card .pl-name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Musik-Ansicht ist FIX – kein Scrollen, alles auf einer Seite */
.view-music.active {
  overflow: hidden;
  justify-content: center;
}
.np-extra { flex-wrap: wrap; }
.pl-dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Querformat: Info links, Cover rechts – wie CarPlay Now Playing */
@media (orientation: landscape) {
  .view-music .view-head { display: none; }              /* spart Höhe */
  .np-row { flex-direction: row-reverse; align-items: center; justify-content: center; gap: 40px; }
  .np-main { max-width: 540px; text-align: left; }
  .player-controls { justify-content: flex-start; margin: 14px 0 10px; }
  .np-extra { justify-content: flex-start; }
  .now-art { width: min(240px, 52vh); }
  .now-title { font-size: 28px; }
  .now-artist { font-size: 19px; }
  .player-controls { gap: 36px; }
  .ctrl { width: 88px; height: 88px; }
  .ctrl-main { width: 120px; height: 120px; }
  .ctrl-sm { width: 62px; height: 62px; }
  .np-extra { gap: 26px; }
}
/* sehr flache Querformat-Screens: kompakter, aber Regler bleiben groß */
@media (orientation: landscape) and (max-height: 430px) {
  .now-art { width: min(190px, 44vh); }
  .player-controls { margin: 8px 0 6px; gap: 26px; }
  .np-progress { margin: 2px 0 10px; }
  .now-status { min-height: 14px; margin-top: 4px; }
  .ctrl { width: 74px; height: 74px; }
  .ctrl-main { width: 98px; height: 98px; }
  .ctrl-sm { width: 54px; height: 54px; }
}

/* ---------- Weather ---------- */
.weather-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 24px; padding: 30px; text-align: center;
}
.wx-icon { font-size: 84px; line-height: 1; }
.wx-temp { font-size: 64px; font-weight: 900; margin: 8px 0; }
.wx-desc { font-size: 20px; color: var(--muted); }
.wx-extra { display: flex; justify-content: space-around; flex-wrap: wrap; gap: 10px; margin-top: 22px; color: var(--muted); font-size: 15px; }
.wx-updated { margin-top: 16px; font-size: 12px; color: var(--muted); }

/* ---------- Contacts ---------- */
.contact-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.contact-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 18px 12px; min-height: 110px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  position: relative;
}
.contact-card .c-name { font-size: 17px; font-weight: 800; text-align: center; }
.contact-card .c-tel { font-size: 13px; color: var(--muted); }
.contact-card .c-del {
  position: absolute; top: 6px; right: 6px; width: 34px; height: 34px;
  border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: 16px;
}

/* ---------- Ride ---------- */
.ride-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 6px;
}
.stat-label { color: var(--muted); font-size: 14px; }
.stat-value { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ride-actions { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.ride-actions .btn-pill { width: 100%; }

/* ---------- Settings ---------- */
.settings-list { display: flex; flex-direction: column; gap: 4px; }
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px; min-height: 64px; font-size: 16px;
}
.set-row input[type="number"], .set-row input[type="text"] {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; font-size: 16px; width: 130px; text-align: right;
}
.set-row input[type="text"] { width: 190px; text-align: left; }
.set-row input[type="checkbox"] { width: 28px; height: 28px; accent-color: var(--accent); }
.set-block {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.set-block-label { font-size: 16px; font-weight: 600; }
.orient-btns { display: flex; gap: 8px; width: 100%; }
.orient-btn {
  flex: 1; min-height: 56px; padding: 10px 8px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px;
  font-size: 15px; font-weight: 700;
}
.orient-btn.active {
  background: var(--accent); color: #04241c; border-color: transparent;
}
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 48px; height: 48px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-size: 22px; }

/* ---------- Dialogs ---------- */
dialog {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 20px;
  padding: 22px; width: min(92vw, 460px);
}
dialog::backdrop { background: rgba(0,0,0,0.6); }
dialog h2 { margin-bottom: 12px; }
dialog input { width: 100%; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 14px; font-size: 17px; margin: 8px 0; }
dialog menu { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.dest-results { max-height: 240px; overflow-y: auto; }
.dest-results button { display: block; width: 100%; text-align: left; padding: 14px; border-bottom: 1px solid var(--line); font-size: 15px; }

/* ---------- Landscape: dock on the right, content reflows ---------- */
html.layout-landscape {
  --dock-h: 0px;
}
html.layout-landscape .dock {
  top: 0; bottom: 0; right: 0; left: auto;
  width: 96px; height: auto; flex-direction: column;
  border-top: none; border-left: 1px solid rgba(255,255,255,0.10);
  padding-bottom: 0;
}
html.layout-landscape .view { right: 96px; bottom: 0; }
html.layout-landscape .view-navi.active { right: 96px; }
html.layout-landscape .navi-controls { right: 12px; }
html.layout-landscape .ride-stats { grid-template-columns: repeat(3, 1fr); }

@media (prefers-reduced-motion: no-preference) {
  .view.active { animation: fade .18s ease; }
  @keyframes fade { from { opacity: .4; } to { opacity: 1; } }
}

/* ---------- Auth gate ---------- */
.auth-gate {
  position: fixed; inset: 0; z-index: 5000;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
  padding: calc(20px + var(--safe-t)) 20px calc(20px + var(--safe-b));
}
.auth-gate[hidden] { display: none; }
.auth-card {
  width: min(94vw, 420px);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 24px; padding: 28px;
}
.auth-logo {
  font-size: 30px; font-weight: 900; letter-spacing: -0.5px;
  text-align: center; color: var(--accent); margin-bottom: 20px;
}
.auth-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.auth-tab {
  flex: 1; min-height: 52px; border-radius: 12px;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--line); font-size: 16px; font-weight: 700;
}
.auth-tab.active { background: var(--accent); color: #04241c; border-color: transparent; }
#authForm { display: flex; flex-direction: column; gap: 12px; }
#authForm input {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; font-size: 17px;
}
.auth-err {
  color: #fff; background: var(--danger);
  border-radius: 10px; padding: 10px 14px; font-size: 14px; margin: 0;
}
.auth-err[hidden] { display: none; }

/* ---------- Playlist dialog (nutzt fast die ganze Fläche) ---------- */
.playlist-dialog {
  width: min(96vw, 1100px);
  height: 92vh; max-height: 92vh;
  padding: 20px;
}
.playlist-dialog form { display: flex; flex-direction: column; height: 100%; }
.pl-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.pl-dialog-head h2 { margin: 0; }
.playlist-dialog .playlist-grid {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
