:root {
  --bg: #050711;
  --panel: rgba(6, 13, 28, 0.92);
  --panel2: rgba(9, 18, 38, 0.96);
  --border: rgba(88, 190, 255, 0.28);
  --cyan: #41d9ff;
  --blue: #1f8cff;
  --green: #4ade80;
  --yellow: #facc15;
  --red: #fb7185;
  --text: #ecf8ff;
  --muted: rgba(236, 248, 255, 0.58);
  --black: #02040a;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Poppins', system-ui, sans-serif;
  overflow: hidden;
}

.bike-dashboard {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  background:
    radial-gradient(circle at 10% 0%, rgba(65, 217, 255, 0.18), transparent 28%),
    radial-gradient(circle at 90% 100%, rgba(31, 140, 255, 0.16), transparent 30%),
    var(--bg);
}

.panel {
  min-height: 0;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    var(--panel);
  box-shadow:
    0 14px 32px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* ── Wspólna belka modułu ── */
.module-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 4px 10px;
  border-bottom: 1px solid rgba(65, 217, 255, 0.16);
  background: rgba(0, 0, 0, 0.28);
  flex-shrink: 0;
  position: relative;
  z-index: 5;
  flex-wrap: wrap;
}

.module-toolbar .toolbar-field {
  flex: 1 1 140px;
}

.module-toolbar .dropdown {
  position: absolute;
  left: 10px;
  right: 10px;
  top: calc(100% - 2px);
  width: auto;
}

.module-toolbar.compact {
  min-height: 32px;
  justify-content: space-between;
}

.module-title {
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  color: var(--cyan);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  flex-shrink: 0;
  user-select: none;
}

.toolbar-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  padding: 2px 4px 2px 12px;
}

.toolbar-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  outline: none;
  font-size: 13px;
  padding: 6px 0;
}

.toolbar-field input::placeholder {
  color: var(--muted);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--cyan);
  flex-shrink: 0;
}

.icon-btn.round {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(65, 217, 255, 0.28);
  background: rgba(65, 217, 255, 0.08);
  font-size: 14px;
}

.icon-btn.round.active {
  background: var(--cyan);
  color: #06100a;
}

.icon-btn.listening {
  background: rgba(251, 113, 133, 0.25);
  color: #ffb4c0;
  box-shadow: 0 0 0 2px rgba(251, 113, 133, 0.35);
}

.icon-svg {
  width: 20px;
  height: 20px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
  padding: 0;
  border: 0;
}

.status-dot.live,
.status-dot.conn-online {
  background: var(--green);
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.55);
}

.status-dot.off,
.status-dot.conn-offline {
  background: var(--red);
  box-shadow: 0 0 10px rgba(251, 113, 133, 0.45);
}

.status-dot.conn-connecting {
  background: var(--yellow);
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.45);
}

.dropdown {
  max-height: min(42vh, 220px);
  overflow: auto;
  z-index: 30;
  background: rgba(2, 4, 10, 0.96);
  border: 1px solid rgba(65, 217, 255, 0.22);
  border-radius: 12px;
  padding: 4px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.dropdown-message {
  padding: 8px 10px;
  font-size: 11px;
  color: var(--yellow);
  font-family: 'Share Tech Mono', monospace;
}

.dropdown-section {
  padding: 6px 10px 4px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: 'Share Tech Mono', monospace;
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 13px;
}

.dropdown-item:hover,
.dropdown-item:focus-visible {
  background: rgba(65, 217, 255, 0.1);
}

.dropdown-item-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-item-action {
  flex-shrink: 0;
  color: var(--cyan);
  font-size: 14px;
  font-weight: 700;
}

.dropdown-item-action svg {
  width: 18px;
  height: 18px;
}

button {
  border: 1px solid rgba(65, 217, 255, 0.38);
  border-radius: 999px;
  background: rgba(65, 217, 255, 0.12);
  color: var(--text);
  font-weight: 700;
  font-size: 11px;
  padding: 5px 9px;
  cursor: pointer;
  touch-action: manipulation;
}

button:active {
  transform: scale(0.97);
}

.mini-button {
  padding: 3px 8px;
  font-size: 10px;
}

.mini-status {
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  color: var(--cyan);
  letter-spacing: 0.08em;
}

.hidden {
  display: none !important;
}

/* ── Kamera ── */
.camera-panel {
  display: flex;
  flex-direction: column;
}

.camera-frame {
  flex: 1;
  min-height: 0;
  position: relative;
  background: #01030a;
}

.camera-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera-frame .fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: 'Share Tech Mono', monospace;
  font-size: clamp(14px, 3vw, 22px);
  color: var(--muted);
  letter-spacing: 0.2em;
  background: rgba(1, 3, 10, 0.92);
}

/* ── Mapa ── */
.map-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.map-panel .module-toolbar {
  flex-wrap: wrap;
  z-index: 500;
}

.map-panel .module-toolbar .dropdown {
  z-index: 600;
}

#map {
  width: 100%;
  height: 100%;
  background: #0a1220;
}

