/* En celular, los drawers conservan su posicionamiento como hojas sobre .stage. */
#right-panel { display: contents; }

/* En escritorio, los cuatro contenidos comparten un solo espacio a la derecha. */
@media (min-width: 901px) {
  body.territorio-real {
    --rail-w: clamp(72px, min(18vw, calc(40vw - 288px)), 340px);
    --right-w: clamp(310px, calc(35.5vw - 10px), 620px);
  }
  .stage #map { right: var(--right-w); }
  #right-panel {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: var(--right-w);
    display: flex;
    flex-direction: column;
    background: var(--glass-2);
    border-left: 1px solid var(--line);
    z-index: 30;
  }
  #right-panel > .drawer {
    position: static;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    animation: none;
  }
  #right-panel .drawer-body { flex: 1 1 auto; overflow-y: auto; }
  #list-panel .lp-legal {
    margin: 0;
    padding: 12px 16px;
    background: #f0f2ec;
    border-top: 1px solid var(--line-soft);
  }
}

/* Tablet horizontal: la barra conserva sus acciones sin comprimir el mapa. */
@media (min-width: 901px) and (max-width: 1050px) {
  .rail-btn { justify-content: center; }
  .rail-btn span { display: none; }
}

/* Aviso y atribución en una misma pila Leaflet, dentro del ancho real del mapa. */
#map .leaflet-bottom.leaflet-right {
  top: auto;
  bottom: 12px;
  left: 12px;
  right: 12px;
  pointer-events: none;
}
#map .leaflet-bottom.leaflet-right .leaflet-control { pointer-events: auto; }
#map .legal-mini {
  position: static;
  display: block;
  float: right;
  clear: both;
  width: max-content;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: break-word;
}
#map .leaflet-control-attribution {
  max-width: 100%;
  box-sizing: border-box;
  margin: 6px 0 0 !important;
  padding: 3px 6px;
  background: #faf9f4 !important;
  color: #183447 !important;
  border: 1px solid var(--line);
  border-radius: 3px;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  font-size: 11px !important;
  line-height: 1.35;
}
#map .leaflet-control-attribution a { color: #245e7a !important; }

/* El zoom queda fuera de la zona inferior compartida. */
#map .leaflet-top.leaflet-left { top: 12px; bottom: auto; left: auto; right: 12px; }
#map .leaflet-top.leaflet-left .leaflet-control { margin: 0 !important; }

@media (max-width: 900px) {
  /* Barra 64px + separación 12px + hoja asomada 90px + respiro 12px. */
  #map .leaflet-bottom.leaflet-right { bottom: calc(64px + 12px + 90px + 12px); }
}
