body.map-page {
  margin: 0;
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.map-header .header-inner {
  gap: 1rem;
}

.plan-panel-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--brand-gold);
  border-radius: 6px;
  background: rgba(15, 40, 103, 0.35);
  cursor: pointer;
  touch-action: manipulation;
}

.plan-panel-toggle-bar {
  display: block;
  width: 20px;
  height: 2px;
  margin: 0 auto;
  background: var(--brand-gold);
  border-radius: 1px;
}

.plan-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 45;
}

.map-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #eee;
}

.map-sidebar-title {
  margin: 0;
  font-size: 1rem;
  color: var(--brand-blue-dark);
}

.plan-panel-close {
  border: none;
  background: none;
  font-size: 1.5rem;
  line-height: 1;
  color: #555;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 2;
}

.layer-hint,
.layer-note {
  color: #666;
  font-size: 0.75rem;
  line-height: 1.35;
}

.layer-hint {
  margin: 0 0 0.5rem;
}

.layer-note {
  font-weight: 400;
}

#map {
  flex: 1;
  width: 100%;
  min-height: 0;
  background: #e8eef4;
}

.chart-zoom-ctrl .chart-zoom-btn {
  display: block;
  width: 29px;
  height: 29px;
  padding: 0;
  border: none;
  background: #fff;
  color: #333;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.chart-zoom-ctrl .chart-zoom-btn:hover {
  background: #f0f0f0;
}

.chart-zoom-ctrl .chart-zoom-btn + .chart-zoom-btn {
  border-top: 1px solid #ddd;
}

.map-sidebar {
  position: fixed;
  top: 3.5rem;
  right: 0;
  width: 280px;
  max-height: calc(100vh - 3.5rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: rgba(255, 248, 231, 0.98);
  border-left: 3px solid var(--brand-gold);
  padding: 0.75rem 1rem;
  z-index: 55;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.08);
  font-size: 0.875rem;
  transition: transform 0.25s ease, visibility 0.25s ease;
  transform: translateX(100%);
  visibility: hidden;
  pointer-events: none;
}

.map-sidebar.is-open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.map-sidebar h2 {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #555;
}

.map-sidebar-section {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #eee;
}

.layer-toggle {
  display: block;
  margin: 0.35rem 0;
  cursor: pointer;
}

.layer-toggle input {
  margin-right: 0.4rem;
}

.route-manual-add {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.route-manual-add input {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.55rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.85rem;
}

.route-manual-add .btn-map {
  flex-shrink: 0;
}

.route-manual-msg {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
  color: #2e7d32;
}

.route-manual-msg.route-manual-error {
  color: #b71c1c;
}

.map-hint {
  margin: 0 0 0.5rem;
  color: #666;
  font-size: 0.8rem;
  line-height: 1.4;
}

.route-summary {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 0.5rem;
}

.route-empty {
  color: #888;
  margin: 0;
}

.route-waypoint {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid #f0f0f0;
}

.route-waypoint.is-dragging {
  opacity: 0.45;
}

.route-waypoint.is-drop-target {
  background: #fff3cc;
  border-radius: 4px;
}

.route-drag-handle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-height: 40px;
  margin-top: 0.1rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  color: #888;
  cursor: grab;
  touch-action: none;
  padding: 0;
  -webkit-user-select: none;
  user-select: none;
}

.route-drag-handle:hover,
.route-drag-handle:focus {
  color: var(--brand-blue);
  border-color: var(--brand-gold);
  background: #fff8e0;
}

.route-drag-handle:active {
  cursor: grabbing;
  color: var(--brand-blue-dark);
  background: var(--brand-gold-light);
}

.route-drag-handle svg {
  display: block;
}

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

.route-waypoint-name {
  display: block;
  color: #444;
  font-size: 0.8rem;
  line-height: 1.3;
  word-break: break-word;
}

.route-waypoint-kind {
  display: inline-block;
  margin-top: 0.15rem;
  padding: 0.1rem 0.35rem;
  background: #fff3cc;
  color: var(--brand-blue-dark);
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
}

.route-delete {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  color: #b71c1c;
  cursor: pointer;
  touch-action: manipulation;
}

.route-delete:hover,
.route-delete:focus {
  background: #ffebee;
  border-color: #ef9a9a;
}

.route-leg {
  padding: 0.35rem 0;
  border-bottom: 1px solid #f0f0f0;
}

.route-leg strong {
  color: var(--brand-blue-dark);
}

.route-total {
  margin-top: 0.5rem;
  font-weight: 600;
  color: var(--brand-blue-dark);
}

.route-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-map {
  padding: 0.4rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  font-size: 0.8rem;
  cursor: pointer;
}

.btn-map:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-map-primary {
  background: var(--brand-blue);
  color: #fff;
  border-color: var(--brand-blue-dark);
}

.btn-map-primary:hover:not(:disabled) {
  background: var(--brand-blue-light);
}

.map-attribution {
  margin: 0.5rem 0 0;
  font-size: 0.7rem;
  color: #888;
  line-height: 1.4;
}

.map-attribution a {
  color: var(--brand-blue);
}

.maplibregl-popup-content {
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
}

.maplibregl-popup-content a {
  color: var(--brand-blue);
  font-weight: 600;
}

.map-panel-ctrl .map-panel-ctrl-btn {
  display: block;
  min-width: 52px;
  height: 29px;
  padding: 0 0.45rem;
  border: none;
  background: #fff;
  color: var(--brand-blue-dark);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.map-panel-ctrl .map-panel-ctrl-btn:hover {
  background: var(--brand-gold-light);
}

.maplibregl-ctrl-attrib {
  font-size: 0.65rem;
}

.waypoint-picker {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  width: min(360px, calc(100vw - 2rem));
  background: #fff;
  border: 2px solid var(--brand-gold);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  z-index: 200;
  overflow: hidden;
  pointer-events: auto;
}

.waypoint-picker.picker-centered {
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
}

.picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  background: var(--brand-blue);
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
}

.picker-close {
  background: none;
  border: none;
  color: var(--brand-gold);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.picker-list {
  list-style: none;
  margin: 0;
  padding: 0.35rem 0;
  max-height: 240px;
  overflow-y: auto;
}

.picker-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.85rem;
  border: none;
  background: #fff;
  cursor: pointer;
  touch-action: manipulation;
}

.picker-option:hover,
.picker-option:focus {
  background: #fff3cc;
}

.picker-id {
  display: block;
  font-weight: 700;
  color: var(--brand-blue-dark);
  font-size: 0.95rem;
}

.picker-meta {
  display: block;
  color: #666;
  font-size: 0.75rem;
  margin-top: 0.1rem;
}

.picker-name {
  display: block;
  color: #444;
  font-size: 0.8rem;
  margin-top: 0.15rem;
}

.picker-option-raw .picker-id {
  font-weight: 600;
  color: #555;
}

.picker-raw {
  border-top: 1px solid #eee;
}

@media (max-width: 768px) {
  .map-sidebar {
    width: 100%;
    max-height: min(78vh, 520px);
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    border-left: none;
    border-top: 1px solid #ccc;
    border-radius: 12px 12px 0 0;
    transform: translateY(100%);
  }

  .map-sidebar {
    transform: translateY(100%);
  }

  .map-sidebar.is-open {
    transform: translateY(0);
  }

  #map {
    flex: 1;
    height: auto;
  }

  .waypoint-picker {
    bottom: 1rem;
    width: calc(100vw - 1rem);
  }

  .route-delete {
    width: 44px;
    height: 44px;
  }
}