.map-panel .leaflet-container {
  background: #0a1220;
  font-family: 'Poppins', sans-serif;
}

.map-fab {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 400;
  width: 44px;
  height: 44px;
  background: rgba(2, 4, 10, 0.88);
  border: 1px solid rgba(65, 217, 255, 0.35);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.map-end-route {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 400;
  width: 36px;
  height: 36px;
  font-size: 22px;
  line-height: 1;
  background: rgba(2, 4, 10, 0.88);
  border: 1px solid rgba(251, 113, 133, 0.45);
  color: var(--red);
}

.route-chip {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 400;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(2, 4, 10, 0.88);
  border: 1px solid rgba(65, 217, 255, 0.28);
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  color: var(--cyan);
  pointer-events: none;
}

.bike-marker-icon {
  background: transparent !important;
  border: none !important;
}

.bike-marker-shell {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
}

.bike-marker-ring {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
  display: grid;
  place-items: center;
}

.bike-marker-arrow-svg {
  width: 24px;
  height: 24px;
  color: #1a73e8;
  transform-origin: center center;
}

/* ── Muzyka WinAmp-like ── */
.music-panel {
  padding: 0;
  min-height: 0;
}

.winamp-shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 5px;
  border-radius: 0;
  border: 0;
  background:
    linear-gradient(180deg, rgba(18, 25, 43, 0.95), rgba(1, 3, 10, 0.98));
  padding: 0 6px 6px;
  position: relative;
  min-height: 0;
}

.winamp-shell .module-toolbar {
  margin: 0 -6px;
  border-radius: 18px 18px 0 0;
}

.map-body {
  flex: 1;
  min-height: 0;
  position: relative;
}

.music-display {
  border: 1px solid rgba(65, 217, 255, 0.2);
  background: #02050d;
  padding: 8px 10px 10px;
  font-family: 'Share Tech Mono', monospace;
  color: var(--cyan);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.track-line {
  display: flex;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
}

#trackTitle {
  overflow: hidden;
  text-overflow: ellipsis;
}

.time-line {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.progress-wrap {
  height: 8px;
  background: rgba(65, 217, 255, 0.12);
  border: 1px solid rgba(65, 217, 255, 0.22);
  cursor: pointer;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  transition: width 0.25s linear;
}

.music-display .music-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-top: 2px;
}

.music-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.playlist {
  margin: 0;
  padding: 4px 4px 4px 28px;
  overflow: auto;
  background: #01030a;
  border: 1px solid rgba(65, 217, 255, 0.18);
  font-family: 'Share Tech Mono', monospace;
  color: rgba(65, 217, 255, 0.78);
  font-size: 11px;
  min-height: 0;
}

.playlist li {
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 4px;
}

.playlist li.active {
  color: #06100a;
  background: var(--cyan);
}

.playlist li.highlight {
  outline: 1px solid var(--yellow);
}

.youtube-player-host {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 200px;
  height: 112px;
  opacity: 0.001;
  pointer-events: none;
  overflow: hidden;
}

/* ── Licznik oryginalny (tmp3 / ifrappe) ── */
.speed-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #000;
}

.cockpit-host {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
}

#cockpit {
  --cockpit-scale: 1;
  width: 512px;
  height: 384px;
  transform: scale(var(--cockpit-scale));
  transform-origin: center center;
  background: #000 url('./assets/gauge/background.png') 50% -60% no-repeat;
  background-size: 438px;
  position: relative;
  flex-shrink: 0;
}

#arrow {
  background: url('./assets/gauge/arrow.png') center center no-repeat;
  width: 293px;
  height: 293px;
  margin: 0 auto;
  position: relative;
  top: 20px;
  transform: rotate(-45deg);
}

#speedWrapper {
  position: absolute;
  font-family: 'Orbitron', sans-serif;
  font-size: 24px;
  color: #fff;
  text-align: center;
  width: 100%;
  top: 80px;
  z-index: 2;
  pointer-events: none;
}

#speed {
  font-size: 56px;
  font-weight: 700;
}

#leftScale {
  width: 56px;
  position: absolute;
  top: 55px;
  left: 91px;
  z-index: 1;
}

#leftScale img,
#rightScale img {
  width: 100%;
  height: auto;
  display: block;
}

#rightScale {
  width: 56px;
  position: absolute;
  top: 55px;
  right: 91px;
  z-index: 1;
}

#speedWrapper small {
  display: block;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.65);
  margin-top: 2px;
}

/* ── Toast ── */
.toast-root {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(6, 13, 28, 0.96);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.25s ease;
}

.toast.info { border-color: var(--cyan); color: var(--cyan); }
.toast.warn { border-color: var(--yellow); color: var(--yellow); }
.toast.error { border-color: var(--red); color: var(--red); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 720px) {
  .bike-dashboard {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, 1fr);
  }

  .module-toolbar {
    flex-wrap: wrap;
    min-height: auto;
    padding-bottom: 6px;
  }

  .toolbar-field {
    width: 100%;
    order: 2;
  }
}
