#cnrail-location-card {
  --cnrail-accent: #1187d1;
  position: fixed;
  right: 12px;
  bottom: 52px;
  z-index: 1200;
  width: min(292px, calc(100vw - 24px));
  padding: 14px 16px 12px;
  color: #17212b;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(18, 54, 80, 0.12);
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(12, 33, 51, 0.22);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

#cnrail-location-card[data-state="ready"] { --cnrail-accent: #158d5b; }
#cnrail-location-card[data-state="demo"] { --cnrail-accent: #7357c7; }
#cnrail-location-card[data-state="error"] { --cnrail-accent: #c94842; }
#cnrail-location-card[data-state="pending"] { --cnrail-accent: #b47a0c; }

.cnrail-train-notice {
  margin: 0 6px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #edf5fc;
  color: #28465f;
  font-size: 12px;
  line-height: 1.6;
}
.cnrail-train-notice strong { display: block; font-size: 13px; }
.cnrail-train-notice p { margin: 4px 0; }
.cnrail-train-notice button { margin-left: 12px; }

.cnrail-location-head,
.cnrail-location-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cnrail-location-head {
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#cnrail-location-card.is-dragging {
  cursor: grabbing;
  box-shadow: 0 12px 38px rgba(12, 33, 51, 0.3);
}

#cnrail-location-card.is-dragging .cnrail-location-head { cursor: grabbing; }

.cnrail-location-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: #44515e;
  font-size: 13px;
  font-weight: 700;
}

.cnrail-location-state i {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--cnrail-accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--cnrail-accent) 16%, transparent);
}

.cnrail-location-head button,
.cnrail-location-foot button {
  border: 0;
  color: var(--cnrail-accent);
  background: transparent;
  cursor: pointer;
}

.cnrail-location-head button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--cnrail-accent) 10%, white);
  font-size: 24px;
  line-height: 30px;
  touch-action: manipulation;
}

.cnrail-speed {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 5px 0 8px;
}

.cnrail-speed strong {
  color: #0d1d2c;
  font-size: 34px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.cnrail-speed span {
  color: #687784;
  font-size: 13px;
}

.cnrail-location-grid {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 4px 12px;
  padding-top: 8px;
  border-top: 1px solid #e5eaee;
  font-size: 13px;
}

.cnrail-location-grid span { color: #71808d; }
.cnrail-location-grid b {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.cnrail-location-foot {
  margin-top: 9px;
  color: #768490;
  font-size: 11px;
}

.cnrail-location-foot span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cnrail-location-foot button {
  display: none;
  flex: 0 0 auto;
  padding: 0;
  font-size: 12px;
}

#cnrail-location-card[data-state="error"] .cnrail-location-foot button { display: block; }

.cnrail-live-marker {
  --cnrail-heading: 0deg;
  position: relative;
  width: 28px;
  height: 28px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #087fe2;
  box-shadow: 0 2px 8px rgba(0, 54, 100, 0.4), 0 0 0 9px rgba(8, 127, 226, 0.18);
}

.cnrail-live-marker::before {
  content: "";
  position: absolute;
  inset: -10px;
  border: 2px solid rgba(8, 127, 226, 0.32);
  border-radius: 50%;
  animation: cnrail-location-pulse 1.8s ease-out infinite;
}

.cnrail-live-marker span {
  position: absolute;
  left: 50%;
  top: -11px;
  width: 0;
  height: 0;
  border-right: 5px solid transparent;
  border-bottom: 10px solid #087fe2;
  border-left: 5px solid transparent;
  transform: translateX(-50%) rotate(var(--cnrail-heading));
  transform-origin: 50% 24px;
}

@keyframes cnrail-location-pulse {
  from { opacity: 0.9; transform: scale(0.65); }
  to { opacity: 0; transform: scale(1.45); }
}

@media (max-width: 820px) {
  #cnrail-location-card {
    right: 8px;
    bottom: 48px;
    width: 260px;
    padding: 11px 13px 10px;
  }
  .cnrail-speed strong { font-size: 29px; }
}

@media (max-width: 480px) {
  #cnrail-location-card {
    right: 6px;
    bottom: 44px;
    width: min(244px, calc(100vw - 12px));
  }
  .cnrail-location-grid { grid-template-columns: 42px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .cnrail-live-marker::before { animation: none; }
}
.cnrail-snap-info {
  margin-top: 8px;
  color: #64748b;
  font-size: 11px;
  line-height: 1.5;
}
.cnrail-snap-info[data-snapped="true"] { color: #07815c; }
